mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
gl: retreive the gldisplay/app gl context as soon as possible
fixes the usage of gst_gl_display_filter_gl_api
This commit is contained in:
parent
ae08ada8f0
commit
51620950e4
5 changed files with 123 additions and 42 deletions
|
@ -45,6 +45,8 @@ static void gst_gl_base_mixer_pad_finalize (GObject * object);
|
||||||
|
|
||||||
static void gst_gl_base_mixer_set_context (GstElement * element,
|
static void gst_gl_base_mixer_set_context (GstElement * element,
|
||||||
GstContext * context);
|
GstContext * context);
|
||||||
|
static GstStateChangeReturn gst_gl_base_mixer_change_state (GstElement *
|
||||||
|
element, GstStateChange transition);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -280,6 +282,7 @@ gst_gl_base_mixer_class_init (GstGLBaseMixerClass * klass)
|
||||||
|
|
||||||
element_class->set_context =
|
element_class->set_context =
|
||||||
GST_DEBUG_FUNCPTR (gst_gl_base_mixer_set_context);
|
GST_DEBUG_FUNCPTR (gst_gl_base_mixer_set_context);
|
||||||
|
element_class->change_state = gst_gl_base_mixer_change_state;
|
||||||
|
|
||||||
agg_class->sinkpads_type = GST_TYPE_GL_BASE_MIXER_PAD;
|
agg_class->sinkpads_type = GST_TYPE_GL_BASE_MIXER_PAD;
|
||||||
agg_class->sink_query = gst_gl_base_mixer_sink_query;
|
agg_class->sink_query = gst_gl_base_mixer_sink_query;
|
||||||
|
@ -692,3 +695,38 @@ gst_gl_base_mixer_stop (GstAggregator * agg)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstStateChangeReturn
|
||||||
|
gst_gl_base_mixer_change_state (GstElement * element, GstStateChange transition)
|
||||||
|
{
|
||||||
|
GstGLBaseMixer *mix = GST_GL_BASE_MIXER (element);
|
||||||
|
GstGLBaseMixerClass *mix_class = GST_GL_BASE_MIXER_GET_CLASS (mix);
|
||||||
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (mix, "changing state: %s => %s",
|
||||||
|
gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
|
||||||
|
gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
|
||||||
|
|
||||||
|
switch (transition) {
|
||||||
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
|
if (!gst_gl_ensure_element_data (element, &mix->display,
|
||||||
|
&mix->priv->other_context))
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
|
||||||
|
gst_gl_display_filter_gl_api (mix->display, mix_class->supported_gl_api);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||||
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
switch (transition) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -610,12 +610,6 @@ _ensure_gl_setup (GstGLImageSink * gl_sink)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (gl_sink, "Ensuring setup");
|
GST_DEBUG_OBJECT (gl_sink, "Ensuring setup");
|
||||||
|
|
||||||
if (!gst_gl_ensure_element_data (gl_sink, &gl_sink->display,
|
|
||||||
&gl_sink->other_context))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
gst_gl_display_filter_gl_api (gl_sink->display, SUPPORTED_GL_APIS);
|
|
||||||
|
|
||||||
if (!gl_sink->context) {
|
if (!gl_sink->context) {
|
||||||
do {
|
do {
|
||||||
GstGLContext *other_context;
|
GstGLContext *other_context;
|
||||||
|
@ -819,7 +813,11 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
_ensure_gl_setup (glimage_sink);
|
if (!gst_gl_ensure_element_data (glimage_sink, &glimage_sink->display,
|
||||||
|
&glimage_sink->other_context))
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
|
||||||
|
gst_gl_display_filter_gl_api (glimage_sink->display, SUPPORTED_GL_APIS);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
g_atomic_int_set (&glimage_sink->to_quit, 0);
|
g_atomic_int_set (&glimage_sink->to_quit, 0);
|
||||||
|
|
|
@ -92,6 +92,8 @@ static gboolean gst_gl_test_src_do_seek (GstBaseSrc * bsrc,
|
||||||
static gboolean gst_gl_test_src_query (GstBaseSrc * bsrc, GstQuery * query);
|
static gboolean gst_gl_test_src_query (GstBaseSrc * bsrc, GstQuery * query);
|
||||||
static void gst_gl_test_src_set_context (GstElement * element,
|
static void gst_gl_test_src_set_context (GstElement * element,
|
||||||
GstContext * context);
|
GstContext * context);
|
||||||
|
static GstStateChangeReturn gst_gl_test_src_change_state (GstElement * element,
|
||||||
|
GstStateChange transition);
|
||||||
|
|
||||||
static void gst_gl_test_src_get_times (GstBaseSrc * basesrc,
|
static void gst_gl_test_src_get_times (GstBaseSrc * basesrc,
|
||||||
GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
|
GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
|
||||||
|
@ -178,6 +180,7 @@ gst_gl_test_src_class_init (GstGLTestSrcClass * klass)
|
||||||
gst_static_pad_template_get (&src_factory));
|
gst_static_pad_template_get (&src_factory));
|
||||||
|
|
||||||
element_class->set_context = gst_gl_test_src_set_context;
|
element_class->set_context = gst_gl_test_src_set_context;
|
||||||
|
element_class->change_state = gst_gl_test_src_change_state;
|
||||||
|
|
||||||
gstbasesrc_class->set_caps = gst_gl_test_src_setcaps;
|
gstbasesrc_class->set_caps = gst_gl_test_src_setcaps;
|
||||||
gstbasesrc_class->get_caps = gst_gl_test_src_getcaps;
|
gstbasesrc_class->get_caps = gst_gl_test_src_getcaps;
|
||||||
|
@ -901,3 +904,37 @@ gst_gl_test_src_callback (gpointer stuff)
|
||||||
gst_buffer_unref (src->buffer);
|
gst_buffer_unref (src->buffer);
|
||||||
src->buffer = NULL;
|
src->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstStateChangeReturn
|
||||||
|
gst_gl_test_src_change_state (GstElement * element, GstStateChange transition)
|
||||||
|
{
|
||||||
|
GstGLTestSrc *src = GST_GL_TEST_SRC (element);
|
||||||
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (src, "changing state: %s => %s",
|
||||||
|
gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
|
||||||
|
gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
|
||||||
|
|
||||||
|
switch (transition) {
|
||||||
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
|
if (!gst_gl_ensure_element_data (element, &src->display,
|
||||||
|
&src->other_context))
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
|
||||||
|
gst_gl_display_filter_gl_api (src->display, SUPPORTED_GL_APIS);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||||
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
switch (transition) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -49,7 +49,8 @@ enum
|
||||||
#define gst_gl_base_filter_parent_class parent_class
|
#define gst_gl_base_filter_parent_class parent_class
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstGLBaseFilter, gst_gl_base_filter,
|
G_DEFINE_TYPE_WITH_CODE (GstGLBaseFilter, gst_gl_base_filter,
|
||||||
GST_TYPE_BASE_TRANSFORM, GST_DEBUG_CATEGORY_INIT (gst_gl_base_filter_debug,
|
GST_TYPE_BASE_TRANSFORM, GST_DEBUG_CATEGORY_INIT (gst_gl_base_filter_debug,
|
||||||
"glbasefilter", 0, "glbasefilter element"););
|
"glbasefilter", 0, "glbasefilter element");
|
||||||
|
);
|
||||||
|
|
||||||
static void gst_gl_base_filter_set_property (GObject * object, guint prop_id,
|
static void gst_gl_base_filter_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -58,6 +59,8 @@ static void gst_gl_base_filter_get_property (GObject * object, guint prop_id,
|
||||||
|
|
||||||
static void gst_gl_base_filter_set_context (GstElement * element,
|
static void gst_gl_base_filter_set_context (GstElement * element,
|
||||||
GstContext * context);
|
GstContext * context);
|
||||||
|
static GstStateChangeReturn gst_gl_base_filter_change_state (GstElement *
|
||||||
|
element, GstStateChange transition);
|
||||||
static gboolean gst_gl_base_filter_query (GstBaseTransform * trans,
|
static gboolean gst_gl_base_filter_query (GstBaseTransform * trans,
|
||||||
GstPadDirection direction, GstQuery * query);
|
GstPadDirection direction, GstQuery * query);
|
||||||
static void gst_gl_base_filter_reset (GstGLBaseFilter * filter);
|
static void gst_gl_base_filter_reset (GstGLBaseFilter * filter);
|
||||||
|
@ -95,6 +98,7 @@ gst_gl_base_filter_class_init (GstGLBaseFilterClass * klass)
|
||||||
gst_gl_base_filter_propose_allocation;
|
gst_gl_base_filter_propose_allocation;
|
||||||
|
|
||||||
element_class->set_context = gst_gl_base_filter_set_context;
|
element_class->set_context = gst_gl_base_filter_set_context;
|
||||||
|
element_class->change_state = gst_gl_base_filter_change_state;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_CONTEXT,
|
g_object_class_install_property (gobject_class, PROP_CONTEXT,
|
||||||
g_param_spec_object ("context",
|
g_param_spec_object ("context",
|
||||||
|
@ -191,24 +195,6 @@ _find_local_gl_context (GstGLBaseFilter * filter)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_ensure_gl_setup (GstGLBaseFilter * filter)
|
|
||||||
{
|
|
||||||
GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
|
|
||||||
|
|
||||||
if (!gst_gl_ensure_element_data (filter, &filter->display,
|
|
||||||
&filter->priv->other_context)) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_gl_display_filter_gl_api (filter->display,
|
|
||||||
filter_class->supported_gl_api);
|
|
||||||
|
|
||||||
_find_local_gl_context (filter);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_gl_base_filter_query (GstBaseTransform * trans, GstPadDirection direction,
|
gst_gl_base_filter_query (GstBaseTransform * trans, GstPadDirection direction,
|
||||||
GstQuery * query)
|
GstQuery * query)
|
||||||
|
@ -221,8 +207,7 @@ gst_gl_base_filter_query (GstBaseTransform * trans, GstPadDirection direction,
|
||||||
{
|
{
|
||||||
if (direction == GST_PAD_SINK
|
if (direction == GST_PAD_SINK
|
||||||
&& gst_base_transform_is_passthrough (trans)) {
|
&& gst_base_transform_is_passthrough (trans)) {
|
||||||
if (!_ensure_gl_setup (filter))
|
_find_local_gl_context (filter);
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return gst_pad_peer_query (GST_BASE_TRANSFORM_SRC_PAD (trans), query);
|
return gst_pad_peer_query (GST_BASE_TRANSFORM_SRC_PAD (trans), query);
|
||||||
}
|
}
|
||||||
|
@ -303,16 +288,6 @@ gst_gl_base_filter_reset (GstGLBaseFilter * filter)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_gl_base_filter_start (GstBaseTransform * bt)
|
gst_gl_base_filter_start (GstBaseTransform * bt)
|
||||||
{
|
{
|
||||||
GstGLBaseFilter *filter = GST_GL_BASE_FILTER (bt);
|
|
||||||
GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
|
|
||||||
|
|
||||||
if (!gst_gl_ensure_element_data (filter, &filter->display,
|
|
||||||
&filter->priv->other_context))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
gst_gl_display_filter_gl_api (filter->display,
|
|
||||||
filter_class->supported_gl_api);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,3 +376,40 @@ gst_gl_base_filter_propose_allocation (GstBaseTransform * trans,
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstStateChangeReturn
|
||||||
|
gst_gl_base_filter_change_state (GstElement * element,
|
||||||
|
GstStateChange transition)
|
||||||
|
{
|
||||||
|
GstGLBaseFilter *filter = GST_GL_BASE_FILTER (element);
|
||||||
|
GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
|
||||||
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (filter, "changing state: %s => %s",
|
||||||
|
gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
|
||||||
|
gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
|
||||||
|
|
||||||
|
switch (transition) {
|
||||||
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
|
if (!gst_gl_ensure_element_data (element, &filter->display,
|
||||||
|
&filter->priv->other_context))
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
|
||||||
|
gst_gl_display_filter_gl_api (filter->display,
|
||||||
|
filter_class->supported_gl_api);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||||
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
switch (transition) {
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -169,10 +169,6 @@ gst_gl_filter_start (GstBaseTransform * bt)
|
||||||
{
|
{
|
||||||
GstGLFilter *filter = GST_GL_FILTER (bt);
|
GstGLFilter *filter = GST_GL_FILTER (bt);
|
||||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||||
GstGLDisplay *display = GST_GL_BASE_FILTER (bt)->display;
|
|
||||||
|
|
||||||
if (display)
|
|
||||||
gst_gl_display_filter_gl_api (display, filter_class->supported_gl_api);
|
|
||||||
|
|
||||||
if (filter_class->onStart)
|
if (filter_class->onStart)
|
||||||
filter_class->onStart (filter);
|
filter_class->onStart (filter);
|
||||||
|
|
Loading…
Reference in a new issue