diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index f51ebae30c..b505b7511c 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 a93a1068ea..6e7f4b3d1f 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 c116df5d28..1501cbc932 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,