summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2014-10-13 11:53:47 +0200
committerSebastian Dröge <sebastian@centricular.com>2014-10-13 11:57:22 +0200
commit3efaa0dec0a81a1dc18e810b877778aa08e6d66e (patch)
tree48adf648c7fc79c04acded898d6b86b36f429605 /ext
parentf426aee5db2e855b8cff9e71897ccb1eeb99f984 (diff)
downloadgstreamer-plugins-bad-3efaa0dec0a81a1dc18e810b877778aa08e6d66e.tar.gz
glmixer: Add other-context property
Diffstat (limited to 'ext')
-rw-r--r--ext/gl/gstglmixer.c41
-rw-r--r--ext/gl/gstglmixer.h2
2 files changed, 40 insertions, 3 deletions
diff --git a/ext/gl/gstglmixer.c b/ext/gl/gstglmixer.c
index 04c951fdb..0095437dc 100644
--- a/ext/gl/gstglmixer.c
+++ b/ext/gl/gstglmixer.c
@@ -182,7 +182,7 @@ gst_gl_mixer_propose_allocation (GstGLMixer * mix,
if (!mix->context) {
mix->context = gst_gl_context_new (mix->display);
- if (!gst_gl_context_create (mix->context, NULL, &error))
+ if (!gst_gl_context_create (mix->context, mix->other_context, &error))
goto context_error;
}
@@ -327,7 +327,8 @@ enum
enum
{
- PROP_0
+ PROP_0,
+ PROP_OTHER_CONTEXT
};
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
@@ -403,6 +404,12 @@ gst_gl_mixer_class_init (GstGLMixerClass * klass)
gobject_class->get_property = gst_gl_mixer_get_property;
gobject_class->set_property = gst_gl_mixer_set_property;
+ g_object_class_install_property (gobject_class, PROP_OTHER_CONTEXT,
+ g_param_spec_object ("other-context",
+ "External OpenGL context",
+ "Give an external OpenGL context with which to share textures",
+ GST_GL_TYPE_CONTEXT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_factory));
gst_element_class_add_pad_template (element_class,
@@ -642,6 +649,16 @@ gst_gl_mixer_decide_allocation (GstGLMixer * mix, GstQuery * query)
}
}
+ if (mix->other_context) {
+ if (!other_context) {
+ other_context = mix->other_context;
+ } else {
+ GST_ELEMENT_WARNING (mix, LIBRARY, SETTINGS,
+ ("%s", "Cannot share with more than one GL context"),
+ ("%s", "Cannot share with more than one GL context"));
+ }
+ }
+
if (!mix->context) {
mix->context = gst_gl_context_new (mix->display);
if (!gst_gl_context_create (mix->context, other_context, &error))
@@ -998,7 +1015,12 @@ static void
gst_gl_mixer_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
+ GstGLMixer *mix = GST_GL_MIXER (object);
+
switch (prop_id) {
+ case PROP_OTHER_CONTEXT:
+ g_value_set_object (value, mix->other_context);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1009,7 +1031,16 @@ static void
gst_gl_mixer_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
+ GstGLMixer *mix = GST_GL_MIXER (object);
+
switch (prop_id) {
+ case PROP_OTHER_CONTEXT:
+ {
+ if (mix->other_context)
+ gst_object_unref (mix->other_context);
+ mix->other_context = g_value_dup_object (value);
+ break;
+ }
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1110,6 +1141,12 @@ gst_gl_mixer_stop (GstAggregator * agg)
gst_object_unref (mix->context);
mix->context = NULL;
}
+
+ if (mix->other_context) {
+ gst_object_unref (mix->other_context);
+ mix->other_context = NULL;
+ }
+
gst_gl_mixer_reset (mix);
return TRUE;
diff --git a/ext/gl/gstglmixer.h b/ext/gl/gstglmixer.h
index d66ef30c1..5ea246ba5 100644
--- a/ext/gl/gstglmixer.h
+++ b/ext/gl/gstglmixer.h
@@ -66,7 +66,7 @@ struct _GstGLMixer
GstGLDownload *download;
GstGLDisplay *display;
- GstGLContext *context;
+ GstGLContext *context, *other_context;
GLuint fbo;
GLuint depthbuffer;