From 80ede091935f07d93dda456ae7f6976b9b6bbc0c Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 29 Apr 2020 22:01:32 +1000 Subject: [PATCH] webrtcbin: only start gathering on local descriptions If we are in a state where we are answering, we would start gathering when the offer is set which is incorrect for at least two reasons. 1. Sending ICE candidates before sending an answer is a hard error in all of the major browsers and will fail the negotiation. 2. If libnice ever adds the username fragment to the candidate for ice-restart hardening, the ice username and fragment would be incorrect. JSEP also hints that the right call flow is to only start gathering when a local description is set in 4.1.9 setLocalDescription "This API indirectly controls the candidate gathering process." as well as hints throughout other sections. Part-of: --- ext/webrtc/gstwebrtcbin.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index fd6e812536..986cfb7c1d 100644 --- a/ext/webrtc/gstwebrtcbin.c +++ b/ext/webrtc/gstwebrtcbin.c @@ -4448,21 +4448,24 @@ _set_description_task (GstWebRTCBin * webrtc, struct set_description *sd) _get_ice_credentials_from_sdp_media (sd->sdp->sdp, i, &ufrag, &pwd); - if (sd->source == SDP_LOCAL) + if (sd->source == SDP_LOCAL) { gst_webrtc_ice_set_local_credentials (webrtc->priv->ice, item->stream, ufrag, pwd); - else + } else { gst_webrtc_ice_set_remote_credentials (webrtc->priv->ice, item->stream, ufrag, pwd); + } g_free (ufrag); g_free (pwd); } - for (i = 0; i < webrtc->priv->ice_stream_map->len; i++) { - IceStreamItem *item = - &g_array_index (webrtc->priv->ice_stream_map, IceStreamItem, i); + if (sd->source == SDP_LOCAL) { + for (i = 0; i < webrtc->priv->ice_stream_map->len; i++) { + IceStreamItem *item = + &g_array_index (webrtc->priv->ice_stream_map, IceStreamItem, i); - gst_webrtc_ice_gather_candidates (webrtc->priv->ice, item->stream); + gst_webrtc_ice_gather_candidates (webrtc->priv->ice, item->stream); + } } /* Add any pending trickle ICE candidates if we have both offer and answer */