From df9064fdc6203da28fecedd2dcc81537d3888f30 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 26 Jan 2021 10:39:34 +0100 Subject: [PATCH] rtpbasedepayload: set attributes on newly requested extensions Users were supposed to configure the extension themselves but it was impossible to do so as they didn't have access to the caps. Fix #864 Part-of: --- gst-libs/gst/rtp/gstrtpbasedepayload.c | 13 +++++++++++-- tests/check/libs/rtpbasedepayload.c | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/rtp/gstrtpbasedepayload.c b/gst-libs/gst/rtp/gstrtpbasedepayload.c index 2cffef3..a5e8ea2 100644 --- a/gst-libs/gst/rtp/gstrtpbasedepayload.c +++ b/gst-libs/gst/rtp/gstrtpbasedepayload.c @@ -539,8 +539,17 @@ gst_rtp_base_depayload_setcaps (GstRTPBaseDepayload * filter, GstCaps * caps) "extension id %" G_GUINT64_FORMAT, uri, ext_id); gst_clear_object (&ext); } - /* it is the signal handler's responsibility to set attributes if - * required */ + + if (ext && !gst_rtp_header_extension_set_attributes_from_caps (ext, + caps)) { + GST_WARNING_OBJECT (filter, + "Failed to configure rtp header " "extension %" + GST_PTR_FORMAT " attributes from caps %" GST_PTR_FORMAT, + ext, caps); + res = FALSE; + g_clear_object (&ext); + goto ext_out; + } /* We don't create an extension implementation by default and require * the caller to set the appropriate extension if it's required */ diff --git a/tests/check/libs/rtpbasedepayload.c b/tests/check/libs/rtpbasedepayload.c index cc7b03e..b5f566d 100644 --- a/tests/check/libs/rtpbasedepayload.c +++ b/tests/check/libs/rtpbasedepayload.c @@ -1645,12 +1645,14 @@ request_extension (GstRTPBaseDepayload * depayload, guint ext_id, GST_START_TEST (rtp_base_depayload_request_extension) { GstRTPHeaderExtension *ext; + GstRTPDummyHdrExt *dummy; State *state; state = create_depayloader ("application/x-rtp,extmap-3=(string)" DUMMY_HDR_EXT_URI, NULL); ext = rtp_dummy_hdr_ext_new (); + dummy = GST_RTP_DUMMY_HDR_EXT (ext); gst_rtp_header_extension_set_id (ext, 3); GST_RTP_DUMMY_DEPAY (state->element)->push_method = @@ -1659,6 +1661,8 @@ GST_START_TEST (rtp_base_depayload_request_extension) g_signal_connect (state->element, "request-extension", G_CALLBACK (request_extension), ext); + fail_unless (dummy->set_attributes_count == 0); + set_state (state, GST_STATE_PLAYING); push_rtp_buffer (state, "pts", 0 * GST_SECOND, @@ -1672,6 +1676,7 @@ GST_START_TEST (rtp_base_depayload_request_extension) validate_buffer (0, "pts", 0 * GST_SECOND, "discont", FALSE, NULL); fail_unless_equals_int (GST_RTP_DUMMY_HDR_EXT (ext)->read_count, 1); + fail_unless (dummy->set_attributes_count == 1); gst_object_unref (ext); destroy_depayloader (state); -- 2.7.4