From 1a6c470c54b3bbe31a4103994d2d4e1738ac58e1 Mon Sep 17 00:00:00 2001
|
From: Jeffy Chen <jeffy.chen@rock-chips.com>
|
Date: Wed, 11 May 2022 18:12:39 +0800
|
Subject: [PATCH 32/33] waylandsink: Parse video size in propose_allocation()
|
|
In some cases it would be called before set_caps().
|
|
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
|
---
|
ext/wayland/gstwaylandsink.c | 24 +++++++++++++++++++-----
|
1 file changed, 19 insertions(+), 5 deletions(-)
|
|
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
|
index 04f1e2a..8ba2e06 100644
|
--- a/ext/wayland/gstwaylandsink.c
|
+++ b/ext/wayland/gstwaylandsink.c
|
@@ -724,11 +724,10 @@ gst_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
|
}
|
|
static GstBufferPool *
|
-gst_wayland_create_pool (GstWaylandSink * sink, GstCaps * caps)
|
+gst_wayland_create_pool (GstWaylandSink * sink, GstCaps * caps, gsize size)
|
{
|
GstBufferPool *pool = NULL;
|
GstStructure *structure;
|
- gsize size = sink->video_info.size;
|
GstAllocator *alloc;
|
|
pool = g_object_new (gst_wayland_pool_get_type (), NULL);
|
@@ -779,7 +778,7 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
/* create a new pool for the new caps */
|
if (sink->pool)
|
gst_object_unref (sink->pool);
|
- sink->pool = gst_wayland_create_pool (sink, caps);
|
+ sink->pool = gst_wayland_create_pool (sink, caps, sink->video_info.size);
|
|
use_dmabuf = gst_caps_features_contains (gst_caps_get_features (caps, 0),
|
GST_CAPS_FEATURE_MEMORY_DMABUF);
|
@@ -818,10 +817,15 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
|
GstBufferPool *pool = NULL;
|
gboolean need_pool;
|
GstAllocator *alloc;
|
+ GstVideoInfo info;
|
GstStructure *s;
|
gint value;
|
|
gst_query_parse_allocation (query, &caps, &need_pool);
|
+ if (!caps)
|
+ goto no_caps;
|
+ if (!gst_video_info_from_caps (&info, caps))
|
+ goto invalid_caps;
|
|
s = gst_caps_get_structure (caps, 0);
|
if (gst_structure_get_int (s, "arm-afbc", &value) && value) {
|
@@ -830,9 +834,9 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
|
}
|
|
if (need_pool)
|
- pool = gst_wayland_create_pool (sink, caps);
|
+ pool = gst_wayland_create_pool (sink, caps, info.size);
|
|
- gst_query_add_allocation_pool (query, pool, sink->video_info.size, 2, 0);
|
+ gst_query_add_allocation_pool (query, pool, info.size, 2, 0);
|
if (pool)
|
g_object_unref (pool);
|
|
@@ -843,6 +847,16 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
|
g_object_unref (alloc);
|
|
return TRUE;
|
+no_caps:
|
+ {
|
+ GST_DEBUG_OBJECT (bsink, "no caps specified");
|
+ return FALSE;
|
+ }
|
+invalid_caps:
|
+ {
|
+ GST_DEBUG_OBJECT (bsink, "invalid caps specified");
|
+ return FALSE;
|
+ }
|
}
|
|
static void
|
--
|
2.20.1
|