Commit 223d2792 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Introduce new stream_type_from_caps helper.

parent 6d37b673
......@@ -32,6 +32,7 @@ GST_DEBUG_CATEGORY_EXTERN(wine) DECLSPEC_HIDDEN;
extern NTSTATUS wg_init_gstreamer(void *args) DECLSPEC_HIDDEN;
extern GstStreamType stream_type_from_caps(GstCaps *caps) DECLSPEC_HIDDEN;
extern GstElement *create_element(const char *name, const char *plugin_set) DECLSPEC_HIDDEN;
extern GstElement *find_element(GstElementFactoryListType type, GstCaps *src_caps, GstCaps *sink_caps) DECLSPEC_HIDDEN;
extern bool append_element(GstElement *container, GstElement *element, GstElement **first, GstElement **last) DECLSPEC_HIDDEN;
......
......@@ -47,6 +47,27 @@
GST_DEBUG_CATEGORY(wine);
GstStreamType stream_type_from_caps(GstCaps *caps)
{
const gchar *media_type;
if (!caps || !gst_caps_get_size(caps))
return GST_STREAM_TYPE_UNKNOWN;
media_type = gst_structure_get_name(gst_caps_get_structure(caps, 0));
if (g_str_has_prefix(media_type, "video/")
|| g_str_has_prefix(media_type, "image/"))
return GST_STREAM_TYPE_VIDEO;
if (g_str_has_prefix(media_type, "audio/"))
return GST_STREAM_TYPE_AUDIO;
if (g_str_has_prefix(media_type, "text/")
|| g_str_has_prefix(media_type, "subpicture/")
|| g_str_has_prefix(media_type, "closedcaption/"))
return GST_STREAM_TYPE_TEXT;
return GST_STREAM_TYPE_UNKNOWN;
}
GstElement *create_element(const char *name, const char *plugin_set)
{
GstElement *element;
......
......@@ -60,17 +60,6 @@ struct wg_transform
GstCaps *output_caps;
};
static bool is_caps_video(GstCaps *caps)
{
const gchar *media_type;
if (!caps || !gst_caps_get_size(caps))
return false;
media_type = gst_structure_get_name(gst_caps_get_structure(caps, 0));
return g_str_has_prefix(media_type, "video/");
}
static void align_video_info_planes(gsize plane_align, GstVideoInfo *info, GstVideoAlignment *align)
{
gst_video_alignment_reset(align);
......@@ -127,7 +116,7 @@ static gboolean transform_sink_query_cb(GstPad *pad, GstObject *parent, GstQuery
GstCaps *caps;
gst_query_parse_allocation(query, &caps, &needs_pool);
if (!is_caps_video(caps) || !needs_pool)
if (stream_type_from_caps(caps) != GST_STREAM_TYPE_VIDEO || !needs_pool)
break;
if (!gst_video_info_from_caps(&info, caps)
......@@ -671,7 +660,7 @@ static NTSTATUS read_transform_output_data(GstBuffer *buffer, GstCaps *caps, gsi
if ((ret = !needs_copy))
total_size = sample->size = info.size;
else if (is_caps_video(caps))
else if (stream_type_from_caps(caps) == GST_STREAM_TYPE_VIDEO)
ret = copy_video_buffer(buffer, caps, plane_align, sample, &total_size);
else
ret = copy_buffer(buffer, caps, sample, &total_size);
......@@ -707,7 +696,7 @@ static NTSTATUS read_transform_output_data(GstBuffer *buffer, GstCaps *caps, gsi
if (needs_copy)
{
if (is_caps_video(caps))
if (stream_type_from_caps(caps) == GST_STREAM_TYPE_VIDEO)
GST_WARNING("Copied %u bytes, sample %p, flags %#x", sample->size, sample, sample->flags);
else
GST_INFO("Copied %u bytes, sample %p, flags %#x", sample->size, sample, sample->flags);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment