Skip to content

Commit

Permalink
rtpbasedepayload: set attributes on newly requested extensions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Guillaume Desmottes committed Jan 27, 2021
1 parent 912cf46 commit df9064f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gst-libs/gst/rtp/gstrtpbasedepayload.c
Expand Up @@ -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 */
Expand Down
5 changes: 5 additions & 0 deletions tests/check/libs/rtpbasedepayload.c
Expand Up @@ -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 =
Expand All @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit df9064f

Please sign in to comment.