From 303c8025c621c5616ff2173f95eef41feb86c397 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Wed, 27 Oct 2021 00:20:57 +0200 Subject: [PATCH] webrtcbin: fix check_negotiation computing on caps event It seems logical that check_negotiation be true if received_caps is *not* equal to the new caps. Also clean up handling of transceivers' ssrc events, as this patch triggered a leaky code path. Part-of: --- subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c | 16 ++++++++-------- .../gst-plugins-bad/ext/webrtc/webrtctransceiver.c | 7 +++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c index bf41b97..4dad466 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c @@ -269,10 +269,11 @@ gst_webrtc_bin_pad_update_ssrc_event (GstWebRTCBinPad * wpad) WebRTCTransceiver *trans = (WebRTCTransceiver *) wpad->trans; GstPad *pad = GST_PAD (wpad); - trans->ssrc_event = + gst_event_take (&trans->ssrc_event, gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM_STICKY, - gst_structure_new ("GstWebRtcBinUpdateTos", "ssrc", G_TYPE_UINT, - trans->current_ssrc, NULL)); + gst_structure_new ("GstWebRtcBinUpdateTos", "ssrc", G_TYPE_UINT, + trans->current_ssrc, NULL))); + gst_pad_send_event (pad, gst_event_ref (trans->ssrc_event)); } } @@ -302,7 +303,7 @@ gst_webrtcbin_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) gst_event_parse_caps (event, &caps); check_negotiation = (!wpad->received_caps - || gst_caps_is_equal (wpad->received_caps, caps)); + || !gst_caps_is_equal (wpad->received_caps, caps)); gst_caps_replace (&wpad->received_caps, caps); GST_DEBUG_OBJECT (parent, @@ -468,8 +469,7 @@ gst_webrtc_bin_pad_new (const gchar * name, GstPadDirection direction) G_DEFINE_TYPE_WITH_CODE (GstWebRTCBin, gst_webrtc_bin, GST_TYPE_BIN, G_ADD_PRIVATE (GstWebRTCBin) GST_DEBUG_CATEGORY_INIT (gst_webrtc_bin_debug, "webrtcbin", 0, - "webrtcbin element"); - ); + "webrtcbin element");); enum { @@ -1489,8 +1489,8 @@ _check_if_negotiation_is_needed (GstWebRTCBin * webrtc) /* If connection has created any RTCDataChannel's, and no m= section has * been negotiated yet for data, return "true". */ if (webrtc->priv->data_channels->len > 0) { - if (_message_get_datachannel_index (webrtc-> - current_local_description->sdp) >= G_MAXUINT) { + if (_message_get_datachannel_index (webrtc->current_local_description-> + sdp) >= G_MAXUINT) { GST_LOG_OBJECT (webrtc, "no data channel media section and have %u " "transports", webrtc->priv->data_channels->len); diff --git a/subprojects/gst-plugins-bad/ext/webrtc/webrtctransceiver.c b/subprojects/gst-plugins-bad/ext/webrtc/webrtctransceiver.c index aa9f1e2..963dfc6 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/webrtctransceiver.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/webrtctransceiver.c @@ -32,7 +32,8 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); G_DEFINE_TYPE_WITH_CODE (WebRTCTransceiver, webrtc_transceiver, GST_TYPE_WEBRTC_RTP_TRANSCEIVER, GST_DEBUG_CATEGORY_INIT (webrtc_transceiver_debug, - "webrtctransceiver", 0, "webrtctransceiver");); + "webrtctransceiver", 0, "webrtctransceiver"); + ); #define DEFAULT_FEC_TYPE GST_WEBRTC_FEC_TYPE_NONE #define DEFAULT_DO_NACK FALSE @@ -157,9 +158,7 @@ webrtc_transceiver_finalize (GObject * object) gst_caps_replace (&trans->last_configured_caps, NULL); - if (trans->ssrc_event) - gst_event_unref (trans->ssrc_event); - trans->ssrc_event = NULL; + gst_event_replace (&trans->ssrc_event, NULL); G_OBJECT_CLASS (parent_class)->finalize (object); } -- 2.7.4