mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 05:01:23 +00:00
glbasefilter: add a class function on set_caps (from GL)
This is simply a convenience to avoid duplicating the thread marshalling on set_caps.
This commit is contained in:
parent
0e928db89e
commit
cb9463d1a2
2 changed files with 49 additions and 2 deletions
|
@ -50,9 +50,9 @@ enum
|
|||
#define gst_gl_base_filter_parent_class parent_class
|
||||
G_DEFINE_TYPE_WITH_CODE (GstGLBaseFilter, gst_gl_base_filter,
|
||||
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_finalize (GObject * object);
|
||||
static void gst_gl_base_filter_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_gl_base_filter_get_property (GObject * object, guint prop_id,
|
||||
|
@ -67,6 +67,8 @@ static gboolean gst_gl_base_filter_query (GstBaseTransform * trans,
|
|||
static void gst_gl_base_filter_reset (GstGLBaseFilter * filter);
|
||||
static gboolean gst_gl_base_filter_start (GstBaseTransform * bt);
|
||||
static gboolean gst_gl_base_filter_stop (GstBaseTransform * bt);
|
||||
static gboolean gst_gl_base_filter_set_caps (GstBaseTransform * bt,
|
||||
GstCaps * incaps, GstCaps * outcaps);
|
||||
static gboolean gst_gl_base_filter_decide_allocation (GstBaseTransform * trans,
|
||||
GstQuery * query);
|
||||
|
||||
|
@ -85,10 +87,12 @@ gst_gl_base_filter_class_init (GstGLBaseFilterClass * klass)
|
|||
gobject_class = (GObjectClass *) klass;
|
||||
element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gobject_class->finalize = gst_gl_base_filter_finalize;
|
||||
gobject_class->set_property = gst_gl_base_filter_set_property;
|
||||
gobject_class->get_property = gst_gl_base_filter_get_property;
|
||||
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->query = gst_gl_base_filter_query;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->set_caps = gst_gl_base_filter_set_caps;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_base_filter_start;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_base_filter_stop;
|
||||
GST_BASE_TRANSFORM_CLASS (klass)->decide_allocation =
|
||||
|
@ -112,6 +116,17 @@ gst_gl_base_filter_init (GstGLBaseFilter * filter)
|
|||
filter->priv = GST_GL_BASE_FILTER_GET_PRIVATE (filter);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_base_filter_finalize (GObject * object)
|
||||
{
|
||||
GstGLBaseFilter *filter = GST_GL_BASE_FILTER (object);
|
||||
|
||||
gst_caps_replace (&filter->in_caps, NULL);
|
||||
gst_caps_replace (&filter->out_caps, NULL);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_base_filter_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
|
@ -325,6 +340,16 @@ gst_gl_base_filter_gl_stop (GstGLContext * context, gpointer data)
|
|||
filter->priv->gl_started = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_gl_set_caps (GstGLContext * context, GstGLBaseFilter * filter)
|
||||
{
|
||||
GstGLBaseFilterClass *filter_class = GST_GL_BASE_FILTER_GET_CLASS (filter);
|
||||
|
||||
if (filter_class->gl_set_caps)
|
||||
filter->priv->gl_result =
|
||||
filter_class->gl_set_caps (filter, filter->in_caps, filter->out_caps);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_base_filter_decide_allocation (GstBaseTransform * trans,
|
||||
GstQuery * query)
|
||||
|
@ -369,6 +394,11 @@ gst_gl_base_filter_decide_allocation (GstBaseTransform * trans,
|
|||
goto error;
|
||||
}
|
||||
|
||||
gst_gl_context_thread_add (filter->context,
|
||||
(GstGLContextThreadFunc) _gl_set_caps, filter);
|
||||
if (!filter->priv->gl_result)
|
||||
goto error;
|
||||
|
||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans,
|
||||
query);
|
||||
|
||||
|
@ -387,6 +417,18 @@ error:
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_base_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
|
||||
GstCaps * outcaps)
|
||||
{
|
||||
GstGLBaseFilter *filter = GST_GL_BASE_FILTER (bt);
|
||||
|
||||
gst_caps_replace (&filter->in_caps, incaps);
|
||||
gst_caps_replace (&filter->out_caps, outcaps);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_gl_base_filter_change_state (GstElement * element,
|
||||
GstStateChange transition)
|
||||
|
|
|
@ -55,6 +55,9 @@ struct _GstGLBaseFilter
|
|||
GstGLDisplay *display;
|
||||
GstGLContext *context;
|
||||
|
||||
GstCaps *in_caps;
|
||||
GstCaps *out_caps;
|
||||
|
||||
/* <private> */
|
||||
gpointer _padding[GST_PADDING];
|
||||
|
||||
|
@ -66,6 +69,7 @@ struct _GstGLBaseFilter
|
|||
* @base_transform_class: parent class
|
||||
* @gl_start: called in the GL thread to setup the element GL state.
|
||||
* @gl_stop: called in the GL thread to setup the element GL state.
|
||||
* @gl_set_caps: called in the GL thread when caps are set on @filter.
|
||||
*/
|
||||
struct _GstGLBaseFilterClass
|
||||
{
|
||||
|
@ -74,6 +78,7 @@ struct _GstGLBaseFilterClass
|
|||
|
||||
gboolean (*gl_start) (GstGLBaseFilter *filter);
|
||||
void (*gl_stop) (GstGLBaseFilter *filter);
|
||||
gboolean (*gl_set_caps) (GstGLBaseFilter *filter, GstCaps * incaps, GstCaps * outcaps);
|
||||
|
||||
gpointer _padding[GST_PADDING];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue