mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
gst: handle combinations in gst_stream_type_get_name()
This should handle the majority of the valid stream cases. The element setting the stream type may set each type separately. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2804>
This commit is contained in:
parent
e87a2c38c0
commit
04dc8e2484
2 changed files with 101 additions and 4 deletions
|
@ -555,7 +555,6 @@ gst_stream_get_property (GObject * object, guint prop_id,
|
||||||
const gchar *
|
const gchar *
|
||||||
gst_stream_type_get_name (GstStreamType stype)
|
gst_stream_type_get_name (GstStreamType stype)
|
||||||
{
|
{
|
||||||
/* FIXME : Make this more flexible */
|
|
||||||
switch (stype) {
|
switch (stype) {
|
||||||
case GST_STREAM_TYPE_UNKNOWN:
|
case GST_STREAM_TYPE_UNKNOWN:
|
||||||
return "unknown";
|
return "unknown";
|
||||||
|
@ -567,8 +566,32 @@ gst_stream_type_get_name (GstStreamType stype)
|
||||||
return "container";
|
return "container";
|
||||||
case GST_STREAM_TYPE_TEXT:
|
case GST_STREAM_TYPE_TEXT:
|
||||||
return "text";
|
return "text";
|
||||||
default:
|
default:{
|
||||||
g_return_val_if_reached ("invalid");
|
gchar str[32] = { 0, };
|
||||||
return "invalid";
|
|
||||||
|
#define _GST_STREAM_TYPE_ALL \
|
||||||
|
(GST_STREAM_TYPE_AUDIO \
|
||||||
|
| GST_STREAM_TYPE_VIDEO \
|
||||||
|
| GST_STREAM_TYPE_CONTAINER \
|
||||||
|
| GST_STREAM_TYPE_TEXT)
|
||||||
|
|
||||||
|
if ((stype & (~_GST_STREAM_TYPE_ALL)) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if ((stype & GST_STREAM_TYPE_CONTAINER) != 0)
|
||||||
|
g_strlcat (str, "+container", sizeof (str));
|
||||||
|
if ((stype & GST_STREAM_TYPE_VIDEO) != 0)
|
||||||
|
g_strlcat (str, "+video", sizeof (str));
|
||||||
|
if ((stype & GST_STREAM_TYPE_AUDIO) != 0)
|
||||||
|
g_strlcat (str, "+audio", sizeof (str));
|
||||||
|
if ((stype & GST_STREAM_TYPE_TEXT) != 0)
|
||||||
|
g_strlcat (str, "+text", sizeof (str));
|
||||||
|
|
||||||
|
g_assert (str[0] != '\0');
|
||||||
|
|
||||||
|
return g_intern_string (str + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_return_val_if_reached ("invalid");
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,6 +211,79 @@ GST_START_TEST (test_notifies)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_stream_type_name)
|
||||||
|
{
|
||||||
|
GstStream *stream = NULL;
|
||||||
|
GstStreamType stream_type;
|
||||||
|
|
||||||
|
/* Create and set stream type */
|
||||||
|
stream = gst_stream_new ("here/we/go", NULL, GST_STREAM_TYPE_UNKNOWN, 0);
|
||||||
|
fail_unless (stream != NULL);
|
||||||
|
|
||||||
|
/* Check the stream type names */
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type), "unknown");
|
||||||
|
|
||||||
|
gst_stream_set_stream_type (stream, GST_STREAM_TYPE_AUDIO);
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type), "audio");
|
||||||
|
|
||||||
|
gst_stream_set_stream_type (stream, GST_STREAM_TYPE_VIDEO);
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type), "video");
|
||||||
|
|
||||||
|
gst_stream_set_stream_type (stream, GST_STREAM_TYPE_CONTAINER);
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type),
|
||||||
|
"container");
|
||||||
|
|
||||||
|
gst_stream_set_stream_type (stream, GST_STREAM_TYPE_TEXT);
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type), "text");
|
||||||
|
|
||||||
|
/* Check mixed stream type names */
|
||||||
|
gst_stream_set_stream_type (stream,
|
||||||
|
GST_STREAM_TYPE_VIDEO | GST_STREAM_TYPE_AUDIO);
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type),
|
||||||
|
"video+audio");
|
||||||
|
|
||||||
|
gst_stream_set_stream_type (stream,
|
||||||
|
GST_STREAM_TYPE_VIDEO | GST_STREAM_TYPE_TEXT);
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type),
|
||||||
|
"video+text");
|
||||||
|
|
||||||
|
gst_stream_set_stream_type (stream,
|
||||||
|
GST_STREAM_TYPE_AUDIO | GST_STREAM_TYPE_TEXT);
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type),
|
||||||
|
"audio+text");
|
||||||
|
|
||||||
|
gst_stream_set_stream_type (stream,
|
||||||
|
GST_STREAM_TYPE_VIDEO | GST_STREAM_TYPE_AUDIO | GST_STREAM_TYPE_TEXT);
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type),
|
||||||
|
"video+audio+text");
|
||||||
|
|
||||||
|
gst_stream_set_stream_type (stream,
|
||||||
|
GST_STREAM_TYPE_VIDEO | GST_STREAM_TYPE_AUDIO | GST_STREAM_TYPE_TEXT |
|
||||||
|
GST_STREAM_TYPE_CONTAINER);
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type),
|
||||||
|
"container+video+audio+text");
|
||||||
|
|
||||||
|
gst_stream_set_stream_type (stream,
|
||||||
|
GST_STREAM_TYPE_AUDIO | GST_STREAM_TYPE_CONTAINER);
|
||||||
|
stream_type = gst_stream_get_stream_type (stream);
|
||||||
|
fail_unless_equals_string (gst_stream_type_get_name (stream_type),
|
||||||
|
"container+audio");
|
||||||
|
|
||||||
|
gst_object_unref (stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
static Suite *
|
static Suite *
|
||||||
gst_streams_suite (void)
|
gst_streams_suite (void)
|
||||||
{
|
{
|
||||||
|
@ -221,6 +294,7 @@ gst_streams_suite (void)
|
||||||
tcase_add_test (tc_chain, test_stream_creation);
|
tcase_add_test (tc_chain, test_stream_creation);
|
||||||
tcase_add_test (tc_chain, test_stream_event);
|
tcase_add_test (tc_chain, test_stream_event);
|
||||||
tcase_add_test (tc_chain, test_notifies);
|
tcase_add_test (tc_chain, test_notifies);
|
||||||
|
tcase_add_test (tc_chain, test_stream_type_name);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue