mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-16 19:25:18 +00:00
rtphdrext: Pass just the attributes to the subclass
Since the base class now does the parsing, there is no need to reproduce that code in all the subclasses, just pass the attributes which are the only relevant bit anyway. Also, only store the direction if the subclass accepted the caps Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/906>
This commit is contained in:
parent
e65053a477
commit
5ec82c1c4e
5 changed files with 43 additions and 85 deletions
|
@ -13295,7 +13295,7 @@
|
|||
"GstRTPHeaderExtensionClass::get_max_size",
|
||||
"GstRTPHeaderExtensionClass::get_supported_flags",
|
||||
"GstRTPHeaderExtensionClass::read",
|
||||
"GstRTPHeaderExtensionClass::set_attributes_from_caps",
|
||||
"GstRTPHeaderExtensionClass::set_attributes",
|
||||
"GstRTPHeaderExtensionClass::set_caps_from_attributes",
|
||||
"GstRTPHeaderExtensionClass::set_non_rtp_sink_caps",
|
||||
"GstRTPHeaderExtensionClass::update_non_rtp_src_caps",
|
||||
|
@ -64700,4 +64700,4 @@
|
|||
"zbar:message",
|
||||
"zebrastripe",
|
||||
"zebrastripe:threshold"
|
||||
]
|
||||
]
|
||||
|
|
|
@ -412,6 +412,10 @@ gst_rtp_header_extension_set_attributes_from_caps (GstRTPHeaderExtension * ext,
|
|||
GstStructure *structure;
|
||||
gchar *field_name;
|
||||
const GValue *val;
|
||||
GstRTPHeaderExtensionDirection direction =
|
||||
GST_RTP_HEADER_EXTENSION_DIRECTION_DEFAULT;
|
||||
const gchar *attributes = "";
|
||||
gboolean ret = TRUE;
|
||||
|
||||
g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
|
||||
g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE);
|
||||
|
@ -443,15 +447,15 @@ gst_rtp_header_extension_set_attributes_from_caps (GstRTPHeaderExtension * ext,
|
|||
const gchar *dir = g_value_get_string (inner_val);
|
||||
|
||||
if (!strcmp (dir, ""))
|
||||
priv->direction = GST_RTP_HEADER_EXTENSION_DIRECTION_DEFAULT;
|
||||
direction = GST_RTP_HEADER_EXTENSION_DIRECTION_DEFAULT;
|
||||
else if (!strcmp (dir, "sendrecv"))
|
||||
priv->direction = GST_RTP_HEADER_EXTENSION_DIRECTION_SENDRECV;
|
||||
direction = GST_RTP_HEADER_EXTENSION_DIRECTION_SENDRECV;
|
||||
else if (!strcmp (dir, "sendonly"))
|
||||
priv->direction = GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY;
|
||||
direction = GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY;
|
||||
else if (!strcmp (dir, "recvonly"))
|
||||
priv->direction = GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY;
|
||||
direction = GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY;
|
||||
else if (!strcmp (dir, "inactive"))
|
||||
priv->direction = GST_RTP_HEADER_EXTENSION_DIRECTION_INACTIVE;
|
||||
direction = GST_RTP_HEADER_EXTENSION_DIRECTION_INACTIVE;
|
||||
else
|
||||
goto error;
|
||||
} else {
|
||||
|
@ -468,15 +472,20 @@ gst_rtp_header_extension_set_attributes_from_caps (GstRTPHeaderExtension * ext,
|
|||
inner_val = gst_value_array_get_value (val, 2);
|
||||
if (!G_VALUE_HOLDS_STRING (inner_val))
|
||||
goto error;
|
||||
|
||||
attributes = g_value_get_string (inner_val);
|
||||
} else {
|
||||
/* unknown caps format */
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (klass->set_attributes_from_caps)
|
||||
return klass->set_attributes_from_caps (ext, caps);
|
||||
else
|
||||
return TRUE;
|
||||
if (klass->set_attributes)
|
||||
ret = klass->set_attributes (ext, direction, attributes);
|
||||
|
||||
if (ret)
|
||||
priv->direction = direction;
|
||||
|
||||
return ret;
|
||||
|
||||
error:
|
||||
return FALSE;
|
||||
|
|
|
@ -167,8 +167,8 @@ struct _GstRTPHeaderExtension
|
|||
* extension needs for its function.
|
||||
* @update_non_rtp_src_caps: update depayloader non-RTP (depayloaded) caps with
|
||||
* the information parsed from RTP header.
|
||||
* @set_attributes_from_caps: read the caps information to set the necessary
|
||||
* attributes that may be signaled e.g. with an SDP.
|
||||
* @set_attributes: set the necessary attributes that may be signaled e.g. with
|
||||
* an SDP.
|
||||
* @set_caps_from_attributes: write the necessary caps field/s for the configured
|
||||
* attributes e.g. as signalled with SDP.
|
||||
*
|
||||
|
@ -202,8 +202,9 @@ struct _GstRTPHeaderExtensionClass
|
|||
const GstCaps * caps);
|
||||
gboolean (*update_non_rtp_src_caps) (GstRTPHeaderExtension * ext,
|
||||
GstCaps * caps);
|
||||
gboolean (*set_attributes_from_caps) (GstRTPHeaderExtension * ext,
|
||||
const GstCaps * caps);
|
||||
gboolean (*set_attributes) (GstRTPHeaderExtension * ext,
|
||||
GstRTPHeaderExtensionDirection direction,
|
||||
const gchar * attributes);
|
||||
gboolean (*set_caps_from_attributes) (GstRTPHeaderExtension * ext,
|
||||
GstCaps * caps);
|
||||
|
||||
|
|
|
@ -83,8 +83,8 @@ static gboolean
|
|||
gst_rtp_dummy_hdr_ext_set_caps_from_attributes (GstRTPHeaderExtension * ext,
|
||||
GstCaps * caps);
|
||||
static gboolean
|
||||
gst_rtp_dummy_hdr_ext_set_attributes_from_caps (GstRTPHeaderExtension * ext,
|
||||
const GstCaps * caps);
|
||||
gst_rtp_dummy_hdr_ext_set_attributes (GstRTPHeaderExtension * ext,
|
||||
GstRTPHeaderExtensionDirection direction, const gchar * attributes);
|
||||
static gboolean
|
||||
gst_rtp_dummy_hdr_ext_update_non_rtp_src_caps (GstRTPHeaderExtension * ext,
|
||||
GstCaps * caps);
|
||||
|
@ -108,8 +108,8 @@ gst_rtp_dummy_hdr_ext_class_init (GstRTPDummyHdrExtClass * klass)
|
|||
gst_rtp_dummy_hdr_ext_get_max_size;
|
||||
gstrtpheaderextension_class->write = gst_rtp_dummy_hdr_ext_write;
|
||||
gstrtpheaderextension_class->read = gst_rtp_dummy_hdr_ext_read;
|
||||
gstrtpheaderextension_class->set_attributes_from_caps =
|
||||
gst_rtp_dummy_hdr_ext_set_attributes_from_caps;
|
||||
gstrtpheaderextension_class->set_attributes =
|
||||
gst_rtp_dummy_hdr_ext_set_attributes;
|
||||
gstrtpheaderextension_class->set_caps_from_attributes =
|
||||
gst_rtp_dummy_hdr_ext_set_caps_from_attributes;
|
||||
gstrtpheaderextension_class->update_non_rtp_src_caps =
|
||||
|
@ -211,57 +211,17 @@ gst_rtp_dummy_hdr_ext_set_caps_from_attributes (GstRTPHeaderExtension * ext,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_dummy_hdr_ext_set_attributes_from_caps (GstRTPHeaderExtension * ext,
|
||||
const GstCaps * caps)
|
||||
gst_rtp_dummy_hdr_ext_set_attributes (GstRTPHeaderExtension * ext,
|
||||
GstRTPHeaderExtensionDirection direction, const gchar * attributes)
|
||||
{
|
||||
GstRTPDummyHdrExt *dummy = GST_RTP_DUMMY_HDR_EXT (ext);
|
||||
gchar *field_name = gst_rtp_header_extension_get_sdp_caps_field_name (ext);
|
||||
GstStructure *s = gst_caps_get_structure (caps, 0);
|
||||
const gchar *ext_uri;
|
||||
const GValue *arr;
|
||||
gchar *new_attrs = NULL;
|
||||
|
||||
dummy->set_attributes_count++;
|
||||
|
||||
if (!field_name)
|
||||
return FALSE;
|
||||
|
||||
if ((ext_uri = gst_structure_get_string (s, field_name))) {
|
||||
if (g_strcmp0 (ext_uri, gst_rtp_header_extension_get_uri (ext)) != 0) {
|
||||
/* incompatible extension uri for this instance */
|
||||
goto error;
|
||||
}
|
||||
} else if ((arr = gst_structure_get_value (s, field_name))
|
||||
&& GST_VALUE_HOLDS_ARRAY (arr)
|
||||
&& gst_value_array_get_size (arr) == 3) {
|
||||
const GValue *val;
|
||||
|
||||
val = gst_value_array_get_value (arr, 1);
|
||||
if (!G_VALUE_HOLDS_STRING (val))
|
||||
goto error;
|
||||
if (g_strcmp0 (g_value_get_string (val),
|
||||
gst_rtp_header_extension_get_uri (ext)) != 0)
|
||||
goto error;
|
||||
|
||||
val = gst_value_array_get_value (arr, 2);
|
||||
if (!G_VALUE_HOLDS_STRING (val))
|
||||
goto error;
|
||||
new_attrs = g_value_dup_string (val);
|
||||
} else {
|
||||
/* unknown caps format */
|
||||
goto error;
|
||||
}
|
||||
|
||||
g_free (dummy->attributes);
|
||||
dummy->attributes = new_attrs;
|
||||
dummy->attributes = g_strdup (attributes);
|
||||
|
||||
g_free (field_name);
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
g_free (field_name);
|
||||
g_free (new_attrs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -114,28 +114,16 @@ set_vad (GstRTPHeaderExtension * ext, gboolean vad)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_rtp_header_extension_rfc6464_set_attributes_from_caps (GstRTPHeaderExtension
|
||||
* ext, const GstCaps * caps)
|
||||
gst_rtp_header_extension_rfc6464_set_attributes (GstRTPHeaderExtension * ext,
|
||||
GstRTPHeaderExtensionDirection direction, const gchar * attributes)
|
||||
{
|
||||
gchar *field_name = gst_rtp_header_extension_get_sdp_caps_field_name (ext);
|
||||
GstStructure *s = gst_caps_get_structure (caps, 0);
|
||||
const GValue *arr;
|
||||
|
||||
arr = gst_structure_get_value (s, field_name);
|
||||
g_free (field_name);
|
||||
|
||||
if (GST_VALUE_HOLDS_ARRAY (arr)) {
|
||||
const GValue *val = gst_value_array_get_value (arr, 2);
|
||||
const gchar *vad_attr = g_value_get_string (val);
|
||||
|
||||
if (g_str_equal (vad_attr, "vad=on"))
|
||||
set_vad (ext, TRUE);
|
||||
else if (g_str_equal (vad_attr, "vad=off"))
|
||||
set_vad (ext, FALSE);
|
||||
else {
|
||||
GST_WARNING_OBJECT (ext, "Invalid attribute: %s", vad_attr);
|
||||
return FALSE;
|
||||
}
|
||||
if (g_str_equal (attributes, "vad=on") || g_str_equal (attributes, "")) {
|
||||
set_vad (ext, TRUE);
|
||||
} else if (g_str_equal (attributes, "vad=off")) {
|
||||
set_vad (ext, FALSE);
|
||||
} else {
|
||||
GST_WARNING_OBJECT (ext, "Invalid attribute: %s", attributes);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -247,8 +235,8 @@ gst_rtp_header_extension_rfc6464_class_init (GstRTPHeaderExtensionRfc6464Class *
|
|||
rtp_hdr_class->get_supported_flags =
|
||||
gst_rtp_header_extension_rfc6464_get_supported_flags;
|
||||
rtp_hdr_class->get_max_size = gst_rtp_header_extension_rfc6464_get_max_size;
|
||||
rtp_hdr_class->set_attributes_from_caps =
|
||||
gst_rtp_header_extension_rfc6464_set_attributes_from_caps;
|
||||
rtp_hdr_class->set_attributes =
|
||||
gst_rtp_header_extension_rfc6464_set_attributes;
|
||||
rtp_hdr_class->set_caps_from_attributes =
|
||||
gst_rtp_header_extension_rfc6464_set_caps_from_attributes;
|
||||
rtp_hdr_class->write = gst_rtp_header_extension_rfc6464_write;
|
||||
|
|
Loading…
Reference in a new issue