mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
[516/906] add skeleton GstGLMeta
the GstVideoMeta _map/unmap functions still need implementing
This commit is contained in:
parent
369905e5bd
commit
53dddca0f6
3 changed files with 214 additions and 0 deletions
|
@ -11,6 +11,7 @@ EXTRA_DIST = \
|
|||
libgstgl_@GST_API_VERSION@_la_SOURCES = \
|
||||
gstgldisplay.c \
|
||||
gstglmemory.c \
|
||||
gstglmeta.c \
|
||||
gstglfilter.c \
|
||||
gstglmixer.c \
|
||||
gstglshader.c \
|
||||
|
@ -34,6 +35,7 @@ libgstgl_@GST_API_VERSION@include_HEADERS = \
|
|||
gstglwindow.h \
|
||||
gstgldisplay.h \
|
||||
gstglmemory.h \
|
||||
gstglmeta.h \
|
||||
gstgles2.h \
|
||||
gstglfilter.h \
|
||||
gstglmixer.h \
|
||||
|
|
136
gst-libs/gst/gl/gstglmeta.c
Normal file
136
gst-libs/gst/gl/gstglmeta.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2012 Matthew Waters <ystreet00@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., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/video/gstvideometa.h>
|
||||
|
||||
#include "gstglmeta.h"
|
||||
|
||||
/* GstVideoMeta map/unmap */
|
||||
gboolean
|
||||
gst_gl_meta_map (GstVideoMeta * meta, guint plane, GstMapInfo * info,
|
||||
gpointer * data, gint * stride, GstMapFlags flags)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_gl_meta_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * info)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_meta_init (GstGLMeta * gl_meta, gpointer params, GstBuffer * buffer)
|
||||
{
|
||||
gl_meta->buffer = buffer;
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_meta_free (GstGLMeta * gl_meta, GstBuffer * buffer)
|
||||
{
|
||||
if (gl_meta->display) {
|
||||
g_object_unref (gl_meta->display);
|
||||
gl_meta->display = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_meta_transform (GstBuffer * dest, GstMeta * meta,
|
||||
GstBuffer * buffer, GQuark type, gpointer data)
|
||||
{
|
||||
GstGLMeta *dmeta, *smeta;
|
||||
|
||||
smeta = (GstGLMeta *) meta;
|
||||
|
||||
if (GST_META_TRANSFORM_IS_COPY (type)) {
|
||||
GstMetaTransformCopy *copy = data;
|
||||
|
||||
if (!copy->region) {
|
||||
/* only copy if the complete data is copied as well */
|
||||
dmeta =
|
||||
(GstGLMeta *) gst_buffer_add_meta (dest, GST_GL_META_INFO,
|
||||
smeta->display);
|
||||
dmeta->buffer = dest;
|
||||
|
||||
dmeta->memory =
|
||||
(GstGLMemory *) gst_memory_copy (GST_MEMORY_CAST (smeta->memory), 0,
|
||||
-1);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_gl_meta_api_get_type (void)
|
||||
{
|
||||
static volatile GType type;
|
||||
static const gchar *tags[] = { "memory", NULL }; /* don't know what to set here */
|
||||
|
||||
if (g_once_init_enter (&type)) {
|
||||
GType _type = gst_meta_api_type_register ("GstGLMetaAPI", tags);
|
||||
g_once_init_leave (&type, _type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
const GstMetaInfo *
|
||||
gst_gl_meta_get_info (void)
|
||||
{
|
||||
static const GstMetaInfo *gl_meta_info = NULL;
|
||||
|
||||
if (gl_meta_info == NULL) {
|
||||
gl_meta_info =
|
||||
gst_meta_register (GST_GL_META_API_TYPE, "GstGLMeta",
|
||||
sizeof (GstGLMeta), (GstMetaInitFunction) gst_gl_meta_init,
|
||||
(GstMetaFreeFunction) gst_gl_meta_free,
|
||||
(GstMetaTransformFunction) gst_gl_meta_transform);
|
||||
}
|
||||
return gl_meta_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_buffer_add_gl_meta:
|
||||
* @buffer: a #GstBuffer
|
||||
* @display: the #GstGLDisplay to use
|
||||
*
|
||||
* Creates and adds a #GstGLMeta to a @buffer.
|
||||
*
|
||||
* Returns: (transfer full): a newly created #GstGLMeta
|
||||
*/
|
||||
GstGLMeta *
|
||||
gst_buffer_add_gl_meta (GstBuffer * buffer, GstGLDisplay * display)
|
||||
{
|
||||
GstGLMeta *gl_meta;
|
||||
|
||||
gl_meta = (GstGLMeta *) gst_buffer_add_meta (buffer, GST_GL_META_INFO, NULL);
|
||||
|
||||
gl_meta->display = g_object_ref (display);
|
||||
|
||||
g_assert (gst_buffer_n_memory (buffer) == 1);
|
||||
|
||||
gl_meta->memory = (GstGLMemory *) gst_buffer_get_memory (buffer, 0);
|
||||
|
||||
return gl_meta;
|
||||
}
|
76
gst-libs/gst/gl/gstglmeta.h
Normal file
76
gst-libs/gst/gl/gstglmeta.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* GStreame
|
||||
* Copyright (C) 2007 Matthew Waters <ystreet00@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., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GST_GL_META_H_
|
||||
#define _GST_GL_META_H_
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/video/gstvideometa.h>
|
||||
|
||||
#include "gstgldisplay.h"
|
||||
#include "gstglmemory.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstGLMeta GstGLMeta;
|
||||
|
||||
GType gst_gl_meta_api_get_type (void);
|
||||
#define GST_GL_META_API_TYPE (gst_gl_meta_api_get_type())
|
||||
#define GST_GL_META_INFO (gst_gl_meta_get_info())
|
||||
const GstMetaInfo * gst_gl_meta_get_info (void);
|
||||
|
||||
/**
|
||||
* GstGLMeta:
|
||||
* @meta: parent #GstMeta
|
||||
* @buffer: #GstBuffer this meta belongs to
|
||||
* @video_meta: the #GstVideoMeta associated with this meta
|
||||
* @display: the #GstGLDisplay
|
||||
* @texture_id: the GL texture associated with this meta
|
||||
*
|
||||
* Extra buffer metadata describing OpenGL objects
|
||||
*/
|
||||
struct _GstGLMeta {
|
||||
GstMeta meta;
|
||||
GstBuffer *buffer;
|
||||
|
||||
GstGLDisplay *display;
|
||||
|
||||
GstGLMemory *memory;
|
||||
};
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
# define GST_GL_VIDEO_CAPS \
|
||||
GST_VIDEO_CAPS_MAKE ("{ RGB, RGBx, RGBA, BGR, BGRx, BGRA, xRGB, xBGR, ARGB, ABGR, I420, YV12, YUY2, UYVY, AYUV }")
|
||||
#else /* OPENGL_ES2 */
|
||||
# define GST_GL_VIDEO_CAPS \
|
||||
GST_VIDEO_CAPS_MAKE ("{ RGB, RGBx, RGBA, I420, YV12, YUY2, UYVY, AYUV }")
|
||||
#endif /* OPENGL_ES2 */
|
||||
|
||||
#define gst_buffer_get_gl_meta(b) ((GstGLMeta*)gst_buffer_get_meta((b),GST_GL_META_API_TYPE))
|
||||
GstGLMeta * gst_buffer_add_gl_meta (GstBuffer * buffer, GstGLDisplay * display);
|
||||
|
||||
gboolean gst_gl_meta_map (GstVideoMeta *meta, guint plane, GstMapInfo *info,
|
||||
gpointer *data, gint * stride, GstMapFlags flags);
|
||||
gboolean gst_gl_meta_unmap (GstVideoMeta *meta, guint plane, GstMapInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _GST_GL_META_H_ */
|
Loading…
Reference in a new issue