Skip to content

Commit

Permalink
rtpbasepayload: 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.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1021>
  • Loading branch information
Guillaume Desmottes committed Jan 27, 2021
1 parent 5acde55 commit 912cf46
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gst-libs/gst/rtp/gstrtpbasepayload.c
Expand Up @@ -1388,8 +1388,17 @@ gst_rtp_base_payload_negotiate (GstRTPBasePayload * payload)
"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,
srccaps)) {
GST_WARNING_OBJECT (payload,
"Failed to configure rtp header " "extension %"
GST_PTR_FORMAT " attributes from caps %" GST_PTR_FORMAT,
ext, srccaps);
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/rtpbasepayload.c
Expand Up @@ -2150,16 +2150,20 @@ request_extension (GstRTPBasePayload * depayload, guint ext_id,
GST_START_TEST (rtp_base_payload_caps_request)
{
GstRTPHeaderExtension *ext;
GstRTPDummyHdrExt *dummy;
State *state;

state =
create_payloader ("application/x-rtp", &sinktmpl_with_extmap_str, NULL);

ext = rtp_dummy_hdr_ext_new ();
dummy = GST_RTP_DUMMY_HDR_EXT (ext);
gst_rtp_header_extension_set_id (ext, 4);
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_buffer (state, "pts", 0 * GST_SECOND, NULL);
Expand All @@ -2175,6 +2179,7 @@ GST_START_TEST (rtp_base_payload_caps_request)
validate_normal_start_events (0);

fail_unless_equals_int (GST_RTP_DUMMY_HDR_EXT (ext)->write_count, 1);
fail_unless (dummy->set_attributes_count == 1);

gst_object_unref (ext);
destroy_payloader (state);
Expand Down
3 changes: 3 additions & 0 deletions tests/check/libs/rtpdummyhdrextimpl.c
Expand Up @@ -53,6 +53,7 @@ struct _GstRTPDummyHdrExt
GstRTPHeaderExtensionFlags supported_flags;
guint read_count;
guint write_count;
guint set_attributes_count;

gchar *direction;
gchar *attributes;
Expand Down Expand Up @@ -245,6 +246,8 @@ gst_rtp_dummy_hdr_ext_set_attributes_from_caps (GstRTPHeaderExtension * ext,
const gchar *ext_uri;
const GValue *arr;

dummy->set_attributes_count++;

if (!field_name)
return FALSE;

Expand Down

0 comments on commit 912cf46

Please sign in to comment.