From 703dcd102e372ccbac12e53add14b7332a23166b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 May 2026 12:58:39 +0000 Subject: [PATCH] Implement nice_agent_clear_stream_local_addresses Agent-Logs-Url: https://github.com/pexip/libnice/sessions/285af649-49e4-46aa-b4da-604a0fdfd6bf Co-authored-by: bitflows <19825042+bitflows@users.noreply.github.com> --- agent/agent.c | 29 +++++++++++++++++++++++++++++ agent/agent.h | 16 ++++++++++++++++ nice/libnice.sym | 1 + 3 files changed, 46 insertions(+) diff --git a/agent/agent.c b/agent/agent.c index 8d978c0..d12c6fe 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -2036,6 +2036,35 @@ nice_agent_add_stream_local_address_from_string (NiceAgent * agent, return nice_agent_add_stream_local_address (agent, stream_id, &nice_addr); } +NICEAPI_EXPORT gboolean +nice_agent_clear_stream_local_addresses (NiceAgent * agent, guint stream_id) +{ + gboolean result = FALSE; + Stream *stream; + GSList *item; + + agent_lock (agent); + + stream = agent_find_stream (agent, stream_id); + + if (!stream) { + goto done; + } + + for (item = stream->local_addresses; item; item = g_slist_next (item)) { + NiceAddress *address = item->data; + nice_address_free (address); + } + g_slist_free (stream->local_addresses); + stream->local_addresses = NULL; + + result = TRUE; + +done: + agent_unlock (agent); + return result; +} + /* Recompute foundations of all candidate pairs from a given stream * having a specific remote candidate, and eventually update the * priority of the selected pair as well. diff --git a/agent/agent.h b/agent/agent.h index cb1be18..c9341f4 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -348,6 +348,22 @@ nice_agent_add_local_address_from_string (NiceAgent *agent, const gchar *addr); NICE_EXPORT gboolean nice_agent_add_stream_local_address (NiceAgent *agent, guint stream_id, NiceAddress *addr); +/** + * nice_agent_clear_stream_local_addresses: + * @agent: The #NiceAgent Object + * @stream_id: The stream whose local addresses should be cleared + * + * Remove all local addresses that were previously configured on the + * stream @stream_id with nice_agent_add_stream_local_address() or + * nice_agent_add_stream_local_address_from_string(). After this call, + * new local addresses may be added to replace the cleared ones. + * + * See also: nice_agent_add_stream_local_address() + * Returns: %TRUE on success, %FALSE if the stream id is invalid + */ +NICE_EXPORT gboolean +nice_agent_clear_stream_local_addresses (NiceAgent *agent, guint stream_id); + /** * nice_agent_add_stream_local_address_from_string: * @agent: The #NiceAgent Object diff --git a/nice/libnice.sym b/nice/libnice.sym index d2b93b9..cdda488 100644 --- a/nice/libnice.sym +++ b/nice/libnice.sym @@ -19,6 +19,7 @@ nice_agent_add_local_address nice_agent_add_local_address_from_string nice_agent_add_stream_local_address nice_agent_add_stream_local_address_from_string +nice_agent_clear_stream_local_addresses nice_agent_add_stream nice_agent_set_stream nice_agent_attach_recv