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_DISPLAY_H__ 22 #define __GST_WL_DISPLAY_H__ 23 24 #include <gst/gst.h> 25 #include <gst/video/video.h> 26 #include <wayland-client.h> 27 #include "xdg-shell-client-protocol.h" 28 #include "viewporter-client-protocol.h" 29 #include "linux-dmabuf-unstable-v1-client-protocol.h" 30 #include "fullscreen-shell-unstable-v1-client-protocol.h" 31 32 G_BEGIN_DECLS 33 34 #define GST_TYPE_WL_DISPLAY (gst_wl_display_get_type ()) 35 #define GST_WL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_WL_DISPLAY, GstWlDisplay)) 36 #define GST_IS_WL_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_WL_DISPLAY)) 37 #define GST_WL_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_WL_DISPLAY, GstWlDisplayClass)) 38 #define GST_IS_WL_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_WL_DISPLAY)) 39 #define GST_WL_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_WL_DISPLAY, GstWlDisplayClass)) 40 41 typedef struct _GstWlDisplay GstWlDisplay; 42 typedef struct _GstWlDisplayClass GstWlDisplayClass; 43 44 struct _GstWlDisplay 45 { 46 GObject parent_instance; 47 48 /* public objects */ 49 struct wl_display *display; 50 struct wl_display *display_wrapper; 51 struct wl_event_queue *queue; 52 53 /* globals */ 54 struct wl_registry *registry; 55 struct wl_compositor *compositor; 56 struct wl_subcompositor *subcompositor; 57 struct wl_shell *wl_shell; 58 struct xdg_wm_base *xdg_wm_base; 59 struct zwp_fullscreen_shell_v1 *fullscreen_shell; 60 struct wl_shm *shm; 61 struct wp_viewporter *viewporter; 62 struct zwp_linux_dmabuf_v1 *dmabuf; 63 GArray *shm_formats; 64 GArray *dmabuf_formats; 65 66 /* private */ 67 gboolean own_display; 68 GThread *thread; 69 GstPoll *wl_fd_poll; 70 71 GMutex buffers_mutex; 72 GHashTable *buffers; 73 gboolean shutting_down; 74 }; 75 76 struct _GstWlDisplayClass 77 { 78 GObjectClass parent_class; 79 }; 80 81 GType gst_wl_display_get_type (void); 82 83 GstWlDisplay *gst_wl_display_new (const gchar * name, GError ** error); 84 GstWlDisplay *gst_wl_display_new_existing (struct wl_display * display, 85 gboolean take_ownership, GError ** error); 86 87 /* see wlbuffer.c for explanation */ 88 void gst_wl_display_register_buffer (GstWlDisplay * self, gpointer gstmem, 89 gpointer wlbuffer); 90 void gst_wl_display_unregister_buffer (GstWlDisplay * self, gpointer gstmem); 91 gpointer gst_wl_display_lookup_buffer (GstWlDisplay * self, gpointer gstmem); 92 93 gboolean gst_wl_display_check_format_for_shm (GstWlDisplay * display, 94 GstVideoFormat format); 95 gboolean gst_wl_display_check_format_for_dmabuf (GstWlDisplay * display, 96 GstVideoFormat format); 97 98 G_END_DECLS 99 100 #endif /* __GST_WL_DISPLAY_H__ */ 101