From eefd793011a778462dda3a0c3894b15db060d0f7 Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Wed, 11 May 2022 09:17:46 +0100 Subject: [PATCH] webrtc: Use new libnice API to get the candidate relay address Corresponding libnice API added in: https://gitlab.freedesktop.org/libnice/libnice/-/merge_requests/229 (0.1.19) https://gitlab.freedesktop.org/libnice/libnice/-/merge_requests/232 (0.1.20) Part-of: --- .../gst-plugins-bad/ext/webrtc/gstwebrtcice.c | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.c b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.c index 9f2dc68d30..04adc8f1f2 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.c @@ -886,10 +886,44 @@ static gchar * _get_server_url (GstWebRTCICE * ice, NiceCandidate * cand) { switch (cand->type) { - case NICE_CANDIDATE_TYPE_RELAYED: + case NICE_CANDIDATE_TYPE_RELAYED:{ +#if NICE_CHECK_VERSION(0, 1, 19) + NiceAddress addr; + gchar ipaddr[NICE_ADDRESS_STRING_LEN]; + nice_candidate_relay_address (cand, &addr); + nice_address_to_string (&addr, ipaddr); + return g_strdup (ipaddr); +#else + static gboolean warned = FALSE; + if (!warned) { + GST_WARNING + ("libnice version < 0.1.19 detected, relayed candidate server address might be wrong."); + warned = TRUE; + } return g_strdup (gst_uri_get_host (ice->turn_server)); - case NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE: +#endif + } + case NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE:{ +#if NICE_CHECK_VERSION(0, 1, 20) + NiceAddress addr; + gchar ipaddr[NICE_ADDRESS_STRING_LEN]; + if (nice_candidate_stun_server_address (cand, &addr)) { + nice_address_to_string (&addr, ipaddr); + return g_strdup (ipaddr); + } else { + return g_strdup (gst_uri_get_host (ice->stun_server)); + } +#else + static gboolean warned = FALSE; + if (!warned) { + GST_WARNING + ("libnice version < 0.1.20 detected, server-reflexive candidate server " + "address might be wrong."); + warned = TRUE; + } +#endif return g_strdup (gst_uri_get_host (ice->stun_server)); + } default: return g_strdup (""); } -- 2.34.1