hc
2023-02-14 0cc9b7c44253c93447ddf73e206fbdbb3d9f16b1
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
From 35d33587722cf44478632827bfb7049c003c4fef Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Wed, 22 Dec 2021 16:04:46 +0800
Subject: [PATCH 26/33] waylandsink: Use the correct video info to access
 allocated buffer
 
The video info might changed after pool activated.
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 ext/wayland/gstwaylandsink.c | 10 +++++-----
 ext/wayland/gstwaylandsink.h |  1 +
 2 files changed, 6 insertions(+), 5 deletions(-)
 
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
index fe7e0e3..934464c 100644
--- a/ext/wayland/gstwaylandsink.c
+++ b/ext/wayland/gstwaylandsink.c
@@ -917,7 +917,6 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer)
   GstVideoCropMeta *crop;
   GstVideoMeta *vmeta;
   GstVideoFormat format;
-  GstVideoInfo old_vinfo;
   GstMemory *mem;
   struct wl_buffer *wbuf = NULL;
 
@@ -991,7 +990,6 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer)
   /* update video info from video meta */
   mem = gst_buffer_peek_memory (buffer, 0);
 
-  old_vinfo = sink->video_info;
   vmeta = gst_buffer_get_video_meta (buffer);
   if (vmeta) {
     gint i;
@@ -1032,9 +1030,6 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer)
       GstVideoFrame src, dst;
       GstVideoInfo src_info = sink->video_info;
 
-      /* rollback video info changes */
-      sink->video_info = old_vinfo;
-
       /* we don't know how to create a wl_buffer directly from the provided
        * memory, so we have to copy the data to shm memory that we know how
        * to handle... */
@@ -1060,8 +1055,13 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer)
         if (!gst_buffer_pool_set_config (sink->pool, config) ||
             !gst_buffer_pool_set_active (sink->pool, TRUE))
           goto activate_failed;
+
+        sink->pool_vinfo = sink->video_info;
       }
 
+      /* rollback video info changes */
+      sink->video_info = sink->pool_vinfo;
+
       ret = gst_buffer_pool_acquire_buffer (sink->pool, &to_render, NULL);
       if (ret != GST_FLOW_OK)
         goto no_buffer;
diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h
index 1f70f76..4f517f8 100644
--- a/ext/wayland/gstwaylandsink.h
+++ b/ext/wayland/gstwaylandsink.h
@@ -61,6 +61,7 @@ struct _GstWaylandSink
 
   gboolean video_info_changed;
   GstVideoInfo video_info;
+  GstVideoInfo pool_vinfo;
   gboolean fullscreen;
   GstWlWindowLayer layer;
   gdouble alpha;
-- 
2.20.1