mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 21:48:55 +00:00
gluploadmeta; remove convenience helper API
It was not really useful as if one knows about libgstgl, one can just use GLMemory objects directly.
This commit is contained in:
parent
50337e601e
commit
3591c6bfa0
11 changed files with 1 additions and 572 deletions
|
@ -90,7 +90,6 @@
|
||||||
<xi:include href="xml/gstglshader.xml"/>
|
<xi:include href="xml/gstglshader.xml"/>
|
||||||
<xi:include href="xml/gstglsyncmeta.xml"/>
|
<xi:include href="xml/gstglsyncmeta.xml"/>
|
||||||
<xi:include href="xml/gstglupload.xml"/>
|
<xi:include href="xml/gstglupload.xml"/>
|
||||||
<xi:include href="xml/gstgluploadmeta.xml"/>
|
|
||||||
<xi:include href="xml/gstglutils.xml"/>
|
<xi:include href="xml/gstglutils.xml"/>
|
||||||
<xi:include href="xml/gstglwindow.xml"/>
|
<xi:include href="xml/gstglwindow.xml"/>
|
||||||
<xi:include href="xml/gstglwindowandroid.xml"/>
|
<xi:include href="xml/gstglwindowandroid.xml"/>
|
||||||
|
|
|
@ -1191,26 +1191,6 @@ GST_TYPE_GL_UPLOAD
|
||||||
GstGLUploadPrivate
|
GstGLUploadPrivate
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
|
||||||
<FILE>gstgluploadmeta</FILE>
|
|
||||||
<TITLE>GstGLUploadMeta</TITLE>
|
|
||||||
GstGLUploadMeta
|
|
||||||
gst_gl_upload_meta_new
|
|
||||||
gst_gl_upload_meta_set_format
|
|
||||||
gst_gl_upload_meta_get_format
|
|
||||||
gst_gl_upload_meta_add_to_buffer
|
|
||||||
<SUBSECTION Standard>
|
|
||||||
GST_GL_UPLOAD_META
|
|
||||||
GST_GL_UPLOAD_META_CAST
|
|
||||||
GST_GL_UPLOAD_META_CLASS
|
|
||||||
GST_GL_UPLOAD_META_GET_CLASS
|
|
||||||
gst_gl_upload_meta_get_type
|
|
||||||
GST_IS_GL_UPLOAD_META
|
|
||||||
GST_IS_GL_UPLOAD_META_CLASS
|
|
||||||
GST_TYPE_GL_UPLOAD_META
|
|
||||||
GstGLUploadMetaPrivate
|
|
||||||
</SECTION>
|
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gstglutils</FILE>
|
<FILE>gstglutils</FILE>
|
||||||
<TITLE>Utilities</TITLE>
|
<TITLE>Utilities</TITLE>
|
||||||
|
|
|
@ -36,6 +36,5 @@ gst_gl_filter_get_type
|
||||||
gst_gl_framebuffer_get_type
|
gst_gl_framebuffer_get_type
|
||||||
gst_gl_shader_get_type
|
gst_gl_shader_get_type
|
||||||
gst_gl_upload_get_type
|
gst_gl_upload_get_type
|
||||||
gst_gl_upload_meta_get_type
|
|
||||||
gst_gl_window_get_type
|
gst_gl_window_get_type
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ libgstgl_@GST_API_VERSION@_la_SOURCES = \
|
||||||
gstglslstage.c \
|
gstglslstage.c \
|
||||||
gstglcolorconvert.c \
|
gstglcolorconvert.c \
|
||||||
gstglupload.c \
|
gstglupload.c \
|
||||||
gstgluploadmeta.c \
|
|
||||||
gstglwindow.c \
|
gstglwindow.c \
|
||||||
gstglapi.c \
|
gstglapi.c \
|
||||||
gstglfeature.c \
|
gstglfeature.c \
|
||||||
|
@ -51,7 +50,6 @@ libgstgl_@GST_API_VERSION@include_HEADERS = \
|
||||||
gstglsl.h \
|
gstglsl.h \
|
||||||
gstglslstage.h \
|
gstglslstage.h \
|
||||||
gstglcolorconvert.h \
|
gstglcolorconvert.h \
|
||||||
gstgluploadmeta.h \
|
|
||||||
gstglupload.h \
|
gstglupload.h \
|
||||||
gstglapi.h \
|
gstglapi.h \
|
||||||
gstglfeature.h \
|
gstglfeature.h \
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include <gst/gl/gstglshaderstrings.h>
|
#include <gst/gl/gstglshaderstrings.h>
|
||||||
#include <gst/gl/gstglcolorconvert.h>
|
#include <gst/gl/gstglcolorconvert.h>
|
||||||
#include <gst/gl/gstglupload.h>
|
#include <gst/gl/gstglupload.h>
|
||||||
#include <gst/gl/gstgluploadmeta.h>
|
|
||||||
#include <gst/gl/gstglbasebuffer.h>
|
#include <gst/gl/gstglbasebuffer.h>
|
||||||
#include <gst/gl/gstglmemory.h>
|
#include <gst/gl/gstglmemory.h>
|
||||||
#include <gst/gl/gstglbufferpool.h>
|
#include <gst/gl/gstglbufferpool.h>
|
||||||
|
|
|
@ -59,10 +59,6 @@ typedef struct _GstGLUpload GstGLUpload;
|
||||||
typedef struct _GstGLUploadClass GstGLUploadClass;
|
typedef struct _GstGLUploadClass GstGLUploadClass;
|
||||||
typedef struct _GstGLUploadPrivate GstGLUploadPrivate;
|
typedef struct _GstGLUploadPrivate GstGLUploadPrivate;
|
||||||
|
|
||||||
typedef struct _GstGLUploadMeta GstGLUploadMeta;
|
|
||||||
typedef struct _GstGLUploadMetaClass GstGLUploadMetaClass;
|
|
||||||
typedef struct _GstGLUploadMetaPrivate GstGLUploadMetaPrivate;
|
|
||||||
|
|
||||||
typedef struct _GstGLBufferPool GstGLBufferPool;
|
typedef struct _GstGLBufferPool GstGLBufferPool;
|
||||||
typedef struct _GstGLBufferPoolClass GstGLBufferPoolClass;
|
typedef struct _GstGLBufferPoolClass GstGLBufferPoolClass;
|
||||||
typedef struct _GstGLBufferPoolPrivate GstGLBufferPoolPrivate;
|
typedef struct _GstGLBufferPoolPrivate GstGLBufferPoolPrivate;
|
||||||
|
|
|
@ -54,7 +54,6 @@ struct _GstGLBufferPoolPrivate
|
||||||
GstVideoAlignment valign;
|
GstVideoAlignment valign;
|
||||||
GstGLTextureTarget tex_target;
|
GstGLTextureTarget tex_target;
|
||||||
gboolean add_videometa;
|
gboolean add_videometa;
|
||||||
gboolean add_uploadmeta;
|
|
||||||
gboolean add_glsyncmeta;
|
gboolean add_glsyncmeta;
|
||||||
gboolean want_eglimage;
|
gboolean want_eglimage;
|
||||||
GstBuffer *last_buffer;
|
GstBuffer *last_buffer;
|
||||||
|
@ -77,7 +76,6 @@ static const gchar **
|
||||||
gst_gl_buffer_pool_get_options (GstBufferPool * pool)
|
gst_gl_buffer_pool_get_options (GstBufferPool * pool)
|
||||||
{
|
{
|
||||||
static const gchar *options[] = { GST_BUFFER_POOL_OPTION_VIDEO_META,
|
static const gchar *options[] = { GST_BUFFER_POOL_OPTION_VIDEO_META,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META,
|
|
||||||
GST_BUFFER_POOL_OPTION_GL_SYNC_META,
|
GST_BUFFER_POOL_OPTION_GL_SYNC_META,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT,
|
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT,
|
||||||
GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D,
|
GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D,
|
||||||
|
@ -99,7 +97,7 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
guint max_align, n;
|
guint max_align, n;
|
||||||
GstAllocator *allocator = NULL;
|
GstAllocator *allocator = NULL;
|
||||||
GstAllocationParams alloc_params;
|
GstAllocationParams alloc_params;
|
||||||
gboolean reset = TRUE, ret = TRUE;
|
gboolean ret = TRUE;
|
||||||
gint p;
|
gint p;
|
||||||
|
|
||||||
if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &min_buffers,
|
if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &min_buffers,
|
||||||
|
@ -135,16 +133,11 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
if (priv->im_format == -1)
|
if (priv->im_format == -1)
|
||||||
goto unknown_format;
|
goto unknown_format;
|
||||||
|
|
||||||
if (priv->caps)
|
|
||||||
reset = !gst_caps_is_equal (priv->caps, caps);
|
|
||||||
|
|
||||||
gst_caps_replace (&priv->caps, caps);
|
gst_caps_replace (&priv->caps, caps);
|
||||||
priv->info = info;
|
priv->info = info;
|
||||||
|
|
||||||
priv->add_videometa = gst_buffer_pool_config_has_option (config,
|
priv->add_videometa = gst_buffer_pool_config_has_option (config,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||||
priv->add_uploadmeta = gst_buffer_pool_config_has_option (config,
|
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META);
|
|
||||||
priv->add_glsyncmeta = gst_buffer_pool_config_has_option (config,
|
priv->add_glsyncmeta = gst_buffer_pool_config_has_option (config,
|
||||||
GST_BUFFER_POOL_OPTION_GL_SYNC_META);
|
GST_BUFFER_POOL_OPTION_GL_SYNC_META);
|
||||||
|
|
||||||
|
@ -188,13 +181,6 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
priv->params = alloc_params;
|
priv->params = alloc_params;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reset) {
|
|
||||||
if (glpool->upload)
|
|
||||||
gst_object_unref (glpool->upload);
|
|
||||||
|
|
||||||
glpool->upload = gst_gl_upload_meta_new (glpool->context);
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->tex_target = 0;
|
priv->tex_target = 0;
|
||||||
{
|
{
|
||||||
GstStructure *s = gst_caps_get_structure (caps, 0);
|
GstStructure *s = gst_caps_get_structure (caps, 0);
|
||||||
|
@ -280,11 +266,6 @@ unknown_format:
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_gl_buffer_pool_start (GstBufferPool * pool)
|
gst_gl_buffer_pool_start (GstBufferPool * pool)
|
||||||
{
|
{
|
||||||
GstGLBufferPool *glpool = GST_GL_BUFFER_POOL_CAST (pool);
|
|
||||||
GstGLBufferPoolPrivate *priv = glpool->priv;
|
|
||||||
|
|
||||||
gst_gl_upload_meta_set_format (glpool->upload, &priv->info);
|
|
||||||
|
|
||||||
return GST_BUFFER_POOL_CLASS (parent_class)->start (pool);
|
return GST_BUFFER_POOL_CLASS (parent_class)->start (pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,9 +303,6 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
||||||
&priv->params, info, valign, buf))
|
&priv->params, info, valign, buf))
|
||||||
goto mem_create_failed;
|
goto mem_create_failed;
|
||||||
|
|
||||||
if (priv->add_uploadmeta)
|
|
||||||
gst_gl_upload_meta_add_to_buffer (glpool->upload, buf);
|
|
||||||
|
|
||||||
if (priv->add_glsyncmeta)
|
if (priv->add_glsyncmeta)
|
||||||
gst_buffer_add_gl_sync_meta (glpool->context, buf);
|
gst_buffer_add_gl_sync_meta (glpool->context, buf);
|
||||||
|
|
||||||
|
@ -475,9 +453,6 @@ gst_gl_buffer_pool_finalize (GObject * object)
|
||||||
if (priv->caps)
|
if (priv->caps)
|
||||||
gst_caps_unref (priv->caps);
|
gst_caps_unref (priv->caps);
|
||||||
|
|
||||||
if (pool->upload)
|
|
||||||
gst_object_unref (pool->upload);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_gl_buffer_pool_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gst_gl_buffer_pool_parent_class)->finalize (object);
|
||||||
|
|
||||||
/* only release the context once all our memory have been deleted */
|
/* only release the context once all our memory have been deleted */
|
||||||
|
|
|
@ -46,7 +46,6 @@ struct _GstGLBufferPool
|
||||||
GstBufferPool bufferpool;
|
GstBufferPool bufferpool;
|
||||||
|
|
||||||
GstGLContext *context;
|
GstGLContext *context;
|
||||||
GstGLUploadMeta *upload;
|
|
||||||
|
|
||||||
GstGLBufferPoolPrivate *priv;
|
GstGLBufferPoolPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,380 +0,0 @@
|
||||||
/*
|
|
||||||
* GStreamer
|
|
||||||
* Copyright (C) 2012-2014 Matthew Waters <ystree00@gmail.com>
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "gl.h"
|
|
||||||
#include "gstgluploadmeta.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SECTION:gstgluploadmeta
|
|
||||||
* @short_description: an object that provides #GstVideoGLTextureUploadMeta
|
|
||||||
* @see_also: #GstGLUpload, #GstGLMemory
|
|
||||||
*
|
|
||||||
* #GstGLUploadMeta is an object that uploads data from system memory into GL textures.
|
|
||||||
*
|
|
||||||
* A #GstGLUpload can be created with gst_gl_upload_new()
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
|
|
||||||
#define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
|
|
||||||
#define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
|
|
||||||
#define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
|
|
||||||
#define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
|
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
|
||||||
|
|
||||||
struct _GstGLUploadMetaPrivate
|
|
||||||
{
|
|
||||||
GstBuffer *buffer;
|
|
||||||
gboolean initted;
|
|
||||||
|
|
||||||
GstGLMemory *in_tex[GST_VIDEO_MAX_PLANES];
|
|
||||||
GstGLMemory *out_tex[GST_VIDEO_MAX_PLANES];
|
|
||||||
};
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_gl_upload_meta_debug);
|
|
||||||
#define GST_CAT_DEFAULT gst_gl_upload_meta_debug
|
|
||||||
|
|
||||||
#define DEBUG_INIT \
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_gl_upload_meta_debug, "gluploadmeta", 0, "uploadmeta");
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstGLUploadMeta, gst_gl_upload_meta, GST_TYPE_OBJECT, DEBUG_INIT);
|
|
||||||
static void gst_gl_upload_meta_finalize (GObject * object);
|
|
||||||
static void gst_gl_upload_meta_reset (GstGLUploadMeta * upload);
|
|
||||||
|
|
||||||
#define GST_GL_UPLOAD_META_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
|
|
||||||
GST_TYPE_GL_UPLOAD_META, GstGLUploadMetaPrivate))
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_upload_meta_class_init (GstGLUploadMetaClass * klass)
|
|
||||||
{
|
|
||||||
g_type_class_add_private (klass, sizeof (GstGLUploadMetaPrivate));
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (klass)->finalize = gst_gl_upload_meta_finalize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_upload_meta_init (GstGLUploadMeta * upload)
|
|
||||||
{
|
|
||||||
upload->priv = GST_GL_UPLOAD_META_GET_PRIVATE (upload);
|
|
||||||
|
|
||||||
upload->context = NULL;
|
|
||||||
|
|
||||||
gst_video_info_set_format (&upload->info, GST_VIDEO_FORMAT_ENCODED, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_gl_upload_meta_new:
|
|
||||||
* @context: a #GstGLContext
|
|
||||||
*
|
|
||||||
* Returns: a new #GstGLUploadMeta object
|
|
||||||
*/
|
|
||||||
GstGLUploadMeta *
|
|
||||||
gst_gl_upload_meta_new (GstGLContext * context)
|
|
||||||
{
|
|
||||||
GstGLUploadMeta *upload;
|
|
||||||
|
|
||||||
upload = g_object_new (GST_TYPE_GL_UPLOAD_META, NULL);
|
|
||||||
|
|
||||||
upload->context = gst_object_ref (context);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (upload, "Created upload for context %"GST_PTR_FORMAT, upload->context);
|
|
||||||
|
|
||||||
return upload;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_upload_meta_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
GstGLUploadMeta *upload;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (object, "Finalizing");
|
|
||||||
upload = GST_GL_UPLOAD_META (object);
|
|
||||||
|
|
||||||
gst_gl_upload_meta_reset (upload);
|
|
||||||
|
|
||||||
if (upload->context) {
|
|
||||||
gst_object_unref (upload->context);
|
|
||||||
upload->context = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_gl_upload_meta_parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_upload_meta_reset (GstGLUploadMeta * upload)
|
|
||||||
{
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
|
||||||
if (upload->priv->out_tex[i]) {
|
|
||||||
gst_memory_unref ((GstMemory *) upload->priv->out_tex[i]);
|
|
||||||
upload->priv->out_tex[i] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
|
||||||
if (upload->priv->in_tex[i]) {
|
|
||||||
gst_memory_unref ((GstMemory *) upload->priv->in_tex[i]);
|
|
||||||
upload->priv->in_tex[i] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_gst_gl_upload_meta_set_format_unlocked (GstGLUploadMeta * upload,
|
|
||||||
GstVideoInfo *info)
|
|
||||||
{
|
|
||||||
g_return_if_fail (upload != NULL);
|
|
||||||
g_return_if_fail (GST_VIDEO_INFO_FORMAT (info) !=
|
|
||||||
GST_VIDEO_FORMAT_UNKNOWN);
|
|
||||||
g_return_if_fail (GST_VIDEO_INFO_FORMAT (info) !=
|
|
||||||
GST_VIDEO_FORMAT_ENCODED);
|
|
||||||
|
|
||||||
if (gst_video_info_is_equal (&upload->info, info))
|
|
||||||
return;
|
|
||||||
|
|
||||||
gst_gl_upload_meta_reset (upload);
|
|
||||||
upload->info = *info;
|
|
||||||
upload->priv->initted = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_gl_upload_meta_set_format:
|
|
||||||
* @upload: a #GstGLUpload
|
|
||||||
* @info: input #GstVideoInfo
|
|
||||||
*
|
|
||||||
* Initializes @upload with the information required for upload.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gst_gl_upload_meta_set_format (GstGLUploadMeta * upload, GstVideoInfo * info)
|
|
||||||
{
|
|
||||||
GST_OBJECT_LOCK (upload);
|
|
||||||
_gst_gl_upload_meta_set_format_unlocked (upload, info);
|
|
||||||
GST_OBJECT_UNLOCK (upload);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_gl_upload_meta_get_format:
|
|
||||||
* @upload: a #GstGLUpload
|
|
||||||
*
|
|
||||||
* Returns: (transfer none): The #GstVideoInfo set by
|
|
||||||
* gst_gl_upload_meta_set_format()
|
|
||||||
*/
|
|
||||||
GstVideoInfo *
|
|
||||||
gst_gl_upload_meta_get_format (GstGLUploadMeta * upload)
|
|
||||||
{
|
|
||||||
GstVideoInfo *ret;
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (upload);
|
|
||||||
ret = &upload->info;
|
|
||||||
GST_OBJECT_LOCK (upload);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_perform_with_gl_memory (GstGLUploadMeta * upload, GstVideoGLTextureUploadMeta *
|
|
||||||
meta, guint texture_id[4])
|
|
||||||
{
|
|
||||||
gboolean res = TRUE;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->info); i++) {
|
|
||||||
GstGLMemory *in_mem = upload->priv->in_tex[i];
|
|
||||||
|
|
||||||
if (GST_MEMORY_FLAG_IS_SET (in_mem, GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD)) {
|
|
||||||
GstMapInfo map_info;
|
|
||||||
guint tex_id;
|
|
||||||
|
|
||||||
tex_id = in_mem->tex_id;
|
|
||||||
in_mem->tex_id = texture_id[i];
|
|
||||||
|
|
||||||
if (!gst_memory_map ((GstMemory *) in_mem, &map_info, GST_MAP_READ | GST_MAP_GL)) {
|
|
||||||
GST_WARNING_OBJECT (upload, "Failed to map GL memory");
|
|
||||||
res = FALSE;
|
|
||||||
}
|
|
||||||
gst_memory_unmap ((GstMemory *) in_mem, &map_info);
|
|
||||||
|
|
||||||
in_mem->tex_id = tex_id;
|
|
||||||
GST_MINI_OBJECT_FLAG_SET (in_mem, GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD);
|
|
||||||
} else {
|
|
||||||
GstGLMemory *out_mem;
|
|
||||||
gint mem_width, mem_height;
|
|
||||||
|
|
||||||
if (!upload->priv->out_tex[i]) {
|
|
||||||
/* the GL upload meta creates GL_TEXTURE_2D textures */
|
|
||||||
upload->priv->out_tex[i] = gst_gl_memory_wrapped_texture (upload->context,
|
|
||||||
texture_id[i], GST_GL_TEXTURE_TARGET_2D, &upload->info, i, NULL, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
out_mem = upload->priv->out_tex[i];
|
|
||||||
|
|
||||||
if (out_mem->tex_id != texture_id[i]) {
|
|
||||||
out_mem->tex_id = texture_id[i];
|
|
||||||
GST_MINI_OBJECT_FLAG_SET (out_mem, GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD);
|
|
||||||
}
|
|
||||||
|
|
||||||
mem_width = gst_gl_memory_get_texture_width (out_mem);
|
|
||||||
mem_height = gst_gl_memory_get_texture_height (out_mem);
|
|
||||||
|
|
||||||
if (!(res = gst_gl_memory_copy_into_texture (in_mem, out_mem->tex_id,
|
|
||||||
GST_GL_TEXTURE_TARGET_2D, out_mem->tex_type, mem_width, mem_height,
|
|
||||||
GST_VIDEO_INFO_PLANE_STRIDE (&out_mem->info, out_mem->plane),
|
|
||||||
FALSE)))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_perform_with_data_unlocked (GstGLUploadMeta * upload,
|
|
||||||
GstVideoGLTextureUploadMeta * meta,
|
|
||||||
gpointer data[GST_VIDEO_MAX_PLANES], guint texture_id[4])
|
|
||||||
{
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->info); i++) {
|
|
||||||
if (!upload->priv->in_tex[i])
|
|
||||||
upload->priv->in_tex[i] = gst_gl_memory_wrapped (upload->context,
|
|
||||||
GST_GL_TEXTURE_TARGET_2D, &upload->info, i, NULL, data[i], NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _perform_with_gl_memory (upload, meta, texture_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_perform_for_gl_texture_upload_meta (GstVideoGLTextureUploadMeta *
|
|
||||||
meta, guint texture_id[4])
|
|
||||||
{
|
|
||||||
GstGLUploadMeta *upload;
|
|
||||||
GstVideoFrame frame;
|
|
||||||
GstMemory *mem;
|
|
||||||
gboolean ret;
|
|
||||||
guint i, n;
|
|
||||||
|
|
||||||
g_return_val_if_fail (meta != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (texture_id != NULL, FALSE);
|
|
||||||
|
|
||||||
upload = meta->user_data;
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (upload);
|
|
||||||
|
|
||||||
if (!upload->priv->initted) {
|
|
||||||
GstVideoInfo info;
|
|
||||||
GstVideoMeta *v_meta = gst_buffer_get_video_meta (upload->priv->buffer);
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
if (!(ret = v_meta != NULL))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
gst_video_info_init (&info);
|
|
||||||
info.finfo = gst_video_format_get_info (v_meta->format);
|
|
||||||
info.width = v_meta->width;
|
|
||||||
info.height = v_meta->height;
|
|
||||||
|
|
||||||
for (i = 0; i < info.finfo->n_planes; i++) {
|
|
||||||
info.offset[i] = v_meta->offset[i];
|
|
||||||
info.stride[i] = v_meta->stride[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
_gst_gl_upload_meta_set_format_unlocked (upload, &info);
|
|
||||||
upload->priv->initted = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_LOG ("Uploading for meta with textures %i,%i,%i,%i", texture_id[0],
|
|
||||||
texture_id[1], texture_id[2], texture_id[3]);
|
|
||||||
|
|
||||||
/* GstGLMemory */
|
|
||||||
n = gst_buffer_n_memory (upload->priv->buffer);
|
|
||||||
mem = gst_buffer_peek_memory (upload->priv->buffer, 0);
|
|
||||||
|
|
||||||
if (gst_is_gl_memory (mem) && n == GST_VIDEO_INFO_N_PLANES (&upload->info)) {
|
|
||||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->info); i++)
|
|
||||||
upload->priv->in_tex[i] = (GstGLMemory *) gst_buffer_peek_memory (upload->priv->buffer, i);
|
|
||||||
|
|
||||||
ret = _perform_with_gl_memory (upload, meta, texture_id);
|
|
||||||
|
|
||||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->info); i++)
|
|
||||||
upload->priv->in_tex[i] = NULL;
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ret = gst_video_frame_map (&frame, &upload->info, upload->priv->buffer,
|
|
||||||
GST_MAP_READ))) {
|
|
||||||
GST_ERROR ("failed to map video frame");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* update the video info from the one updated by frame_map using video meta */
|
|
||||||
_gst_gl_upload_meta_set_format_unlocked (upload, &frame.info);
|
|
||||||
|
|
||||||
ret = _perform_with_data_unlocked (upload, meta, frame.data, texture_id);
|
|
||||||
|
|
||||||
gst_video_frame_unmap (&frame);
|
|
||||||
|
|
||||||
out:
|
|
||||||
GST_OBJECT_UNLOCK (upload);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_gl_upload_meta_add_to_buffer:
|
|
||||||
* @upload: a #GstGLUploadMeta
|
|
||||||
* @buffer: a #GstBuffer
|
|
||||||
*
|
|
||||||
* Adds a #GstVideoGLTextureUploadMeta on @buffer using @upload
|
|
||||||
*
|
|
||||||
* Returns: whether it was successful
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
gst_gl_upload_meta_add_to_buffer (GstGLUploadMeta * upload, GstBuffer * buffer)
|
|
||||||
{
|
|
||||||
GstVideoGLTextureType texture_types[GST_VIDEO_MAX_PLANES];
|
|
||||||
GstVideoMeta *v_meta;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
g_return_val_if_fail (upload != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (buffer != NULL, FALSE);
|
|
||||||
v_meta = gst_buffer_get_video_meta (buffer);
|
|
||||||
g_return_val_if_fail (v_meta != NULL, FALSE);
|
|
||||||
|
|
||||||
upload->priv->buffer = buffer;
|
|
||||||
|
|
||||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
|
||||||
texture_types[i] = gst_gl_texture_type_from_format (upload->context, v_meta->format, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_buffer_add_video_gl_texture_upload_meta (buffer,
|
|
||||||
GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL, 1, texture_types,
|
|
||||||
_perform_for_gl_texture_upload_meta, gst_object_ref (upload),
|
|
||||||
gst_object_ref, gst_object_unref);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
/*
|
|
||||||
* GStreamer
|
|
||||||
* Copyright (C) 2012 Matthew Waters <ystree00@gmail.com>
|
|
||||||
*
|
|
||||||
* 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_GL_UPLOAD_META_H__
|
|
||||||
#define __GST_GL_UPLOAD_META_H__
|
|
||||||
|
|
||||||
#include <gst/video/video.h>
|
|
||||||
#include <gst/gstmemory.h>
|
|
||||||
|
|
||||||
#include <gst/gl/gstgl_fwd.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
GType gst_gl_upload_meta_get_type (void);
|
|
||||||
#define GST_TYPE_GL_UPLOAD_META (gst_gl_upload_meta_get_type())
|
|
||||||
#define GST_GL_UPLOAD_META(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_UPLOAD_META,GstGLUploadMeta))
|
|
||||||
#define GST_GL_UPLOAD_META_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_UPLOAD_META,GstGLUploadMetaClass))
|
|
||||||
#define GST_IS_GL_UPLOAD_META(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_UPLOAD_META))
|
|
||||||
#define GST_IS_GL_UPLOAD_META_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_UPLOAD_META))
|
|
||||||
#define GST_GL_UPLOAD_META_CAST(obj) ((GstGLUploadMeta*)(obj))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstGLUploadMeta
|
|
||||||
*
|
|
||||||
* Opaque #GstGLUploadMeta object
|
|
||||||
*/
|
|
||||||
struct _GstGLUploadMeta
|
|
||||||
{
|
|
||||||
/* <private> */
|
|
||||||
GstObject parent;
|
|
||||||
|
|
||||||
GstGLContext *context;
|
|
||||||
|
|
||||||
/* input data */
|
|
||||||
GstVideoInfo info;
|
|
||||||
|
|
||||||
/* <private> */
|
|
||||||
GstGLUploadMetaPrivate *priv;
|
|
||||||
|
|
||||||
gpointer _reserved[GST_PADDING];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstGLUploadMetaClass:
|
|
||||||
*
|
|
||||||
* The #GstGLUploadMetaClass struct only contains private data
|
|
||||||
*/
|
|
||||||
struct _GstGLUploadMetaClass
|
|
||||||
{
|
|
||||||
GstObjectClass object_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GstGLUploadMeta * gst_gl_upload_meta_new (GstGLContext * context);
|
|
||||||
|
|
||||||
void gst_gl_upload_meta_set_format (GstGLUploadMeta * upload, GstVideoInfo * info);
|
|
||||||
GstVideoInfo * gst_gl_upload_meta_get_format (GstGLUploadMeta * upload);
|
|
||||||
|
|
||||||
gboolean gst_gl_upload_meta_add_to_buffer (GstGLUploadMeta * upload, GstBuffer * buffer);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __GST_GL_UPLOAD_META_H__ */
|
|
|
@ -249,62 +249,6 @@ GST_START_TEST (test_upload_buffer)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_upload_meta_producer)
|
|
||||||
{
|
|
||||||
GstBuffer *buffer;
|
|
||||||
GstGLMemory *gl_mem;
|
|
||||||
GstVideoInfo in_info;
|
|
||||||
GstVideoGLTextureUploadMeta *gl_upload_meta;
|
|
||||||
guint tex_ids[] = { 0, 0, 0, 0 };
|
|
||||||
GstGLUploadMeta *upload_meta;
|
|
||||||
gboolean res;
|
|
||||||
gint i = 0;
|
|
||||||
|
|
||||||
gst_video_info_set_format (&in_info, GST_VIDEO_FORMAT_RGBA, WIDTH, HEIGHT);
|
|
||||||
|
|
||||||
/* create GL buffer */
|
|
||||||
buffer = gst_buffer_new ();
|
|
||||||
gl_mem =
|
|
||||||
gst_gl_memory_wrapped (context, GST_GL_TEXTURE_TARGET_2D, &in_info, 0,
|
|
||||||
NULL, rgba_data, NULL, NULL);
|
|
||||||
gst_buffer_append_memory (buffer, (GstMemory *) gl_mem);
|
|
||||||
|
|
||||||
gst_gl_context_gen_texture (context, &tex_ids[0], GST_VIDEO_FORMAT_RGBA,
|
|
||||||
WIDTH, HEIGHT);
|
|
||||||
|
|
||||||
upload_meta = gst_gl_upload_meta_new (context);
|
|
||||||
gst_gl_upload_meta_set_format (upload_meta, &in_info);
|
|
||||||
|
|
||||||
gst_buffer_add_video_meta_full (buffer, 0, GST_VIDEO_FORMAT_RGBA, WIDTH,
|
|
||||||
HEIGHT, 1, in_info.offset, in_info.stride);
|
|
||||||
gst_gl_upload_meta_add_to_buffer (upload_meta, buffer);
|
|
||||||
|
|
||||||
gl_upload_meta = gst_buffer_get_video_gl_texture_upload_meta (buffer);
|
|
||||||
fail_if (gl_upload_meta == NULL, "Failed to add GstVideoGLTextureUploadMeta"
|
|
||||||
" to buffer\n");
|
|
||||||
|
|
||||||
res = gst_video_gl_texture_upload_meta_upload (gl_upload_meta, tex_ids);
|
|
||||||
fail_if (res == FALSE, "Failed to upload GstVideoGLTextureUploadMeta\n");
|
|
||||||
|
|
||||||
tex_id = tex_ids[0];
|
|
||||||
|
|
||||||
gst_gl_window_set_preferred_size (window, WIDTH, HEIGHT);
|
|
||||||
gst_gl_window_draw (window);
|
|
||||||
gst_gl_window_send_message (window, GST_GL_WINDOW_CB (init), context);
|
|
||||||
|
|
||||||
while (i < 2) {
|
|
||||||
gst_gl_window_send_message (window, GST_GL_WINDOW_CB (draw_render),
|
|
||||||
context);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_object_unref (upload_meta);
|
|
||||||
gst_gl_context_del_texture (context, &tex_ids[0]);
|
|
||||||
gst_buffer_unref (buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_END_TEST;
|
|
||||||
|
|
||||||
|
|
||||||
static Suite *
|
static Suite *
|
||||||
gst_gl_upload_suite (void)
|
gst_gl_upload_suite (void)
|
||||||
|
@ -316,7 +260,6 @@ gst_gl_upload_suite (void)
|
||||||
tcase_add_checked_fixture (tc_chain, setup, teardown);
|
tcase_add_checked_fixture (tc_chain, setup, teardown);
|
||||||
tcase_add_test (tc_chain, test_upload_data);
|
tcase_add_test (tc_chain, test_upload_data);
|
||||||
tcase_add_test (tc_chain, test_upload_buffer);
|
tcase_add_test (tc_chain, test_upload_buffer);
|
||||||
tcase_add_test (tc_chain, test_upload_meta_producer);
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue