rtpbasedepayload: set attributes on newly requested extensions
authorGuillaume Desmottes <guillaume.desmottes@collabora.com>
Tue, 26 Jan 2021 09:39:34 +0000 (10:39 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.com>
Wed, 27 Jan 2021 08:48:49 +0000 (09:48 +0100)
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>

gst-libs/gst/rtp/gstrtpbasedepayload.c
tests/check/libs/rtpbasedepayload.c

index 2cffef3..a5e8ea2 100644 (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 */
index cc7b03e..b5f566d 100644 (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);