From 223d279205420d37c32f8af3d9883f84a7e0da67 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Bernon?= Date: Wed, 15 Mar 2023 14:58:04 +0100 Subject: [PATCH] winegstreamer: Introduce new stream_type_from_caps helper. --- dlls/winegstreamer/unix_private.h | 1 + dlls/winegstreamer/unixlib.c | 21 +++++++++++++++++++++ dlls/winegstreamer/wg_transform.c | 17 +++-------------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/dlls/winegstreamer/unix_private.h b/dlls/winegstreamer/unix_private.h index 2f4e168c3a2..962668045c1 100644 --- a/dlls/winegstreamer/unix_private.h +++ b/dlls/winegstreamer/unix_private.h @@ -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; diff --git a/dlls/winegstreamer/unixlib.c b/dlls/winegstreamer/unixlib.c index 7111402bf0a..6ffd41e9712 100644 --- a/dlls/winegstreamer/unixlib.c +++ b/dlls/winegstreamer/unixlib.c @@ -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; diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index 978d790fbb6..7755dac2523 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -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); -- 2.11.4.GIT