Replace the acceptcaps function with a query.
gst_proxy_pad_query_default (GstPad * pad, GstQuery * query)
{
gboolean res;
+ GstPad *target;
g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
g_return_val_if_fail (GST_IS_QUERY (query), FALSE);
+ target = gst_proxy_pad_get_target (pad);
+
switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_ACCEPT_CAPS:
+ {
+ if (target) {
+ res = gst_pad_query (target, query);
+ gst_object_unref (target);
+ } else {
+ GST_DEBUG_OBJECT (pad, "no target");
+ /* We don't have a target, we return TRUE and we assume that any future
+ * target will be able to deal with any configured caps. */
+ res = TRUE;
+ }
+ break;
+ }
default:
{
- GstPad *target;
-
- if (!(target = gst_proxy_pad_get_target (pad)))
- goto no_target;
-
- res = gst_pad_query (target, query);
- gst_object_unref (target);
+ if (target) {
+ res = gst_pad_query (target, query);
+ gst_object_unref (target);
+ } else {
+ GST_DEBUG_OBJECT (pad, "no target pad");
+ res = FALSE;
+ }
break;
}
}
-
return res;
-
- /* ERRORS */
-no_target:
- {
- GST_DEBUG_OBJECT (pad, "no target pad");
- return FALSE;
- }
}
/**
gst_proxy_pad_iterate_internal_links_default);
gst_pad_set_getcaps_function (pad, gst_proxy_pad_getcaps_default);
- gst_pad_set_acceptcaps_function (pad, gst_proxy_pad_acceptcaps_default);
gst_pad_set_fixatecaps_function (pad, gst_proxy_pad_fixatecaps_default);
gst_pad_set_unlink_function (pad, gst_proxy_pad_unlink_default);
}
static GstCaps *gst_pad_get_caps_unlocked (GstPad * pad, GstCaps * filter);
static void gst_pad_set_pad_template (GstPad * pad, GstPadTemplate * templ);
static gboolean gst_pad_activate_default (GstPad * pad);
-static gboolean gst_pad_acceptcaps_default (GstPad * pad, GstCaps * caps);
static void gst_pad_fixate_caps_default (GstPad * pad, GstCaps * caps);
static GstFlowReturn gst_pad_chain_list_default (GstPad * pad,
GstBufferList * list);
GST_DEBUG_REGISTER_FUNCPTR (gst_pad_event_default);
GST_DEBUG_REGISTER_FUNCPTR (gst_pad_query_default);
GST_DEBUG_REGISTER_FUNCPTR (gst_pad_iterate_internal_links_default);
- GST_DEBUG_REGISTER_FUNCPTR (gst_pad_acceptcaps_default);
GST_DEBUG_REGISTER_FUNCPTR (gst_pad_chain_list_default);
GST_DEBUG_REGISTER_FUNCPTR (gst_pad_fixate_caps_default);
}
GST_PAD_EVENTFUNC (pad) = gst_pad_event_default;
GST_PAD_QUERYFUNC (pad) = gst_pad_query_default;
GST_PAD_ITERINTLINKFUNC (pad) = gst_pad_iterate_internal_links_default;
- GST_PAD_ACCEPTCAPSFUNC (pad) = gst_pad_acceptcaps_default;
GST_PAD_FIXATECAPSFUNC (pad) = gst_pad_fixate_caps_default;
GST_PAD_CHAINLISTFUNC (pad) = gst_pad_chain_list_default;
}
/**
- * gst_pad_set_acceptcaps_function:
- * @pad: a #GstPad.
- * @acceptcaps: the #GstPadAcceptCapsFunction to set.
- *
- * Sets the given acceptcaps function for the pad. The acceptcaps function
- * will be called to check if the pad can accept the given caps. Setting the
- * acceptcaps function to NULL restores the default behaviour of allowing
- * any caps that matches the caps from gst_pad_get_caps().
- */
-void
-gst_pad_set_acceptcaps_function (GstPad * pad,
- GstPadAcceptCapsFunction acceptcaps)
-{
- g_return_if_fail (GST_IS_PAD (pad));
-
- GST_PAD_ACCEPTCAPSFUNC (pad) = acceptcaps;
- GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "acceptcapsfunc set to %s",
- GST_DEBUG_FUNCPTR_NAME (acceptcaps));
-}
-
-/**
* gst_pad_set_fixatecaps_function:
* @pad: a #GstPad.
* @fixatecaps: the #GstPadFixateCapsFunction to set.
fixatefunc (pad, caps);
}
-/* Default accept caps implementation just checks against
- * against the allowed caps for the pad */
-static gboolean
-gst_pad_acceptcaps_default (GstPad * pad, GstCaps * caps)
-{
- /* get the caps and see if it intersects to something not empty */
- GstCaps *allowed;
- gboolean result = FALSE;
-
- GST_DEBUG_OBJECT (pad, "caps %" GST_PTR_FORMAT, caps);
-
- allowed = gst_pad_get_caps (pad, NULL);
- if (!allowed)
- goto nothing_allowed;
-
- GST_DEBUG_OBJECT (pad, "allowed caps %" GST_PTR_FORMAT, allowed);
-
- result = gst_caps_is_subset (caps, allowed);
-
- gst_caps_unref (allowed);
-
- return result;
-
- /* ERRORS */
-nothing_allowed:
- {
- GST_DEBUG_OBJECT (pad, "no caps allowed on the pad");
- return FALSE;
- }
-}
-
/**
* gst_pad_accept_caps:
* @pad: a #GstPad to check
gboolean
gst_pad_accept_caps (GstPad * pad, GstCaps * caps)
{
- gboolean result;
- GstPadAcceptCapsFunction acceptfunc;
-#if 0
- GstCaps *existing = NULL;
-#endif
+ gboolean res;
+ GstQuery *query;
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
+ g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
- /* any pad can be unnegotiated */
- if (caps == NULL)
- return TRUE;
-
- /* lock for checking the existing caps */
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "accept caps of %p", caps);
-#if 0
- GST_OBJECT_LOCK (pad);
- /* The current caps on a pad are trivially acceptable */
- if (G_LIKELY ((existing = GST_PAD_CAPS (pad)))) {
- if (caps == existing || gst_caps_is_equal (caps, existing))
- goto is_same_caps;
- }
- GST_OBJECT_UNLOCK (pad);
-#endif
- acceptfunc = GST_PAD_ACCEPTCAPSFUNC (pad);
- /* Only null if the element explicitly unset it */
- if (G_UNLIKELY (acceptfunc == NULL))
- goto no_func;
-
- /* we can call the function */
- result = acceptfunc (pad, caps);
- GST_DEBUG_OBJECT (pad, "acceptfunc returned %d", result);
-
- return result;
-
-#if 0
-is_same_caps:
- {
- GST_DEBUG_OBJECT (pad, "pad had same caps");
- GST_OBJECT_UNLOCK (pad);
- return TRUE;
- }
-#endif
-no_func:
- {
- GST_DEBUG_OBJECT (pad, "no acceptcaps function");
- return FALSE;
+ query = gst_query_new_accept_caps (caps);
+ res = gst_pad_query (pad, query);
+ if (res) {
+ GST_DEBUG_OBJECT (pad, "query returned %d", res);
+ gst_query_parse_accept_caps_result (query, &res);
}
+ gst_query_unref (query);
+
+ return res;
}
/**
* @caps: a #GstCaps to check on the pad
*
* Check if the peer of @pad accepts @caps. If @pad has no peer, this function
- * returns TRUE.
+ * returns FALSE.
*
* Returns: TRUE if the peer of @pad can accept the caps or @pad has no peer.
*/
gboolean
gst_pad_peer_accept_caps (GstPad * pad, GstCaps * caps)
{
- GstPad *peerpad;
gboolean result;
+ GstQuery *query;
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
+ g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
- GST_OBJECT_LOCK (pad);
-
- GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "peer accept caps of (%p)", pad);
-
- peerpad = GST_PAD_PEER (pad);
- if (G_UNLIKELY (peerpad == NULL))
- goto no_peer;
-
- gst_object_ref (peerpad);
- /* release lock before calling external methods but keep ref to pad */
- GST_OBJECT_UNLOCK (pad);
-
- result = gst_pad_accept_caps (peerpad, caps);
-
- gst_object_unref (peerpad);
+ query = gst_query_new_accept_caps (caps);
+ result = gst_pad_peer_query (pad, query);
+ gst_query_unref (query);
return result;
-
-no_peer:
- {
- GST_OBJECT_UNLOCK (pad);
- return TRUE;
- }
}
/**
return result;
}
+/* Default accept caps implementation just checks against
+ * the allowed caps for the pad */
+static gboolean
+gst_pad_query_accept_caps (GstPad * pad, GstQuery * query)
+{
+ /* get the caps and see if it intersects to something not empty */
+ GstCaps *caps, *allowed;
+ gboolean result;
+
+ gst_query_parse_accept_caps (query, &caps);
+
+ GST_DEBUG_OBJECT (pad, "caps %" GST_PTR_FORMAT, caps);
+
+ allowed = gst_pad_get_caps (pad, NULL);
+ if (allowed) {
+ GST_DEBUG_OBJECT (pad, "allowed caps %" GST_PTR_FORMAT, allowed);
+ result = gst_caps_is_subset (caps, allowed);
+ gst_caps_unref (allowed);
+ } else {
+ GST_DEBUG_OBJECT (pad, "no caps allowed on the pad");
+ result = FALSE;
+ }
+ gst_query_set_accept_caps_result (query, result);
+
+ return TRUE;
+}
+
/**
* gst_pad_query_default:
* @pad: a #GstPad to call the default query handler on.
case GST_QUERY_SCHEDULING:
forward = FALSE;
break;
+ case GST_QUERY_ACCEPT_CAPS:
+ ret = gst_pad_query_accept_caps (pad, query);
+ forward = FALSE;
+ break;
case GST_QUERY_POSITION:
case GST_QUERY_SEEKING:
case GST_QUERY_FORMATS:
typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad, GstCaps *filter);
/**
- * GstPadAcceptCapsFunction:
- * @pad: the #GstPad to check
- * @caps: the #GstCaps to check
- *
- * Check if @pad can accept @caps. By default this function will see if @caps
- * intersect with the result from gst_pad_get_caps() by can be overridden to
- * perform extra checks.
- *
- * Returns: TRUE if the caps can be accepted by the pad.
- */
-typedef gboolean (*GstPadAcceptCapsFunction) (GstPad *pad, GstCaps *caps);
-/**
* GstPadFixateCapsFunction:
* @pad: a #GstPad
* @caps: the #GstCaps to fixate
* @block_cond: conditional to signal pad block
* @probes: installed probes
* @getcapsfunc: function to get caps of the pad
- * @acceptcapsfunc: function to check if pad can accept caps
* @fixatecapsfunc: function to fixate caps
* @mode: current activation mode of the pad
* @activatefunc: pad activation function
/* the pad capabilities */
GstPadGetCapsFunction getcapsfunc;
- GstPadAcceptCapsFunction acceptcapsfunc;
GstPadFixateCapsFunction fixatecapsfunc;
GstPadActivateMode mode;
#define GST_PAD_UNLINKFUNC(pad) (GST_PAD_CAST(pad)->unlinkfunc)
#define GST_PAD_GETCAPSFUNC(pad) (GST_PAD_CAST(pad)->getcapsfunc)
-#define GST_PAD_ACCEPTCAPSFUNC(pad) (GST_PAD_CAST(pad)->acceptcapsfunc)
#define GST_PAD_FIXATECAPSFUNC(pad) (GST_PAD_CAST(pad)->fixatecapsfunc)
#define GST_PAD_IS_SRC(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
/* capsnego functions */
void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps);
-void gst_pad_set_acceptcaps_function (GstPad *pad, GstPadAcceptCapsFunction acceptcaps);
void gst_pad_set_fixatecaps_function (GstPad *pad, GstPadFixateCapsFunction fixatecaps);
GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
"min-buffers", "max-buffers", "prefix", "postfix", "align", "time",
"GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps",
"GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode",
- "random-access", "sequential", "allocator", "GstEventFlushStop", "options"
+ "random-access", "sequential", "allocator", "GstEventFlushStop", "options",
+ "GstQueryAcceptCaps", "result"
};
GQuark _priv_gst_quark_table[GST_QUARK_MAX];
GST_QUARK_ALLOCATOR = 126,
GST_QUARK_EVENT_FLUSH_STOP = 127,
GST_QUARK_OPTIONS = 128,
+ GST_QUARK_QUERY_ACCEPT_CAPS = 129,
+ GST_QUARK_RESULT = 130,
- GST_QUARK_MAX = 129
+ GST_QUARK_MAX = 131
} GstQuarkId;
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
{GST_QUERY_URI, "uri", "URI of the source or sink", 0},
{GST_QUERY_ALLOCATION, "allocation", "Allocation properties", 0},
{GST_QUERY_SCHEDULING, "scheduling", "Scheduling properties", 0},
+ {GST_QUERY_ACCEPT_CAPS, "accept-caps", "Accept caps", 0},
{GST_QUERY_NONE, NULL, NULL, 0}
};
GST_QUARK (MAXSIZE), G_TYPE_INT, maxsize,
GST_QUARK (ALIGN), G_TYPE_INT, align, NULL);
}
+
+/**
+ * gst_query_new_accept_caps
+ * @caps: a #GstCaps
+ *
+ * Constructs a new query object for querying if @caps are accepted.
+ *
+ * Free-function: gst_query_unref
+ *
+ * Returns: (transfer full): a new #GstQuery
+ */
+GstQuery *
+gst_query_new_accept_caps (GstCaps * caps)
+{
+ GstQuery *query;
+ GstStructure *structure;
+
+ structure = gst_structure_new_id (GST_QUARK (QUERY_ACCEPT_CAPS),
+ GST_QUARK (CAPS), GST_TYPE_CAPS, caps,
+ GST_QUARK (RESULT), G_TYPE_BOOLEAN, FALSE, NULL);
+ query = gst_query_new (GST_QUERY_ACCEPT_CAPS, structure);
+
+ return query;
+}
+
+void
+gst_query_parse_accept_caps (GstQuery * query, GstCaps ** caps)
+{
+ GstStructure *structure;
+
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
+
+ structure = GST_QUERY_STRUCTURE (query);
+ gst_structure_id_get (structure, GST_QUARK (CAPS), GST_TYPE_CAPS, caps, NULL);
+}
+
+void
+gst_query_set_accept_caps_result (GstQuery * query, gboolean result)
+{
+ GstStructure *structure;
+
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
+ g_return_if_fail (gst_query_is_writable (query));
+
+ structure = GST_QUERY_STRUCTURE (query);
+ gst_structure_id_set (structure,
+ GST_QUARK (RESULT), G_TYPE_BOOLEAN, result, NULL);
+}
+
+void
+gst_query_parse_accept_caps_result (GstQuery * query, gboolean * result)
+{
+ GstStructure *structure;
+
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
+
+ structure = GST_QUERY_STRUCTURE (query);
+ gst_structure_id_get (structure,
+ GST_QUARK (RESULT), G_TYPE_BOOLEAN, result, NULL);
+}
* @GST_QUERY_URI: query the URI of the source or sink. Since 0.10.22.
* @GST_QUERY_ALLOCATION: the buffer allocation properties
* @GST_QUERY_SCHEDULING: the scheduling properties
+ * @GST_QUERY_ACCEPT_CAPS: the accept caps query
*
* Standard predefined Query types
*/
GST_QUERY_CUSTOM,
GST_QUERY_URI,
GST_QUERY_ALLOCATION,
- GST_QUERY_SCHEDULING
+ GST_QUERY_SCHEDULING,
+ GST_QUERY_ACCEPT_CAPS,
+ GST_QUERY_LAST
} GstQueryType;
/**
void gst_query_parse_scheduling (GstQuery *query, gboolean *pull_mode,
gboolean *random_access, gboolean *sequential,
gint *minsize, gint *maxsize, gint *align);
+/* accept-caps query */
+GstQuery * gst_query_new_accept_caps (GstCaps *caps);
+void gst_query_parse_accept_caps (GstQuery *query, GstCaps **caps);
+void gst_query_set_accept_caps_result (GstQuery *query, gboolean result);
+void gst_query_parse_accept_caps_result (GstQuery *query, gboolean *result);
G_END_DECLS
static GstFlowReturn gst_base_transform_chain (GstPad * pad,
GstBuffer * buffer);
static GstCaps *gst_base_transform_getcaps (GstPad * pad, GstCaps * filter);
-static gboolean gst_base_transform_acceptcaps (GstPad * pad, GstCaps * caps);
static gboolean gst_base_transform_acceptcaps_default (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps);
static gboolean gst_base_transform_setcaps (GstBaseTransform * trans,
trans->sinkpad = gst_pad_new_from_template (pad_template, "sink");
gst_pad_set_getcaps_function (trans->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_transform_getcaps));
- gst_pad_set_acceptcaps_function (trans->sinkpad,
- GST_DEBUG_FUNCPTR (gst_base_transform_acceptcaps));
gst_pad_set_event_function (trans->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_transform_sink_event));
gst_pad_set_chain_function (trans->sinkpad,
trans->srcpad = gst_pad_new_from_template (pad_template, "src");
gst_pad_set_getcaps_function (trans->srcpad,
GST_DEBUG_FUNCPTR (gst_base_transform_getcaps));
- gst_pad_set_acceptcaps_function (trans->srcpad,
- GST_DEBUG_FUNCPTR (gst_base_transform_acceptcaps));
gst_pad_set_event_function (trans->srcpad,
GST_DEBUG_FUNCPTR (gst_base_transform_src_event));
gst_pad_set_getrange_function (trans->srcpad,
}
}
-static gboolean
-gst_base_transform_acceptcaps (GstPad * pad, GstCaps * caps)
-{
- gboolean ret = TRUE;
- GstBaseTransform *trans;
- GstBaseTransformClass *bclass;
-
- trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
- bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
-
- if (bclass->accept_caps)
- ret = bclass->accept_caps (trans, GST_PAD_DIRECTION (pad), caps);
-
- gst_object_unref (trans);
-
- return ret;
-}
-
/* called when new caps arrive on the sink or source pad,
* We try to find the best caps for the other side using our _find_transform()
* function. If there are caps, we configure the transform for this new
{
gboolean ret = FALSE;
GstPad *otherpad;
+ GstBaseTransformClass *klass;
otherpad = (direction == GST_PAD_SRC) ? trans->sinkpad : trans->srcpad;
+ klass = GST_BASE_TRANSFORM_GET_CLASS (trans);
+
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_ALLOCATION:
{
GST_DEBUG_OBJECT (trans, "doing passthrough query");
ret = gst_pad_peer_query (otherpad, query);
} else {
- GstBaseTransformClass *klass;
-
GST_DEBUG_OBJECT (trans, "propose allocation values");
-
- klass = GST_BASE_TRANSFORM_GET_CLASS (trans);
/* pass the query to the propose_allocation vmethod if any */
if (G_LIKELY (klass->propose_allocation))
ret = klass->propose_allocation (trans, query);
}
break;
}
+ case GST_QUERY_ACCEPT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_query_parse_accept_caps (query, &caps);
+ if (klass->accept_caps) {
+ ret = klass->accept_caps (trans, direction, caps);
+ gst_query_set_accept_caps_result (query, ret);
+ /* return TRUE, we answered the query */
+ ret = TRUE;
+ }
+ break;
+ }
default:
ret = gst_pad_peer_query (otherpad, query);
break;
static void gst_selector_pad_reset (GstSelectorPad * pad);
static gboolean gst_selector_pad_event (GstPad * pad, GstEvent * event);
static GstCaps *gst_selector_pad_getcaps (GstPad * pad, GstCaps * filter);
-static gboolean gst_selector_pad_acceptcaps (GstPad * pad, GstCaps * caps);
static gboolean gst_selector_pad_query (GstPad * pad, GstQuery * query);
static GstIterator *gst_selector_pad_iterate_linked_pads (GstPad * pad);
static GstFlowReturn gst_selector_pad_chain (GstPad * pad, GstBuffer * buf);
otherpad = gst_input_selector_get_linked_pad (sel, pad, TRUE);
switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_ACCEPT_CAPS:
default:
if (otherpad)
res = gst_pad_peer_query (otherpad, query);
return caps;
}
-static gboolean
-gst_selector_pad_acceptcaps (GstPad * pad, GstCaps * caps)
-{
- GstInputSelector *sel;
- gboolean res;
-
- sel = GST_INPUT_SELECTOR (gst_pad_get_parent (pad));
- if (G_UNLIKELY (sel == NULL))
- return FALSE;
-
- GST_DEBUG_OBJECT (sel, "Checking acceptcaps of srcpad peer");
- res = gst_pad_peer_accept_caps (sel->srcpad, caps);
- gst_object_unref (sel);
-
- return res;
-}
-
/* must be called with the SELECTOR_LOCK, will block while the pad is blocked
* or return TRUE when flushing */
static gboolean
GST_DEBUG_FUNCPTR (gst_selector_pad_event));
gst_pad_set_getcaps_function (sinkpad,
GST_DEBUG_FUNCPTR (gst_selector_pad_getcaps));
- gst_pad_set_acceptcaps_function (sinkpad,
- GST_DEBUG_FUNCPTR (gst_selector_pad_acceptcaps));
gst_pad_set_query_function (sinkpad,
GST_DEBUG_FUNCPTR (gst_selector_pad_query));
gst_pad_set_chain_function (sinkpad,
if (GST_IS_BUFFER (object)) {
GstBuffer *buffer;
GstClockTime timestamp, duration;
-#if 0
- GstCaps *caps;
-#endif
buffer = GST_BUFFER_CAST (object);
timestamp = GST_BUFFER_TIMESTAMP (buffer);
duration = GST_BUFFER_DURATION (buffer);
-#if 0
- caps = GST_BUFFER_CAPS (buffer);
-#endif
apply_buffer (mq, sq, timestamp, duration, &sq->src_segment);
"SingleQueue %d : Pushing buffer %p with ts %" GST_TIME_FORMAT,
sq->id, buffer, GST_TIME_ARGS (timestamp));
-#if 0
- /* Set caps on pad before pushing, this avoids core calling the acceptcaps
- * function on the srcpad, which will call acceptcaps upstream, which might
- * not accept these caps (anymore). */
- if (caps && caps != GST_PAD_CAPS (sq->srcpad))
- gst_pad_set_caps (sq->srcpad, caps);
-#endif
-
result = gst_pad_push (sq->srcpad, buffer);
} else if (GST_IS_EVENT (object)) {
GstEvent *event;
gboolean res;
switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_ACCEPT_CAPS:
default:
/* default handling */
res = gst_pad_peer_query (sq->srcpad, query);
}
static gboolean
-gst_multi_queue_acceptcaps (GstPad * pad, GstCaps * caps)
-{
- GstSingleQueue *sq = gst_pad_get_element_private (pad);
- GstPad *otherpad;
- gboolean result;
-
- otherpad = (pad == sq->srcpad) ? sq->sinkpad : sq->srcpad;
-
- GST_LOG_OBJECT (otherpad, "Accept caps from the peer of this pad");
-
- result = gst_pad_peer_accept_caps (otherpad, caps);
-
- return result;
-}
-
-static gboolean
gst_multi_queue_src_activate_push (GstPad * pad, gboolean active)
{
GstMultiQueue *mq;
/* FIXME, Handle position offset depending on queue size */
switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_ACCEPT_CAPS:
default:
/* default handling */
res = gst_pad_peer_query (sq->sinkpad, query);
GST_DEBUG_FUNCPTR (gst_multi_queue_sink_event));
gst_pad_set_getcaps_function (sq->sinkpad,
GST_DEBUG_FUNCPTR (gst_multi_queue_getcaps));
- gst_pad_set_acceptcaps_function (sq->sinkpad,
- GST_DEBUG_FUNCPTR (gst_multi_queue_acceptcaps));
gst_pad_set_query_function (sq->sinkpad,
GST_DEBUG_FUNCPTR (gst_multi_queue_sink_query));
gst_pad_set_iterate_internal_links_function (sq->sinkpad,
GST_DEBUG_FUNCPTR (gst_multi_queue_src_activate_push));
gst_pad_set_getcaps_function (sq->srcpad,
GST_DEBUG_FUNCPTR (gst_multi_queue_getcaps));
- gst_pad_set_acceptcaps_function (sq->srcpad,
- GST_DEBUG_FUNCPTR (gst_multi_queue_acceptcaps));
gst_pad_set_event_function (sq->srcpad,
GST_DEBUG_FUNCPTR (gst_multi_queue_src_event));
gst_pad_set_query_function (sq->srcpad,
static void gst_queue_loop (GstPad * pad);
static gboolean gst_queue_handle_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_queue_handle_sink_query (GstPad * pad, GstQuery * query);
static gboolean gst_queue_handle_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_queue_handle_src_query (GstPad * pad, GstQuery * query);
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_chain);
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_sink_activate_push);
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_handle_sink_event);
+ GST_DEBUG_REGISTER_FUNCPTR (gst_queue_handle_sink_query);
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_link_sink);
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_getcaps);
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_acceptcaps);
gst_pad_set_activatepush_function (queue->sinkpad,
gst_queue_sink_activate_push);
gst_pad_set_event_function (queue->sinkpad, gst_queue_handle_sink_event);
+ gst_pad_set_query_function (queue->sinkpad, gst_queue_handle_sink_query);
gst_pad_set_link_function (queue->sinkpad, gst_queue_link_sink);
gst_pad_set_getcaps_function (queue->sinkpad, gst_queue_getcaps);
- gst_pad_set_acceptcaps_function (queue->sinkpad, gst_queue_acceptcaps);
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
queue->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
gst_pad_set_activatepush_function (queue->srcpad,
gst_queue_src_activate_push);
gst_pad_set_link_function (queue->srcpad, gst_queue_link_src);
- gst_pad_set_acceptcaps_function (queue->srcpad, gst_queue_acceptcaps);
gst_pad_set_getcaps_function (queue->srcpad, gst_queue_getcaps);
gst_pad_set_event_function (queue->srcpad, gst_queue_handle_src_event);
gst_pad_set_query_function (queue->srcpad, gst_queue_handle_src_query);
}
static gboolean
+gst_queue_handle_sink_query (GstPad * pad, GstQuery * query)
+{
+ GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad));
+ gboolean res;
+
+ if (G_UNLIKELY (queue == NULL))
+ return FALSE;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_ACCEPT_CAPS:
+ default:
+ res = gst_pad_peer_query (queue->srcpad, query);
+ break;
+ }
+ gst_object_unref (queue);
+
+ return res;
+}
+
+static gboolean
gst_queue_is_empty (GstQueue * queue)
{
if (queue->queue.length == 0)
gst_queue_handle_src_query (GstPad * pad, GstQuery * query)
{
GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad));
- GstPad *peer;
gboolean res;
if (G_UNLIKELY (queue == NULL))
return FALSE;
- if (!(peer = gst_pad_get_peer (queue->sinkpad))) {
- gst_object_unref (queue);
- return FALSE;
- }
-
- res = gst_pad_query (peer, query);
- gst_object_unref (peer);
+ res = gst_pad_peer_query (queue->sinkpad, query);
if (!res) {
gst_object_unref (queue);
return FALSE;
static void gst_queue2_loop (GstPad * pad);
static gboolean gst_queue2_handle_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_queue2_handle_sink_query (GstPad * pad, GstQuery * query);
static gboolean gst_queue2_handle_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_queue2_handle_src_query (GstPad * pad, GstQuery * query);
GstQuery * query);
static GstCaps *gst_queue2_getcaps (GstPad * pad, GstCaps * filter);
-static gboolean gst_queue2_acceptcaps (GstPad * pad, GstCaps * caps);
static GstFlowReturn gst_queue2_get_range (GstPad * pad, guint64 offset,
guint length, GstBuffer ** buffer);
GST_DEBUG_FUNCPTR (gst_queue2_sink_activate_push));
gst_pad_set_event_function (queue->sinkpad,
GST_DEBUG_FUNCPTR (gst_queue2_handle_sink_event));
+ gst_pad_set_query_function (queue->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_queue2_handle_sink_query));
gst_pad_set_getcaps_function (queue->sinkpad,
GST_DEBUG_FUNCPTR (gst_queue2_getcaps));
- gst_pad_set_acceptcaps_function (queue->sinkpad,
- GST_DEBUG_FUNCPTR (gst_queue2_acceptcaps));
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
queue->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
GST_DEBUG_FUNCPTR (gst_queue2_get_range));
gst_pad_set_getcaps_function (queue->srcpad,
GST_DEBUG_FUNCPTR (gst_queue2_getcaps));
- gst_pad_set_acceptcaps_function (queue->srcpad,
- GST_DEBUG_FUNCPTR (gst_queue2_acceptcaps));
gst_pad_set_event_function (queue->srcpad,
GST_DEBUG_FUNCPTR (gst_queue2_handle_src_event));
gst_pad_set_query_function (queue->srcpad,
queue->current = add_range (queue, 0);
}
-static gboolean
-gst_queue2_acceptcaps (GstPad * pad, GstCaps * caps)
-{
- GstQueue2 *queue;
- GstPad *otherpad;
- gboolean result;
-
- queue = GST_QUEUE2 (GST_PAD_PARENT (pad));
-
- otherpad = (pad == queue->srcpad ? queue->sinkpad : queue->srcpad);
- result = gst_pad_peer_accept_caps (otherpad, caps);
-
- return result;
-}
-
static GstCaps *
gst_queue2_getcaps (GstPad * pad, GstCaps * filter)
{
}
static gboolean
+gst_queue2_handle_sink_query (GstPad * pad, GstQuery * query)
+{
+ gboolean res;
+ GstQueue2 *queue;
+
+ queue = GST_QUEUE2 (gst_pad_get_parent (pad));
+ if (G_UNLIKELY (queue == NULL))
+ return FALSE;
+
+ switch (GST_QUERY_TYPE (query)) {
+ default:
+ res = gst_pad_peer_query (queue->srcpad, query);
+ break;
+ }
+ gst_object_unref (queue);
+
+ return res;
+}
+
+static gboolean
gst_queue2_is_empty (GstQueue2 * queue)
{
/* never empty on EOS */
}
static gboolean
-gst_queue2_peer_query (GstQueue2 * queue, GstPad * pad, GstQuery * query)
-{
- gboolean ret = FALSE;
- GstPad *peer;
-
- if ((peer = gst_pad_get_peer (pad))) {
- ret = gst_pad_query (peer, query);
- gst_object_unref (peer);
- }
- return ret;
-}
-
-static gboolean
gst_queue2_handle_src_query (GstPad * pad, GstQuery * query)
{
GstQueue2 *queue;
gint64 peer_pos;
GstFormat format;
- if (!gst_queue2_peer_query (queue, queue->sinkpad, query))
+ if (!gst_pad_peer_query (queue->sinkpad, query))
goto peer_failed;
/* get peer position */
{
GST_DEBUG_OBJECT (queue, "doing peer query");
- if (!gst_queue2_peer_query (queue, queue->sinkpad, query))
+ if (!gst_pad_peer_query (queue->sinkpad, query))
goto peer_failed;
GST_DEBUG_OBJECT (queue, "peer query success");
/* FIXME - is this condition correct? what should ring buffer do? */
if (QUEUE_IS_USING_QUEUE (queue)) {
/* no temp file, just forward to the peer */
- if (!gst_queue2_peer_query (queue, queue->sinkpad, query))
+ if (!gst_pad_peer_query (queue->sinkpad, query))
goto peer_failed;
GST_DEBUG_OBJECT (queue, "buffering forwarded to peer");
} else {
}
default:
/* peer handled other queries */
- if (!gst_queue2_peer_query (queue, queue->sinkpad, query))
+ if (!gst_pad_peer_query (queue->sinkpad, query))
goto peer_failed;
break;
}
static GstFlowReturn gst_tee_chain (GstPad * pad, GstBuffer * buffer);
static GstFlowReturn gst_tee_chain_list (GstPad * pad, GstBufferList * list);
static gboolean gst_tee_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_tee_sink_query (GstPad * pad, GstQuery * query);
static gboolean gst_tee_sink_acceptcaps (GstPad * pad, GstCaps * caps);
static gboolean gst_tee_sink_activate_push (GstPad * pad, gboolean active);
static gboolean gst_tee_src_query (GstPad * pad, GstQuery * query);
gst_pad_set_event_function (tee->sinkpad,
GST_DEBUG_FUNCPTR (gst_tee_sink_event));
+ gst_pad_set_query_function (tee->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_tee_sink_query));
gst_pad_set_getcaps_function (tee->sinkpad,
GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
- gst_pad_set_acceptcaps_function (tee->sinkpad,
- GST_DEBUG_FUNCPTR (gst_tee_sink_acceptcaps));
gst_pad_set_activatepush_function (tee->sinkpad,
GST_DEBUG_FUNCPTR (gst_tee_sink_activate_push));
gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain));
return res;
}
+static gboolean
+gst_tee_sink_query (GstPad * pad, GstQuery * query)
+{
+ gboolean res;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_ACCEPT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_query_parse_accept_caps (query, &caps);
+ res = gst_tee_sink_acceptcaps (pad, caps);
+ gst_query_set_accept_caps_result (query, res);
+ res = TRUE;
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, query);
+ break;
+ }
+
+ return res;
+}
+
static void
gst_tee_do_message (GstTee * tee, GstPad * pad, gpointer data, gboolean is_list)
{
if (pad->getcapsfunc)
n_print (" Has getcapsfunc(): %s\n",
GST_DEBUG_FUNCPTR_NAME (pad->getcapsfunc));
- /* gst_pad_acceptcaps_default is static :/ */
- if (pad->acceptcapsfunc)
- n_print (" Has acceptcapsfunc(): %s\n",
- GST_DEBUG_FUNCPTR_NAME (pad->acceptcapsfunc));
if (pad->fixatecapsfunc)
n_print (" Has fixatecapsfunc(): %s\n",
GST_DEBUG_FUNCPTR_NAME (pad->fixatecapsfunc));