From 2aefc0924853cdedf271977cd6c3471d86f0ac11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 3 Jan 2013 15:22:38 +0100 Subject: [PATCH] eglglessink: Handle copying of GstMemory properly We have to use the default video meta mapping functions. --- ext/eglgles/gsteglglessink.c | 5 +++++ ext/eglgles/video_platform_wrapper.c | 18 ++++++++++++------ ext/eglgles/video_platform_wrapper.h | 3 +++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ext/eglgles/gsteglglessink.c b/ext/eglgles/gsteglglessink.c index ce7827d557..b994605332 100644 --- a/ext/eglgles/gsteglglessink.c +++ b/ext/eglgles/gsteglglessink.c @@ -3303,6 +3303,11 @@ gst_eglglessink_allocate_eglimage (GstEglGlesSink * eglglessink, gst_buffer_add_video_meta_full (buffer, 0, format, width, height, mem->n_textures, offset, stride); + if (!default_map_video) { + default_map_video = meta->map; + default_unmap_video = meta->unmap; + } + meta->map = eglglessink->eglglesctx.eglimage_video_map; meta->unmap = eglglessink->eglglesctx.eglimage_video_unmap; diff --git a/ext/eglgles/video_platform_wrapper.c b/ext/eglgles/video_platform_wrapper.c index 0f963dd265..bc71a6921b 100644 --- a/ext/eglgles/video_platform_wrapper.c +++ b/ext/eglgles/video_platform_wrapper.c @@ -61,6 +61,9 @@ GST_DEBUG_CATEGORY_STATIC (eglgles_platform_wrapper); #define GST_CAT_DEFAULT eglgles_platform_wrapper +PlatformMapVideo default_map_video; +PlatformUnmapVideo default_unmap_video; + /* XXX: Likely to be removed */ gboolean platform_wrapper_init (void) @@ -345,11 +348,12 @@ eglimage_video_map (GstVideoMeta * meta, guint plane, GstEGLImageMemory *mem; GstVideoInfo vinfo; - g_return_val_if_fail (gst_buffer_n_memory (meta->buffer) == 1, FALSE); + if (gst_buffer_n_memory (meta->buffer) != 1) + return default_map_video (meta, plane, info, data, stride, flags); gmem = gst_buffer_peek_memory (meta->buffer, 0); - g_return_val_if_fail (strcmp (gmem->allocator->mem_type, - GST_EGL_IMAGE_MEMORY_NAME) == 0, FALSE); + if (strcmp (gmem->allocator->mem_type, GST_EGL_IMAGE_MEMORY_NAME) != 0) + return default_map_video (meta, plane, info, data, stride, flags); mem = GST_EGL_IMAGE_MEMORY ((gmem->parent ? gmem->parent : gmem)); @@ -446,11 +450,13 @@ eglimage_video_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * info) EGL_NONE }; - g_return_val_if_fail (gst_buffer_n_memory (meta->buffer) == 1, FALSE); + if (gst_buffer_n_memory (meta->buffer) != 1) + return default_unmap_video (meta, plane, info); gmem = gst_buffer_peek_memory (meta->buffer, 0); - g_return_val_if_fail (strcmp (gmem->allocator->mem_type, - GST_EGL_IMAGE_MEMORY_NAME) == 0, FALSE); + if (strcmp (gmem->allocator->mem_type, GST_EGL_IMAGE_MEMORY_NAME) != 0) + return default_unmap_video (meta, plane, info); + mem = GST_EGL_IMAGE_MEMORY ((gmem->parent ? gmem->parent : gmem)); g_mutex_lock (&mem->lock); diff --git a/ext/eglgles/video_platform_wrapper.h b/ext/eglgles/video_platform_wrapper.h index f1813dd98a..47693df2ee 100644 --- a/ext/eglgles/video_platform_wrapper.h +++ b/ext/eglgles/video_platform_wrapper.h @@ -95,6 +95,9 @@ typedef struct typedef gboolean (*PlatformMapVideo) (GstVideoMeta *meta, guint plane, GstMapInfo *info, gpointer *data, gint * stride, GstMapFlags flags); typedef gboolean (*PlatformUnmapVideo) (GstVideoMeta *meta, guint plane, GstMapInfo *info); +extern PlatformMapVideo default_map_video; +extern PlatformUnmapVideo default_unmap_video; + gboolean platform_can_map_eglimage (GstMemoryMapFunction *map, GstMemoryUnmapFunction *unmap, PlatformMapVideo *video_map, PlatformUnmapVideo *video_unmap); gboolean platform_has_custom_eglimage_alloc (void); gboolean platform_alloc_eglimage (EGLDisplay display, EGLContext context, GLint format, GLint type, gint width, gint height, GLuint tex_id, EGLImageKHR *image, gpointer *image_platform_data);