• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * GStreamer
3  * Copyright (C) 2019 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_IO_SURFACE_VULKAN_MEMORY_H_
22 #define _GST_IO_SURFACE_VULKAN_MEMORY_H_
23 
24 #include <IOSurface/IOSurfaceRef.h>
25 #include <IOSurface/IOSurfaceObjc.h>
26 #include <gst/gst.h>
27 #include <gst/gstallocator.h>
28 #include <gst/video/video.h>
29 #include <gst/vulkan/vulkan.h>
30 
31 G_BEGIN_DECLS
32 
33 #define GST_TYPE_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR (gst_io_surface_vulkan_memory_allocator_get_type())
34 GType gst_io_surface_vulkan_memory_allocator_get_type(void);
35 
36 #define GST_IS_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR))
37 #define GST_IS_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR))
38 #define GST_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR, GstIOSurfaceVulkanMemoryAllocatorClass))
39 #define GST_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR, GstIOSurfaceVulkanMemoryAllocator))
40 #define GST_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR, GstIOSurfaceVulkanMemoryAllocatorClass))
41 #define GST_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR_CAST(obj)            ((GstIOSurfaceVulkanMemoryAllocator *)(obj))
42 
43 typedef struct _GstIOSurfaceVulkanMemory
44 {
45   GstVulkanImageMemory vulkan_mem;
46   IOSurfaceRef surface;
47   guint plane;
48 } GstIOSurfaceVulkanMemory;
49 
50 #define GST_IO_SURFACE_VULKAN_MEMORY_ALLOCATOR_NAME   "IOSurfaceVulkanMemory"
51 
52 void gst_io_surface_vulkan_memory_init (void);
53 
54 GstIOSurfaceVulkanMemory *
55 gst_io_surface_vulkan_memory_wrapped (GstVulkanDevice * device,
56     IOSurfaceRef surface,
57     unsigned int fmt, /* MTLPixelFormat */
58     GstVideoInfo * info,
59     guint plane,
60     gpointer user_data,
61     GDestroyNotify notify);
62 
63 gboolean gst_is_io_surface_vulkan_memory (GstMemory * mem);
64 
65 typedef struct _GstIOSurfaceVulkanMemoryAllocator
66 {
67   GstVulkanMemoryAllocator allocator;
68 } GstIOSurfaceVulkanMemoryAllocator;
69 
70 typedef struct _GstIOSurfaceVulkanMemoryAllocatorClass
71 {
72   GstVulkanMemoryAllocatorClass parent_class;
73 } GstIOSurfaceVulkanMemoryAllocatorClass;
74 
75 G_END_DECLS
76 
77 #endif /* _GST_IO_SURFACE_MEMORY_H_ */
78