agent: add nice_agent_get_sockets API
authorOlivier Crête <olivier.crete@collabora.com>
Fri, 28 Jun 2019 21:03:44 +0000 (17:03 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Tue, 2 Jul 2019 19:18:59 +0000 (15:18 -0400)
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

README
agent/agent.c
agent/agent.h
agent/component.c
agent/component.h
configure.ac
docs/reference/libnice/libnice-docs.xml
docs/reference/libnice/libnice-sections.txt
meson.build
nice/libnice.sym

diff --git a/README b/README
index 7eccc63..dc4c009 100644 (file)
--- a/README
+++ b/README
@@ -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)
index e653d02..c59be3b 100644 (file)
@@ -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;
+}
index c3b77a3..1164138 100644 (file)
@@ -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__ */
index 15be010..60ffe5e 100644 (file)
@@ -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;
+}
index d098511..c18b312 100644 (file)
@@ -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
 
index c1367c4..651839a 100644 (file)
@@ -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,
index 5bb5f08..e3e0966 100644 (file)
       <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>
index bff9c96..4be4f1a 100644 (file)
@@ -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
index 114d7c6..132a556 100644 (file)
@@ -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'
index 1e6d127..007be55 100644 (file)
@@ -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