Commit 875a23a7 authored by Olivier Crête's avatar Olivier Crête

agent: add nice_agent_get_sockets API

This API makes it possible to get an array of all of the sockets used
by a specific component, this is useful to set options on the socket.

Also bump GLib requirement to 2.54, which is the version in RHEL 7
parent b9985474
......@@ -16,7 +16,7 @@ See the file COPYING.
Requirements
------------
glib >= 2.44
glib >= 2.54
pkg-config
gnutls >= 2.12.0 or OpenSSL
gupnp-igd >= 0.1.2 (optional)
......
......@@ -6694,3 +6694,18 @@ nice_agent_close_async (NiceAgent *agent, GAsyncReadyCallback callback,
agent_unlock (agent);
}
NICEAPI_EXPORT GPtrArray *
nice_agent_get_sockets (NiceAgent *agent, guint stream_id, guint component_id)
{
GPtrArray *array = NULL;
NiceComponent *component;
agent_lock (agent);
if (agent_find_component (agent, stream_id, component_id, NULL, &component))
array = nice_component_get_sockets (component);
agent_unlock (agent);
return array;
}
......@@ -1681,6 +1681,29 @@ void
nice_agent_close_async (NiceAgent *agent, GAsyncReadyCallback callback,
gpointer callback_data);
/**
* nice_agent_get_sockets:
* @agent: The #NiceAgent Object
* @stream_id: The ID of the stream
* @component_id: The ID of the component
*
* Each component can have multiple sockets, this is an API to retrieve them all
* to be able to set properties. Most of the sockets for a component are created when
* calling nice_agent_gather_candidates(), so this API should be called right after to
* able to set properties on the sockets before they are used.
*
* These sockets can be a mix of UDP & TCP sockets depending on the compatibility mode
* and options that have been set.
*
* Returns: (element-type GSocket) (transfer full): An array
* containing all of the sockets for this component. Free with
* g_ptr_array_unref() when done.
*
* Since: 0.1.17
*/
GPtrArray *
nice_agent_get_sockets (NiceAgent *agent, guint stream_id, guint component_id);
G_END_DECLS
#endif /* __LIBNICE_AGENT_H__ */
......@@ -1587,3 +1587,22 @@ nice_component_verify_remote_candidate (NiceComponent *component,
return FALSE;
}
/* Must be called with agent lock held */
/* Returns a transfer full GPtrArray of GSocket */
GPtrArray *
nice_component_get_sockets (NiceComponent *component)
{
GPtrArray *array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
GSList *item;
for (item = component->local_candidates; item; item = item->next) {
NiceCandidate *cand = item->data;
NiceSocket *nicesock = cand->sockptr;
if (nicesock->fileno && !g_ptr_array_find (array, nicesock->fileno, NULL))
g_ptr_array_add (array, g_object_ref (nicesock->fileno));
}
return array;
}
......@@ -309,6 +309,8 @@ gboolean
nice_component_verify_remote_candidate (NiceComponent *component,
const NiceAddress *address, NiceSocket *nicesock);
GPtrArray *
nice_component_get_sockets (NiceComponent *component);
G_END_DECLS
......
......@@ -95,9 +95,9 @@ AC_CHECK_HEADERS([ifaddrs.h],
AC_CHECK_TYPES([size_t, ssize_t])
# Also put matching version in LIBNICE_CFLAGS
GLIB_REQ=2.48
GLIB_REQ=2.54
LIBNICE_CFLAGS="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_44 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_44"
LIBNICE_CFLAGS="-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_54 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_54"
dnl Support different levels of compiler error reporting.
dnl This configure flag is designed to mimic one from gnome-common,
......
......@@ -113,6 +113,10 @@
<title>Index of new symbols in 0.1.16</title>
<xi:include href="xml/api-index-0.1.16.xml"><xi:fallback/></xi:include>
</index>
<index role="0.1.17">
<title>Index of new symbols in 0.1.17</title>
<xi:include href="xml/api-index-0.1.17.xml"><xi:fallback/></xi:include>
</index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
</part>
</book>
......@@ -54,6 +54,7 @@ nice_agent_parse_remote_stream_sdp
nice_agent_parse_remote_candidate_sdp
nice_agent_get_io_stream
nice_agent_get_selected_socket
nice_agent_get_sockets
nice_agent_get_component_state
nice_agent_close_async
nice_component_state_to_string
......
......@@ -18,7 +18,7 @@ endif
soversion = 10
libversion = '10.9.0'
glib_req = '>= 2.48'
glib_req = '>= 2.54'
gnutls_req = '>= 2.12.0'
gupnp_igd_req = '>= 0.2.4'
gst_req = '>= 1.0.0'
......
......@@ -36,6 +36,7 @@ nice_agent_get_local_credentials
nice_agent_get_remote_candidates
nice_agent_get_selected_pair
nice_agent_get_selected_socket
nice_agent_get_sockets
nice_agent_get_stream_name
nice_agent_get_type
nice_agent_new
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment