return result;
}
+static gboolean
+on_agent_refreshes_pruned (NiceAgent *agent, gpointer user_data)
+{
+ // This is called from a timeout cb with agent lock held
+
+ agent_queue_signal (agent, signals[SIGNAL_CLOSED]);
+
+ return G_SOURCE_REMOVE;
+}
+
+void
+nice_agent_close_async (NiceAgent *agent)
+{
+ agent_lock (agent);
+
+ refresh_prune_agent_async (agent, on_agent_refreshes_pruned);
+
+ agent_unlock (agent);
+}
NiceAgent *agent,
guint stream_id);
+/**
+ * nice_agent_close_async:
+ * @agent: The #NiceAgent object
+ *
+ * Asynchronously closes resources the agent has allocated on remote servers.
+ * The agent will emit "closed" signal when the operation finishes.
+ *
+ * Calling this function before freeing the agent makes sure the allocated relay
+ * ports aren't left behind on TURN server but properly removed.
+ *
+ * Since: 0.1.16
+ */
+void
+nice_agent_close_async (NiceAgent *agent);
+
G_END_DECLS
#endif /* __LIBNICE_AGENT_H__ */
nice_agent_get_io_stream
nice_agent_get_selected_socket
nice_agent_get_component_state
+nice_agent_close_async
nice_component_state_to_string
<SUBSECTION Standard>
NICE_AGENT
nice_address_to_string
nice_agent_add_local_address
nice_agent_add_stream
+nice_agent_close_async
nice_agent_recv
nice_agent_recv_messages
nice_agent_recv_nonblocking
static gboolean global_ragent_gathering_done = FALSE;
static gboolean global_lagent_ibr_received = FALSE;
static gboolean global_ragent_ibr_received = FALSE;
+static gboolean global_lagent_closed = FALSE;
+static gboolean global_ragent_closed = FALSE;
static int global_lagent_cands = 0;
static int global_ragent_cands = 0;
static gint global_ragent_read = 0;
(void)agent; (void)stream_id; (void)data;
}
+static void cb_closed (NiceAgent *agent, gpointer data)
+{
+ g_debug ("test-fullmode:%s: %p", G_STRFUNC, agent);
+
+ *((gboolean *)data) = TRUE;
+}
+
static void set_candidates (NiceAgent *from, guint from_stream,
NiceAgent *to, guint to_stream, guint component, gboolean remove_non_relay)
{
g_signal_connect (G_OBJECT (ragent), "initial-binding-request-received",
G_CALLBACK (cb_initial_binding_request_received),
GUINT_TO_POINTER (2));
+ g_signal_connect (G_OBJECT (lagent), "closed",
+ G_CALLBACK (cb_closed), &global_lagent_closed);
+ g_signal_connect (G_OBJECT (ragent), "closed",
+ G_CALLBACK (cb_closed), &global_ragent_closed);
stun_server = getenv ("NICE_STUN_SERVER");
stun_server_port = getenv ("NICE_STUN_SERVER_PORT");
g_assert (global_ragent_state[0] == NICE_COMPONENT_STATE_READY);
g_assert (global_ragent_state[1] == NICE_COMPONENT_STATE_READY);
+ nice_agent_close_async (lagent);
+ nice_agent_close_async (ragent);
+
+ while (!global_lagent_closed || !global_ragent_closed) {
+ g_main_context_iteration (NULL, TRUE);
+ }
+
g_object_unref (lagent);
g_object_unref (ragent);
static guint global_components_ready = 0;
static gboolean global_lagent_gathering_done = FALSE;
static gboolean global_ragent_gathering_done = FALSE;
+static gboolean global_lagent_closed = FALSE;
+static gboolean global_ragent_closed = FALSE;
static int global_lagent_cands = 0;
static int global_ragent_cands = 0;
++global_ragent_cands;
}
+static void cb_closed (NiceAgent *agent, gpointer data)
+{
+ g_debug ("test-turn:%s: %p", G_STRFUNC, agent);
+
+ *((gboolean *)data) = TRUE;
+}
+
static void set_candidates (NiceAgent *from, guint from_stream,
NiceAgent *to, guint to_stream, guint component, gboolean remove_non_relay,
gboolean force_relay)
global_components_ready = 0;
global_lagent_gathering_done = FALSE;
global_ragent_gathering_done = FALSE;
+ global_lagent_closed = FALSE;
+ global_ragent_closed = FALSE;
global_lagent_cands = global_ragent_cands = 0;
lagent = nice_agent_new (NULL, NICE_COMPATIBILITY_RFC5245);
G_CALLBACK (cb_new_selected_pair), GUINT_TO_POINTER(1));
g_signal_connect (G_OBJECT (ragent), "new-selected-pair",
G_CALLBACK (cb_new_selected_pair), GUINT_TO_POINTER (2));
+ g_signal_connect (G_OBJECT (lagent), "closed",
+ G_CALLBACK (cb_closed), &global_lagent_closed);
+ g_signal_connect (G_OBJECT (ragent), "closed",
+ G_CALLBACK (cb_closed), &global_ragent_closed);
g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, NULL);
g_object_set (G_OBJECT (ragent), "controlling-mode", FALSE, NULL);
nice_agent_remove_stream (lagent, ls_id);
nice_agent_remove_stream (ragent, rs_id);
+ nice_agent_close_async (lagent);
+ nice_agent_close_async (ragent);
+
+ while (!global_lagent_closed || !global_ragent_closed) {
+ g_main_context_iteration (NULL, TRUE);
+ }
+
g_source_remove (timer_id);
g_clear_object(&lagent);