1 /* GStreamer Wayland video sink
2  *
3  * Copyright (C) 2014 Collabora Ltd.
4  *
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.
9  *
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.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __GST_WL_WINDOW_H__
22 #define __GST_WL_WINDOW_H__
23 
24 #include "wldisplay.h"
25 #include "wlbuffer.h"
26 #include <gst/video/video.h>
27 
28 G_BEGIN_DECLS
29 
30 #define GST_TYPE_WL_WINDOW                  (gst_wl_window_get_type ())
31 #define GST_WL_WINDOW(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_WL_WINDOW, GstWlWindow))
32 #define GST_IS_WL_WINDOW(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_WL_WINDOW))
33 #define GST_WL_WINDOW_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_WL_WINDOW, GstWlWindowClass))
34 #define GST_IS_WL_WINDOW_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_WL_WINDOW))
35 #define GST_WL_WINDOW_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_WL_WINDOW, GstWlWindowClass))
36 
37 typedef struct _GstWlWindow GstWlWindow;
38 typedef struct _GstWlWindowClass GstWlWindowClass;
39 
40 struct _GstWlWindow
41 {
42   GObject parent_instance;
43 
44   GMutex *render_lock;
45 
46   GstWlDisplay *display;
47   struct wl_surface *area_surface;
48   struct wl_surface *area_surface_wrapper;
49   struct wl_subsurface *area_subsurface;
50   struct wp_viewport *area_viewport;
51   struct wl_surface *video_surface;
52   struct wl_surface *video_surface_wrapper;
53   struct wl_subsurface *video_subsurface;
54   struct wp_viewport *video_viewport;
55   struct wl_shell_surface *wl_shell_surface;
56   struct xdg_surface *xdg_surface;
57   struct xdg_toplevel *xdg_toplevel;
58   gboolean configured;
59   GCond configure_cond;
60   GMutex configure_mutex;
61 
62   /* the size and position of the area_(sub)surface */
63   GstVideoRectangle render_rectangle;
64 
65   /* the size and position of the video_subsurface */
66   GstVideoRectangle video_rectangle;
67 
68   /* the size of the video in the buffers */
69   gint video_width, video_height;
70 
71   /* this will be set when viewporter is available and black background has
72    * already been set on the area_subsurface */
73   gboolean no_border_update;
74 
75 };
76 
77 struct _GstWlWindowClass
78 {
79   GObjectClass parent_class;
80 };
81 
82 GType gst_wl_window_get_type (void);
83 
84 void gst_wl_window_ensure_fullscreen (GstWlWindow * window,
85         gboolean fullscreen);
86 GstWlWindow *gst_wl_window_new_toplevel (GstWlDisplay * display,
87         const GstVideoInfo * info, gboolean fullscreen, GMutex * render_lock);
88 GstWlWindow *gst_wl_window_new_in_surface (GstWlDisplay * display,
89         struct wl_surface * parent, GMutex * render_lock);
90 
91 GstWlDisplay *gst_wl_window_get_display (GstWlWindow * window);
92 struct wl_surface *gst_wl_window_get_wl_surface (GstWlWindow * window);
93 gboolean gst_wl_window_is_toplevel (GstWlWindow *window);
94 
95 void gst_wl_window_render (GstWlWindow * window, GstWlBuffer * buffer,
96         const GstVideoInfo * info);
97 void gst_wl_window_set_render_rectangle (GstWlWindow * window, gint x, gint y,
98         gint w, gint h);
99 
100 G_END_DECLS
101 
102 #endif /* __GST_WL_WINDOW_H__ */
103