From acac78c1ce3e24f88140e4b3428a74fc886eda30 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Mon, 2 Sep 2019 15:00:27 +1000 Subject: [PATCH] applemedia: rename IOSurfaceMemory -> IOSurfaceGLMemory --- sys/applemedia/corevideobuffer.c | 6 +- ...{iosurfacememory.c => iosurfaceglmemory.c} | 99 ++++++++++--------- sys/applemedia/iosurfaceglmemory.h | 80 +++++++++++++++ sys/applemedia/iosurfacememory.h | 80 --------------- sys/applemedia/meson.build | 2 +- sys/applemedia/videotexturecache-gl.m | 4 +- 6 files changed, 137 insertions(+), 134 deletions(-) rename sys/applemedia/{iosurfacememory.c => iosurfaceglmemory.c} (64%) create mode 100644 sys/applemedia/iosurfaceglmemory.h delete mode 100644 sys/applemedia/iosurfacememory.h diff --git a/sys/applemedia/corevideobuffer.c b/sys/applemedia/corevideobuffer.c index fdebf20af9..7500707468 100644 --- a/sys/applemedia/corevideobuffer.c +++ b/sys/applemedia/corevideobuffer.c @@ -23,7 +23,7 @@ #include "corevideobuffer.h" #include "corevideomemory.h" #if !HAVE_IOS -#include "iosurfacememory.h" +#include "iosurfaceglmemory.h" #endif #include "videotexturecache-gl.h" @@ -107,7 +107,7 @@ _create_glmem (GstAppleCoreVideoPixelBuffer * gpixbuf, #if HAVE_IOS return gst_video_texture_cache_create_memory (cache, gpixbuf, plane, size); #else - GstIOSurfaceMemory *mem; + GstIOSurfaceGLMemory *mem; CVPixelBufferRef pixel_buf = gpixbuf->buf; IOSurfaceRef surface = CVPixelBufferGetIOSurface (pixel_buf); GstGLFormat tex_format; @@ -116,7 +116,7 @@ _create_glmem (GstAppleCoreVideoPixelBuffer * gpixbuf, tex_format = gst_gl_format_from_video_info (cache_gl->ctx, info, plane); CFRetain (pixel_buf); - mem = gst_io_surface_memory_wrapped (cache_gl->ctx, + mem = gst_io_surface_gl_memory_wrapped (cache_gl->ctx, surface, GST_GL_TEXTURE_TARGET_RECTANGLE, tex_format, info, plane, NULL, pixel_buf, (GDestroyNotify) CFRelease); return GST_MEMORY_CAST (mem); diff --git a/sys/applemedia/iosurfacememory.c b/sys/applemedia/iosurfaceglmemory.c similarity index 64% rename from sys/applemedia/iosurfacememory.c rename to sys/applemedia/iosurfaceglmemory.c index 09baaa815b..56e5bad031 100644 --- a/sys/applemedia/iosurfacememory.c +++ b/sys/applemedia/iosurfaceglmemory.c @@ -22,27 +22,27 @@ #include "config.h" #endif -#include "iosurfacememory.h" +#include "iosurfaceglmemory.h" -GST_DEBUG_CATEGORY_STATIC (GST_CAT_IO_SURFACE_MEMORY); -#define GST_CAT_DEFAULT GST_CAT_IO_SURFACE_MEMORY +GST_DEBUG_CATEGORY_STATIC (GST_CAT_IO_SURFACE_GL_MEMORY); +#define GST_CAT_DEFAULT GST_CAT_IO_SURFACE_GL_MEMORY -G_DEFINE_TYPE (GstIOSurfaceMemoryAllocator, gst_io_surface_memory_allocator, - GST_TYPE_GL_MEMORY_ALLOCATOR); +G_DEFINE_TYPE (GstIOSurfaceGLMemoryAllocator, + gst_io_surface_gl_memory_allocator, GST_TYPE_GL_MEMORY_ALLOCATOR); typedef struct { - GstIOSurfaceMemory *memory; + GstIOSurfaceGLMemory *memory; IOSurfaceRef surface; } ContextThreadData; -static void _io_surface_memory_set_surface (GstIOSurfaceMemory * memory, +static void _io_surface_gl_memory_set_surface (GstIOSurfaceGLMemory * memory, IOSurfaceRef surface); -static GstAllocator *_io_surface_memory_allocator; +static GstAllocator *_io_surface_gl_memory_allocator; static gboolean -_io_surface_memory_create (GstGLBaseMemory * bmem, GError ** error) +_io_surface_gl_memory_create (GstGLBaseMemory * bmem, GError ** error) { GstGLMemory *gl_mem = (GstGLMemory *) bmem; GstGLContext *context = gl_mem->mem.context; @@ -60,19 +60,19 @@ _io_surface_memory_create (GstGLBaseMemory * bmem, GError ** error) } static void -_io_surface_memory_destroy (GstGLBaseMemory * gl_mem) +_io_surface_gl_memory_destroy (GstGLBaseMemory * gl_mem) { GST_GL_BASE_MEMORY_ALLOCATOR_CLASS - (gst_io_surface_memory_allocator_parent_class)->destroy (gl_mem); - _io_surface_memory_set_surface ((GstIOSurfaceMemory *) gl_mem, NULL); + (gst_io_surface_gl_memory_allocator_parent_class)->destroy (gl_mem); + _io_surface_gl_memory_set_surface ((GstIOSurfaceGLMemory *) gl_mem, NULL); } static gpointer -_io_surface_memory_allocator_map (GstGLBaseMemory * bmem, +_io_surface_gl_memory_allocator_map (GstGLBaseMemory * bmem, GstMapInfo * info, gsize size) { GstGLMemory *gl_mem = (GstGLMemory *) bmem; - GstIOSurfaceMemory *mem = (GstIOSurfaceMemory *) gl_mem; + GstIOSurfaceGLMemory *mem = (GstIOSurfaceGLMemory *) gl_mem; GST_LOG ("mapping surface %p flags %d gl? %d", mem->surface, info->flags, ((info->flags & GST_MAP_GL) != 0)); @@ -89,10 +89,11 @@ _io_surface_memory_allocator_map (GstGLBaseMemory * bmem, } static void -_io_surface_memory_allocator_unmap (GstGLBaseMemory * bmem, GstMapInfo * info) +_io_surface_gl_memory_allocator_unmap (GstGLBaseMemory * bmem, + GstMapInfo * info) { GstGLMemory *gl_mem = (GstGLMemory *) bmem; - GstIOSurfaceMemory *mem = (GstIOSurfaceMemory *) gl_mem; + GstIOSurfaceGLMemory *mem = (GstIOSurfaceGLMemory *) gl_mem; GST_LOG ("unmapping surface %p flags %d gl? %d", mem->surface, info->flags, ((info->flags & GST_MAP_GL) != 0)); @@ -105,15 +106,15 @@ _io_surface_memory_allocator_unmap (GstGLBaseMemory * bmem, GstMapInfo * info) static GstMemory * _mem_alloc (GstAllocator * allocator, gsize size, GstAllocationParams * params) { - g_warning ("use gst_io_surface_memory_wrapped () to allocate from this " + g_warning ("use gst_io_surface_gl_memory_wrapped () to allocate from this " "IOSurface allocator"); return NULL; } static void -gst_io_surface_memory_allocator_class_init (GstIOSurfaceMemoryAllocatorClass * - klass) + gst_io_surface_gl_memory_allocator_class_init + (GstIOSurfaceGLMemoryAllocatorClass * klass) { GstAllocatorClass *allocator_class = (GstAllocatorClass *) klass; GstGLBaseMemoryAllocatorClass *gl_base_allocator_class = @@ -121,50 +122,51 @@ gst_io_surface_memory_allocator_class_init (GstIOSurfaceMemoryAllocatorClass * allocator_class->alloc = _mem_alloc; - gl_base_allocator_class->create = _io_surface_memory_create; - gl_base_allocator_class->destroy = _io_surface_memory_destroy; - gl_base_allocator_class->map = _io_surface_memory_allocator_map; - gl_base_allocator_class->unmap = _io_surface_memory_allocator_unmap; + gl_base_allocator_class->create = _io_surface_gl_memory_create; + gl_base_allocator_class->destroy = _io_surface_gl_memory_destroy; + gl_base_allocator_class->map = _io_surface_gl_memory_allocator_map; + gl_base_allocator_class->unmap = _io_surface_gl_memory_allocator_unmap; } static void -gst_io_surface_memory_allocator_init (GstIOSurfaceMemoryAllocator * allocator) +gst_io_surface_gl_memory_allocator_init (GstIOSurfaceGLMemoryAllocator * + allocator) { GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator); - alloc->mem_type = GST_IO_SURFACE_MEMORY_ALLOCATOR_NAME; + alloc->mem_type = GST_IO_SURFACE_GL_MEMORY_ALLOCATOR_NAME; GST_OBJECT_FLAG_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC); } void -gst_ios_surface_memory_init (void) +gst_ios_surface_gl_memory_init (void) { static volatile gsize _init = 0; if (g_once_init_enter (&_init)) { - GST_DEBUG_CATEGORY_INIT (GST_CAT_IO_SURFACE_MEMORY, "iosurface", 0, + GST_DEBUG_CATEGORY_INIT (GST_CAT_IO_SURFACE_GL_MEMORY, "iosurfacegl", 0, "IOSurface Buffer"); - _io_surface_memory_allocator = - g_object_new (GST_TYPE_IO_SURFACE_MEMORY_ALLOCATOR, NULL); - gst_object_ref_sink (_io_surface_memory_allocator); + _io_surface_gl_memory_allocator = + g_object_new (GST_TYPE_IO_SURFACE_GL_MEMORY_ALLOCATOR, NULL); + gst_object_ref_sink (_io_surface_gl_memory_allocator); - gst_allocator_register (GST_IO_SURFACE_MEMORY_ALLOCATOR_NAME, - gst_object_ref (_io_surface_memory_allocator)); + gst_allocator_register (GST_IO_SURFACE_GL_MEMORY_ALLOCATOR_NAME, + gst_object_ref (_io_surface_gl_memory_allocator)); g_once_init_leave (&_init, 1); } } gboolean -gst_is_io_surface_memory (GstMemory * mem) +gst_is_io_surface_gl_memory (GstMemory * mem) { return mem != NULL && mem->allocator != NULL && g_type_is_a (G_OBJECT_TYPE (mem->allocator), - GST_TYPE_IO_SURFACE_MEMORY_ALLOCATOR); + GST_TYPE_IO_SURFACE_GL_MEMORY_ALLOCATOR); } -static GstIOSurfaceMemory * -_io_surface_memory_new (GstGLContext * context, +static GstIOSurfaceGLMemory * +_io_surface_gl_memory_new (GstGLContext * context, IOSurfaceRef surface, GstGLTextureTarget target, GstGLFormat tex_format, @@ -172,24 +174,25 @@ _io_surface_memory_new (GstGLContext * context, guint plane, GstVideoAlignment * valign, gpointer user_data, GDestroyNotify notify) { - GstIOSurfaceMemory *mem; + GstIOSurfaceGLMemory *mem; g_return_val_if_fail (target == GST_GL_TEXTURE_TARGET_RECTANGLE, NULL); - mem = g_new0 (GstIOSurfaceMemory, 1); - gst_gl_memory_init (&mem->gl_mem, _io_surface_memory_allocator, NULL, context, - target, tex_format, NULL, info, plane, valign, user_data, notify); + mem = g_new0 (GstIOSurfaceGLMemory, 1); + gst_gl_memory_init (&mem->gl_mem, _io_surface_gl_memory_allocator, NULL, + context, target, tex_format, NULL, info, plane, valign, user_data, + notify); GST_MINI_OBJECT_FLAG_SET (mem, GST_MEMORY_FLAG_READONLY); mem->surface = NULL; - gst_io_surface_memory_set_surface (mem, surface); + gst_io_surface_gl_memory_set_surface (mem, surface); return mem; } -GstIOSurfaceMemory * -gst_io_surface_memory_wrapped (GstGLContext * context, +GstIOSurfaceGLMemory * +gst_io_surface_gl_memory_wrapped (GstGLContext * context, IOSurfaceRef surface, GstGLTextureTarget target, GstGLFormat tex_format, @@ -197,12 +200,12 @@ gst_io_surface_memory_wrapped (GstGLContext * context, guint plane, GstVideoAlignment * valign, gpointer user_data, GDestroyNotify notify) { - return _io_surface_memory_new (context, surface, target, tex_format, info, + return _io_surface_gl_memory_new (context, surface, target, tex_format, info, plane, valign, user_data, notify); } static void -_io_surface_memory_set_surface (GstIOSurfaceMemory * memory, +_io_surface_gl_memory_set_surface (GstIOSurfaceGLMemory * memory, IOSurfaceRef surface) { GstGLMemory *gl_mem = (GstGLMemory *) memory; @@ -239,17 +242,17 @@ _io_surface_memory_set_surface (GstIOSurfaceMemory * memory, static void _do_set_surface (GstGLContext * context, ContextThreadData * data) { - _io_surface_memory_set_surface (data->memory, data->surface); + _io_surface_gl_memory_set_surface (data->memory, data->surface); } void -gst_io_surface_memory_set_surface (GstIOSurfaceMemory * memory, +gst_io_surface_gl_memory_set_surface (GstIOSurfaceGLMemory * memory, IOSurfaceRef surface) { GstGLContext *context; ContextThreadData data = { memory, surface }; - g_return_if_fail (gst_is_io_surface_memory ((GstMemory *) memory)); + g_return_if_fail (gst_is_io_surface_gl_memory ((GstMemory *) memory)); context = memory->gl_mem.mem.context; gst_gl_context_thread_add (context, diff --git a/sys/applemedia/iosurfaceglmemory.h b/sys/applemedia/iosurfaceglmemory.h new file mode 100644 index 0000000000..1950c82e76 --- /dev/null +++ b/sys/applemedia/iosurfaceglmemory.h @@ -0,0 +1,80 @@ +/* + * GStreamer + * Copyright (C) 2015 Alessandro Decina + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GST_IO_SURFACE_GL_MEMORY_H_ +#define _GST_IO_SURFACE_GL_MEMORY_H_ + +#include +#include +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define GST_TYPE_IO_SURFACE_GL_MEMORY_ALLOCATOR (gst_io_surface_gl_memory_allocator_get_type()) +GType gst_io_surface_gl_memory_allocator_get_type(void); + +#define GST_IS_IO_SURFACE_GL_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_IO_SURFACE_GL_MEMORY_ALLOCATOR)) +#define GST_IS_IO_SURFACE_GL_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_IO_SURFACE_GL_MEMORY_ALLOCATOR)) +#define GST_IO_SURFACE_GL_MEMORY_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_IO_SURFACE_GL_MEMORY_ALLOCATOR, GstIOSurfaceGLMemoryAllocatorClass)) +#define GST_IO_SURFACE_GL_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_IO_SURFACE_GL_MEMORY_ALLOCATOR, GstIOSurfaceGLMemoryAllocator)) +#define GST_IO_SURFACE_GL_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_IO_SURFACE_GL_MEMORY_ALLOCATOR, GstIOSurfaceGLMemoryAllocatorClass)) +#define GST_IO_SURFACE_GL_MEMORY_ALLOCATOR_CAST(obj) ((GstIOSurfaceGLMemoryAllocator *)(obj)) + +typedef struct _GstIOSurfaceGLMemory +{ + GstGLMemory gl_mem; + IOSurfaceRef surface; +} GstIOSurfaceGLMemory; + +#define GST_IO_SURFACE_GL_MEMORY_ALLOCATOR_NAME "IOSurfaceGLMemory" + +void gst_ios_surface_gl_memory_init (void); + +GstIOSurfaceGLMemory * +gst_io_surface_gl_memory_wrapped (GstGLContext * context, + IOSurfaceRef surface, + GstGLTextureTarget target, + GstGLFormat tex_format, + GstVideoInfo * info, + guint plane, + GstVideoAlignment *valign, + gpointer user_data, + GDestroyNotify notify); + +void gst_io_surface_gl_memory_set_surface (GstIOSurfaceGLMemory *memory, IOSurfaceRef surface); + +gboolean gst_is_io_surface_gl_memory (GstMemory * mem); + +typedef struct _GstIOSurfaceGLMemoryAllocator +{ + GstGLMemoryAllocator allocator; +} GstIOSurfaceGLMemoryAllocator; + +typedef struct _GstIOSurfaceGLMemoryAllocatorClass +{ + GstGLMemoryAllocatorClass parent_class; +} GstIOSurfaceGLMemoryAllocatorClass; + +G_END_DECLS + +#endif /* _GST_IO_SURFACE_MEMORY_H_ */ diff --git a/sys/applemedia/iosurfacememory.h b/sys/applemedia/iosurfacememory.h deleted file mode 100644 index 3160c7dffd..0000000000 --- a/sys/applemedia/iosurfacememory.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2015 Alessandro Decina - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _GST_IO_SURFACE_MEMORY_H_ -#define _GST_IO_SURFACE_MEMORY_H_ - -#include -#include -#include -#include -#include -#include - -G_BEGIN_DECLS - -#define GST_TYPE_IO_SURFACE_MEMORY_ALLOCATOR (gst_io_surface_memory_allocator_get_type()) -GType gst_io_surface_memory_allocator_get_type(void); - -#define GST_IS_IO_SURFACE_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_IO_SURFACE_MEMORY_ALLOCATOR)) -#define GST_IS_IO_SURFACE_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_IO_SURFACE_MEMORY_ALLOCATOR)) -#define GST_IO_SURFACE_MEMORY_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_IO_SURFACE_MEMORY_ALLOCATOR, GstIOSurfaceMemoryAllocatorClass)) -#define GST_IO_SURFACE_MEMORY_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_IO_SURFACE_MEMORY_ALLOCATOR, GstIOSurfaceMemoryAllocator)) -#define GST_IO_SURFACE_MEMORY_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_IO_SURFACE_MEMORY_ALLOCATOR, GstIOSurfaceMemoryAllocatorClass)) -#define GST_IO_SURFACE_MEMORY_ALLOCATOR_CAST(obj) ((GstIOSurfaceMemoryAllocator *)(obj)) - -typedef struct _GstIOSurfaceMemory -{ - GstGLMemory gl_mem; - IOSurfaceRef surface; -} GstIOSurfaceMemory; - -#define GST_IO_SURFACE_MEMORY_ALLOCATOR_NAME "IOSurfaceMemory" - -void gst_ios_surface_memory_init (void); - -GstIOSurfaceMemory * -gst_io_surface_memory_wrapped (GstGLContext * context, - IOSurfaceRef surface, - GstGLTextureTarget target, - GstGLFormat tex_format, - GstVideoInfo * info, - guint plane, - GstVideoAlignment *valign, - gpointer user_data, - GDestroyNotify notify); - -void gst_io_surface_memory_set_surface (GstIOSurfaceMemory *memory, IOSurfaceRef surface); - -gboolean gst_is_io_surface_memory (GstMemory * mem); - -typedef struct _GstIOSurfaceMemoryAllocator -{ - GstGLMemoryAllocator allocator; -} GstIOSurfaceMemoryAllocator; - -typedef struct _GstIOSurfaceMemoryAllocatorClass -{ - GstGLMemoryAllocatorClass parent_class; -} GstIOSurfaceMemoryAllocatorClass; - -G_END_DECLS - -#endif /* _GST_IO_SURFACE_MEMORY_H_ */ diff --git a/sys/applemedia/meson.build b/sys/applemedia/meson.build index 5a093b2dda..c97be20415 100644 --- a/sys/applemedia/meson.build +++ b/sys/applemedia/meson.build @@ -71,7 +71,7 @@ if host_system == 'ios' applemedia_frameworks += [ios_media_dep] else applemedia_sources += [ - 'iosurfacememory.c' + 'iosurfaceglmemory.c' ] applemedia_objc_args += ['-mmacosx-version-min=10.8'] cocoa_dep = dependency('Cocoa', required : applemedia_option) diff --git a/sys/applemedia/videotexturecache-gl.m b/sys/applemedia/videotexturecache-gl.m index 00743faf21..6315041b16 100644 --- a/sys/applemedia/videotexturecache-gl.m +++ b/sys/applemedia/videotexturecache-gl.m @@ -23,7 +23,7 @@ #if !HAVE_IOS #import -#include "iosurfacememory.h" +#include "iosurfaceglmemory.h" #endif #include "iosglmemory.h" #include "videotexturecache-gl.h" @@ -135,7 +135,7 @@ gst_video_texture_cache_gl_constructed (GObject * object) CVOpenGLESTextureCacheCreate (kCFAllocatorDefault, (CFDictionaryRef) cache_attrs, (__bridge CVEAGLContext) (gpointer) gst_gl_context_get_gl_context (cache_gl->ctx), NULL, &cache_gl->cache); #else - gst_ios_surface_memory_init (); + gst_ios_surface_gl_memory_init (); #if 0 cache->pool = GST_BUFFER_POOL (gst_gl_buffer_pool_new (ctx)); #endif