waylandsink: implement the GstVideoOverlay & GstWaylandVideo interfaces
[platform/upstream/gstreamer.git] / ext / wayland / gstwaylandsink.c
1 /* GStreamer Wayland video sink
2  *
3  * Copyright (C) 2011 Intel Corporation
4  * Copyright (C) 2011 Sreerenj Balachandran <sreerenj.balachandran@intel.com>
5  * Copyright (C) 2012 Wim Taymans <wim.taymans@gmail.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301 USA.
21  */
22
23 /**
24  * SECTION:element-waylandsink
25  *
26  *  The waylandsink is creating its own window and render the decoded video frames to that.
27  *  Setup the Wayland environment as described in
28  *  <ulink url="http://wayland.freedesktop.org/building.html">Wayland</ulink> home page.
29  *  The current implementaion is based on weston compositor.
30  *
31  * <refsect2>
32  * <title>Example pipelines</title>
33  * |[
34  * gst-launch -v videotestsrc ! waylandsink
35  * ]| test the video rendering in wayland
36  * </refsect2>
37  */
38
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
42
43 #include "gstwaylandsink.h"
44 #include "wlvideoformat.h"
45 #include "waylandpool.h"
46
47 #include <gst/wayland/wayland.h>
48 #include <gst/video/videooverlay.h>
49
50 /* signals */
51 enum
52 {
53   SIGNAL_0,
54   LAST_SIGNAL
55 };
56
57 /* Properties */
58 enum
59 {
60   PROP_0,
61   PROP_DISPLAY
62 };
63
64 GST_DEBUG_CATEGORY (gstwayland_debug);
65 #define GST_CAT_DEFAULT gstwayland_debug
66
67 #if G_BYTE_ORDER == G_BIG_ENDIAN
68 #define CAPS "{xRGB, ARGB}"
69 #else
70 #define CAPS "{BGRx, BGRA}"
71 #endif
72
73 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
74     GST_PAD_SINK,
75     GST_PAD_ALWAYS,
76     GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (CAPS))
77     );
78
79 static void gst_wayland_sink_get_property (GObject * object,
80     guint prop_id, GValue * value, GParamSpec * pspec);
81 static void gst_wayland_sink_set_property (GObject * object,
82     guint prop_id, const GValue * value, GParamSpec * pspec);
83 static void gst_wayland_sink_finalize (GObject * object);
84
85 static GstStateChangeReturn gst_wayland_sink_change_state (GstElement * element,
86     GstStateChange transition);
87
88 static GstCaps *gst_wayland_sink_get_caps (GstBaseSink * bsink,
89     GstCaps * filter);
90 static gboolean gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps);
91 static gboolean gst_wayland_sink_preroll (GstBaseSink * bsink,
92     GstBuffer * buffer);
93 static gboolean
94 gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query);
95 static gboolean gst_wayland_sink_render (GstBaseSink * bsink,
96     GstBuffer * buffer);
97
98 /* VideoOverlay interface */
99 static void gst_wayland_sink_videooverlay_init (GstVideoOverlayInterface *
100     iface);
101 static void gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay,
102     guintptr handle);
103 static void gst_wayland_sink_expose (GstVideoOverlay * overlay);
104
105 /* WaylandVideo interface */
106 static void gst_wayland_sink_waylandvideo_init (GstWaylandVideoInterface *
107     iface);
108 static void gst_wayland_sink_set_surface_size (GstWaylandVideo * video,
109     gint w, gint h);
110 static void gst_wayland_sink_pause_rendering (GstWaylandVideo * video);
111 static void gst_wayland_sink_resume_rendering (GstWaylandVideo * video);
112
113 #define gst_wayland_sink_parent_class parent_class
114 G_DEFINE_TYPE_WITH_CODE (GstWaylandSink, gst_wayland_sink, GST_TYPE_VIDEO_SINK,
115     G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_OVERLAY,
116         gst_wayland_sink_videooverlay_init)
117     G_IMPLEMENT_INTERFACE (GST_TYPE_WAYLAND_VIDEO,
118         gst_wayland_sink_waylandvideo_init));
119
120 static void
121 gst_wayland_sink_class_init (GstWaylandSinkClass * klass)
122 {
123   GObjectClass *gobject_class;
124   GstElementClass *gstelement_class;
125   GstBaseSinkClass *gstbasesink_class;
126
127   gobject_class = (GObjectClass *) klass;
128   gstelement_class = (GstElementClass *) klass;
129   gstbasesink_class = (GstBaseSinkClass *) klass;
130
131   gobject_class->set_property = gst_wayland_sink_set_property;
132   gobject_class->get_property = gst_wayland_sink_get_property;
133   gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_wayland_sink_finalize);
134
135   gst_element_class_add_pad_template (gstelement_class,
136       gst_static_pad_template_get (&sink_template));
137
138   gst_element_class_set_static_metadata (gstelement_class,
139       "wayland video sink", "Sink/Video",
140       "Output to wayland surface",
141       "Sreerenj Balachandran <sreerenj.balachandran@intel.com>");
142
143   gstelement_class->change_state =
144       GST_DEBUG_FUNCPTR (gst_wayland_sink_change_state);
145
146   gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_wayland_sink_get_caps);
147   gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_wayland_sink_set_caps);
148   gstbasesink_class->preroll = GST_DEBUG_FUNCPTR (gst_wayland_sink_preroll);
149   gstbasesink_class->propose_allocation =
150       GST_DEBUG_FUNCPTR (gst_wayland_sink_propose_allocation);
151   gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_wayland_sink_render);
152
153   g_object_class_install_property (gobject_class, PROP_DISPLAY,
154       g_param_spec_string ("display", "Wayland Display name", "Wayland "
155           "display name to connect to, if not supplied with GstVideoOverlay",
156           NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
157 }
158
159 static void
160 gst_wayland_sink_init (GstWaylandSink * sink)
161 {
162   g_cond_init (&sink->render_cond);
163 }
164
165 static void
166 gst_wayland_sink_get_property (GObject * object,
167     guint prop_id, GValue * value, GParamSpec * pspec)
168 {
169   GstWaylandSink *sink = GST_WAYLAND_SINK (object);
170
171   switch (prop_id) {
172     case PROP_DISPLAY:
173       g_value_set_string (value, sink->display_name);
174       break;
175     default:
176       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
177       break;
178   }
179 }
180
181 static void
182 gst_wayland_sink_set_property (GObject * object,
183     guint prop_id, const GValue * value, GParamSpec * pspec)
184 {
185   GstWaylandSink *sink = GST_WAYLAND_SINK (object);
186
187   switch (prop_id) {
188     case PROP_DISPLAY:
189       sink->display_name = g_value_dup_string (value);
190       break;
191     default:
192       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
193       break;
194   }
195 }
196
197 static void
198 gst_wayland_sink_finalize (GObject * object)
199 {
200   GstWaylandSink *sink = GST_WAYLAND_SINK (object);
201
202   GST_DEBUG_OBJECT (sink, "Finalizing the sink..");
203
204   if (sink->window)
205     g_object_unref (sink->window);
206   if (sink->display)
207     g_object_unref (sink->display);
208   if (sink->pool)
209     gst_object_unref (sink->pool);
210
211   if (sink->display_name)
212     g_free (sink->display_name);
213
214   g_cond_clear (&sink->render_cond);
215
216   G_OBJECT_CLASS (parent_class)->finalize (object);
217 }
218
219 static GstStateChangeReturn
220 gst_wayland_sink_change_state (GstElement * element, GstStateChange transition)
221 {
222   GstWaylandSink *sink = GST_WAYLAND_SINK (element);
223   GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
224
225   switch (transition) {
226     case GST_STATE_CHANGE_READY_TO_PAUSED:
227       if (!sink->window)
228         gst_video_overlay_prepare_window_handle (GST_VIDEO_OVERLAY (sink));
229       break;
230     default:
231       break;
232   }
233
234   ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
235   if (ret == GST_STATE_CHANGE_FAILURE)
236     return ret;
237
238   switch (transition) {
239     case GST_STATE_CHANGE_PAUSED_TO_READY:
240       if (gst_wl_window_is_toplevel (sink->window)) {
241         g_clear_object (&sink->window);
242         g_clear_object (&sink->display);
243         g_clear_object (&sink->pool);
244       }
245       break;
246     default:
247       break;
248   }
249
250   return ret;
251 }
252
253 static GstCaps *
254 gst_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
255 {
256   GstWaylandSink *sink;
257   GstCaps *caps;
258   gint width, height;
259
260   sink = GST_WAYLAND_SINK (bsink);
261
262   caps = gst_pad_get_pad_template_caps (GST_VIDEO_SINK_PAD (sink));
263
264   /* If we don't have a window yet, it will
265    * be created using the upstream size.
266    * Otherwise, we should tell upstream exactly
267    * what size we want. We don't resize ourselves. */
268   if (sink->window) {
269     caps = gst_caps_make_writable (caps);
270     gst_wl_window_get_size (sink->window, &width, &height);
271     gst_caps_set_simple (caps, "width", G_TYPE_INT, width,
272         "height", G_TYPE_INT, height, NULL);
273   }
274
275   if (filter) {
276     GstCaps *intersection;
277
278     intersection =
279         gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
280     gst_caps_unref (caps);
281     caps = intersection;
282   }
283   return caps;
284 }
285
286 static gboolean
287 gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
288 {
289   GstWaylandSink *sink;
290   GstBufferPool *newpool;
291   GstVideoInfo info;
292   GError *error = NULL;
293   enum wl_shm_format format;
294   GArray *formats;
295   gint i;
296   GstStructure *structure;
297   static GstAllocationParams params = { 0, 0, 0, 15, };
298
299   sink = GST_WAYLAND_SINK (bsink);
300   GST_OBJECT_LOCK (sink);
301
302   GST_DEBUG_OBJECT (sink, "set caps %" GST_PTR_FORMAT, caps);
303
304   /* extract info from caps */
305   if (!gst_video_info_from_caps (&info, caps))
306     goto invalid_format;
307
308   format = gst_video_format_to_wayland_format (GST_VIDEO_INFO_FORMAT (&info));
309   if (format == -1)
310     goto invalid_format;
311
312   /* store the video size */
313   sink->video_width = info.width;
314   sink->video_height = info.height;
315
316   /* create the output window if needed */
317   if (!sink->window || sink->video_width != sink->window->width ||
318       sink->video_height != sink->window->height) {
319
320     if (!sink->display)
321       sink->display = gst_wl_display_new (sink->display_name, &error);
322
323     if (sink->display == NULL)
324       goto display_failed;
325
326     g_clear_object (&sink->window);
327     sink->window = gst_wl_window_new_toplevel (sink->display, sink->video_width,
328         sink->video_height);
329   }
330
331   /* verify we support the requested format */
332   formats = sink->display->formats;
333   for (i = 0; i < formats->len; i++) {
334     if (g_array_index (formats, uint32_t, i) == format)
335       break;
336   }
337
338   if (i >= formats->len)
339     goto unsupported_format;
340
341   /* create a new pool for the new configuration */
342   newpool = gst_wayland_buffer_pool_new (sink->display);
343   if (!newpool)
344     goto pool_failed;
345
346   structure = gst_buffer_pool_get_config (newpool);
347   gst_buffer_pool_config_set_params (structure, caps, info.size, 2, 0);
348   gst_buffer_pool_config_set_allocator (structure, NULL, &params);
349   if (!gst_buffer_pool_set_config (newpool, structure))
350     goto config_failed;
351
352   gst_object_replace ((GstObject **) & sink->pool, (GstObject *) newpool);
353   gst_object_unref (newpool);
354
355   sink->negotiated = TRUE;
356   GST_OBJECT_UNLOCK (sink);
357   return TRUE;
358
359 invalid_format:
360   {
361     GST_DEBUG_OBJECT (sink,
362         "Could not locate image format from caps %" GST_PTR_FORMAT, caps);
363     goto failure;
364   }
365 display_failed:
366   {
367     GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_READ_WRITE,
368         ("Could not initialise Wayland output"),
369         ("Failed to create GstWlDisplay: '%s'", error->message));
370     g_error_free (error);
371     goto failure;
372   }
373 unsupported_format:
374   {
375     GST_DEBUG_OBJECT (sink, "Format %s is not available on the display",
376         gst_wayland_format_to_string (format));
377     goto failure;
378   }
379 pool_failed:
380   {
381     GST_DEBUG_OBJECT (sink, "Failed to create new pool");
382     goto failure;
383   }
384 config_failed:
385   {
386     GST_DEBUG_OBJECT (bsink, "failed setting config");
387     goto failure;
388   }
389 failure:
390   {
391     GST_OBJECT_UNLOCK (sink);
392     return FALSE;
393   }
394 }
395
396 static gboolean
397 gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
398 {
399   GstWaylandSink *sink = GST_WAYLAND_SINK (bsink);
400   GstBufferPool *pool = NULL;
401   GstStructure *config;
402   GstCaps *caps;
403   guint size;
404   gboolean need_pool;
405
406   gst_query_parse_allocation (query, &caps, &need_pool);
407
408   if (caps == NULL)
409     goto no_caps;
410
411   if (sink->pool)
412     pool = gst_object_ref (sink->pool);
413
414   if (pool != NULL) {
415     GstCaps *pcaps;
416
417     /* we had a pool, check caps */
418     config = gst_buffer_pool_get_config (pool);
419     gst_buffer_pool_config_get_params (config, &pcaps, &size, NULL, NULL);
420
421     if (!gst_caps_is_equal (caps, pcaps)) {
422       /* different caps, we can't use this pool */
423       gst_object_unref (pool);
424       pool = NULL;
425     }
426     gst_structure_free (config);
427   }
428
429   if (pool == NULL && need_pool) {
430     GstVideoInfo info;
431
432     if (!gst_video_info_from_caps (&info, caps))
433       goto invalid_caps;
434
435     GST_DEBUG_OBJECT (sink, "create new pool");
436     pool = gst_wayland_buffer_pool_new (sink->display);
437
438     /* the normal size of a frame */
439     size = info.size;
440
441     config = gst_buffer_pool_get_config (pool);
442     gst_buffer_pool_config_set_params (config, caps, size, 2, 0);
443     if (!gst_buffer_pool_set_config (pool, config))
444       goto config_failed;
445   }
446   if (pool) {
447     gst_query_add_allocation_pool (query, pool, size, 2, 0);
448     gst_object_unref (pool);
449   }
450
451   return TRUE;
452
453   /* ERRORS */
454 no_caps:
455   {
456     GST_DEBUG_OBJECT (bsink, "no caps specified");
457     return FALSE;
458   }
459 invalid_caps:
460   {
461     GST_DEBUG_OBJECT (bsink, "invalid caps specified");
462     return FALSE;
463   }
464 config_failed:
465   {
466     GST_DEBUG_OBJECT (bsink, "failed setting config");
467     gst_object_unref (pool);
468     return FALSE;
469   }
470 }
471
472 static GstFlowReturn
473 gst_wayland_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer)
474 {
475   GST_DEBUG_OBJECT (bsink, "preroll buffer %p", buffer);
476   return gst_wayland_sink_render (bsink, buffer);
477 }
478
479 static void
480 frame_redraw_callback (void *data, struct wl_callback *callback, uint32_t time)
481 {
482   GST_LOG ("frame_redraw_cb");
483   wl_callback_destroy (callback);
484 }
485
486 static const struct wl_callback_listener frame_callback_listener = {
487   frame_redraw_callback
488 };
489
490 static GstFlowReturn
491 gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
492 {
493   GstWaylandSink *sink = GST_WAYLAND_SINK (bsink);
494   GstVideoRectangle src, dst, res;
495   GstBuffer *to_render;
496   GstWlMeta *meta;
497   GstFlowReturn ret = GST_FLOW_OK;
498   struct wl_surface *surface;
499   struct wl_callback *callback;
500
501   GST_OBJECT_LOCK (sink);
502
503   GST_LOG_OBJECT (sink, "render buffer %p", buffer);
504
505   /* surface is resizing - drop buffers until finished */
506   if (sink->drawing_frozen || !sink->negotiated)
507     goto done;
508
509   meta = gst_buffer_get_wl_meta (buffer);
510
511   if (meta && meta->display == sink->display) {
512     GST_LOG_OBJECT (sink, "buffer %p from our pool, writing directly", buffer);
513     to_render = buffer;
514   } else {
515     GstMapInfo src;
516     GST_LOG_OBJECT (sink, "buffer %p not from our pool, copying", buffer);
517
518     if (!sink->pool)
519       goto no_pool;
520
521     if (!gst_buffer_pool_set_active (sink->pool, TRUE))
522       goto activate_failed;
523
524     ret = gst_buffer_pool_acquire_buffer (sink->pool, &to_render, NULL);
525     if (ret != GST_FLOW_OK)
526       goto no_buffer;
527
528     gst_buffer_map (buffer, &src, GST_MAP_READ);
529     gst_buffer_fill (to_render, 0, src.data, src.size);
530     gst_buffer_unmap (buffer, &src);
531
532     meta = gst_buffer_get_wl_meta (to_render);
533   }
534
535   src.w = sink->video_width;
536   src.h = sink->video_height;
537   dst.w = sink->window->width;
538   dst.h = sink->window->height;
539
540   gst_video_sink_center_rect (src, dst, &res, FALSE);
541
542   surface = gst_wl_window_get_wl_surface (sink->window);
543
544   wl_surface_attach (surface, meta->wbuffer, 0, 0);
545   wl_surface_damage (surface, 0, 0, res.w, res.h);
546   callback = wl_surface_frame (surface);
547   wl_callback_add_listener (callback, &frame_callback_listener, NULL);
548   wl_surface_commit (surface);
549   wl_display_flush (sink->display->display);
550
551   /* notify _resume_rendering() in case it's waiting */
552   g_cond_broadcast (&sink->render_cond);
553
554   if (buffer != to_render)
555     gst_buffer_unref (to_render);
556   goto done;
557
558 no_buffer:
559   {
560     GST_WARNING_OBJECT (sink, "could not create image");
561     goto done;
562   }
563 no_pool:
564   {
565     GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
566         ("Internal error: can't allocate images"),
567         ("We don't have a bufferpool negotiated"));
568     ret = GST_FLOW_ERROR;
569     goto done;
570   }
571 activate_failed:
572   {
573     GST_ERROR_OBJECT (sink, "failed to activate bufferpool.");
574     ret = GST_FLOW_ERROR;
575     goto done;
576   }
577 done:
578   {
579     GST_OBJECT_UNLOCK (sink);
580     return ret;
581   }
582 }
583
584 static void
585 gst_wayland_sink_videooverlay_init (GstVideoOverlayInterface * iface)
586 {
587   iface->set_window_handle = gst_wayland_sink_set_window_handle;
588   iface->expose = gst_wayland_sink_expose;
589 }
590
591 static void
592 gst_wayland_sink_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
593 {
594   GstWaylandSink *sink = GST_WAYLAND_SINK (overlay);
595   GstWaylandWindowHandle *whandle = (GstWaylandWindowHandle *) handle;
596   GError *error = NULL;
597   GstPad *peer;
598
599   g_return_if_fail (sink != NULL);
600
601   GST_DEBUG_OBJECT (sink, "Setting window handle %" GST_PTR_FORMAT,
602       (void *) handle);
603
604   if (GST_STATE (sink) > GST_STATE_READY)
605     gst_wayland_sink_pause_rendering (GST_WAYLAND_VIDEO (sink));
606
607   g_clear_object (&sink->window);
608   g_clear_object (&sink->display);
609
610   if (handle) {
611     sink->display =
612         gst_wl_display_new_existing (whandle->display, FALSE, &error);
613     if (error) {
614       GST_ELEMENT_WARNING (sink, RESOURCE, OPEN_READ_WRITE,
615           ("Could not set window handle"),
616           ("Failed to use the external wayland display: '%s'", error->message));
617       g_error_free (error);
618     } else {
619       sink->window = gst_wl_window_new_from_surface (sink->display,
620           whandle->surface, whandle->width, whandle->height);
621     }
622   } else {
623     /* reconfigure to force creation of new window in set_caps */
624     sink->negotiated = FALSE;
625     peer = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink));
626     if (peer) {
627       gst_pad_send_event (peer, gst_event_new_reconfigure ());
628       gst_object_unref (peer);
629     }
630   }
631
632   if (GST_STATE (sink) > GST_STATE_READY)
633     gst_wayland_sink_resume_rendering (GST_WAYLAND_VIDEO (sink));
634 }
635
636 static void
637 gst_wayland_sink_expose (GstVideoOverlay * overlay)
638 {
639   GstWaylandSink *sink = GST_WAYLAND_SINK (overlay);
640   g_return_if_fail (sink != NULL);
641 }
642
643 static void
644 gst_wayland_sink_waylandvideo_init (GstWaylandVideoInterface * iface)
645 {
646   iface->set_surface_size = gst_wayland_sink_set_surface_size;
647   iface->pause_rendering = gst_wayland_sink_pause_rendering;
648   iface->resume_rendering = gst_wayland_sink_resume_rendering;
649 }
650
651 static void
652 gst_wayland_sink_set_surface_size (GstWaylandVideo * video, gint w, gint h)
653 {
654   GstWaylandSink *sink = GST_WAYLAND_SINK (video);
655   GstPad *peer;
656
657   g_return_if_fail (sink != NULL);
658   g_return_if_fail (sink->window != NULL);
659
660   GST_OBJECT_LOCK (sink);
661   if (!sink->window) {
662     GST_OBJECT_UNLOCK (sink);
663     GST_WARNING_OBJECT (sink,
664         "set_surface_size called without window, ignoring");
665     return;
666   }
667
668   gst_wl_window_set_size (sink->window, w, h);
669   sink->negotiated = FALSE;
670   GST_OBJECT_UNLOCK (sink);
671
672   /* upstream must change video size because we can't resize ourselves.
673    * This can be removed when we move to wl_viewport */
674   if (GST_STATE (sink) > GST_STATE_READY) {
675     peer = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink));
676     if (peer) {
677       gst_pad_send_event (peer, gst_event_new_reconfigure ());
678       gst_object_unref (peer);
679     }
680   }
681 }
682
683 static void
684 gst_wayland_sink_pause_rendering (GstWaylandVideo * video)
685 {
686   GstWaylandSink *sink = GST_WAYLAND_SINK (video);
687   g_return_if_fail (sink != NULL);
688
689   GST_OBJECT_LOCK (sink);
690   sink->drawing_frozen = TRUE;
691   GST_OBJECT_UNLOCK (sink);
692 }
693
694 static void
695 gst_wayland_sink_resume_rendering (GstWaylandVideo * video)
696 {
697   GstWaylandSink *sink = GST_WAYLAND_SINK (video);
698   g_return_if_fail (sink != NULL);
699
700   GST_OBJECT_LOCK (sink);
701   sink->drawing_frozen = FALSE;
702   g_cond_wait (&sink->render_cond, GST_OBJECT_GET_LOCK (sink));
703   GST_OBJECT_UNLOCK (sink);
704 }
705
706 static gboolean
707 plugin_init (GstPlugin * plugin)
708 {
709   GST_DEBUG_CATEGORY_INIT (gstwayland_debug, "waylandsink", 0,
710       " wayland video sink");
711
712   return gst_element_register (plugin, "waylandsink", GST_RANK_MARGINAL,
713       GST_TYPE_WAYLAND_SINK);
714 }
715
716 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
717     GST_VERSION_MINOR,
718     waylandsink,
719     "Wayland Video Sink", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME,
720     GST_PACKAGE_ORIGIN)