1 /* 2 * GStreamer 3 * Copyright (C) 2015 Matthew Waters <matthew@centricular.com> 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 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef __GST_VULKAN_DISPLAY_H__ 22 #define __GST_VULKAN_DISPLAY_H__ 23 24 #include <gst/gst.h> 25 26 #include <gst/vulkan/gstvkwindow.h> 27 #include <gst/vulkan/gstvkinstance.h> 28 29 G_BEGIN_DECLS 30 31 #define GST_TYPE_VULKAN_DISPLAY (gst_vulkan_display_get_type()) 32 #define GST_VULKAN_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VULKAN_DISPLAY,GstVulkanDisplay)) 33 #define GST_VULKAN_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VULKAN_DISPLAY,GstVulkanDisplayClass)) 34 #define GST_IS_VULKAN_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VULKAN_DISPLAY)) 35 #define GST_IS_VULKAN_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VULKAN_DISPLAY)) 36 #define GST_VULKAN_DISPLAY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_VULKAN_DISPLAY, GstVulkanDisplayClass)) 37 GST_VULKAN_API 38 GType gst_vulkan_display_get_type (void); 39 /** 40 * GST_VULKAN_DISPLAY_CAST 41 * 42 * Since: 1.18 43 */ 44 #define GST_VULKAN_DISPLAY_CAST(obj) ((GstVulkanDisplay*)(obj)) 45 46 /** 47 * GST_VULKAN_DISPLAY_CONTEXT_TYPE_STR 48 * 49 * Since: 1.18 50 */ 51 #define GST_VULKAN_DISPLAY_CONTEXT_TYPE_STR "gst.vulkan.display" 52 53 typedef struct _GstVulkanDisplay GstVulkanDisplay; 54 typedef struct _GstVulkanDisplayClass GstVulkanDisplayClass; 55 typedef struct _GstVulkanDisplayPrivate GstVulkanDisplayPrivate; 56 57 /** 58 * GstVulkanDisplayType: 59 * @GST_VULKAN_DISPLAY_TYPE_NONE: no display 60 * @GST_VULKAN_DISPLAY_TYPE_XCB: XCB display 61 * @GST_VULKAN_DISPLAY_TYPE_WAYLAND: wayland display 62 * @GST_VULKAN_DISPLAY_TYPE_COCOA: cocoa display for macOS 63 * @GST_VULKAN_DISPLAY_TYPE_IOS: ios display 64 * @GST_VULKAN_DISPLAY_TYPE_WIN32: win32 display 65 * @GST_VULKAN_DISPLAY_TYPE_ANY: any display type 66 * 67 * Since: 1.18 68 */ 69 typedef enum 70 { 71 GST_VULKAN_DISPLAY_TYPE_NONE = 0, 72 GST_VULKAN_DISPLAY_TYPE_XCB = (1 << 0), 73 GST_VULKAN_DISPLAY_TYPE_WAYLAND = (1 << 1), 74 GST_VULKAN_DISPLAY_TYPE_COCOA = (1 << 2), 75 GST_VULKAN_DISPLAY_TYPE_IOS = (1 << 3), 76 GST_VULKAN_DISPLAY_TYPE_WIN32 = (1 << 4), 77 GST_VULKAN_DISPLAY_TYPE_ANDROID = (1 << 5), 78 79 GST_VULKAN_DISPLAY_TYPE_ANY = G_MAXUINT32 80 } GstVulkanDisplayType; 81 82 /** 83 * GstVulkanDisplay: 84 * 85 * The contents of a #GstVulkanDisplay are private and should only be accessed 86 * through the provided API 87 * 88 * Since: 1.18 89 */ 90 struct _GstVulkanDisplay 91 { 92 /* <private> */ 93 GstObject object; 94 95 GstVulkanDisplayType type; 96 97 GstVulkanInstance *instance; 98 99 /* <protected> */ 100 GList *windows; /* OBJECT lock */ 101 GMainContext *main_context; 102 GMainLoop *main_loop; 103 GSource *event_source; 104 105 /* <private> */ 106 gpointer _reserved [GST_PADDING]; 107 }; 108 109 /** 110 * GstVulkanDisplayClass: 111 * @object_class: parent #GstObjectClass 112 * @get_handle: get the native handle to the display 113 * @create_window: create a window 114 * 115 * Since: 1.18 116 */ 117 struct _GstVulkanDisplayClass 118 { 119 GstObjectClass object_class; 120 121 gpointer (*get_handle) (GstVulkanDisplay * display); 122 GstVulkanWindow * (*create_window) (GstVulkanDisplay * display); 123 124 /* <private> */ 125 gpointer _reserved [GST_PADDING]; 126 }; 127 128 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstVulkanDisplay, gst_object_unref) 129 130 GST_VULKAN_API 131 GstVulkanDisplay * gst_vulkan_display_new (GstVulkanInstance *instance); 132 GST_VULKAN_API 133 GstVulkanDisplay * gst_vulkan_display_new_with_type (GstVulkanInstance *instance, 134 GstVulkanDisplayType type); 135 GST_VULKAN_API 136 GstVulkanDisplayType gst_vulkan_display_choose_type (GstVulkanInstance *instance); 137 GST_VULKAN_API 138 const gchar * gst_vulkan_display_type_to_extension_string (GstVulkanDisplayType type); 139 140 141 GST_VULKAN_API 142 gpointer gst_vulkan_display_get_handle (GstVulkanDisplay * display); 143 GST_VULKAN_API 144 GstVulkanDisplayType gst_vulkan_display_get_handle_type (GstVulkanDisplay * display); 145 GST_VULKAN_API 146 GstVulkanWindow * gst_vulkan_display_create_window (GstVulkanDisplay * display); 147 148 GST_VULKAN_API 149 gboolean gst_context_get_vulkan_display (GstContext * context, 150 GstVulkanDisplay ** display); 151 GST_VULKAN_API 152 void gst_context_set_vulkan_display (GstContext * context, 153 GstVulkanDisplay * display); 154 GST_VULKAN_API 155 gboolean gst_vulkan_display_handle_context_query (GstElement * element, 156 GstQuery * query, 157 GstVulkanDisplay * display); 158 GST_VULKAN_API 159 gboolean gst_vulkan_display_run_context_query (GstElement * element, 160 GstVulkanDisplay ** display); 161 162 /* GstVulkanWindow usage only */ 163 GST_VULKAN_API 164 gboolean gst_vulkan_display_remove_window (GstVulkanDisplay * display, GstVulkanWindow * window); 165 GST_VULKAN_API 166 GstVulkanWindow * gst_vulkan_display_find_window (GstVulkanDisplay * display, gpointer data, GCompareFunc compare_func); 167 168 G_END_DECLS 169 170 #endif /* __GST_VULKAN_DISPLAY_H__ */ 171