mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
rtphdrext test: Use helper function for caps
Also, let the base class parse the direction for us. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/906>
This commit is contained in:
parent
2db9f42b36
commit
674611c851
2 changed files with 10 additions and 52 deletions
|
@ -56,7 +56,6 @@ struct _GstRTPDummyHdrExt
|
||||||
guint set_attributes_count;
|
guint set_attributes_count;
|
||||||
guint caps_field_value;
|
guint caps_field_value;
|
||||||
|
|
||||||
gchar *direction;
|
|
||||||
gchar *attributes;
|
gchar *attributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -139,8 +138,6 @@ gst_rtp_dummy_hdr_ext_finalize (GObject * object)
|
||||||
|
|
||||||
g_free (dummy->attributes);
|
g_free (dummy->attributes);
|
||||||
dummy->attributes = NULL;
|
dummy->attributes = NULL;
|
||||||
g_free (dummy->direction);
|
|
||||||
dummy->direction = NULL;
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_rtp_dummy_hdr_ext_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gst_rtp_dummy_hdr_ext_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -208,42 +205,9 @@ gst_rtp_dummy_hdr_ext_set_caps_from_attributes (GstRTPHeaderExtension * ext,
|
||||||
GstCaps * caps)
|
GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstRTPDummyHdrExt *dummy = GST_RTP_DUMMY_HDR_EXT (ext);
|
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);
|
|
||||||
|
|
||||||
if (!field_name)
|
return gst_rtp_header_extension_set_caps_from_attributes_helper (ext, caps,
|
||||||
return FALSE;
|
dummy->attributes);
|
||||||
|
|
||||||
if (dummy->attributes || dummy->direction) {
|
|
||||||
GValue arr = G_VALUE_INIT;
|
|
||||||
GValue val = G_VALUE_INIT;
|
|
||||||
|
|
||||||
g_value_init (&arr, GST_TYPE_ARRAY);
|
|
||||||
g_value_init (&val, G_TYPE_STRING);
|
|
||||||
|
|
||||||
/* direction */
|
|
||||||
g_value_set_string (&val, dummy->direction);
|
|
||||||
gst_value_array_append_value (&arr, &val);
|
|
||||||
|
|
||||||
/* uri */
|
|
||||||
g_value_set_string (&val, gst_rtp_header_extension_get_uri (ext));
|
|
||||||
gst_value_array_append_value (&arr, &val);
|
|
||||||
|
|
||||||
/* attributes */
|
|
||||||
g_value_set_string (&val, dummy->attributes);
|
|
||||||
gst_value_array_append_value (&arr, &val);
|
|
||||||
|
|
||||||
gst_structure_set_value (s, field_name, &arr);
|
|
||||||
|
|
||||||
g_value_unset (&val);
|
|
||||||
g_value_unset (&arr);
|
|
||||||
} else {
|
|
||||||
gst_structure_set (s, field_name, G_TYPE_STRING,
|
|
||||||
gst_rtp_header_extension_get_uri (ext), NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (field_name);
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -253,9 +217,9 @@ gst_rtp_dummy_hdr_ext_set_attributes_from_caps (GstRTPHeaderExtension * ext,
|
||||||
GstRTPDummyHdrExt *dummy = GST_RTP_DUMMY_HDR_EXT (ext);
|
GstRTPDummyHdrExt *dummy = GST_RTP_DUMMY_HDR_EXT (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);
|
||||||
gchar *new_attrs = NULL, *new_direction = NULL;
|
|
||||||
const gchar *ext_uri;
|
const gchar *ext_uri;
|
||||||
const GValue *arr;
|
const GValue *arr;
|
||||||
|
gchar *new_attrs = NULL;
|
||||||
|
|
||||||
dummy->set_attributes_count++;
|
dummy->set_attributes_count++;
|
||||||
|
|
||||||
|
@ -279,11 +243,6 @@ gst_rtp_dummy_hdr_ext_set_attributes_from_caps (GstRTPHeaderExtension * ext,
|
||||||
gst_rtp_header_extension_get_uri (ext)) != 0)
|
gst_rtp_header_extension_get_uri (ext)) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
val = gst_value_array_get_value (arr, 0);
|
|
||||||
if (!G_VALUE_HOLDS_STRING (val))
|
|
||||||
goto error;
|
|
||||||
new_direction = g_value_dup_string (val);
|
|
||||||
|
|
||||||
val = gst_value_array_get_value (arr, 2);
|
val = gst_value_array_get_value (arr, 2);
|
||||||
if (!G_VALUE_HOLDS_STRING (val))
|
if (!G_VALUE_HOLDS_STRING (val))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -295,15 +254,12 @@ gst_rtp_dummy_hdr_ext_set_attributes_from_caps (GstRTPHeaderExtension * ext,
|
||||||
|
|
||||||
g_free (dummy->attributes);
|
g_free (dummy->attributes);
|
||||||
dummy->attributes = new_attrs;
|
dummy->attributes = new_attrs;
|
||||||
g_free (dummy->direction);
|
|
||||||
dummy->direction = new_direction;
|
|
||||||
|
|
||||||
g_free (field_name);
|
g_free (field_name);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
g_free (field_name);
|
g_free (field_name);
|
||||||
g_free (new_direction);
|
|
||||||
g_free (new_attrs);
|
g_free (new_attrs);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,8 @@ GST_START_TEST (rtp_header_ext_caps_with_attributes)
|
||||||
|
|
||||||
gst_rtp_header_extension_set_id (dummy, 1);
|
gst_rtp_header_extension_set_id (dummy, 1);
|
||||||
|
|
||||||
GST_RTP_DUMMY_HDR_EXT (dummy)->direction = g_strdup (direction);
|
gst_rtp_header_extension_set_direction (dummy,
|
||||||
|
GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY);
|
||||||
GST_RTP_DUMMY_HDR_EXT (dummy)->attributes = g_strdup (attributes);
|
GST_RTP_DUMMY_HDR_EXT (dummy)->attributes = g_strdup (attributes);
|
||||||
|
|
||||||
fail_unless (gst_rtp_header_extension_set_caps_from_attributes (dummy, caps));
|
fail_unless (gst_rtp_header_extension_set_caps_from_attributes (dummy, caps));
|
||||||
|
@ -111,8 +112,9 @@ GST_START_TEST (rtp_header_ext_caps_with_attributes)
|
||||||
val = gst_value_array_get_value (arr, 2);
|
val = gst_value_array_get_value (arr, 2);
|
||||||
fail_unless_equals_int (g_strcmp0 (g_value_get_string (val), attributes), 0);
|
fail_unless_equals_int (g_strcmp0 (g_value_get_string (val), attributes), 0);
|
||||||
|
|
||||||
g_free (GST_RTP_DUMMY_HDR_EXT (dummy)->direction);
|
gst_rtp_header_extension_set_direction (dummy,
|
||||||
GST_RTP_DUMMY_HDR_EXT (dummy)->direction = NULL;
|
GST_RTP_HEADER_EXTENSION_DIRECTION_SENDRECV |
|
||||||
|
GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED);
|
||||||
g_free (GST_RTP_DUMMY_HDR_EXT (dummy)->attributes);
|
g_free (GST_RTP_DUMMY_HDR_EXT (dummy)->attributes);
|
||||||
GST_RTP_DUMMY_HDR_EXT (dummy)->attributes = NULL;
|
GST_RTP_DUMMY_HDR_EXT (dummy)->attributes = NULL;
|
||||||
|
|
||||||
|
@ -120,8 +122,8 @@ GST_START_TEST (rtp_header_ext_caps_with_attributes)
|
||||||
|
|
||||||
fail_unless_equals_int (g_strcmp0 (GST_RTP_DUMMY_HDR_EXT (dummy)->attributes,
|
fail_unless_equals_int (g_strcmp0 (GST_RTP_DUMMY_HDR_EXT (dummy)->attributes,
|
||||||
attributes), 0);
|
attributes), 0);
|
||||||
fail_unless_equals_int (g_strcmp0 (GST_RTP_DUMMY_HDR_EXT (dummy)->direction,
|
fail_unless_equals_int (gst_rtp_header_extension_get_direction (dummy),
|
||||||
direction), 0);
|
GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY);
|
||||||
|
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
gst_object_unref (dummy);
|
gst_object_unref (dummy);
|
||||||
|
|
Loading…
Reference in a new issue