Rémi Bernon : winegstreamer: Reply with a video buffer pool to ALLOCATION queries.

Alexandre Julliard julliard at winehq.org
Thu Jun 2 16:26:10 CDT 2022


Module: wine
Branch: master
Commit: f7ca5cfa27e433530f2725d44045ea5284fd332a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f7ca5cfa27e433530f2725d44045ea5284fd332a

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Thu May 12 23:59:38 2022 +0200

winegstreamer: Reply with a video buffer pool to ALLOCATION queries.

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 at codeweavers.com>

---

 dlls/winegstreamer/wg_transform.c | 62 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c
index 93fe0039a63..0c1654567e5 100644
--- a/dlls/winegstreamer/wg_transform.c
+++ b/dlls/winegstreamer/wg_transform.c
@@ -58,6 +58,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);
@@ -81,6 +92,56 @@ 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);
+            }
+
+            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);
@@ -252,6 +313,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




More information about the wine-cvs mailing list