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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1021>

gst-libs/gst/rtp/gstrtpbasepayload.c
tests/check/libs/rtpbasepayload.c
tests/check/libs/rtpdummyhdrextimpl.c

index e40c6c6..ee44287 100644 (file)
@@ -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 */
index 73afca2..a94faa5 100644 (file)
@@ -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);
@@ -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);
index 180dbc8..379bfe1 100644 (file)
@@ -53,6 +53,7 @@ struct _GstRTPDummyHdrExt
   GstRTPHeaderExtensionFlags supported_flags;
   guint read_count;
   guint write_count;
+  guint set_attributes_count;
 
   gchar *direction;
   gchar *attributes;
@@ -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;