mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
new caopengllayersink element
renders gstreamer gl scene/video frames to a caopengllayer retreivable from the "layer" property.
This commit is contained in:
parent
1cf843292b
commit
e5708eb453
4 changed files with 1159 additions and 1 deletions
|
@ -4,6 +4,8 @@ plugin_LTLIBRARIES = libgstopengl.la
|
|||
AM_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
|
||||
AM_LIBS = $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS)
|
||||
|
||||
libgstopengl_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
|
||||
|
||||
# full opengl required
|
||||
if USE_OPENGL
|
||||
OPENGL_SOURCES = \
|
||||
|
@ -84,6 +86,23 @@ libgstopengl_la_SOURCES += \
|
|||
endif
|
||||
endif
|
||||
|
||||
if HAVE_WINDOW_COCOA
|
||||
libgstopengl_la_SOURCES += \
|
||||
caopengllayersink.m \
|
||||
caopengllayersink.h
|
||||
|
||||
libgstopengl_la_OBJCFLAGS = \
|
||||
-I$(top_srcdir)/gst-libs \
|
||||
-I$(top_builddir)/gst-libs \
|
||||
$(GL_OBJCFLAGS) \
|
||||
$(GST_PLUGINS_BASE_CFLAGS) \
|
||||
$(GST_BASE_CFLAGS) \
|
||||
$(GST_OBJCFLAGS)
|
||||
|
||||
|
||||
libgstopengl_la_LIBTOOLFLAGS += --tag=CC
|
||||
endif
|
||||
|
||||
# check order of CFLAGS and LIBS, shouldn't the order be the other way around
|
||||
# (like in AM_CFLAGS)?
|
||||
libgstopengl_la_CFLAGS = \
|
||||
|
@ -110,5 +129,4 @@ libgstopengl_la_LIBADD = \
|
|||
$(GRAPHENE_LIBS)
|
||||
|
||||
libgstopengl_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
libgstopengl_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
|
||||
|
||||
|
|
98
ext/gl/caopengllayersink.h
Normal file
98
ext/gl/caopengllayersink.h
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2015 Matthew Waters <matthew@centricular.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 __CA_OPENGL_LAYER_SINK_H__
|
||||
#define __CA_OPENGL_LAYER_SINK_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/gstvideosink.h>
|
||||
#include <gst/video/video.h>
|
||||
|
||||
#include <gst/gl/gl.h>
|
||||
#include <gst/gl/cocoa/gstglcaopengllayer.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_CA_OPENGL_LAYER_SINK \
|
||||
(gst_ca_opengl_layer_sink_get_type())
|
||||
#define GST_CA_OPENGL_LAYER_SINK(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CA_OPENGL_LAYER_SINK,GstCAOpenGLLayerSink))
|
||||
#define GST_CA_OPENGL_LAYER_SINK_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CA_OPENGL_LAYER_SINK,GstCAOpenGLLayerSinkClass))
|
||||
#define GST_IS_CA_OPENGL_LAYER_SINK(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CA_OPENGL_LAYER_SINK))
|
||||
#define GST_IS_CA_OPENGL_LAYER_SINK_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CA_OPENGL_LAYER_SINK))
|
||||
|
||||
typedef struct _GstCAOpenGLLayerSink GstCAOpenGLLayerSink;
|
||||
typedef struct _GstCAOpenGLLayerSinkClass GstCAOpenGLLayerSinkClass;
|
||||
|
||||
struct _GstCAOpenGLLayerSink
|
||||
{
|
||||
GstVideoSink video_sink;
|
||||
|
||||
/* caps */
|
||||
GstVideoInfo info;
|
||||
GstCaps *gl_caps;
|
||||
|
||||
/* gl state */
|
||||
GstGLDisplay *display;
|
||||
GstGLContext *other_context;
|
||||
GstGLContext *context;
|
||||
|
||||
GstGLUpload *upload;
|
||||
GstGLColorConvert *convert;
|
||||
guint next_tex;
|
||||
GstBuffer *next_buffer;
|
||||
|
||||
GstGLCAOpenGLLayer *layer;
|
||||
|
||||
volatile gint to_quit;
|
||||
gboolean keep_aspect_ratio;
|
||||
|
||||
GstBufferPool *pool;
|
||||
|
||||
/* avoid replacing the stored_buffer while drawing */
|
||||
GMutex drawing_lock;
|
||||
GstBuffer *stored_buffer;
|
||||
GLuint redisplay_texture;
|
||||
|
||||
gboolean caps_change;
|
||||
guint window_width;
|
||||
guint window_height;
|
||||
|
||||
/* gl state */
|
||||
GstGLShader *redisplay_shader;
|
||||
GLuint vao;
|
||||
GLuint vertex_buffer;
|
||||
GLint attr_position;
|
||||
GLint attr_texture;
|
||||
};
|
||||
|
||||
struct _GstCAOpenGLLayerSinkClass
|
||||
{
|
||||
GstVideoSinkClass video_sink_class;
|
||||
};
|
||||
|
||||
GType gst_ca_opengl_layer_sink_get_type(void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CA_OPENGL_LAYER_SINK__ */
|
1031
ext/gl/caopengllayersink.m
Normal file
1031
ext/gl/caopengllayersink.m
Normal file
File diff suppressed because it is too large
Load diff
|
@ -75,6 +75,11 @@
|
|||
#endif /* HAVE_PNG */
|
||||
#endif /* GST_GL_HAVE_OPENGL */
|
||||
|
||||
#if GST_GL_HAVE_WINDOW_COCOA
|
||||
/* avoid including Cocoa/CoreFoundation from a C file... */
|
||||
extern GType gst_ca_opengl_layer_sink_get_type (void);
|
||||
#endif
|
||||
|
||||
#ifdef USE_EGL_RPI
|
||||
#include <bcm_host.h>
|
||||
#endif
|
||||
|
@ -202,6 +207,12 @@ plugin_init (GstPlugin * plugin)
|
|||
#endif
|
||||
#endif /* HAVE_PNG */
|
||||
#endif /* GST_GL_HAVE_OPENGL */
|
||||
#if GST_GL_HAVE_WINDOW_COCOA
|
||||
if (!gst_element_register (plugin, "caopengllayersink",
|
||||
GST_RANK_NONE, gst_ca_opengl_layer_sink_get_type ())) {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue