2 * GStreamer Wayland Library
3 * Copyright (C) 2014 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
25 #include <gst/wayland/wayland.h>
26 #include <gst/video/videooverlay.h>
29 gst_is_wayland_display_handle_need_context_message (GstMessage * msg)
31 const gchar *type = NULL;
33 g_return_val_if_fail (GST_IS_MESSAGE (msg), FALSE);
35 if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_NEED_CONTEXT &&
36 gst_message_parse_context_type (msg, &type)) {
37 return !g_strcmp0 (type, GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE);
44 gst_wayland_display_handle_context_new (struct wl_display * display)
47 gst_context_new (GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE, TRUE);
48 gst_structure_set (gst_context_writable_structure (context),
49 "handle", G_TYPE_POINTER, display, NULL);
54 gst_wayland_display_handle_context_get_handle (GstContext * context)
56 const GstStructure *s;
57 struct wl_display *display;
59 g_return_val_if_fail (GST_IS_CONTEXT (context), NULL);
61 s = gst_context_get_structure (context);
62 gst_structure_get (s, "handle", G_TYPE_POINTER, &display, NULL);
67 G_DEFINE_INTERFACE (GstWaylandVideo, gst_wayland_video, GST_TYPE_VIDEO_OVERLAY);
70 gst_wayland_video_default_init (GstWaylandVideoInterface * klass)
76 * gst_wayland_video_set_surface_size:
78 * This tells the video sink to change the size of its drawing
79 * surface. The caller must call gst_wayland_video_pause_rendering
80 * before calling this method and gst_wayland_video_resume_rendering
81 * later, on the next redraw request.
84 gst_wayland_video_set_surface_size (GstWaylandVideo * video, gint w, gint h)
86 GstWaylandVideoInterface *iface;
88 g_return_if_fail (video != NULL);
89 g_return_if_fail (GST_IS_WAYLAND_VIDEO (video));
91 iface = GST_WAYLAND_VIDEO_GET_INTERFACE (video);
93 if (iface->set_surface_size) {
94 iface->set_surface_size (video, w, h);
99 * gst_wayland_video_pause_rendering:
101 * This tells the video sink to stop rendering on the surface,
102 * dropping frames in the meanwhile. This should be called
103 * before resizing a stack of subsurfaces, one of which is
104 * the surface of the video sink.
107 gst_wayland_video_pause_rendering (GstWaylandVideo * video)
109 GstWaylandVideoInterface *iface;
111 g_return_if_fail (video != NULL);
112 g_return_if_fail (GST_IS_WAYLAND_VIDEO (video));
114 iface = GST_WAYLAND_VIDEO_GET_INTERFACE (video);
116 if (iface->pause_rendering) {
117 iface->pause_rendering (video);
122 * gst_wayland_video_resume_rendering:
124 * Resumes surface rendering that was previously paused
125 * with gst_wayland_video_pause_rendering. This function will
126 * block until there is a new wl_buffer commited on the surface
127 * inside the element, either with a new frame (if the element
128 * is PLAYING) or with an old frame (if the element is PAUSED).
131 gst_wayland_video_resume_rendering (GstWaylandVideo * video)
133 GstWaylandVideoInterface *iface;
135 g_return_if_fail (video != NULL);
136 g_return_if_fail (GST_IS_WAYLAND_VIDEO (video));
138 iface = GST_WAYLAND_VIDEO_GET_INTERFACE (video);
140 if (iface->resume_rendering) {
141 iface->resume_rendering (video);