gltestsrc: Add other-context property

This commit is contained in:
Sebastian Dröge 2014-10-13 13:25:42 +02:00
parent d8a262a589
commit fe3fafe652
2 changed files with 39 additions and 1 deletions

View file

@ -59,6 +59,7 @@ GST_DEBUG_CATEGORY_STATIC (gl_test_src_debug);
enum
{
PROP_0,
PROP_OTHER_CONTEXT,
PROP_PATTERN,
PROP_TIMESTAMP_OFFSET,
PROP_IS_LIVE
@ -89,6 +90,7 @@ static void gst_gl_test_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_gl_test_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_gl_test_src_dispose (GObject * object);
static gboolean gst_gl_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps);
static GstCaps *gst_gl_test_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
@ -161,7 +163,13 @@ gst_gl_test_src_class_init (GstGLTestSrcClass * klass)
gobject_class->set_property = gst_gl_test_src_set_property;
gobject_class->get_property = gst_gl_test_src_get_property;
gobject_class->dispose = gst_gl_test_src_dispose;
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));
g_object_class_install_property (gobject_class, PROP_PATTERN,
g_param_spec_enum ("pattern", "Pattern",
"Type of test pattern to generate", GST_TYPE_GL_TEST_SRC_PATTERN,
@ -388,6 +396,18 @@ gst_gl_test_src_set_pattern (GstGLTestSrc * gltestsrc, gint pattern_type)
}
}
static void
gst_gl_test_src_dispose (GObject * object)
{
GstGLTestSrc *src = GST_GL_TEST_SRC (object);
if (src->other_context)
gst_object_unref (src->other_context);
src->other_context = NULL;
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gst_gl_test_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
@ -395,6 +415,11 @@ gst_gl_test_src_set_property (GObject * object, guint prop_id,
GstGLTestSrc *src = GST_GL_TEST_SRC (object);
switch (prop_id) {
case PROP_OTHER_CONTEXT:
if (src->other_context)
gst_object_unref (src->other_context);
src->other_context = g_value_dup_object (value);
break;
case PROP_PATTERN:
gst_gl_test_src_set_pattern (src, g_value_get_enum (value));
break;
@ -416,6 +441,9 @@ gst_gl_test_src_get_property (GObject * object, guint prop_id,
GstGLTestSrc *src = GST_GL_TEST_SRC (object);
switch (prop_id) {
case PROP_OTHER_CONTEXT:
g_value_set_object (value, src->other_context);
break;
case PROP_PATTERN:
g_value_set_enum (value, src->pattern_type);
break;
@ -784,6 +812,16 @@ gst_gl_test_src_decide_allocation (GstBaseSrc * basesrc, GstQuery * query)
}
}
if (src->other_context) {
if (!other_context) {
other_context = src->other_context;
} else {
GST_ELEMENT_WARNING (src, LIBRARY, SETTINGS,
("%s", "Cannot share with more than one GL context"),
("%s", "Cannot share with more than one GL context"));
}
}
if (!src->context) {
src->context = gst_gl_context_new (src->display);
if (!gst_gl_context_create (src->context, other_context, &error))

View file

@ -108,7 +108,7 @@ struct _GstGLTestSrc {
GstGLDownload *download;
GstGLDisplay *display;
GstGLContext *context;
GstGLContext *context, *other_context;
gint64 timestamp_offset; /* base offset */
GstClockTime running_time; /* total running time */
gint64 n_frames; /* total frames sent */