rtphdrext: Store the direction in the base class
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Thu, 23 Sep 2021 20:24:04 +0000 (16:24 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 28 Sep 2021 20:04:55 +0000 (20:04 +0000)
Store the direction associated wit the RTP header extension in the
base class so it can use it.

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

subprojects/gst-plugins-base/gst-libs/gst/rtp/gstrtphdrext.c
subprojects/gst-plugins-base/gst-libs/gst/rtp/gstrtphdrext.h

index 6101c75..7611eb0 100644 (file)
@@ -43,10 +43,15 @@ GST_DEBUG_CATEGORY_STATIC (rtphderext_debug);
 
 #define MAX_RTP_EXT_ID 256
 
+#define GST_RTP_HEADER_EXTENSION_DIRECTION_DEFAULT      \
+  (GST_RTP_HEADER_EXTENSION_DIRECTION_SENDRECV |        \
+      GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED)
+
 typedef struct
 {
   guint ext_id;
   gboolean wants_update_non_rtp_src_caps;
+  GstRTPHeaderExtensionDirection direction;
 } GstRTPHeaderExtensionPrivate;
 
 /**
@@ -193,6 +198,7 @@ gst_rtp_header_extension_init (GstRTPHeaderExtension * ext)
       gst_rtp_header_extension_get_instance_private (ext);
 
   priv->ext_id = G_MAXUINT32;
+  priv->direction = GST_RTP_HEADER_EXTENSION_DIRECTION_DEFAULT;
 }
 
 /**
@@ -736,3 +742,52 @@ gst_rtp_header_extension_create_from_uri (const gchar * uri)
 
   return NULL;
 }
+
+/**
+ * gst_rtp_header_extension_set_direction:
+ * @ext: the #GstRTPHeaderExtension
+ * @direction: The direction
+ *
+ * Set the direction that this header extension should be used in.
+ * If #GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED is included, the
+ * direction will not be included in the caps (as it shouldn't be in the
+ * extmap line in the SDP).
+ *
+ * Since: 1.20
+ */
+
+void
+gst_rtp_header_extension_set_direction (GstRTPHeaderExtension * ext,
+    GstRTPHeaderExtensionDirection direction)
+{
+  GstRTPHeaderExtensionPrivate *priv =
+      gst_rtp_header_extension_get_instance_private (ext);
+
+  g_return_if_fail (GST_IS_RTP_HEADER_EXTENSION (ext));
+  g_return_if_fail (direction <= GST_RTP_HEADER_EXTENSION_DIRECTION_DEFAULT);
+
+  priv->direction = direction;
+}
+
+/**
+ * gst_rtp_header_extension_get_direction:
+ * @ext: the #GstRTPHeaderExtension
+ *
+ * Retrieve the direction
+ *
+ * Returns: The direction
+ *
+ * Since: 1.20
+ */
+
+GstRTPHeaderExtensionDirection
+gst_rtp_header_extension_get_direction (GstRTPHeaderExtension * ext)
+{
+  GstRTPHeaderExtensionPrivate *priv =
+      gst_rtp_header_extension_get_instance_private (ext);
+
+  g_return_val_if_fail (GST_IS_RTP_HEADER_EXTENSION (ext),
+      GST_RTP_HEADER_EXTENSION_DIRECTION_DEFAULT);
+
+  return priv->direction;
+}
index 76e7775..5fbf013 100644 (file)
@@ -104,6 +104,33 @@ typedef enum /*< underscore_name=gst_rtp_header_extension_flags >*/
 } GstRTPHeaderExtensionFlags;
 
 /**
+ * GstRTPHeaderExtensionDirection:
+ * @GST_RTP_HEADER_EXTENSION_DIRECTION_INACTIVE: Neither send nor
+ * receive RTP Header Extensions
+ * @GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY: Only send RTP Header
+ * Extensions @GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY: Only
+ * receive RTP Header Extensions
+ * @GST_RTP_HEADER_EXTENSION_DIRECTION_SENDRECV: Send and receive RTP
+ * Header Extensions ext
+ * @GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED: RTP header extension
+ * direction is inherited from the stream
+ *
+ * Direction to which to apply the RTP Header Extension
+ *
+ * Since: 1.20
+ */
+typedef enum /*< underscore_name=gst_rtp_header_extension_direction >*/
+{
+  GST_RTP_HEADER_EXTENSION_DIRECTION_INACTIVE = 0,
+  GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY = (1 << 0),
+  GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY = (1 << 1),
+  GST_RTP_HEADER_EXTENSION_DIRECTION_SENDRECV = (
+    GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY |
+    GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY),
+  GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED = (1 << 2)
+} GstRTPHeaderExtensionDirection;
+
+/**
  * GstRTPHeaderExtension:
  * @parent: the parent #GObject
  * @ext_id: the configured extension id
@@ -248,6 +275,12 @@ GstRTPHeaderExtension * gst_rtp_header_extension_create_from_uri (const gchar *
 GST_RTP_API
 gchar *                    gst_rtp_header_extension_get_sdp_caps_field_name (GstRTPHeaderExtension * ext);
 
+GST_RTP_API
+void               gst_rtp_header_extension_set_direction (GstRTPHeaderExtension * ext,
+                                                            GstRTPHeaderExtensionDirection direction);
+GST_RTP_API
+GstRTPHeaderExtensionDirection gst_rtp_header_extension_get_direction (GstRTPHeaderExtension * ext);
+
 G_END_DECLS
 
 #endif /* __GST_RTPHDREXT_H__ */