Implement fixed caps with an object flag instead of a custom getcaps function.
GST_DEBUG_REGISTER_FUNCPTR (gst_pad_iterate_internal_links_default);
GST_DEBUG_REGISTER_FUNCPTR (gst_pad_acceptcaps_default);
- /* from gstutils.c */
- GST_DEBUG_REGISTER_FUNCPTR (gst_pad_get_fixed_caps_func);
-
klass->have_data = default_have_data;
}
{
GstCaps *result = NULL;
GstPadTemplate *templ;
+ gboolean fixed_caps;
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps");
- if (GST_PAD_GETCAPSFUNC (pad)) {
+ fixed_caps = GST_PAD_IS_FIXED_CAPS (pad);
+
+ if (!fixed_caps && GST_PAD_GETCAPSFUNC (pad)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
"dispatching to pad getcaps function");
goto done;
}
}
+ if (fixed_caps && (result = get_pad_caps (pad))) {
+ GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
+ "using pad caps %p %" GST_PTR_FORMAT, result, result);
+ result = gst_caps_ref (result);
+ goto done;
+ }
if ((templ = GST_PAD_PAD_TEMPLATE (pad))) {
result = GST_PAD_TEMPLATE_CAPS (templ);
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
result = gst_caps_ref (result);
goto done;
}
- if ((result = get_pad_caps (pad))) {
+ if (!fixed_caps && (result = get_pad_caps (pad))) {
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
"using pad caps %p %" GST_PTR_FORMAT, result, result);
-
result = gst_caps_ref (result);
goto done;
}
* reconfiguration happened.
* Since: 0.10.34.
* @GST_PAD_NEED_EVENTS: the pad has pending events
+ * @GST_PAD_FIXED_CAPS: the pad is using fixed caps this means that once the
+ * caps are set on the pad, the getcaps function only
+ * returns those caps.
* @GST_PAD_FLAG_LAST: offset to define more flags
*
* Pad state flags
GST_PAD_BLOCKING = (GST_OBJECT_FLAG_LAST << 4),
GST_PAD_NEED_RECONFIGURE = (GST_OBJECT_FLAG_LAST << 5),
GST_PAD_NEED_EVENTS = (GST_OBJECT_FLAG_LAST << 6),
+ GST_PAD_FIXED_CAPS = (GST_OBJECT_FLAG_LAST << 7),
/* padding */
GST_PAD_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 16)
} GstPadFlags;
#define GST_PAD_DO_BUFFER_SIGNALS(pad) (GST_PAD_CAST(pad)->do_buffer_signals)
#define GST_PAD_DO_EVENT_SIGNALS(pad) (GST_PAD_CAST(pad)->do_event_signals)
+#define GST_PAD_IS_SRC(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
+#define GST_PAD_IS_SINK(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
+
#define GST_PAD_IS_LINKED(pad) (GST_PAD_PEER(pad) != NULL)
+
#define GST_PAD_IS_BLOCKED(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED))
#define GST_PAD_IS_BLOCKING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING))
#define GST_PAD_IS_FLUSHING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING))
#define GST_PAD_IS_IN_SETCAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS))
#define GST_PAD_NEEDS_RECONFIGURE(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_NEED_RECONFIGURE))
#define GST_PAD_NEEDS_EVENTS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_NEED_EVENTS))
-#define GST_PAD_IS_SRC(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
-#define GST_PAD_IS_SINK(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
+#define GST_PAD_IS_FIXED_CAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FIXED_CAPS))
#define GST_PAD_SET_FLUSHING(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLUSHING))
#define GST_PAD_UNSET_FLUSHING(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLUSHING))
* gst_pad_use_fixed_caps:
* @pad: the pad to use
*
- * A helper function you can use that sets the
- * @gst_pad_get_fixed_caps_func as the getcaps function for the
- * pad. This way the function will always return the negotiated caps
+ * A helper function you can use that sets the FIXED_CAPS flag
+ * This way the default getcaps function will always return the negotiated caps
* or in case the pad is not negotiated, the padtemplate caps.
*
* Use this function on a pad that, once gst_pad_set_caps() has been called
void
gst_pad_use_fixed_caps (GstPad * pad)
{
- gst_pad_set_getcaps_function (pad, gst_pad_get_fixed_caps_func);
-}
-
-/**
- * gst_pad_get_fixed_caps_func:
- * @pad: the pad to use
- *
- * A helper function you can use as a GetCaps function that
- * will return the currently negotiated caps or the padtemplate
- * when NULL.
- *
- * Free-function: gst_caps_unref
- *
- * Returns: (transfer full): the currently negotiated caps or the padtemplate.
- */
-GstCaps *
-gst_pad_get_fixed_caps_func (GstPad * pad)
-{
- GstCaps *result;
-
- g_return_val_if_fail (GST_IS_PAD (pad), NULL);
-
- GST_OBJECT_LOCK (pad);
- if (GST_PAD_CAPS (pad)) {
- result = GST_PAD_CAPS (pad);
-
- GST_CAT_DEBUG (GST_CAT_CAPS,
- "using pad caps %p %" GST_PTR_FORMAT, result, result);
-
- result = gst_caps_ref (result);
- } else if (GST_PAD_PAD_TEMPLATE (pad)) {
- GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
-
- result = GST_PAD_TEMPLATE_CAPS (templ);
- GST_CAT_DEBUG (GST_CAT_CAPS,
- "using pad template %p with caps %p %" GST_PTR_FORMAT, templ, result,
- result);
-
- result = gst_caps_ref (result);
- } else {
- GST_CAT_DEBUG (GST_CAT_CAPS, "pad has no caps");
- result = gst_caps_new_empty ();
- }
- GST_OBJECT_UNLOCK (pad);
-
- return result;
+ GST_OBJECT_FLAG_SET (pad, GST_PAD_FIXED_CAPS);
}
/**
/* pad functions */
void gst_pad_use_fixed_caps (GstPad *pad);
-GstCaps* gst_pad_get_fixed_caps_func (GstPad *pad);
GstCaps* gst_pad_proxy_getcaps (GstPad * pad);
gboolean gst_pad_proxy_setcaps (GstPad * pad, GstCaps * caps);