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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1021>
This commit is contained in:
Guillaume Desmottes 2021-01-26 10:39:34 +01:00
parent 912cf46b83
commit df9064fdc6
2 changed files with 16 additions and 2 deletions

View file

@ -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 */

View file

@ -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);