mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-03 21:12:26 +00:00
basetrans: improve fixate_caps function
Make it possible to also implement non-inplace fixate functions. Let the fixate function make the caps writable when needed because some fixate functions might not need to modify the caps.
This commit is contained in:
parent
7b0e4f27fb
commit
90a82c7e81
2 changed files with 16 additions and 11 deletions
|
@ -322,8 +322,8 @@ static GstFlowReturn gst_base_transform_chain (GstPad * pad, GstObject * parent,
|
||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
static GstCaps *gst_base_transform_default_transform_caps (GstBaseTransform *
|
static GstCaps *gst_base_transform_default_transform_caps (GstBaseTransform *
|
||||||
trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter);
|
trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter);
|
||||||
static void gst_base_transform_default_fixate (GstBaseTransform * trans,
|
static GstCaps *gst_base_transform_default_fixate_caps (GstBaseTransform *
|
||||||
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
|
trans, GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
|
||||||
static GstCaps *gst_base_transform_query_caps (GstBaseTransform * trans,
|
static GstCaps *gst_base_transform_query_caps (GstBaseTransform * trans,
|
||||||
GstPad * pad, GstCaps * filter);
|
GstPad * pad, GstCaps * filter);
|
||||||
static gboolean gst_base_transform_acceptcaps_default (GstBaseTransform * trans,
|
static gboolean gst_base_transform_acceptcaps_default (GstBaseTransform * trans,
|
||||||
|
@ -387,7 +387,8 @@ gst_base_transform_class_init (GstBaseTransformClass * klass)
|
||||||
|
|
||||||
klass->transform_caps =
|
klass->transform_caps =
|
||||||
GST_DEBUG_FUNCPTR (gst_base_transform_default_transform_caps);
|
GST_DEBUG_FUNCPTR (gst_base_transform_default_transform_caps);
|
||||||
klass->fixate_caps = GST_DEBUG_FUNCPTR (gst_base_transform_default_fixate);
|
klass->fixate_caps =
|
||||||
|
GST_DEBUG_FUNCPTR (gst_base_transform_default_fixate_caps);
|
||||||
klass->accept_caps =
|
klass->accept_caps =
|
||||||
GST_DEBUG_FUNCPTR (gst_base_transform_acceptcaps_default);
|
GST_DEBUG_FUNCPTR (gst_base_transform_acceptcaps_default);
|
||||||
klass->query = GST_DEBUG_FUNCPTR (gst_base_transform_default_query);
|
klass->query = GST_DEBUG_FUNCPTR (gst_base_transform_default_query);
|
||||||
|
@ -930,12 +931,15 @@ gst_base_transform_configure_caps (GstBaseTransform * trans, GstCaps * in,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static GstCaps *
|
||||||
gst_base_transform_default_fixate (GstBaseTransform * trans,
|
gst_base_transform_default_fixate_caps (GstBaseTransform * trans,
|
||||||
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
|
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (trans, "using default caps fixate function");
|
othercaps = gst_caps_make_writable (othercaps);
|
||||||
gst_caps_fixate (othercaps);
|
gst_caps_fixate (othercaps);
|
||||||
|
GST_DEBUG_OBJECT (trans, "fixated to %" GST_PTR_FORMAT, othercaps);
|
||||||
|
|
||||||
|
return othercaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* given a fixed @caps on @pad, create the best possible caps for the
|
/* given a fixed @caps on @pad, create the best possible caps for the
|
||||||
|
@ -1063,14 +1067,13 @@ gst_base_transform_find_transform (GstBaseTransform * trans, GstPad * pad,
|
||||||
/* second attempt at fixation, call the fixate vmethod */
|
/* second attempt at fixation, call the fixate vmethod */
|
||||||
/* caps could be fixed but the subclass may want to add fields */
|
/* caps could be fixed but the subclass may want to add fields */
|
||||||
if (klass->fixate_caps) {
|
if (klass->fixate_caps) {
|
||||||
othercaps = gst_caps_make_writable (othercaps);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (trans, "calling fixate_caps for %" GST_PTR_FORMAT
|
GST_DEBUG_OBJECT (trans, "calling fixate_caps for %" GST_PTR_FORMAT
|
||||||
" using caps %" GST_PTR_FORMAT " on pad %s:%s", othercaps, caps,
|
" using caps %" GST_PTR_FORMAT " on pad %s:%s", othercaps, caps,
|
||||||
GST_DEBUG_PAD_NAME (otherpad));
|
GST_DEBUG_PAD_NAME (otherpad));
|
||||||
/* note that we pass the complete array of structures to the fixate
|
/* note that we pass the complete array of structures to the fixate
|
||||||
* function, it needs to truncate itself */
|
* function, it needs to truncate itself */
|
||||||
klass->fixate_caps (trans, GST_PAD_DIRECTION (pad), caps, othercaps);
|
othercaps =
|
||||||
|
klass->fixate_caps (trans, GST_PAD_DIRECTION (pad), caps, othercaps);
|
||||||
is_fixed = gst_caps_is_fixed (othercaps);
|
is_fixed = gst_caps_is_fixed (othercaps);
|
||||||
GST_DEBUG_OBJECT (trans, "after fixating %" GST_PTR_FORMAT, othercaps);
|
GST_DEBUG_OBJECT (trans, "after fixating %" GST_PTR_FORMAT, othercaps);
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,9 @@ struct _GstBaseTransform {
|
||||||
* caps, what caps are allowed on the other pad in this
|
* caps, what caps are allowed on the other pad in this
|
||||||
* element ?
|
* element ?
|
||||||
* @fixate_caps: Optional. Given the pad in this direction and the given
|
* @fixate_caps: Optional. Given the pad in this direction and the given
|
||||||
* caps, fixate the caps on the other pad.
|
* caps, fixate the caps on the other pad. The function takes
|
||||||
|
* ownership of @othercaps and returns a fixated version of
|
||||||
|
* @othercaps. @othercaps is not guaranteed to be writable.
|
||||||
* @accept_caps: Optional. Since 0.10.30
|
* @accept_caps: Optional. Since 0.10.30
|
||||||
* Subclasses can override this method to check if @caps can be
|
* Subclasses can override this method to check if @caps can be
|
||||||
* handled by the element. The default implementation might not be
|
* handled by the element. The default implementation might not be
|
||||||
|
@ -224,7 +226,7 @@ struct _GstBaseTransformClass {
|
||||||
GstCaps* (*transform_caps) (GstBaseTransform *trans,
|
GstCaps* (*transform_caps) (GstBaseTransform *trans,
|
||||||
GstPadDirection direction,
|
GstPadDirection direction,
|
||||||
GstCaps *caps, GstCaps *filter);
|
GstCaps *caps, GstCaps *filter);
|
||||||
void (*fixate_caps) (GstBaseTransform *trans,
|
GstCaps* (*fixate_caps) (GstBaseTransform *trans,
|
||||||
GstPadDirection direction, GstCaps *caps,
|
GstPadDirection direction, GstCaps *caps,
|
||||||
GstCaps *othercaps);
|
GstCaps *othercaps);
|
||||||
gboolean (*accept_caps) (GstBaseTransform *trans, GstPadDirection direction,
|
gboolean (*accept_caps) (GstBaseTransform *trans, GstPadDirection direction,
|
||||||
|
|
Loading…
Reference in a new issue