diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index e33801e0f9..8df15d4912 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -324,6 +324,8 @@ static gboolean gst_base_transform_acceptcaps_default (GstBaseTransform * trans, static gboolean gst_base_transform_setcaps (GstBaseTransform * trans, GstPad * pad, GstCaps * caps); static gboolean gst_base_transform_query (GstPad * pad, GstQuery * query); +static gboolean gst_base_transform_default_query (GstBaseTransform * trans, + GstPad * pad, GstQuery * query); static const GstQueryType *gst_base_transform_query_type (GstPad * pad); static GstFlowReturn default_prepare_output_buffer (GstBaseTransform * trans, @@ -378,6 +380,7 @@ gst_base_transform_class_init (GstBaseTransformClass * klass) klass->prepare_output_buffer = GST_DEBUG_FUNCPTR (default_prepare_output_buffer); klass->copy_metadata = GST_DEBUG_FUNCPTR (default_copy_metadata); + klass->query = GST_DEBUG_FUNCPTR (gst_base_transform_default_query); } static void @@ -1299,15 +1302,12 @@ failed_configure: } static gboolean -gst_base_transform_query (GstPad * pad, GstQuery * query) +gst_base_transform_default_query (GstBaseTransform * trans, + GstPad * pad, GstQuery * query) { gboolean ret = FALSE; - GstBaseTransform *trans; GstPad *otherpad; - trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); - if (G_UNLIKELY (trans == NULL)) - return FALSE; otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad; switch (GST_QUERY_TYPE (query)) { @@ -1361,7 +1361,29 @@ gst_base_transform_query (GstPad * pad, GstQuery * query) } done: + return ret; +} + +static gboolean +gst_base_transform_query (GstPad * pad, GstQuery * query) +{ + GstBaseTransform *trans; + GstBaseTransformClass *bclass; + gboolean ret; + + trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); + if (G_UNLIKELY (trans == NULL)) + return FALSE; + + bclass = GST_BASE_TRANSFORM_GET_CLASS (trans); + + if (bclass->query) + ret = bclass->query (trans, pad, query); + else + ret = gst_pad_query_default (pad, query); + gst_object_unref (trans); + return ret; } diff --git a/libs/gst/base/gstbasetransform.h b/libs/gst/base/gstbasetransform.h index 8f79396a56..ca0ffe8f10 100644 --- a/libs/gst/base/gstbasetransform.h +++ b/libs/gst/base/gstbasetransform.h @@ -156,6 +156,10 @@ struct _GstBaseTransform { * handled by the element. The default implementation might not be * the most optimal way to check this in all cases. * @set_caps: allows the subclass to be notified of the actual caps set. + * @query: Optional Since 0.10.36 + * Handle a requested query. Subclasses that implement this + * should must chain up to the parent if they didn't handle the + * query * @transform_size: Optional. Given the size of a buffer in the given direction * with the given caps, calculate the size in bytes of a buffer * on the other pad with the given other caps. @@ -221,6 +225,8 @@ struct _GstBaseTransformClass { GstCaps *caps); gboolean (*set_caps) (GstBaseTransform *trans, GstCaps *incaps, GstCaps *outcaps); + gboolean (*query) (GstBaseTransform *trans, GstPad *pad, + GstQuery *query); /* setup allocation query for output buffers */ gboolean (*setup_allocation) (GstBaseTransform *trans, GstQuery *query); @@ -243,9 +249,10 @@ struct _GstBaseTransformClass { gboolean (*src_event) (GstBaseTransform *trans, GstEvent *event); GstFlowReturn (*prepare_output_buffer) (GstBaseTransform * trans, - GstBuffer *input, GstBuffer **outbuf); + GstBuffer *input, GstBuffer **outbuf); - gboolean (*copy_metadata) (GstBaseTransform * trans, GstBuffer *input, GstBuffer *outbuf); + gboolean (*copy_metadata) (GstBaseTransform * trans, GstBuffer *input, + GstBuffer *outbuf); void (*before_transform) (GstBaseTransform *trans, GstBuffer *buffer); diff --git a/plugins/elements/gstcapsfilter.c b/plugins/elements/gstcapsfilter.c index bb7af5b844..16278dcb70 100644 --- a/plugins/elements/gstcapsfilter.c +++ b/plugins/elements/gstcapsfilter.c @@ -200,9 +200,10 @@ gst_capsfilter_set_property (GObject * object, guint prop_id, gst_caps_unref (nego); } else { GST_DEBUG_OBJECT (capsfilter, "no negotiated caps"); - /* no previous caps, the getcaps function will be used to find suitable - * caps */ - suggest = NULL; + /* Suggest the new caps, we can't just rely on _get_caps as this may + * already be called at this point even though no buffer has been + * pushed yet */ + suggest = gst_caps_copy (new_caps); } GST_DEBUG_OBJECT (capsfilter, "suggesting new caps %" GST_PTR_FORMAT,