From 29befed6855ba421ab8e3418d11890754cf0c0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Tue, 14 Dec 2021 11:28:13 -0500 Subject: [PATCH] webrtcbin: Store the ssrc of the last received packet Part-of: --- .../gst-plugins-bad/ext/webrtc/gstwebrtcbin.c | 34 +++++++++++++++++++ .../gst-plugins-bad/ext/webrtc/gstwebrtcbin.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c index 917a98240a..86fd6437a1 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c @@ -439,6 +439,37 @@ gst_webrtc_bin_pad_init (GstWebRTCBinPad * pad) { } +static GstPadProbeReturn +webrtc_bin_pad_buffer_cb (GstPad * pad, GstPadProbeInfo * info, + gpointer user_data) +{ + GstWebRTCBinPad *wpad; + GstBuffer *buf; + GstRTPBuffer rtpbuf = GST_RTP_BUFFER_INIT; + + if (info->type & GST_PAD_PROBE_TYPE_BUFFER) { + buf = GST_PAD_PROBE_INFO_BUFFER (info); + } else { + GstBufferList *list; + + list = GST_PAD_PROBE_INFO_BUFFER_LIST (info); + buf = gst_buffer_list_get (list, 0); + } + + if (buf == NULL) + return GST_PAD_PROBE_OK; + + if (!gst_rtp_buffer_map (buf, GST_MAP_READ, &rtpbuf)) + return GST_PAD_PROBE_OK; + + wpad = GST_WEBRTC_BIN_PAD (pad); + wpad->last_ssrc = gst_rtp_buffer_get_ssrc (&rtpbuf); + + gst_rtp_buffer_unmap (&rtpbuf); + + return GST_PAD_PROBE_OK; +} + static GstWebRTCBinPad * gst_webrtc_bin_pad_new (const gchar * name, GstPadDirection direction) { @@ -460,6 +491,9 @@ gst_webrtc_bin_pad_new (const gchar * name, GstPadDirection direction) gst_pad_set_event_function (GST_PAD (pad), gst_webrtcbin_sink_event); gst_pad_set_query_function (GST_PAD (pad), gst_webrtcbin_sink_query); + gst_pad_add_probe (GST_PAD (pad), GST_PAD_PROBE_TYPE_BUFFER | + GST_PAD_PROBE_TYPE_BUFFER_LIST, webrtc_bin_pad_buffer_cb, NULL, NULL); + GST_DEBUG_OBJECT (pad, "new visible pad with direction %s", direction == GST_PAD_SRC ? "src" : "sink"); return pad; diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.h b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.h index e2ef991ebc..b80a54ad67 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.h +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.h @@ -46,6 +46,8 @@ struct _GstWebRTCBinPad GstWebRTCRTPTransceiver *trans; gulong block_id; + guint32 last_ssrc; + GstCaps *received_caps; };