From 1ae7ab03d9324fceceec4c54c030c41e38a9e8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Fri, 25 Apr 2025 16:36:37 -0400 Subject: [PATCH] nice: Add function to fill in ufrag/pwd of remote candidates Part-of: --- .../gst-libs/gst/webrtc/nice/nice.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/webrtc/nice/nice.c b/subprojects/gst-plugins-bad/gst-libs/gst/webrtc/nice/nice.c index 4f9132b3ea..86fe1fefdc 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/webrtc/nice/nice.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/webrtc/nice/nice.c @@ -71,6 +71,9 @@ struct _GstWebRTCNicePrivate GHashTable *turn_servers; GstUri *http_proxy; + + gchar *remote_ufrag; + gchar *remote_pwd; }; #define gst_webrtc_nice_parent_class parent_class @@ -576,6 +579,17 @@ _fill_local_candidate_credentials (NiceAgent * agent, NiceCandidate * candidate) } } +static void +_fill_remote_candidate_credentials (GstWebRTCNice * nice, + NiceCandidate * candidate) +{ + if (!candidate->username) + candidate->username = g_strdup (nice->priv->remote_ufrag); + + if (!candidate->password) + candidate->password = g_strdup (nice->priv->remote_pwd); +} + static void _on_new_candidate (NiceAgent * agent, NiceCandidate * candidate, GstWebRTCNice * ice) @@ -874,6 +888,11 @@ gst_webrtc_nice_set_remote_credentials (GstWebRTCICE * ice, nice_agent_set_remote_credentials (nice->priv->nice_agent, item->nice_stream_id, ufrag, pwd); + g_free (nice->priv->remote_ufrag); + g_free (nice->priv->remote_pwd); + nice->priv->remote_ufrag = g_strdup (ufrag); + nice->priv->remote_pwd = g_strdup (pwd); + return TRUE; } @@ -1217,6 +1236,7 @@ gst_webrtc_nice_get_selected_pair (GstWebRTCICE * ice, if (nice_agent_get_selected_pair (nice->priv->nice_agent, stream->stream_id, NICE_COMPONENT_TYPE_RTP, &local_cand, &remote_cand)) { _fill_local_candidate_credentials (nice->priv->nice_agent, local_cand); + _fill_remote_candidate_credentials (nice, remote_cand); *local_stats = g_new0 (GstWebRTCICECandidateStats, 1); _populate_candidate_stats (nice, local_cand, stream, *local_stats, TRUE); @@ -1626,6 +1646,9 @@ gst_webrtc_nice_finalize (GObject * object) g_hash_table_unref (ice->priv->turn_servers); + g_free (ice->priv->remote_ufrag); + g_free (ice->priv->remote_pwd); + G_OBJECT_CLASS (parent_class)->finalize (object); }