From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45988 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47084 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49715 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52183 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winegstreamer/wg_transform.c | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index 946268ee353..4e2b66a16af 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -56,6 +56,17 @@ 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 GstFlowReturn transform_sink_chain_cb(GstPad *pad, GstObject *parent, GstBuffer *buffer) { struct wg_transform *transform = gst_pad_get_element_private(pad); @@ -84,6 +95,59 @@ static GstFlowReturn transform_sink_chain_cb(GstPad *pad, GstObject *parent, Gst return GST_FLOW_OK; }
+static gboolean transform_sink_query_cb(GstPad *pad, GstObject *parent, GstQuery *query) +{ + struct wg_transform *transform = gst_pad_get_element_private(pad); + + GST_LOG("transform %p, type "%s".", transform, gst_query_type_get_name(query->type)); + + switch (query->type) + { + case GST_QUERY_ALLOCATION: + { + GstStructure *config; + gboolean needs_pool; + GstBufferPool *pool; + GstVideoInfo info; + GstCaps *caps; + + gst_query_parse_allocation(query, &caps, &needs_pool); + if (!is_caps_video(caps) || !needs_pool) + break; + + if (!gst_video_info_from_caps(&info, caps) + || !(pool = gst_video_buffer_pool_new())) + break; + + if (!(config = gst_buffer_pool_get_config(pool))) + GST_ERROR("Failed to get pool %p config.", pool); + else + { + gst_buffer_pool_config_set_params(config, caps, + info.size, 0, 0); + if (!gst_buffer_pool_set_config(pool, config)) + GST_ERROR("Failed to set pool %p config.", pool); + } + + if (gst_query_get_n_allocation_pools(query) > 0) + gst_query_set_nth_allocation_pool(query, 0, pool, info.size, 0, 0); + else + gst_query_add_allocation_pool(query, pool, info.size, 0, 0); + + GST_INFO("Proposing pool %p, buffer size %#zx, for query %p.", + pool, info.size, query); + + g_object_unref(pool); + return true; + } + default: + GST_WARNING("Ignoring "%s" query.", gst_query_type_get_name(query->type)); + break; + } + + return gst_pad_query_default(pad, parent, query); +} + static gboolean transform_sink_event_cb(GstPad *pad, GstObject *parent, GstEvent *event) { struct wg_transform *transform = gst_pad_get_element_private(pad); @@ -255,6 +319,7 @@ NTSTATUS wg_transform_create(void *args)
gst_pad_set_element_private(transform->my_sink, transform); gst_pad_set_event_function(transform->my_sink, transform_sink_event_cb); + gst_pad_set_query_function(transform->my_sink, transform_sink_query_cb); gst_pad_set_chain_function(transform->my_sink, transform_sink_chain_cb);
/* Since we append conversion elements, we don't want to filter decoders