1 /*
2  * GStreamer
3  * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
4  * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
5  * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
6  * Copyright (C) 2013 Matthew Waters <ystreet00@gmail.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef __GST_VULKAN_DISPLAY_H__
25 #define __GST_VULKAN_DISPLAY_H__
26 
27 #include <gst/gst.h>
28 
29 #include <vk.h>
30 
31 G_BEGIN_DECLS
32 
33 #define GST_TYPE_VULKAN_DISPLAY             (gst_vulkan_display_get_type())
34 #define GST_VULKAN_DISPLAY(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VULKAN_DISPLAY,GstVulkanDisplay))
35 #define GST_VULKAN_DISPLAY_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VULKAN_DISPLAY,GstVulkanDisplayClass))
36 #define GST_IS_VULKAN_DISPLAY(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VULKAN_DISPLAY))
37 #define GST_IS_VULKAN_DISPLAY_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VULKAN_DISPLAY))
38 #define GST_VULKAN_DISPLAY_CAST(obj)        ((GstVulkanDisplay*)(obj))
39 #define GST_VULKAN_DISPLAY_GET_CLASS(o)     (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_VULKAN_DISPLAY, GstVulkanDisplayClass))
40 GType gst_vulkan_display_get_type (void);
41 
42 #define GST_VULKAN_DISPLAY_CONTEXT_TYPE_STR "gst.vulkan.display"
43 
44 enum _GstVulkanDisplayType
45 {
46   GST_VULKAN_DISPLAY_TYPE_NONE = 0,
47   GST_VULKAN_DISPLAY_TYPE_X11 = (1 << 0),
48   GST_VULKAN_DISPLAY_TYPE_XCB = (1 << 1),
49   GST_VULKAN_DISPLAY_TYPE_WAYLAND = (1 << 2),
50   GST_VULKAN_DISPLAY_TYPE_MIR = (1 << 3),
51   GST_VULKAN_DISPLAY_TYPE_WIN32 = (1 << 4),
52   GST_VULKAN_DISPLAY_TYPE_COCOA = (1 << 5),
53   GST_VULKAN_DISPLAY_TYPE_IOS = (1 << 6),
54 
55   GST_VULKAN_DISPLAY_TYPE_ANY = G_MAXUINT32
56 };
57 
58 /**
59  * GstVulkanDisplay:
60  *
61  * The contents of a #GstVulkanDisplay are private and should only be accessed
62  * through the provided API
63  */
64 struct _GstVulkanDisplay
65 {
66   /* <private> */
67   GstObject                 object;
68 
69   GstVulkanDisplayType      type;
70 
71   GstVulkanInstance        *instance;
72 
73   /* <protected> */
74   GList                    *windows;        /* OBJECT lock */
75   GMainContext             *main_context;
76   GMainLoop                *main_loop;
77   GSource                  *event_source;
78 
79   /* <private> */
80   GstVulkanDisplayPrivate  *priv;
81 };
82 
83 struct _GstVulkanDisplayClass
84 {
85   GstObjectClass object_class;
86 
87   gpointer          (*get_handle)           (GstVulkanDisplay * display);
88   GstVulkanWindow * (*create_window)        (GstVulkanDisplay * display);
89 };
90 
91 GstVulkanDisplay *      gst_vulkan_display_new                      (GstVulkanInstance *instance);
92 GstVulkanDisplay *      gst_vulkan_display_new_with_type            (GstVulkanInstance *instance,
93                                                                      GstVulkanDisplayType type);
94 GstVulkanDisplayType    gst_vulkan_display_choose_type              (GstVulkanInstance *instance);
95 const gchar *           gst_vulkan_display_type_to_extension_string (GstVulkanDisplayType type);
96 
97 
98 gpointer                gst_vulkan_display_get_handle               (GstVulkanDisplay * display);
99 GstVulkanDisplayType    gst_vulkan_display_get_handle_type          (GstVulkanDisplay * display);
100 GstVulkanWindow *       gst_vulkan_display_create_window            (GstVulkanDisplay * display);
101 
102 gboolean                gst_context_get_vulkan_display              (GstContext * context,
103                                                                      GstVulkanDisplay ** display);
104 void                    gst_context_set_vulkan_display              (GstContext * context,
105                                                                      GstVulkanDisplay * display);
106 gboolean                gst_vulkan_display_handle_context_query     (GstElement * element,
107                                                                      GstQuery * query,
108                                                                      GstVulkanDisplay ** display);
109 gboolean                gst_vulkan_display_run_context_query        (GstElement * element,
110                                                                      GstVulkanDisplay ** display);
111 
112 /* GstVulkanWindow usage only */
113 gboolean                gst_vulkan_display_remove_window            (GstVulkanDisplay * display, GstVulkanWindow * window);
114 
115 
116 G_END_DECLS
117 
118 #endif /* __GST_VULKAN_DISPLAY_H__ */
119