rtpbasedepayload: Add "extensions" property for the currently enabled extensions
authorSebastian Dröge <sebastian@centricular.com>
Wed, 21 Feb 2024 10:53:53 +0000 (12:53 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 21 Feb 2024 12:17:24 +0000 (12:17 +0000)
This works the same way as the one from `rtpbasepayload`.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6163>

girs/GstRtp-1.0.gir
subprojects/gst-plugins-base/gst-libs/gst/rtp/gstrtpbasedepayload.c

index 1675b00630221f83ac2f0829f6ab7c6b312b8e9a..80a92288e8fde3f899160ca33a6f06f6def183af 100644 (file)
@@ -2633,6 +2633,19 @@ the need to handle these extensions manually using the
 GstRTPBaseDepayload::request-extension: signal.</doc>
         <type name="gboolean" c:type="gboolean"/>
       </property>
+      <property name="extensions" version="1.24" transfer-ownership="none">
+        <doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/rtp/gstrtpbasedepayload.c">A list of already enabled RTP header extensions. This may be useful for finding
+out which extensions are already enabled (with add-extension signal) and picking a non-conflicting
+ID for a new extension that needs to be added on top of the existing ones.
+
+Note that the value returned by reading this property is not dynamically updated when the set of
+enabled extensions changes by any of existing action signals. Rather, it represents the current state
+at the time the property is read.
+
+Dynamic updates of this property can be received by subscribing to its corresponding "notify" signal, i.e.
+"notify::extensions".</doc>
+        <type name="Gst.ValueArray"/>
+      </property>
       <property name="max-reorder" version="1.18" writable="1" transfer-ownership="none">
         <doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/rtp/gstrtpbasedepayload.c">Max seqnum reorder before the sender is assumed to have restarted.
 
index 1dc8ca307ca4a31bbd7cf0545fdfedd13cb6a39c..0d814de30c7b2b7171dfef79bf7ed95093670188 100644 (file)
@@ -140,9 +140,12 @@ enum
   PROP_SOURCE_INFO,
   PROP_MAX_REORDER,
   PROP_AUTO_HEADER_EXTENSION,
+  PROP_EXTENSIONS,
   PROP_LAST
 };
 
+static GParamSpec *gst_rtp_base_depayload_extensions_pspec;
+
 static void gst_rtp_base_depayload_finalize (GObject * object);
 static void gst_rtp_base_depayload_set_property (GObject * object,
     guint prop_id, const GValue * value, GParamSpec * pspec);
@@ -396,6 +399,33 @@ gst_rtp_base_depayload_class_init (GstRTPBaseDepayloadClass * klass)
       G_CALLBACK (gst_rtp_base_depayload_clear_extensions), NULL, NULL, NULL,
       G_TYPE_NONE, 0);
 
+  gst_rtp_base_depayload_extensions_pspec = gst_param_spec_array ("extensions",
+      "RTP header extensions",
+      "A list of already enabled RTP header extensions",
+      g_param_spec_object ("extension", "RTP header extension",
+          "An already enabled RTP extension", GST_TYPE_RTP_HEADER_EXTENSION,
+          G_PARAM_READABLE | G_PARAM_STATIC_STRINGS),
+      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+  /**
+   * GstRTPBaseDepayload:extensions:
+   *
+   * A list of already enabled RTP header extensions. This may be useful for finding
+   * out which extensions are already enabled (with add-extension signal) and picking a non-conflicting
+   * ID for a new extension that needs to be added on top of the existing ones.
+   *
+   * Note that the value returned by reading this property is not dynamically updated when the set of
+   * enabled extensions changes by any of existing action signals. Rather, it represents the current state
+   * at the time the property is read.
+   *
+   * Dynamic updates of this property can be received by subscribing to its corresponding "notify" signal, i.e.
+   * "notify::extensions".
+   *
+   * Since: 1.24
+   */
+  g_object_class_install_property (G_OBJECT_CLASS (klass),
+      PROP_EXTENSIONS, gst_rtp_base_depayload_extensions_pspec);
+
   gstelement_class->change_state = gst_rtp_base_depayload_change_state;
 
   klass->packet_lost = gst_rtp_base_depayload_packet_lost;
@@ -687,6 +717,9 @@ gst_rtp_base_depayload_setcaps (GstRTPBaseDepayload * filter, GstCaps * caps)
         filter->priv->header_exts);
     GST_OBJECT_UNLOCK (filter);
 
+    g_object_notify_by_pspec (G_OBJECT (filter),
+        gst_rtp_base_depayload_extensions_pspec);
+
   ext_out:
     g_ptr_array_unref (to_add);
     g_ptr_array_unref (to_remove);
@@ -1238,6 +1271,9 @@ gst_rtp_base_depayload_add_extension (GstRTPBaseDepayload * rtpbasepayload,
   GST_OBJECT_LOCK (rtpbasepayload);
   g_ptr_array_add (rtpbasepayload->priv->header_exts, gst_object_ref (ext));
   GST_OBJECT_UNLOCK (rtpbasepayload);
+
+  g_object_notify_by_pspec (G_OBJECT (rtpbasepayload),
+      gst_rtp_base_depayload_extensions_pspec);
 }
 
 static void
@@ -1246,6 +1282,31 @@ gst_rtp_base_depayload_clear_extensions (GstRTPBaseDepayload * rtpbasepayload)
   GST_OBJECT_LOCK (rtpbasepayload);
   g_ptr_array_set_size (rtpbasepayload->priv->header_exts, 0);
   GST_OBJECT_UNLOCK (rtpbasepayload);
+
+  g_object_notify_by_pspec (G_OBJECT (rtpbasepayload),
+      gst_rtp_base_depayload_extensions_pspec);
+}
+
+static void
+gst_rtp_base_depayload_get_extensions (GstRTPBaseDepayload * depayload,
+    GValue * out_value)
+{
+  GPtrArray *extensions;
+  guint i;
+
+  GST_OBJECT_LOCK (depayload);
+  extensions = depayload->priv->header_exts;
+
+  for (i = 0; i < extensions->len; ++i) {
+    GValue value = G_VALUE_INIT;
+    g_value_init (&value, GST_TYPE_RTP_HEADER_EXTENSION);
+
+    g_value_set_object (&value, g_ptr_array_index (extensions, i));
+
+    gst_value_array_append_and_take_value (out_value, &value);
+  }
+
+  GST_OBJECT_UNLOCK (depayload);
 }
 
 static gboolean
@@ -1809,6 +1870,9 @@ gst_rtp_base_depayload_get_property (GObject * object, guint prop_id,
     case PROP_AUTO_HEADER_EXTENSION:
       g_value_set_boolean (value, priv->auto_hdr_ext);
       break;
+    case PROP_EXTENSIONS:
+      gst_rtp_base_depayload_get_extensions (depayload, value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;