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
Pipeline #46405 passed with stages
in 5 minutes and 39 seconds
......@@ -16,7 +16,7 @@ See the file COPYING.
glib >= 2.44
glib >= 2.54
  • @ocrete Is this a hard requirement? This breaks builds for ubuntu 16.04 since installed version of glib/gio is 2.48

  • +1 please don't upgrade if the code doesn't really require any feature from GLib 2.54

  • Oh ok I just saw this #92 (closed)

    So libnice is actually using features from GLib 2.54 (g_ptr_array_find). Well I think that does indeed justify the bump, as 16.04 is not even the latest LTS.

    Edited by Juan Navarro
  • A note about this commit for any future application maintainer that needs to support Ubuntu 16.04 (Xenial) and might reach this page (who knows):

    This just introduces new public API functions, together with the bump of requirement in GLib. Applications that don't need to use the new functions won't see a difference.

    Also as of today, since this change was done, no new code in libnice does actually use any new features of GLib 2.54, so thankfully for custom integrations this commit (875a23a7 - agent: add nice_agent_get_sockets API) can be reverted without any consequence. This allows maintainers to keep building libnice for Ubuntu 16.04 (Xenial) systems.

Please register or sign in to reply
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);
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);
#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);
......@@ -95,9 +95,9 @@ AC_CHECK_HEADERS([ifaddrs.h],
AC_CHECK_TYPES([size_t, ssize_t])
# Also put matching version in LIBNICE_CFLAGS
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 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>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
......@@ -54,6 +54,7 @@ nice_agent_parse_remote_stream_sdp
......@@ -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
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