rtphdrext: Store the direction in the base class

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>
This commit is contained in:
Olivier Crête 2021-09-23 16:24:04 -04:00 committed by GStreamer Marge Bot
parent ba328fb98d
commit 63d669e0bf
2 changed files with 88 additions and 0 deletions

View file

@ -43,10 +43,15 @@ GST_DEBUG_CATEGORY_STATIC (rtphderext_debug);
#define MAX_RTP_EXT_ID 256 #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 typedef struct
{ {
guint ext_id; guint ext_id;
gboolean wants_update_non_rtp_src_caps; gboolean wants_update_non_rtp_src_caps;
GstRTPHeaderExtensionDirection direction;
} GstRTPHeaderExtensionPrivate; } GstRTPHeaderExtensionPrivate;
/** /**
@ -193,6 +198,7 @@ gst_rtp_header_extension_init (GstRTPHeaderExtension * ext)
gst_rtp_header_extension_get_instance_private (ext); gst_rtp_header_extension_get_instance_private (ext);
priv->ext_id = G_MAXUINT32; 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; 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;
}

View file

@ -103,6 +103,33 @@ typedef enum /*< underscore_name=gst_rtp_header_extension_flags >*/
GST_RTP_HEADER_EXTENSION_TWO_BYTE = (1 << 1), GST_RTP_HEADER_EXTENSION_TWO_BYTE = (1 << 1),
} GstRTPHeaderExtensionFlags; } 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: * GstRTPHeaderExtension:
* @parent: the parent #GObject * @parent: the parent #GObject
@ -248,6 +275,12 @@ GstRTPHeaderExtension * gst_rtp_header_extension_create_from_uri (const gchar *
GST_RTP_API GST_RTP_API
gchar * gst_rtp_header_extension_get_sdp_caps_field_name (GstRTPHeaderExtension * ext); 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 G_END_DECLS
#endif /* __GST_RTPHDREXT_H__ */ #endif /* __GST_RTPHDREXT_H__ */