rtphdrext: Add helper function to set fields in caps

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/906>
This commit is contained in:
Olivier Crête 2021-09-24 12:51:01 -04:00 committed by GStreamer Marge Bot
parent e76dce3c6e
commit 87a91d1387
2 changed files with 23 additions and 7 deletions

View file

@ -652,8 +652,8 @@ gst_rtp_header_extension_get_sdp_caps_field_name (GstRTPHeaderExtension * ext)
return g_strdup_printf ("extmap-%u", priv->ext_id); return g_strdup_printf ("extmap-%u", priv->ext_id);
} }
/* /**
* gst_rtp_header_extension_set_caps_from_attributes_default * gst_rtp_header_extension_set_caps_from_attributes_helper:
* @ext: the #GstRTPHeaderExtension * @ext: the #GstRTPHeaderExtension
* @caps: #GstCaps to write fields into * @caps: #GstCaps to write fields into
* *
@ -665,17 +665,20 @@ gst_rtp_header_extension_get_sdp_caps_field_name (GstRTPHeaderExtension * ext)
* advertised in @caps. * advertised in @caps.
* *
* Returns: whether the @ext attributes could be set on @caps. * Returns: whether the @ext attributes could be set on @caps.
*
* Since: 1.20
*/ */
static gboolean gboolean
gst_rtp_header_extension_set_caps_from_attributes_default (GstRTPHeaderExtension gst_rtp_header_extension_set_caps_from_attributes_helper (GstRTPHeaderExtension
* ext, GstCaps * caps) * ext, GstCaps * caps, const gchar * attributes)
{ {
GstRTPHeaderExtensionPrivate *priv = GstRTPHeaderExtensionPrivate *priv =
gst_rtp_header_extension_get_instance_private (ext); gst_rtp_header_extension_get_instance_private (ext);
gchar *field_name = gst_rtp_header_extension_get_sdp_caps_field_name (ext); gchar *field_name = gst_rtp_header_extension_get_sdp_caps_field_name (ext);
GstStructure *s = gst_caps_get_structure (caps, 0); GstStructure *s = gst_caps_get_structure (caps, 0);
if (priv->direction & GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED) { if (priv->direction & GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED &&
(attributes == NULL || attributes[0] == 0)) {
gst_structure_set (s, field_name, G_TYPE_STRING, gst_structure_set (s, field_name, G_TYPE_STRING,
gst_rtp_header_extension_get_uri (ext), NULL); gst_rtp_header_extension_get_uri (ext), NULL);
} else { } else {
@ -705,7 +708,7 @@ gst_rtp_header_extension_set_caps_from_attributes_default (GstRTPHeaderExtension
gst_value_array_append_value (&arr, &val); gst_value_array_append_value (&arr, &val);
/* attributes */ /* attributes */
g_value_set_string (&val, ""); g_value_set_string (&val, attributes);
gst_value_array_append_value (&arr, &val); gst_value_array_append_value (&arr, &val);
gst_structure_set_value (s, field_name, &arr); gst_structure_set_value (s, field_name, &arr);
@ -720,6 +723,14 @@ gst_rtp_header_extension_set_caps_from_attributes_default (GstRTPHeaderExtension
return TRUE; return TRUE;
} }
static gboolean
gst_rtp_header_extension_set_caps_from_attributes_default (GstRTPHeaderExtension
* ext, GstCaps * caps)
{
return gst_rtp_header_extension_set_caps_from_attributes_helper (ext, caps,
NULL);
}
static gboolean static gboolean
gst_rtp_ext_list_filter (GstPluginFeature * feature, gpointer user_data) gst_rtp_ext_list_filter (GstPluginFeature * feature, gpointer user_data)
{ {

View file

@ -281,6 +281,11 @@ void gst_rtp_header_extension_set_direction (GstRTPHeaderExtension *
GST_RTP_API GST_RTP_API
GstRTPHeaderExtensionDirection gst_rtp_header_extension_get_direction (GstRTPHeaderExtension * ext); GstRTPHeaderExtensionDirection gst_rtp_header_extension_get_direction (GstRTPHeaderExtension * ext);
GST_RTP_API
gboolean gst_rtp_header_extension_set_caps_from_attributes_helper (GstRTPHeaderExtension * ext,
GstCaps * caps,
const gchar * attributes);
G_END_DECLS G_END_DECLS
#endif /* __GST_RTPHDREXT_H__ */ #endif /* __GST_RTPHDREXT_H__ */