diff options
author | Matthew Waters <ystreet00@gmail.com> | 2013-11-13 10:43:16 +1100 |
---|---|---|
committer | Matthew Waters <ystreet00@gmail.com> | 2014-03-15 18:37:04 +0100 |
commit | 79260ff8f9a7c6eb7e13616747845175e42eae70 (patch) | |
tree | 5fb3911c4a22d4d1a4abecbecd9915dfde09b9a4 /gst | |
parent | f230ec14ba6cf4704cefc53084b0538b9bc9aca5 (diff) | |
download | gstreamer-plugins-bad-79260ff8f9a7c6eb7e13616747845175e42eae70.tar.gz |
[852/906] use GstContext for GstGLDisplay propogation
implements the hooks required in GstElement::set_context and the context query
Diffstat (limited to 'gst')
-rw-r--r-- | gst/gl/gstglimagesink.c | 32 | ||||
-rw-r--r-- | gst/gl/gstgltestsrc.c | 40 |
2 files changed, 55 insertions, 17 deletions
diff --git a/gst/gl/gstglimagesink.c b/gst/gl/gstglimagesink.c index 66a624b65..909299631 100644 --- a/gst/gl/gstglimagesink.c +++ b/gst/gl/gstglimagesink.c @@ -121,6 +121,8 @@ static void gst_glimage_sink_get_property (GObject * object, guint prop_id, static gboolean gst_glimage_sink_stop (GstBaseSink * bsink); static gboolean gst_glimage_sink_query (GstBaseSink * bsink, GstQuery * query); +static void gst_glimage_sink_set_context (GstElement * element, + GstContext * context); static GstStateChangeReturn gst_glimage_sink_change_state (GstElement * element, GstStateChange transition); @@ -245,7 +247,7 @@ gst_glimage_sink_class_init (GstGLImageSinkClass * klass) gobject_class->finalize = gst_glimage_sink_finalize; gstelement_class->change_state = gst_glimage_sink_change_state; - + gstelement_class->set_context = gst_glimage_sink_set_context; gstbasesink_class->query = GST_DEBUG_FUNCPTR (gst_glimage_sink_query); gstbasesink_class->set_caps = gst_glimage_sink_set_caps; gstbasesink_class->get_times = gst_glimage_sink_get_times; @@ -373,12 +375,18 @@ gst_glimage_sink_query (GstBaseSink * bsink, GstQuery * query) gboolean res = FALSE; switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_CONTEXT: + { + return gst_gl_handle_context_query ((GstElement *) glimage_sink, query, + &glimage_sink->display); + break; + } case GST_QUERY_CUSTOM: { GstStructure *structure = gst_query_writable_structure (query); - if (gst_structure_has_name (structure, "gstgldisplay")) { - gst_structure_set (structure, "gstgldisplay", G_TYPE_POINTER, - glimage_sink->display, NULL); + if (gst_structure_has_name (structure, "gstglcontext")) { + gst_structure_set (structure, "gstglcontext", G_TYPE_POINTER, + glimage_sink->context, NULL); res = TRUE; } else res = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query); @@ -420,6 +428,14 @@ gst_glimage_sink_stop (GstBaseSink * bsink) return TRUE; } +static void +gst_glimage_sink_set_context (GstElement * element, GstContext * context) +{ + GstGLImageSink *gl_sink = GST_GLIMAGE_SINK (element); + + gst_gl_handle_set_context (element, context, &gl_sink->display); +} + static GstStateChangeReturn gst_glimage_sink_change_state (GstElement * element, GstStateChange transition) { @@ -439,8 +455,9 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition) GstGLWindow *window; GError *error = NULL; - GST_INFO ("Creating GstGLDisplay"); - glimage_sink->display = gst_gl_display_new (); + if (!gst_gl_ensure_display (glimage_sink, &glimage_sink->display)) + return GST_STATE_CHANGE_FAILURE; + glimage_sink->context = gst_gl_context_new (glimage_sink->display); gst_gl_display_set_context (glimage_sink->display, glimage_sink->context); @@ -691,6 +708,9 @@ gst_glimage_sink_render (GstBaseSink * bsink, GstBuffer * buf) return GST_FLOW_NOT_NEGOTIATED; } + if (!gst_gl_ensure_display (bsink, &glimage_sink->display)) + return GST_FLOW_NOT_NEGOTIATED; + if (!gst_video_frame_map (&frame, &glimage_sink->info, buf, GST_MAP_READ | GST_MAP_GL)) { GST_WARNING ("Failed to map memory"); diff --git a/gst/gl/gstgltestsrc.c b/gst/gl/gstgltestsrc.c index 1aab25ce8..1707c93d8 100644 --- a/gst/gl/gstgltestsrc.c +++ b/gst/gl/gstgltestsrc.c @@ -78,6 +78,8 @@ static gboolean gst_gl_test_src_is_seekable (GstBaseSrc * psrc); static gboolean gst_gl_test_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment); static gboolean gst_gl_test_src_query (GstBaseSrc * bsrc, GstQuery * query); +static void gst_gl_test_src_set_context (GstElement * element, + GstContext * context); static void gst_gl_test_src_get_times (GstBaseSrc * basesrc, GstBuffer * buffer, GstClockTime * start, GstClockTime * end); @@ -160,6 +162,8 @@ gst_gl_test_src_class_init (GstGLTestSrcClass * klass) gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, gst_caps_from_string (GST_GL_DOWNLOAD_VIDEO_CAPS))); + element_class->set_context = gst_gl_test_src_set_context; + gstbasesrc_class->set_caps = gst_gl_test_src_setcaps; gstbasesrc_class->is_seekable = gst_gl_test_src_is_seekable; gstbasesrc_class->do_seek = gst_gl_test_src_do_seek; @@ -336,16 +340,29 @@ context_error: } } +static void +gst_gl_test_src_set_context (GstElement * element, GstContext * context) +{ + GstGLTestSrc *src = GST_GL_TEST_SRC (element); + + gst_gl_handle_set_context (element, context, &src->display); +} static gboolean gst_gl_test_src_query (GstBaseSrc * bsrc, GstQuery * query) { - gboolean res; + gboolean res = FALSE; GstGLTestSrc *src; src = GST_GL_TEST_SRC (bsrc); switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_CONTEXT: + { + res = gst_gl_handle_context_query ((GstElement *) src, query, + &src->display); + break; + } case GST_QUERY_CONVERT: { GstFormat src_fmt, dest_fmt; @@ -544,28 +561,29 @@ gst_gl_test_src_start (GstBaseSrc * basesrc) { GstGLTestSrc *src = GST_GL_TEST_SRC (basesrc); GstStructure *structure; - GstQuery *display_query; + GstQuery *context_query; const GValue *id_value; - structure = gst_structure_new_empty ("gstgldisplay"); - display_query = gst_query_new_custom (GST_QUERY_CUSTOM, structure); + if (!gst_gl_ensure_display (src, &src->display)) + return FALSE; + + structure = gst_structure_new_empty ("gstglcontext"); + context_query = gst_query_new_custom (GST_QUERY_CUSTOM, structure); - if (!gst_pad_peer_query (basesrc->srcpad, display_query)) { + if (!gst_pad_peer_query (basesrc->srcpad, context_query)) { GST_WARNING - ("Could not query GstGLDisplay from downstream (peer query failed)"); + ("Could not query GstGLContext from downstream (peer query failed)"); } - id_value = gst_structure_get_value (structure, "gstgldisplay"); + id_value = gst_structure_get_value (structure, "gstglcontext"); if (G_VALUE_HOLDS_POINTER (id_value)) { /* at least one gl element is after in our gl chain */ - src->display = - gst_object_ref (GST_GL_DISPLAY (g_value_get_pointer (id_value))); - src->context = gst_gl_display_get_context (src->display); + src->context = + gst_object_ref (GST_GL_CONTEXT (g_value_get_pointer (id_value))); } else { GError *error = NULL; GST_INFO ("Creating GstGLDisplay"); - src->display = gst_gl_display_new (); src->context = gst_gl_context_new (src->display); gst_gl_display_set_context (src->display, src->context); |