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_WINDOW_H__ 22 #define __GST_VULKAN_WINDOW_H__ 23 24 #include <gst/gst.h> 25 26 #include <gst/vulkan/vulkan.h> 27 28 G_BEGIN_DECLS 29 30 #define GST_TYPE_VULKAN_WINDOW (gst_vulkan_window_get_type()) 31 #define GST_VULKAN_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_VULKAN_WINDOW, GstVulkanWindow)) 32 #define GST_VULKAN_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GST_TYPE_VULKAN_WINDOW, GstVulkanWindowClass)) 33 #define GST_IS_VULKAN_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_VULKAN_WINDOW)) 34 #define GST_IS_VULKAN_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_VULKAN_WINDOW)) 35 #define GST_VULKAN_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_VULKAN_WINDOW, GstVulkanWindowClass)) 36 GST_VULKAN_API 37 GType gst_vulkan_window_get_type (void); 38 39 /** 40 * GST_VULKAN_WINDOW_LOCK: 41 * 42 * Since: 1.18 43 */ 44 #define GST_VULKAN_WINDOW_LOCK(w) g_mutex_lock(&GST_VULKAN_WINDOW(w)->lock) 45 /** 46 * GST_VULKAN_WINDOW_UNLOCK: 47 * 48 * Since: 1.18 49 */ 50 #define GST_VULKAN_WINDOW_UNLOCK(w) g_mutex_unlock(&GST_VULKAN_WINDOW(w)->lock) 51 /** 52 * GST_VULKAN_WINDOW_GET_LOCK: 53 * 54 * Since: 1.18 55 */ 56 #define GST_VULKAN_WINDOW_GET_LOCK(w) (&GST_VULKAN_WINDOW(w)->lock) 57 58 /** 59 * GST_VULKAN_WINDOW_ERROR: 60 * 61 * Since: 1.18 62 */ 63 #define GST_VULKAN_WINDOW_ERROR (gst_vulkan_window_error_quark ()) 64 /** 65 * gst_vulkan_window_error_quark: 66 * 67 * Since: 1.18 68 */ 69 GST_VULKAN_API 70 GQuark gst_vulkan_window_error_quark (void); 71 72 /** 73 * GstVulkanWindowError: 74 * @GST_VULKAN_WINDOW_ERROR_FAILED: failed 75 * @GST_VULKAN_WINDOW_ERROR_OLD_LIBS: old libraries 76 * @GST_VULKAN_WINDOW_ERROR_RESOURCE_UNAVAILABLE: resource unavailable 77 * 78 * Since: 1.18 79 */ 80 typedef enum 81 { 82 GST_VULKAN_WINDOW_ERROR_FAILED, 83 GST_VULKAN_WINDOW_ERROR_OLD_LIBS, 84 GST_VULKAN_WINDOW_ERROR_RESOURCE_UNAVAILABLE, 85 } GstVulkanWindowError; 86 87 /** 88 * GstVulkanWindow: 89 * 90 * #GstVulkanWindow is an opaque struct and should only be accessed through the 91 * provided api. 92 * 93 * Since: 1.18 94 */ 95 struct _GstVulkanWindow { 96 /*< private >*/ 97 GstObject parent; 98 99 GstVulkanDisplay *display; 100 101 // GMutex lock; 102 103 gpointer _reserved[GST_PADDING]; 104 }; 105 106 /** 107 * GstVulkanWindowClass: 108 * @parent_class: Parent class 109 * @open: open the connection to the display 110 * @close: close the connection to the display 111 * @get_surface: retrieve the vulkan surface for this window 112 * @get_presentation_support: retrieve whether this window supports presentation 113 * @set_window_handle: set the external window handle to render into 114 * @get_surface_dimensions: retrieve the current size of the window 115 * @handle_event: set whether to handle extra window system events 116 * 117 * Since: 1.18 118 */ 119 struct _GstVulkanWindowClass { 120 GstObjectClass parent_class; 121 122 gboolean (*open) (GstVulkanWindow *window, 123 GError **error); 124 void (*close) (GstVulkanWindow *window); 125 126 VkSurfaceKHR (*get_surface) (GstVulkanWindow *window, 127 GError **error); 128 gboolean (*get_presentation_support) (GstVulkanWindow *window, 129 GstVulkanDevice *device, 130 guint32 queue_family_idx); 131 void (*set_window_handle) (GstVulkanWindow *window, 132 guintptr handle); 133 void (*get_surface_dimensions) (GstVulkanWindow *window, 134 guint * width, 135 guint * height); 136 void (*handle_events) (GstVulkanWindow *window, 137 gboolean handle_events); 138 139 /*< private >*/ 140 gpointer _reserved[GST_PADDING]; 141 }; 142 143 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVulkanWindow, gst_object_unref) 144 145 GST_VULKAN_API 146 GstVulkanWindow * gst_vulkan_window_new (GstVulkanDisplay *display); 147 148 GST_VULKAN_API 149 GstVulkanDisplay * gst_vulkan_window_get_display (GstVulkanWindow *window); 150 GST_VULKAN_API 151 VkSurfaceKHR gst_vulkan_window_get_surface (GstVulkanWindow *window, 152 GError **error); 153 GST_VULKAN_API 154 gboolean gst_vulkan_window_get_presentation_support (GstVulkanWindow *window, 155 GstVulkanDevice *device, 156 guint32 queue_family_idx); 157 GST_VULKAN_API 158 void gst_vulkan_window_get_surface_dimensions (GstVulkanWindow *window, 159 guint *width, 160 guint *height); 161 GST_VULKAN_API 162 void gst_vulkan_window_set_window_handle (GstVulkanWindow *window, 163 guintptr handle); 164 165 GST_VULKAN_API 166 void gst_vulkan_window_handle_events (GstVulkanWindow * window, 167 gboolean handle_events); 168 GST_VULKAN_API 169 void gst_vulkan_window_send_key_event (GstVulkanWindow * window, 170 const char * event_type, 171 const char * key_str); 172 GST_VULKAN_API 173 void gst_vulkan_window_send_mouse_event (GstVulkanWindow * window, 174 const char * event_type, 175 int button, 176 double posx, 177 double posy); 178 179 GST_VULKAN_API 180 gboolean gst_vulkan_window_open (GstVulkanWindow *window, 181 GError ** error); 182 GST_VULKAN_API 183 void gst_vulkan_window_close (GstVulkanWindow *window); 184 185 GST_VULKAN_API 186 void gst_vulkan_window_resize (GstVulkanWindow *window, 187 gint width, 188 gint height); 189 GST_VULKAN_API 190 void gst_vulkan_window_redraw (GstVulkanWindow *window); 191 192 G_END_DECLS 193 194 #endif /* __GST_VULKAN_WINDOW_H__ */ 195