#define GST_PROXY_PAD_TARGET(pad) (GST_PAD_PEER (GST_PROXY_PAD_INTERNAL (pad)))
#define GST_PROXY_PAD_INTERNAL(pad) (GST_PROXY_PAD_PRIVATE (pad)->internal)
+#define GST_PROXY_PAD_ACQUIRE_INTERNAL(pad, internal, retval) \
+ internal = \
+ GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD_CAST (pad))); \
+ if (internal == NULL) \
+ return retval;
+
+#define GST_PROXY_PAD_RELEASE_INTERNAL(internal) gst_object_unref (internal);
+
struct _GstProxyPadPrivate
{
GstPad *internal;
static GstPad *gst_proxy_pad_get_target (GstPad * pad);
/**
- * gst_proxy_pad_event_default:
- * @pad: a #GstPad to push the event to.
- * @parent: the parent of @pad or NULL
- * @event: (transfer full): the #GstEvent to send to the pad.
- *
- * Invoke the default event of the proxy pad.
- *
- * Returns: TRUE if the event was handled.
- *
- * Since: 0.10.36
- */
-gboolean
-gst_proxy_pad_event_default (GstPad * pad, GstObject * parent, GstEvent * event)
-{
- gboolean res;
- GstPad *internal;
-
- g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
- g_return_val_if_fail (GST_IS_EVENT (event), FALSE);
-
- internal = GST_PROXY_PAD_INTERNAL (pad);
- res = gst_pad_push_event (internal, event);
-
- return res;
-}
-
-static gboolean
-gst_proxy_pad_query_caps (GstPad * pad, GstQuery * query)
-{
- gboolean res;
- GstPad *target;
- GstCaps *result;
- GstPadTemplate *templ;
-
- g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
-
- templ = GST_PAD_PAD_TEMPLATE (pad);
- target = gst_proxy_pad_get_target (pad);
- if (target) {
- /* if we have a real target, proxy the call */
- res = gst_pad_query (target, query);
-
- GST_DEBUG_OBJECT (pad, "get caps of target %s:%s : %" GST_PTR_FORMAT,
- GST_DEBUG_PAD_NAME (target), query);
-
- gst_object_unref (target);
-
- /* filter against the template */
- if (templ && res) {
- GstCaps *filt, *tmp;
-
- filt = GST_PAD_TEMPLATE_CAPS (templ);
- if (filt) {
- gst_query_parse_caps_result (query, &result);
- tmp = gst_caps_intersect_full (result, filt, GST_CAPS_INTERSECT_FIRST);
- gst_query_set_caps_result (query, tmp);
- GST_DEBUG_OBJECT (pad,
- "filtered against template gives %" GST_PTR_FORMAT, tmp);
- gst_caps_unref (tmp);
- }
- }
- } else {
- GstCaps *filter;
-
- res = TRUE;
-
- gst_query_parse_caps (query, &filter);
-
- /* else, if we have a template, use its caps. */
- if (templ) {
- result = GST_PAD_TEMPLATE_CAPS (templ);
- GST_DEBUG_OBJECT (pad,
- "using pad template %p with caps %p %" GST_PTR_FORMAT, templ, result,
- result);
-
- if (filter) {
- GstCaps *intersection;
-
- GST_DEBUG_OBJECT (pad, "intersect with filter");
- intersection =
- gst_caps_intersect_full (filter, result, GST_CAPS_INTERSECT_FIRST);
- gst_query_set_caps_result (query, intersection);
- gst_caps_unref (intersection);
- } else {
- gst_query_set_caps_result (query, result);
- }
- goto done;
- }
-
- /* If there's a filter, return that */
- if (filter != NULL) {
- GST_DEBUG_OBJECT (pad, "return filter");
- gst_query_set_caps_result (query, filter);
- goto done;
- }
-
- /* last resort, any caps */
- GST_DEBUG_OBJECT (pad, "pad has no template, returning ANY");
- result = gst_caps_new_any ();
- gst_query_set_caps_result (query, result);
- gst_caps_unref (result);
- }
-
-done:
- return res;
-}
-
-/**
- * gst_proxy_pad_query_default:
- * @pad: a #GstPad to invoke the default query on.
- * @parent: the parent of @pad or NULL
- * @query: (transfer none): the #GstQuery to perform.
- *
- * Invoke the default query function of the proxy pad.
- *
- * Returns: TRUE if the query could be performed.
- *
- * Since: 0.10.36
- */
-gboolean
-gst_proxy_pad_query_default (GstPad * pad, GstObject * parent, 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);
-
-
- switch (GST_QUERY_TYPE (query)) {
- case GST_QUERY_ACCEPT_CAPS:
- {
- target = gst_proxy_pad_get_target (pad);
- 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;
- }
- case GST_QUERY_CAPS:
- {
- res = gst_proxy_pad_query_caps (pad, query);
- break;
- }
- default:
- {
- target = gst_proxy_pad_get_target (pad);
- 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;
-}
-
-/**
- * gst_proyx_pad_iterate_internal_links_default:
+ * gst_proxy_pad_iterate_internal_links_default:
* @pad: the #GstPad to get the internal links of.
* @parent: the parent of @pad or NULL
*
*
* Returns: a #GstIterator of #GstPad, or NULL if @pad has no parent. Unref each
* returned pad with gst_object_unref().
- *
- * Since: 0.10.36
*/
GstIterator *
gst_proxy_pad_iterate_internal_links_default (GstPad * pad, GstObject * parent)
g_return_val_if_fail (GST_IS_PROXY_PAD (pad), NULL);
- internal = GST_PROXY_PAD_INTERNAL (pad);
+ GST_PROXY_PAD_ACQUIRE_INTERNAL (pad, internal, NULL);
+
g_value_init (&v, GST_TYPE_PAD);
- g_value_set_object (&v, internal);
+ g_value_take_object (&v, internal);
res = gst_iterator_new_single (GST_TYPE_PAD, &v);
g_value_unset (&v);
* Invoke the default chain function of the proxy pad.
*
* Returns: a #GstFlowReturn from the pad.
- *
- * Since: 0.10.36
*/
GstFlowReturn
gst_proxy_pad_chain_default (GstPad * pad, GstObject * parent,
g_return_val_if_fail (GST_IS_PROXY_PAD (pad), GST_FLOW_ERROR);
g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
- internal = GST_PROXY_PAD_INTERNAL (pad);
+ GST_PROXY_PAD_ACQUIRE_INTERNAL (pad, internal, GST_FLOW_NOT_LINKED);
res = gst_pad_push (internal, buffer);
+ GST_PROXY_PAD_RELEASE_INTERNAL (internal);
return res;
}
* Invoke the default chain list function of the proxy pad.
*
* Returns: a #GstFlowReturn from the pad.
- *
- * Since: 0.10.36
*/
GstFlowReturn
gst_proxy_pad_chain_list_default (GstPad * pad, GstObject * parent,
g_return_val_if_fail (GST_IS_PROXY_PAD (pad), GST_FLOW_ERROR);
g_return_val_if_fail (GST_IS_BUFFER_LIST (list), GST_FLOW_ERROR);
- internal = GST_PROXY_PAD_INTERNAL (pad);
+ GST_PROXY_PAD_ACQUIRE_INTERNAL (pad, internal, GST_FLOW_NOT_LINKED);
res = gst_pad_push_list (internal, list);
+ GST_PROXY_PAD_RELEASE_INTERNAL (internal);
return res;
}
/**
- * gst_proxy_pad_get_range_default:
+ * gst_proxy_pad_getrange_default:
* @pad: a src #GstPad, returns #GST_FLOW_ERROR if not.
+ * @parent: the parent of @pad
* @offset: The start offset of the buffer
* @size: The length of the buffer
* @buffer: (out callee-allocates): a pointer to hold the #GstBuffer,
* Invoke the default getrange function of the proxy pad.
*
* Returns: a #GstFlowReturn from the pad.
- *
- * Since: 0.10.36
*/
GstFlowReturn
gst_proxy_pad_getrange_default (GstPad * pad, GstObject * parent,
g_return_val_if_fail (GST_IS_PROXY_PAD (pad), GST_FLOW_ERROR);
g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR);
- internal = GST_PROXY_PAD_INTERNAL (pad);
+ GST_PROXY_PAD_ACQUIRE_INTERNAL (pad, internal, GST_FLOW_NOT_LINKED);
res = gst_pad_pull_range (internal, offset, size, buffer);
+ GST_PROXY_PAD_RELEASE_INTERNAL (internal);
return res;
}
*
* Returns: (transfer full): the target #GstProxyPad, can be NULL.
* Unref target pad after usage.
- *
- * Since: 0.10.36
*/
GstProxyPad *
gst_proxy_pad_get_internal (GstProxyPad * pad)
return GST_PROXY_PAD_CAST (internal);
}
-/**
- * gst_proxy_pad_unlink_default:
- * @pad: a #GstPad to unlink
- *
- * Invoke the default unlink function of the proxy pad.
- *
- * Since: 0.10.36
- */
-void
-gst_proxy_pad_unlink_default (GstPad * pad)
-{
- /* nothing to do anymore */
- GST_DEBUG_OBJECT (pad, "pad is unlinked");
-}
-
static void
gst_proxy_pad_class_init (GstProxyPadClass * klass)
{
g_type_class_add_private (klass, sizeof (GstProxyPadPrivate));
/* Register common function pointer descriptions */
- GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_event_default);
- GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_query_default);
GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_iterate_internal_links_default);
- GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_unlink_default);
GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_chain_default);
GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_chain_list_default);
GST_DEBUG_REGISTER_FUNCPTR (gst_proxy_pad_getrange_default);
GST_PROXY_PAD_PRIVATE (ppad) = G_TYPE_INSTANCE_GET_PRIVATE (ppad,
GST_TYPE_PROXY_PAD, GstProxyPadPrivate);
- gst_pad_set_event_function (pad, gst_proxy_pad_event_default);
- gst_pad_set_query_function (pad, gst_proxy_pad_query_default);
gst_pad_set_iterate_internal_links_function (pad,
gst_proxy_pad_iterate_internal_links_default);
- gst_pad_set_unlink_function (pad, gst_proxy_pad_unlink_default);
+ GST_PAD_SET_PROXY_CAPS (pad);
+ GST_PAD_SET_PROXY_SCHEDULING (pad);
+ GST_PAD_SET_PROXY_ALLOCATION (pad);
}
/* in both cases (SRC and SINK) we activate just the internal pad. The targets
* will be activated later (or already in case of a ghost sinkpad). */
- other = GST_PROXY_PAD_INTERNAL (pad);
+ GST_PROXY_PAD_ACQUIRE_INTERNAL (pad, other, FALSE);
ret = gst_pad_activate_mode (other, GST_PAD_MODE_PUSH, active);
+ GST_PROXY_PAD_RELEASE_INTERNAL (other);
return ret;
}
* which will trigger gst_ghost_pad_activate_pull_default, which propagates even
* further upstream */
GST_LOG_OBJECT (pad, "pad is src, activate internal");
- other = GST_PROXY_PAD_INTERNAL (pad);
+ GST_PROXY_PAD_ACQUIRE_INTERNAL (pad, other, FALSE);
ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
+ GST_PROXY_PAD_RELEASE_INTERNAL (other);
} else if (G_LIKELY ((other = gst_pad_get_peer (pad)))) {
/* We are SINK, the ghostpad is SRC, we propagate the activation upstream
* since we hold a pointer to the upstream peer. */
(active ? "" : "de"), GST_DEBUG_PAD_NAME (pad));
/* just activate the internal pad */
- other = GST_PROXY_PAD_INTERNAL (pad);
+ GST_PROXY_PAD_ACQUIRE_INTERNAL (pad, other, FALSE);
ret = gst_pad_activate_mode (other, GST_PAD_MODE_PUSH, active);
+ GST_PROXY_PAD_RELEASE_INTERNAL (other);
return ret;
}
* activation function of the internal pad to propagate the activation
* upstream */
GST_LOG_OBJECT (pad, "pad is src, activate internal");
- other = GST_PROXY_PAD_INTERNAL (pad);
+ GST_PROXY_PAD_ACQUIRE_INTERNAL (pad, other, FALSE);
ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
+ GST_PROXY_PAD_RELEASE_INTERNAL (other);
} else if (G_LIKELY ((other = gst_pad_get_peer (pad)))) {
/* We are SINK and activated by the internal pad, propagate activation
* upstream because we hold a ref to the upstream peer */
return res;
}
-/**
- * gst_ghost_pad_link_default:
- * @pad: the #GstPad to link.
- * @peer: the #GstPad peer
- *
- * Invoke the default link function of a ghost pad.
- *
- * Returns: #GstPadLinkReturn of the operation
- *
- * Since: 0.10.36
- */
-GstPadLinkReturn
-gst_ghost_pad_link_default (GstPad * pad, GstPad * peer)
-{
- GstPadLinkReturn ret;
-
- g_return_val_if_fail (GST_IS_GHOST_PAD (pad), GST_PAD_LINK_REFUSED);
- g_return_val_if_fail (GST_IS_PAD (peer), GST_PAD_LINK_REFUSED);
-
- GST_DEBUG_OBJECT (pad, "linking ghostpad");
-
- ret = GST_PAD_LINK_OK;
- /* if we are a source pad, we should call the peer link function
- * if the peer has one, see design docs. */
- if (GST_PAD_IS_SRC (pad)) {
- if (GST_PAD_LINKFUNC (peer)) {
- ret = GST_PAD_LINKFUNC (peer) (peer, pad);
- if (ret != GST_PAD_LINK_OK)
- GST_DEBUG_OBJECT (pad, "linking failed");
- }
- }
- return ret;
-}
-
-/**
- * gst_ghost_pad_unlink_default:
- * @pad: the #GstPad to link.
- *
- * Invoke the default unlink function of a ghost pad.
- *
- * Since: 0.10.36
- */
-void
-gst_ghost_pad_unlink_default (GstPad * pad)
-{
- g_return_if_fail (GST_IS_GHOST_PAD (pad));
-
- GST_DEBUG_OBJECT (pad, "unlinking ghostpad");
-}
-
static void
gst_ghost_pad_class_init (GstGhostPadClass * klass)
{
GST_DEBUG_REGISTER_FUNCPTR (gst_ghost_pad_activate_pull_default);
GST_DEBUG_REGISTER_FUNCPTR (gst_ghost_pad_activate_push_default);
- GST_DEBUG_REGISTER_FUNCPTR (gst_ghost_pad_link_default);
}
static void
* (GST_TYPE_GHOST_PAD, "direction", @dir, ..., NULL).
*
* Returns: %TRUE if the construction succeeds, %FALSE otherwise.
- *
- * Since: 0.10.22
*/
gboolean
gst_ghost_pad_construct (GstGhostPad * gpad)
gst_pad_set_getrange_function (pad, gst_proxy_pad_getrange_default);
}
- /* link/unlink functions */
- gst_pad_set_link_function (pad, gst_ghost_pad_link_default);
- gst_pad_set_unlink_function (pad, gst_ghost_pad_unlink_default);
-
/* INTERNAL PAD, it always exists and is child of the ghostpad */
otherdir = (dir == GST_PAD_SRC) ? GST_PAD_SINK : GST_PAD_SRC;
if (templ) {
* Will ref the target.
*
* Returns: (transfer full): a new #GstPad, or NULL in case of an error.
- *
- * Since: 0.10.10
*/
GstPad *
* direction will be taken from the @templ.
*
* Returns: (transfer full): a new #GstPad, or NULL in case of an error.
- *
- * Since: 0.10.10
*/
GstPad *
gst_ghost_pad_new_no_target_from_template (const gchar * name,
g_return_val_if_fail (GST_PAD_CAST (gpad) != newtarget, FALSE);
g_return_val_if_fail (newtarget != GST_PROXY_PAD_INTERNAL (gpad), FALSE);
- /* no need for locking, the internal pad's lifecycle is directly linked to the
- * ghostpad's */
+ GST_OBJECT_LOCK (gpad);
internal = GST_PROXY_PAD_INTERNAL (gpad);
if (newtarget)
GST_DEBUG_OBJECT (gpad, "clearing target");
/* clear old target */
- GST_OBJECT_LOCK (gpad);
if ((oldtarget = GST_PROXY_PAD_TARGET (gpad))) {
GST_OBJECT_UNLOCK (gpad);
if (newtarget) {
/* and link to internal pad without any checks */
- GST_DEBUG_OBJECT (gpad, "connecting internal pad to target");
+ GST_DEBUG_OBJECT (gpad, "connecting internal pad to target %"
+ GST_PTR_FORMAT, newtarget);
if (GST_PAD_IS_SRC (internal))
lret =