1From 58800027696e30b40d29b7cf1304e33abe68731c Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Tue, 25 Dec 2018 16:20:35 +0800 4Subject: [PATCH 07/41] waylandsink: Enable changing window handle 5 6Changing window handle is dangerous, but we need this feature for: 7https://redmine.rockchip.com.cn/issues/184629 8 9Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 10--- 11 ext/wayland/gstwaylandsink.c | 22 ++++++++++++++++------ 12 ext/wayland/gstwaylandsink.h | 2 ++ 13 2 files changed, 18 insertions(+), 6 deletions(-) 14 15diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c 16index 0e6421f..5d2721c 100644 17--- a/ext/wayland/gstwaylandsink.c 18+++ b/ext/wayland/gstwaylandsink.c 19@@ -718,9 +718,10 @@ render_last_buffer (GstWaylandSink * self, gboolean redraw) 20 self->callback = callback; 21 wl_callback_add_listener (callback, &frame_callback_listener, self); 22 23- if (G_UNLIKELY (self->video_info_changed && !redraw)) { 24+ if (G_UNLIKELY ((self->video_info_changed && !redraw) || self->resend_info)) { 25 info = &self->video_info; 26 self->video_info_changed = FALSE; 27+ self->resend_info = FALSE; 28 } 29 gst_wl_window_render (self->window, wlbuffer, info); 30 } 31@@ -992,18 +993,21 @@ gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle) 32 33 g_return_if_fail (self != NULL); 34 35- if (self->window != NULL) { 36- GST_WARNING_OBJECT (self, "changing window handle is not supported"); 37+ if (self->window_handle == handle) 38 return; 39- } 40+ 41+ self->window_handle = handle; 42 43 g_mutex_lock (&self->render_lock); 44 45+ if (self->window != NULL) { 46+ GST_WARNING_OBJECT (self, "changing window handle is dangerous"); 47+ g_clear_object (&self->window); 48+ } 49+ 50 GST_DEBUG_OBJECT (self, "Setting window handle %" GST_PTR_FORMAT, 51 (void *) handle); 52 53- g_clear_object (&self->window); 54- 55 if (handle) { 56 if (G_LIKELY (gst_wayland_sink_find_display (self))) { 57 /* we cannot use our own display with an external window handle */ 58@@ -1018,6 +1022,12 @@ gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle) 59 &self->render_lock); 60 gst_wl_window_set_rotate_method (self->window, 61 self->current_rotate_method); 62+ 63+ if (self->last_buffer) { 64+ /* Resend video info to force resize video surface */ 65+ self->resend_info = TRUE; 66+ self->redraw_pending = FALSE; 67+ } 68 } 69 } else { 70 GST_ERROR_OBJECT (self, "Failed to find display handle, " 71diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h 72index 3243d8c..46b5faa 100644 73--- a/ext/wayland/gstwaylandsink.h 74+++ b/ext/wayland/gstwaylandsink.h 75@@ -52,6 +52,7 @@ struct _GstWaylandSink 76 GstWlWindow *window; 77 GstBufferPool *pool; 78 gboolean use_dmabuf; 79+ guintptr window_handle; 80 81 gboolean video_info_changed; 82 GstVideoInfo video_info; 83@@ -59,6 +60,7 @@ struct _GstWaylandSink 84 85 gchar *display_name; 86 87+ gboolean resend_info; 88 gboolean redraw_pending; 89 GMutex render_lock; 90 GstBuffer *last_buffer; 91-- 922.20.1 93 94