diff options
author | Matthew Waters <matthew@centricular.com> | 2020-05-25 13:10:20 +1000 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2020-05-28 19:57:45 +1000 |
commit | 67ae885d4c4b6e510c38882f0edb0800d8ed0946 (patch) | |
tree | 762fd3318d375e11998dd69a478c9061a5c5c19c /ext | |
parent | 06f3a0ed2c212411ad78d51a9143adb0d2a63b09 (diff) | |
download | gstreamer-plugins-bad-67ae885d4c4b6e510c38882f0edb0800d8ed0946.tar.gz |
webrtc: handle an ice-lite remote offer
When the remote peer offers an ice-lite SDP, we need to configure our
ICE negotiation to be in controlling mode as the peer will not be.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1304>
Diffstat (limited to 'ext')
-rw-r--r-- | ext/webrtc/gstwebrtcbin.c | 23 | ||||
-rw-r--r-- | ext/webrtc/webrtcsdp.c | 6 | ||||
-rw-r--r-- | ext/webrtc/webrtcsdp.h | 3 |
3 files changed, 25 insertions, 7 deletions
diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index f51ebae30..b505b7511 100644 --- a/ext/webrtc/gstwebrtcbin.c +++ b/ext/webrtc/gstwebrtcbin.c @@ -2756,9 +2756,6 @@ _create_offer_task (GstWebRTCBin * webrtc, const GstStructure * options) /* FIXME: pre-emptively setup receiving elements when needed */ - /* XXX: only true for the initial offerer */ - g_object_set (webrtc->priv->ice, "controller", TRUE, NULL); - g_list_free (seen_transceivers); if (webrtc->priv->last_generated_answer) @@ -4465,7 +4462,25 @@ _set_description_task (GstWebRTCBin * webrtc, struct set_description *sd) signalling_state_changed = TRUE; } - if (webrtc->signaling_state == GST_WEBRTC_SIGNALING_STATE_STABLE) { + { + gboolean ice_controller = FALSE; + + /* we control ice negotiation if we send the initial offer */ + ice_controller |= + new_signaling_state == GST_WEBRTC_SIGNALING_STATE_HAVE_REMOTE_OFFER + && webrtc->current_remote_description == NULL; + /* or, if the remote is an ice-lite peer */ + ice_controller |= new_signaling_state == GST_WEBRTC_SIGNALING_STATE_STABLE + && webrtc->current_remote_description->type == GST_WEBRTC_SDP_TYPE_OFFER + && _message_has_attribute_key (webrtc->current_remote_description->sdp, + "ice-lite"); + + GST_DEBUG_OBJECT (webrtc, "we are in ice controlling mode: %s", + ice_controller ? "true" : "false"); + g_object_set (webrtc->priv->ice, "controller", ice_controller, NULL); + } + + if (new_signaling_state == GST_WEBRTC_SIGNALING_STATE_STABLE) { GList *tmp; /* media modifications */ diff --git a/ext/webrtc/webrtcsdp.c b/ext/webrtc/webrtcsdp.c index a93a1068e..6e7f4b3d1 100644 --- a/ext/webrtc/webrtcsdp.c +++ b/ext/webrtc/webrtcsdp.c @@ -144,9 +144,8 @@ _check_sdp_crypto (SDPSource source, GstWebRTCSessionDescription * sdp, return TRUE; } -#if 0 -static gboolean -_session_has_attribute_key (const GstSDPMessage * msg, const gchar * key) +gboolean +_message_has_attribute_key (const GstSDPMessage * msg, const gchar * key) { int i; for (i = 0; i < gst_sdp_message_attributes_len (msg); i++) { @@ -159,6 +158,7 @@ _session_has_attribute_key (const GstSDPMessage * msg, const gchar * key) return FALSE; } +#if 0 static gboolean _session_has_attribute_key_value (const GstSDPMessage * msg, const gchar * key, const gchar * value) diff --git a/ext/webrtc/webrtcsdp.h b/ext/webrtc/webrtcsdp.h index c116df5d2..1501cbc93 100644 --- a/ext/webrtc/webrtcsdp.h +++ b/ext/webrtc/webrtcsdp.h @@ -91,6 +91,9 @@ gboolean _message_media_is_datachannel (con guint media_id); G_GNUC_INTERNAL guint _message_get_datachannel_index (const GstSDPMessage * msg); +G_GNUC_INTERNAL +gboolean _message_has_attribute_key (const GstSDPMessage * msg, + const gchar * key); G_GNUC_INTERNAL gboolean _get_bundle_index (GstSDPMessage * sdp, |