mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
[405/906] glfilter: add external-opengl-context property
It repairs the cluttershare and sdlshare example
This commit is contained in:
parent
dec44e571b
commit
a6a5ee2839
4 changed files with 32 additions and 11 deletions
|
@ -44,6 +44,13 @@ GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/* Properties */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_EXTERNAL_OPENGL_CONTEXT
|
||||||
|
};
|
||||||
|
|
||||||
#define DEBUG_INIT(bla) \
|
#define DEBUG_INIT(bla) \
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_gl_filter_debug, "glfilter", 0, "glfilter element");
|
GST_DEBUG_CATEGORY_INIT (gst_gl_filter_debug, "glfilter", 0, "glfilter element");
|
||||||
|
|
||||||
|
@ -107,6 +114,12 @@ gst_gl_filter_class_init (GstGLFilterClass * klass)
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->prepare_output_buffer =
|
GST_BASE_TRANSFORM_CLASS (klass)->prepare_output_buffer =
|
||||||
gst_gl_filter_prepare_output_buffer;
|
gst_gl_filter_prepare_output_buffer;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_EXTERNAL_OPENGL_CONTEXT,
|
||||||
|
g_param_spec_ulong ("external_opengl_context",
|
||||||
|
"External OpenGL context",
|
||||||
|
"Give an external OpenGL context with which to share textures",
|
||||||
|
0, G_MAXULONG, 0, G_PARAM_WRITABLE));
|
||||||
|
|
||||||
klass->set_caps = NULL;
|
klass->set_caps = NULL;
|
||||||
klass->filter = NULL;
|
klass->filter = NULL;
|
||||||
klass->display_init_cb = NULL;
|
klass->display_init_cb = NULL;
|
||||||
|
@ -132,9 +145,14 @@ static void
|
||||||
gst_gl_filter_set_property (GObject * object, guint prop_id,
|
gst_gl_filter_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
//GstGLFilter *filter = GST_GL_FILTER (object);
|
GstGLFilter *filter = GST_GL_FILTER (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
case PROP_EXTERNAL_OPENGL_CONTEXT:
|
||||||
|
{
|
||||||
|
filter->external_gl_context = g_value_get_ulong (value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -209,6 +227,7 @@ gst_gl_filter_reset (GstGLFilter * filter)
|
||||||
filter->height = 0;
|
filter->height = 0;
|
||||||
filter->fbo = 0;
|
filter->fbo = 0;
|
||||||
filter->depthbuffer = 0;
|
filter->depthbuffer = 0;
|
||||||
|
filter->external_gl_context = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -233,7 +252,7 @@ gst_gl_filter_start (GstBaseTransform * bt)
|
||||||
else {
|
else {
|
||||||
/* this gl filter is a sink in terms of the gl chain */
|
/* this gl filter is a sink in terms of the gl chain */
|
||||||
filter->display = gst_gl_display_new ();
|
filter->display = gst_gl_display_new ();
|
||||||
gst_gl_display_create_context (filter->display, 0);
|
gst_gl_display_create_context (filter->display, filter->external_gl_context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ struct _GstGLFilter
|
||||||
gint height;
|
gint height;
|
||||||
GLuint fbo;
|
GLuint fbo;
|
||||||
GLuint depthbuffer;
|
GLuint depthbuffer;
|
||||||
|
|
||||||
|
gulong external_gl_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstGLFilterClass
|
struct _GstGLFilterClass
|
||||||
|
|
|
@ -224,7 +224,7 @@ main (int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
GstPipeline *pipeline = NULL;
|
GstPipeline *pipeline = NULL;
|
||||||
GstBus *bus = NULL;
|
GstBus *bus = NULL;
|
||||||
GstElement *glupload = NULL;
|
GstElement *glfilter = NULL;
|
||||||
GstState state = 0;
|
GstState state = 0;
|
||||||
ClutterActor *stage = NULL;
|
ClutterActor *stage = NULL;
|
||||||
ClutterActor *clutter_texture = NULL;
|
ClutterActor *clutter_texture = NULL;
|
||||||
|
@ -287,10 +287,10 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
/* clutter_gl_context is an external OpenGL context with which gst-plugins-gl want to share textures */
|
/* clutter_gl_context is an external OpenGL context with which gst-plugins-gl want to share textures */
|
||||||
|
|
||||||
glupload = gst_bin_get_by_name (GST_BIN (pipeline), "glupload0");
|
glfilter = gst_bin_get_by_name (GST_BIN (pipeline), "glfilter0");
|
||||||
g_object_set (G_OBJECT (glupload), "external-opengl-context",
|
g_object_set (G_OBJECT (glfilter), "external-opengl-context",
|
||||||
clutter_gl_context, NULL);
|
clutter_gl_context, NULL);
|
||||||
g_object_unref (glupload);
|
g_object_unref (glfilter);
|
||||||
|
|
||||||
/* NULL to PAUSED state pipeline to make sure the gst opengl context is created and
|
/* NULL to PAUSED state pipeline to make sure the gst opengl context is created and
|
||||||
* shared with the clutter one */
|
* shared with the clutter one */
|
||||||
|
@ -359,7 +359,7 @@ main (int argc, char *argv[])
|
||||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
||||||
g_object_unref (pipeline);
|
g_object_unref (pipeline);
|
||||||
|
|
||||||
/* make sure there is no pending gst gl buffer in the communication queues
|
/* make sure there is no pending gst gl buffer in the communication queues
|
||||||
* between clutter and gst-gl
|
* between clutter and gst-gl
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ main (int argc, char **argv)
|
||||||
GMainLoop *loop = NULL;
|
GMainLoop *loop = NULL;
|
||||||
GstPipeline *pipeline = NULL;
|
GstPipeline *pipeline = NULL;
|
||||||
GstBus *bus = NULL;
|
GstBus *bus = NULL;
|
||||||
GstElement *glupload = NULL;
|
GstElement *glfilter = NULL;
|
||||||
GstElement *fakesink = NULL;
|
GstElement *fakesink = NULL;
|
||||||
GstState state;
|
GstState state;
|
||||||
GAsyncQueue *queue_input_buf = NULL;
|
GAsyncQueue *queue_input_buf = NULL;
|
||||||
|
@ -304,10 +304,10 @@ main (int argc, char **argv)
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
|
|
||||||
/* sdl_gl_context is an external OpenGL context with which gst-plugins-gl want to share textures */
|
/* sdl_gl_context is an external OpenGL context with which gst-plugins-gl want to share textures */
|
||||||
glupload = gst_bin_get_by_name (GST_BIN (pipeline), "glupload0");
|
glfilter = gst_bin_get_by_name (GST_BIN (pipeline), "gleffects0");
|
||||||
g_object_set (G_OBJECT (glupload), "external-opengl-context",
|
g_object_set (G_OBJECT (glfilter), "external-opengl-context",
|
||||||
sdl_gl_context, NULL);
|
sdl_gl_context, NULL);
|
||||||
g_object_unref (glupload);
|
g_object_unref (glfilter);
|
||||||
|
|
||||||
/* NULL to PAUSED state pipeline to make sure the gst opengl context is created and
|
/* NULL to PAUSED state pipeline to make sure the gst opengl context is created and
|
||||||
* shared with the sdl one */
|
* shared with the sdl one */
|
||||||
|
|
Loading…
Reference in a new issue