hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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