pad: Merge pad mode activation functions

Add the pad mode to the activate function so that we can reuse the same function
for all activation modes. This makes the core logic smaller and allows for some
elements to make their activation code easier. It would allow us to add more
scheduling modes later without having to add more activate functions.
This commit is contained in:
Wim Taymans 2011-11-21 13:29:05 +01:00
parent 9e3aa102d7
commit 2f1ed65339
15 changed files with 558 additions and 618 deletions

View file

@ -1000,11 +1000,9 @@ gst_ghost_pad_construct
gst_ghost_pad_unlink_default gst_ghost_pad_unlink_default
gst_ghost_pad_link_default gst_ghost_pad_link_default
gst_ghost_pad_activate_pull_default gst_ghost_pad_activate_mode_default
gst_ghost_pad_activate_push_default
gst_ghost_pad_internal_activate_push_default gst_ghost_pad_internal_activate_mode_default
gst_ghost_pad_internal_activate_pull_default
gst_proxy_pad_get_internal gst_proxy_pad_get_internal
@ -1642,8 +1640,7 @@ gst_pad_proxy_query_accept_caps
gst_pad_set_activate_function gst_pad_set_activate_function
GstPadActivateFunction GstPadActivateFunction
gst_pad_set_activatepush_function gst_pad_set_activatemode_function
gst_pad_set_activatepull_function
GstPadActivateModeFunction GstPadActivateModeFunction
gst_pad_check_reconfigure gst_pad_check_reconfigure
@ -1653,8 +1650,7 @@ gst_pad_push
gst_pad_push_event gst_pad_push_event
gst_pad_push_list gst_pad_push_list
gst_pad_pull_range gst_pad_pull_range
gst_pad_activate_pull gst_pad_activate_mode
gst_pad_activate_push
gst_pad_send_event gst_pad_send_event
gst_pad_event_default gst_pad_event_default
@ -1728,7 +1724,7 @@ gst_pad_link_return_get_type
gst_pad_link_check_get_type gst_pad_link_check_get_type
gst_pad_presence_get_type gst_pad_presence_get_type
gst_flow_return_get_type gst_flow_return_get_type
gst_activate_mode_get_type gst_pad_mode_get_type
gst_probe_return_get_type gst_probe_return_get_type
gst_probe_type_get_type gst_probe_type_get_type

View file

@ -458,61 +458,31 @@ G_DEFINE_TYPE (GstGhostPad, gst_ghost_pad, GST_TYPE_PROXY_PAD);
static void gst_ghost_pad_dispose (GObject * object); static void gst_ghost_pad_dispose (GObject * object);
/** static gboolean
* gst_ghost_pad_internal_activate_push_default:
* @pad: the #GstPad to activate or deactivate.
* @parent: the parent of @pad or NULL
* @active: whether the pad should be active or not.
*
* Invoke the default activate push function of a proxy pad that is
* owned by a ghost pad.
*
* Returns: %TRUE if the operation was successful.
*
* Since: 0.10.36
*/
gboolean
gst_ghost_pad_internal_activate_push_default (GstPad * pad, GstObject * parent, gst_ghost_pad_internal_activate_push_default (GstPad * pad, GstObject * parent,
gboolean active) gboolean active)
{ {
gboolean ret; gboolean ret;
GstPad *other; GstPad *other;
g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
GST_LOG_OBJECT (pad, "%sactivate push on %s:%s, we're ok", GST_LOG_OBJECT (pad, "%sactivate push on %s:%s, we're ok",
(active ? "" : "de"), GST_DEBUG_PAD_NAME (pad)); (active ? "" : "de"), GST_DEBUG_PAD_NAME (pad));
/* in both cases (SRC and SINK) we activate just the internal pad. The targets /* 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). */ * will be activated later (or already in case of a ghost sinkpad). */
other = GST_PROXY_PAD_INTERNAL (pad); other = GST_PROXY_PAD_INTERNAL (pad);
ret = gst_pad_activate_push (other, active); ret = gst_pad_activate_mode (other, GST_PAD_MODE_PUSH, active);
return ret; return ret;
} }
/** static gboolean
* gst_ghost_pad_internal_activate_pull_default:
* @pad: the #GstPad to activate or deactivate.
* @parent: the parent of @pad or NULL
* @active: whether the pad should be active or not.
*
* Invoke the default activate pull function of a proxy pad that is
* owned by a ghost pad.
*
* Returns: %TRUE if the operation was successful.
*
* Since: 0.10.36
*/
gboolean
gst_ghost_pad_internal_activate_pull_default (GstPad * pad, GstObject * parent, gst_ghost_pad_internal_activate_pull_default (GstPad * pad, GstObject * parent,
gboolean active) gboolean active)
{ {
gboolean ret; gboolean ret;
GstPad *other; GstPad *other;
g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
GST_LOG_OBJECT (pad, "%sactivate pull on %s:%s", (active ? "" : "de"), GST_LOG_OBJECT (pad, "%sactivate pull on %s:%s", (active ? "" : "de"),
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
@ -524,12 +494,12 @@ gst_ghost_pad_internal_activate_pull_default (GstPad * pad, GstObject * parent,
* further upstream */ * further upstream */
GST_LOG_OBJECT (pad, "pad is src, activate internal"); GST_LOG_OBJECT (pad, "pad is src, activate internal");
other = GST_PROXY_PAD_INTERNAL (pad); other = GST_PROXY_PAD_INTERNAL (pad);
ret = gst_pad_activate_pull (other, active); ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
} else if (G_LIKELY ((other = gst_pad_get_peer (pad)))) { } else if (G_LIKELY ((other = gst_pad_get_peer (pad)))) {
/* We are SINK, the ghostpad is SRC, we propagate the activation upstream /* We are SINK, the ghostpad is SRC, we propagate the activation upstream
* since we hold a pointer to the upstream peer. */ * since we hold a pointer to the upstream peer. */
GST_LOG_OBJECT (pad, "activating peer"); GST_LOG_OBJECT (pad, "activating peer");
ret = gst_pad_activate_pull (other, active); ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
gst_object_unref (other); gst_object_unref (other);
} else { } else {
/* this is failure, we can't activate pull if there is no peer */ /* this is failure, we can't activate pull if there is no peer */
@ -541,18 +511,41 @@ gst_ghost_pad_internal_activate_pull_default (GstPad * pad, GstObject * parent,
} }
/** /**
* gst_ghost_pad_activate_push_default: * gst_ghost_pad_internal_activate_mode_default:
* @pad: the #GstPad to activate or deactivate. * @pad: the #GstPad to activate or deactivate.
* @parent: the parent of @pad or NULL * @parent: the parent of @pad or NULL
* @mode: the requested activation mode
* @active: whether the pad should be active or not. * @active: whether the pad should be active or not.
* *
* Invoke the default activate push function of a ghost pad. * Invoke the default activate mode function of a proxy pad that is
* owned by a ghost pad.
* *
* Returns: %TRUE if the operation was successful. * Returns: %TRUE if the operation was successful.
*
* Since: 0.10.36
*/ */
gboolean gboolean
gst_ghost_pad_internal_activate_mode_default (GstPad * pad, GstObject * parent,
GstPadMode mode, gboolean active)
{
gboolean res;
g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
switch (mode) {
case GST_PAD_MODE_PULL:
res = gst_ghost_pad_internal_activate_pull_default (pad, parent, active);
break;
case GST_PAD_MODE_PUSH:
res = gst_ghost_pad_internal_activate_push_default (pad, parent, active);
break;
default:
GST_LOG_OBJECT (pad, "unknown activation mode %d");
res = FALSE;
break;
}
return res;
}
static gboolean
gst_ghost_pad_activate_push_default (GstPad * pad, GstObject * parent, gst_ghost_pad_activate_push_default (GstPad * pad, GstObject * parent,
gboolean active) gboolean active)
{ {
@ -566,32 +559,18 @@ gst_ghost_pad_activate_push_default (GstPad * pad, GstObject * parent,
/* just activate the internal pad */ /* just activate the internal pad */
other = GST_PROXY_PAD_INTERNAL (pad); other = GST_PROXY_PAD_INTERNAL (pad);
ret = gst_pad_activate_push (other, active); ret = gst_pad_activate_mode (other, GST_PAD_MODE_PUSH, active);
return ret; return ret;
} }
/** static gboolean
* gst_ghost_pad_activate_pull_default:
* @pad: the #GstPad to activate or deactivate.
* @parent: the parent of @pad or NULL
* @active: whether the pad should be active or not.
*
* Invoke the default activate pull function of a ghost pad.
*
* Returns: %TRUE if the operation was successful.
*
* Since: 0.10.36
*/
gboolean
gst_ghost_pad_activate_pull_default (GstPad * pad, GstObject * parent, gst_ghost_pad_activate_pull_default (GstPad * pad, GstObject * parent,
gboolean active) gboolean active)
{ {
gboolean ret; gboolean ret;
GstPad *other; GstPad *other;
g_return_val_if_fail (GST_IS_GHOST_PAD (pad), FALSE);
GST_LOG_OBJECT (pad, "%sactivate pull on %s:%s", (active ? "" : "de"), GST_LOG_OBJECT (pad, "%sactivate pull on %s:%s", (active ? "" : "de"),
GST_DEBUG_PAD_NAME (pad)); GST_DEBUG_PAD_NAME (pad));
@ -601,12 +580,12 @@ gst_ghost_pad_activate_pull_default (GstPad * pad, GstObject * parent,
* upstream */ * upstream */
GST_LOG_OBJECT (pad, "pad is src, activate internal"); GST_LOG_OBJECT (pad, "pad is src, activate internal");
other = GST_PROXY_PAD_INTERNAL (pad); other = GST_PROXY_PAD_INTERNAL (pad);
ret = gst_pad_activate_pull (other, active); ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
} else if (G_LIKELY ((other = gst_pad_get_peer (pad)))) { } else if (G_LIKELY ((other = gst_pad_get_peer (pad)))) {
/* We are SINK and activated by the internal pad, propagate activation /* We are SINK and activated by the internal pad, propagate activation
* upstream because we hold a ref to the upstream peer */ * upstream because we hold a ref to the upstream peer */
GST_LOG_OBJECT (pad, "activating peer"); GST_LOG_OBJECT (pad, "activating peer");
ret = gst_pad_activate_pull (other, active); ret = gst_pad_activate_mode (other, GST_PAD_MODE_PULL, active);
gst_object_unref (other); gst_object_unref (other);
} else { } else {
/* no peer, we fail */ /* no peer, we fail */
@ -617,6 +596,40 @@ gst_ghost_pad_activate_pull_default (GstPad * pad, GstObject * parent,
return ret; return ret;
} }
/**
* gst_ghost_pad_activate_mode_default:
* @pad: the #GstPad to activate or deactivate.
* @parent: the parent of @pad or NULL
* @mode: the requested activation mode
* @active: whether the pad should be active or not.
*
* Invoke the default activate mode function of a ghost pad.
*
* Returns: %TRUE if the operation was successful.
*/
gboolean
gst_ghost_pad_activate_mode_default (GstPad * pad, GstObject * parent,
GstPadMode mode, gboolean active)
{
gboolean res;
g_return_val_if_fail (GST_IS_GHOST_PAD (pad), FALSE);
switch (mode) {
case GST_PAD_MODE_PULL:
res = gst_ghost_pad_activate_pull_default (pad, parent, active);
break;
case GST_PAD_MODE_PUSH:
res = gst_ghost_pad_activate_push_default (pad, parent, active);
break;
default:
GST_LOG_OBJECT (pad, "unknown activation mode %d");
res = FALSE;
break;
}
return res;
}
/** /**
* gst_ghost_pad_link_default: * gst_ghost_pad_link_default:
* @pad: the #GstPad to link. * @pad: the #GstPad to link.
@ -687,10 +700,8 @@ gst_ghost_pad_init (GstGhostPad * pad)
GST_GHOST_PAD_PRIVATE (pad) = G_TYPE_INSTANCE_GET_PRIVATE (pad, GST_GHOST_PAD_PRIVATE (pad) = G_TYPE_INSTANCE_GET_PRIVATE (pad,
GST_TYPE_GHOST_PAD, GstGhostPadPrivate); GST_TYPE_GHOST_PAD, GstGhostPadPrivate);
gst_pad_set_activatepull_function (GST_PAD_CAST (pad), gst_pad_set_activatemode_function (GST_PAD_CAST (pad),
gst_ghost_pad_activate_pull_default); gst_ghost_pad_activate_mode_default);
gst_pad_set_activatepush_function (GST_PAD_CAST (pad),
gst_ghost_pad_activate_push_default);
} }
static void static void
@ -721,8 +732,7 @@ gst_ghost_pad_dispose (GObject * object)
GST_OBJECT_LOCK (pad); GST_OBJECT_LOCK (pad);
internal = GST_PROXY_PAD_INTERNAL (pad); internal = GST_PROXY_PAD_INTERNAL (pad);
gst_pad_set_activatepull_function (internal, NULL); gst_pad_set_activatemode_function (internal, NULL);
gst_pad_set_activatepush_function (internal, NULL);
/* disposes of the internal pad, since the ghostpad is the only possible object /* disposes of the internal pad, since the ghostpad is the only possible object
* that has a refcount on the internal pad. */ * that has a refcount on the internal pad. */
@ -821,10 +831,8 @@ gst_ghost_pad_construct (GstGhostPad * gpad)
GST_PROXY_PAD_INTERNAL (internal) = pad; GST_PROXY_PAD_INTERNAL (internal) = pad;
/* special activation functions for the internal pad */ /* special activation functions for the internal pad */
gst_pad_set_activatepull_function (internal, gst_pad_set_activatemode_function (internal,
gst_ghost_pad_internal_activate_pull_default); gst_ghost_pad_internal_activate_mode_default);
gst_pad_set_activatepush_function (internal,
gst_ghost_pad_internal_activate_push_default);
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);

View file

@ -125,13 +125,11 @@ gboolean gst_ghost_pad_construct (GstGhostPad *gpad);
void gst_ghost_pad_unlink_default (GstPad * pad); void gst_ghost_pad_unlink_default (GstPad * pad);
GstPadLinkReturn gst_ghost_pad_link_default (GstPad * pad, GstPad * peer); GstPadLinkReturn gst_ghost_pad_link_default (GstPad * pad, GstPad * peer);
gboolean gst_ghost_pad_activate_pull_default (GstPad * pad, GstObject * parent, gboolean active); gboolean gst_ghost_pad_activate_mode_default (GstPad * pad, GstObject * parent,
gboolean gst_ghost_pad_activate_push_default (GstPad * pad, GstObject * parent, gboolean active); GstPadMode mode, gboolean active);
gboolean gst_ghost_pad_internal_activate_push_default (GstPad * pad, GstObject * parent, gboolean gst_ghost_pad_internal_activate_mode_default (GstPad * pad, GstObject * parent,
gboolean active); GstPadMode mode, gboolean active);
gboolean gst_ghost_pad_internal_activate_pull_default (GstPad * pad, GstObject * parent,
gboolean active);
G_END_DECLS G_END_DECLS

View file

@ -632,31 +632,30 @@ gst_pad_get_direction (GstPad * pad)
static gboolean static gboolean
gst_pad_activate_default (GstPad * pad, GstObject * parent) gst_pad_activate_default (GstPad * pad, GstObject * parent)
{ {
return gst_pad_activate_push (pad, TRUE); return gst_pad_activate_mode (pad, GST_PAD_MODE_PUSH, TRUE);
} }
static void static void
pre_activate (GstPad * pad, GstPadMode new_mode) pre_activate (GstPad * pad, GstPadMode new_mode)
{ {
switch (new_mode) { switch (new_mode) {
case GST_PAD_MODE_PUSH:
case GST_PAD_MODE_PULL:
GST_OBJECT_LOCK (pad);
GST_DEBUG_OBJECT (pad, "setting ACTIVATE_MODE %d, unset flushing",
new_mode);
GST_PAD_UNSET_FLUSHING (pad);
GST_PAD_MODE (pad) = new_mode;
GST_OBJECT_UNLOCK (pad);
break;
case GST_PAD_MODE_NONE: case GST_PAD_MODE_NONE:
GST_OBJECT_LOCK (pad); GST_OBJECT_LOCK (pad);
GST_DEBUG_OBJECT (pad, "setting ACTIVATE_MODE NONE, set flushing"); GST_DEBUG_OBJECT (pad, "setting PAD_MODE NONE, set flushing");
GST_PAD_SET_FLUSHING (pad); GST_PAD_SET_FLUSHING (pad);
GST_PAD_MODE (pad) = new_mode; GST_PAD_MODE (pad) = new_mode;
/* unlock blocked pads so element can resume and stop */ /* unlock blocked pads so element can resume and stop */
GST_PAD_BLOCK_BROADCAST (pad); GST_PAD_BLOCK_BROADCAST (pad);
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
break; break;
case GST_PAD_MODE_PUSH:
case GST_PAD_MODE_PULL:
GST_OBJECT_LOCK (pad);
GST_DEBUG_OBJECT (pad, "setting PAD_MODE %d, unset flushing", new_mode);
GST_PAD_UNSET_FLUSHING (pad);
GST_PAD_MODE (pad) = new_mode;
GST_OBJECT_UNLOCK (pad);
break;
} }
} }
@ -664,10 +663,6 @@ static void
post_activate (GstPad * pad, GstPadMode new_mode) post_activate (GstPad * pad, GstPadMode new_mode)
{ {
switch (new_mode) { switch (new_mode) {
case GST_PAD_MODE_PUSH:
case GST_PAD_MODE_PULL:
/* nop */
break;
case GST_PAD_MODE_NONE: case GST_PAD_MODE_NONE:
/* ensures that streaming stops */ /* ensures that streaming stops */
GST_PAD_STREAM_LOCK (pad); GST_PAD_STREAM_LOCK (pad);
@ -677,6 +672,10 @@ post_activate (GstPad * pad, GstPadMode new_mode)
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
GST_PAD_STREAM_UNLOCK (pad); GST_PAD_STREAM_UNLOCK (pad);
break; break;
case GST_PAD_MODE_PUSH:
case GST_PAD_MODE_PULL:
/* NOP */
break;
} }
} }
@ -715,46 +714,26 @@ gst_pad_set_active (GstPad * pad, gboolean active)
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
if (active) { if (active) {
switch (old) { if (old == GST_PAD_MODE_NONE) {
case GST_PAD_MODE_PUSH:
GST_DEBUG_OBJECT (pad, "activating pad from push");
ret = TRUE;
break;
case GST_PAD_MODE_PULL:
GST_DEBUG_OBJECT (pad, "activating pad from pull");
ret = TRUE;
break;
case GST_PAD_MODE_NONE:
GST_DEBUG_OBJECT (pad, "activating pad from none"); GST_DEBUG_OBJECT (pad, "activating pad from none");
ret = (GST_PAD_ACTIVATEFUNC (pad)) (pad, parent); ret = (GST_PAD_ACTIVATEFUNC (pad)) (pad, parent);
break; } else {
default: GST_DEBUG_OBJECT (pad, "pad was active in mode %d", old);
GST_DEBUG_OBJECT (pad, "unknown activation mode!"); ret = TRUE;
break;
} }
} else { } else {
switch (old) { if (old == GST_PAD_MODE_NONE) {
case GST_PAD_MODE_PUSH: GST_DEBUG_OBJECT (pad, "pad was inactive");
GST_DEBUG_OBJECT (pad, "deactivating pad from push");
ret = gst_pad_activate_push (pad, FALSE);
break;
case GST_PAD_MODE_PULL:
GST_DEBUG_OBJECT (pad, "deactivating pad from pull");
ret = gst_pad_activate_pull (pad, FALSE);
break;
case GST_PAD_MODE_NONE:
GST_DEBUG_OBJECT (pad, "deactivating pad from none");
ret = TRUE; ret = TRUE;
break; } else {
default: GST_DEBUG_OBJECT (pad, "deactivating pad from mode %d", old);
GST_DEBUG_OBJECT (pad, "unknown activation mode!"); ret = gst_pad_activate_mode (pad, old, FALSE);
break;
} }
} }
RELEASE_PARENT (parent); RELEASE_PARENT (parent);
if (!ret) if (G_UNLIKELY (!ret))
goto failed; goto failed;
if (!active) { if (!active) {
@ -786,15 +765,13 @@ failed:
} }
/** /**
* gst_pad_activate_pull: * gst_pad_activate_mode:
* @pad: the #GstPad to activate or deactivate. * @pad: the #GstPad to activate or deactivate.
* @mode: the requested activation mode
* @active: whether or not the pad should be active. * @active: whether or not the pad should be active.
* *
* Activates or deactivates the given pad in pull mode via dispatching to the * Activates or deactivates the given pad in @mode via dispatching to the
* pad's activatepullfunc. For use from within pad activation functions only. * pad's activatemodefunc. For use from within pad activation functions only.
* When called on sink pads, will first proxy the call to the peer pad, which
* is expected to activate its internally linked pads from within its
* activate_pull function.
* *
* If you don't know what this is, you probably don't want to call it. * If you don't know what this is, you probably don't want to call it.
* *
@ -803,60 +780,42 @@ failed:
* MT safe. * MT safe.
*/ */
gboolean gboolean
gst_pad_activate_pull (GstPad * pad, gboolean active) gst_pad_activate_mode (GstPad * pad, GstPadMode mode, gboolean active)
{ {
gboolean res = FALSE; gboolean res = FALSE;
GstObject *parent; GstObject *parent;
GstPadMode old, new; GstPadMode old, new;
GstPadDirection dir;
GstPad *peer; GstPad *peer;
g_return_val_if_fail (GST_IS_PAD (pad), FALSE); g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
GST_OBJECT_LOCK (pad); GST_OBJECT_LOCK (pad);
old = GST_PAD_MODE (pad); old = GST_PAD_MODE (pad);
dir = GST_PAD_DIRECTION (pad);
ACQUIRE_PARENT (pad, parent, no_parent); ACQUIRE_PARENT (pad, parent, no_parent);
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
if (active) { new = active ? mode : GST_PAD_MODE_NONE;
switch (old) {
case GST_PAD_MODE_PULL: if (old == new)
GST_DEBUG_OBJECT (pad, "activating pad from pull, was ok");
goto was_ok; goto was_ok;
case GST_PAD_MODE_PUSH:
GST_DEBUG_OBJECT (pad, if (active && old != mode) {
"activating pad from push, deactivate push first");
/* pad was activate in the wrong direction, deactivate it /* pad was activate in the wrong direction, deactivate it
* and reactivate it in pull mode */ * and reactivate it in the requested mode */
if (G_UNLIKELY (!gst_pad_activate_push (pad, FALSE))) GST_DEBUG_OBJECT (pad, "deactivating pad from mode %d", old);
if (G_UNLIKELY (!gst_pad_activate_mode (pad, old, FALSE)))
goto deactivate_failed; goto deactivate_failed;
/* fallthrough, pad is deactivated now. */
case GST_PAD_MODE_NONE:
GST_DEBUG_OBJECT (pad, "activating pad from none");
break;
}
} else {
switch (old) {
case GST_PAD_MODE_NONE:
GST_DEBUG_OBJECT (pad, "deactivating pad from none, was ok");
goto was_ok;
case GST_PAD_MODE_PUSH:
GST_DEBUG_OBJECT (pad, "deactivating pad from push, weird");
/* pad was activated in the other direction, deactivate it
* in push mode, this should not happen... */
if (G_UNLIKELY (!gst_pad_activate_push (pad, FALSE)))
goto deactivate_failed;
/* everything is fine now */
goto was_ok;
case GST_PAD_MODE_PULL:
GST_DEBUG_OBJECT (pad, "deactivating pad from pull");
break;
}
} }
if (gst_pad_get_direction (pad) == GST_PAD_SINK) { switch (mode) {
case GST_PAD_MODE_PULL:
{
if (dir == GST_PAD_SINK) {
if ((peer = gst_pad_get_peer (pad))) { if ((peer = gst_pad_get_peer (pad))) {
GST_DEBUG_OBJECT (pad, "calling peer"); GST_DEBUG_OBJECT (pad, "calling peer");
if (G_UNLIKELY (!gst_pad_activate_pull (peer, active))) if (G_UNLIKELY (!gst_pad_activate_mode (peer, mode, active)))
goto peer_failed; goto peer_failed;
gst_object_unref (peer); gst_object_unref (peer);
} else { } else {
@ -873,12 +832,17 @@ gst_pad_activate_pull (GstPad * pad, gboolean active)
goto failure; /* Can't activate pull on a src without a goto failure; /* Can't activate pull on a src without a
getrange function */ getrange function */
} }
break;
}
default:
break;
}
new = active ? GST_PAD_MODE_PULL : GST_PAD_MODE_NONE;
pre_activate (pad, new); pre_activate (pad, new);
if (GST_PAD_ACTIVATEPULLFUNC (pad)) { if (GST_PAD_ACTIVATEMODEFUNC (pad)) {
if (G_UNLIKELY (!GST_PAD_ACTIVATEPULLFUNC (pad) (pad, parent, active))) if (G_UNLIKELY (!GST_PAD_ACTIVATEMODEFUNC (pad) (pad, parent, mode,
active)))
goto failure; goto failure;
} else { } else {
/* can happen for sinks of passthrough elements */ /* can happen for sinks of passthrough elements */
@ -886,8 +850,8 @@ gst_pad_activate_pull (GstPad * pad, gboolean active)
post_activate (pad, new); post_activate (pad, new);
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in pull mode", GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in mode %d",
active ? "activated" : "deactivated"); active ? "activated" : "deactivated", mode);
exit_success: exit_success:
res = TRUE; res = TRUE;
@ -904,22 +868,22 @@ no_parent:
} }
was_ok: was_ok:
{ {
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "already %s in pull mode", GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "already %s in mode %d",
active ? "activated" : "deactivated"); active ? "activated" : "deactivated", mode);
goto exit_success; goto exit_success;
} }
deactivate_failed: deactivate_failed:
{ {
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
"failed to %s in switch to pull from mode %d", "failed to %s in switch to mode %d from mode %d",
(active ? "activate" : "deactivate"), old); (active ? "activate" : "deactivate"), mode, old);
goto exit; goto exit;
} }
peer_failed: peer_failed:
{ {
GST_OBJECT_LOCK (peer); GST_OBJECT_LOCK (peer);
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
"activate_pull on peer (%s:%s) failed", GST_DEBUG_PAD_NAME (peer)); "activate_mode on peer (%s:%s) failed", GST_DEBUG_PAD_NAME (peer));
GST_OBJECT_UNLOCK (peer); GST_OBJECT_UNLOCK (peer);
gst_object_unref (peer); gst_object_unref (peer);
goto exit; goto exit;
@ -933,128 +897,8 @@ not_linked:
failure: failure:
{ {
GST_OBJECT_LOCK (pad); GST_OBJECT_LOCK (pad);
GST_CAT_INFO_OBJECT (GST_CAT_PADS, pad, "failed to %s in pull mode", GST_CAT_INFO_OBJECT (GST_CAT_PADS, pad, "failed to %s in mode %d",
active ? "activate" : "deactivate"); active ? "activate" : "deactivate", mode);
GST_PAD_SET_FLUSHING (pad);
GST_PAD_MODE (pad) = old;
GST_OBJECT_UNLOCK (pad);
goto exit;
}
}
/**
* gst_pad_activate_push:
* @pad: the #GstPad to activate or deactivate.
* @active: whether the pad should be active or not.
*
* Activates or deactivates the given pad in push mode via dispatching to the
* pad's activatepushfunc. For use from within pad activation functions only.
*
* If you don't know what this is, you probably don't want to call it.
*
* Returns: %TRUE if the operation was successful.
*
* MT safe.
*/
gboolean
gst_pad_activate_push (GstPad * pad, gboolean active)
{
gboolean res = FALSE;
GstObject *parent;
GstPadMode old, new;
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "trying to set %s in push mode",
active ? "activated" : "deactivated");
GST_OBJECT_LOCK (pad);
old = GST_PAD_MODE (pad);
ACQUIRE_PARENT (pad, parent, no_parent);
GST_OBJECT_UNLOCK (pad);
if (active) {
switch (old) {
case GST_PAD_MODE_PUSH:
GST_DEBUG_OBJECT (pad, "activating pad from push, was ok");
goto was_ok;
case GST_PAD_MODE_PULL:
GST_DEBUG_OBJECT (pad,
"activating pad from push, deactivating pull first");
/* pad was activate in the wrong direction, deactivate it
* an reactivate it in push mode */
if (G_UNLIKELY (!gst_pad_activate_pull (pad, FALSE)))
goto deactivate_failed;
/* fallthrough, pad is deactivated now. */
case GST_PAD_MODE_NONE:
GST_DEBUG_OBJECT (pad, "activating pad from none");
break;
}
} else {
switch (old) {
case GST_PAD_MODE_NONE:
GST_DEBUG_OBJECT (pad, "deactivating pad from none, was ok");
goto was_ok;
case GST_PAD_MODE_PULL:
GST_DEBUG_OBJECT (pad, "deactivating pad from pull, weird");
/* pad was activated in the other direction, deactivate it
* in pull mode, this should not happen... */
if (G_UNLIKELY (!gst_pad_activate_pull (pad, FALSE)))
goto deactivate_failed;
/* everything is fine now */
goto was_ok;
case GST_PAD_MODE_PUSH:
GST_DEBUG_OBJECT (pad, "deactivating pad from push");
break;
}
}
new = active ? GST_PAD_MODE_PUSH : GST_PAD_MODE_NONE;
pre_activate (pad, new);
if (GST_PAD_ACTIVATEPUSHFUNC (pad)) {
if (G_UNLIKELY (!GST_PAD_ACTIVATEPUSHFUNC (pad) (pad, parent, active))) {
goto failure;
}
} else {
/* quite ok, element relies on state change func to prepare itself */
}
post_activate (pad, new);
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in push mode",
active ? "activated" : "deactivated");
exit_success:
res = TRUE;
exit:
RELEASE_PARENT (parent);
return res;
no_parent:
{
GST_DEBUG_OBJECT (pad, "no parent");
GST_OBJECT_UNLOCK (pad);
return FALSE;
}
was_ok:
{
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "already %s in push mode",
active ? "activated" : "deactivated");
goto exit_success;
}
deactivate_failed:
{
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
"failed to %s in switch to push from mode %d",
(active ? "activate" : "deactivate"), old);
goto exit;
}
failure:
{
GST_OBJECT_LOCK (pad);
GST_CAT_INFO_OBJECT (GST_CAT_PADS, pad, "failed to %s in push mode",
active ? "activate" : "deactivate");
GST_PAD_SET_FLUSHING (pad); GST_PAD_SET_FLUSHING (pad);
GST_PAD_MODE (pad) = old; GST_PAD_MODE (pad) = old;
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
@ -1357,42 +1201,22 @@ gst_pad_set_activate_function (GstPad * pad, GstPadActivateFunction activate)
} }
/** /**
* gst_pad_set_activatepull_function: * gst_pad_set_activatemode_function:
* @pad: a #GstPad. * @pad: a #GstPad.
* @activatepull: the #GstPadActivateModeFunction to set. * @activatemode: the #GstPadActivateModeFunction to set.
* *
* Sets the given activate_pull function for the pad. An activate_pull function * Sets the given activate_mode function for the pad. An activate_mode function
* prepares the element and any upstream connections for pulling. See XXX * prepares the element for data passing.
* part-activation.txt for details.
*/ */
void void
gst_pad_set_activatepull_function (GstPad * pad, gst_pad_set_activatemode_function (GstPad * pad,
GstPadActivateModeFunction activatepull) GstPadActivateModeFunction activatemode)
{ {
g_return_if_fail (GST_IS_PAD (pad)); g_return_if_fail (GST_IS_PAD (pad));
GST_PAD_ACTIVATEPULLFUNC (pad) = activatepull; GST_PAD_ACTIVATEMODEFUNC (pad) = activatemode;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "activatepullfunc set to %s", GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "activatemodefunc set to %s",
GST_DEBUG_FUNCPTR_NAME (activatepull)); GST_DEBUG_FUNCPTR_NAME (activatemode));
}
/**
* gst_pad_set_activatepush_function:
* @pad: a #GstPad.
* @activatepush: the #GstPadActivateModeFunction to set.
*
* Sets the given activate_push function for the pad. An activate_push function
* prepares the element for pushing. See XXX part-activation.txt for details.
*/
void
gst_pad_set_activatepush_function (GstPad * pad,
GstPadActivateModeFunction activatepush)
{
g_return_if_fail (GST_IS_PAD (pad));
GST_PAD_ACTIVATEPUSHFUNC (pad) = activatepush;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "activatepushfunc set to %s",
GST_DEBUG_FUNCPTR_NAME (activatepush));
} }
/** /**

View file

@ -245,6 +245,7 @@ typedef gboolean (*GstPadActivateFunction) (GstPad *pad, GstObject *parent);
* GstPadActivateModeFunction: * GstPadActivateModeFunction:
* @pad: a #GstPad * @pad: a #GstPad
* @parent: the parent of @pad * @parent: the parent of @pad
* @mode: the requested activation mode of @pad
* @active: activate or deactivate the pad. * @active: activate or deactivate the pad.
* *
* The prototype of the push and pull activate functions. * The prototype of the push and pull activate functions.
@ -252,7 +253,7 @@ typedef gboolean (*GstPadActivateFunction) (GstPad *pad, GstObject *parent);
* Returns: TRUE if the pad could be activated or deactivated. * Returns: TRUE if the pad could be activated or deactivated.
*/ */
typedef gboolean (*GstPadActivateModeFunction) (GstPad *pad, GstObject *parent, typedef gboolean (*GstPadActivateModeFunction) (GstPad *pad, GstObject *parent,
gboolean active); GstPadMode mode, gboolean active);
/* data passing */ /* data passing */
@ -616,8 +617,7 @@ typedef enum {
* @probes: installed probes * @probes: installed probes
* @mode: current activation mode of the pad * @mode: current activation mode of the pad
* @activatefunc: pad activation function * @activatefunc: pad activation function
* @activatepushfunc: function to activate/deactivate pad in push mode * @activatemodefunc: function to activate/deactivate pad in the requested mode
* @activatepullfunc: function to activate/deactivate pad in pull mode
* @peer: the pad this pad is linked to * @peer: the pad this pad is linked to
* @linkfunc: function called when pad is linked * @linkfunc: function called when pad is linked
* @unlinkfunc: function called when pad is unlinked * @unlinkfunc: function called when pad is unlinked
@ -653,8 +653,7 @@ struct _GstPad {
GstPadMode mode; GstPadMode mode;
GstPadActivateFunction activatefunc; GstPadActivateFunction activatefunc;
GstPadActivateModeFunction activatepushfunc; GstPadActivateModeFunction activatemodefunc;
GstPadActivateModeFunction activatepullfunc;
/* pad link */ /* pad link */
GstPad *peer; GstPad *peer;
@ -709,8 +708,7 @@ struct _GstPadClass {
#define GST_PAD_MODE(pad) (GST_PAD_CAST(pad)->mode) #define GST_PAD_MODE(pad) (GST_PAD_CAST(pad)->mode)
#define GST_PAD_ACTIVATEFUNC(pad) (GST_PAD_CAST(pad)->activatefunc) #define GST_PAD_ACTIVATEFUNC(pad) (GST_PAD_CAST(pad)->activatefunc)
#define GST_PAD_ACTIVATEPUSHFUNC(pad) (GST_PAD_CAST(pad)->activatepushfunc) #define GST_PAD_ACTIVATEMODEFUNC(pad) (GST_PAD_CAST(pad)->activatemodefunc)
#define GST_PAD_ACTIVATEPULLFUNC(pad) (GST_PAD_CAST(pad)->activatepullfunc)
#define GST_PAD_CHAINFUNC(pad) (GST_PAD_CAST(pad)->chainfunc) #define GST_PAD_CHAINFUNC(pad) (GST_PAD_CAST(pad)->chainfunc)
#define GST_PAD_CHAINLISTFUNC(pad) (GST_PAD_CAST(pad)->chainlistfunc) #define GST_PAD_CHAINLISTFUNC(pad) (GST_PAD_CAST(pad)->chainlistfunc)
#define GST_PAD_GETRANGEFUNC(pad) (GST_PAD_CAST(pad)->getrangefunc) #define GST_PAD_GETRANGEFUNC(pad) (GST_PAD_CAST(pad)->getrangefunc)
@ -814,8 +812,8 @@ GstPadDirection gst_pad_get_direction (GstPad *pad);
gboolean gst_pad_set_active (GstPad *pad, gboolean active); gboolean gst_pad_set_active (GstPad *pad, gboolean active);
gboolean gst_pad_is_active (GstPad *pad); gboolean gst_pad_is_active (GstPad *pad);
gboolean gst_pad_activate_pull (GstPad *pad, gboolean active); gboolean gst_pad_activate_mode (GstPad *pad, GstPadMode mode,
gboolean gst_pad_activate_push (GstPad *pad, gboolean active); gboolean active);
gulong gst_pad_add_probe (GstPad *pad, gulong gst_pad_add_probe (GstPad *pad,
GstPadProbeType mask, GstPadProbeType mask,
@ -840,8 +838,7 @@ GstFlowReturn gst_pad_sticky_events_foreach (GstPad *pad, Gs
/* data passing setup functions */ /* data passing setup functions */
void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate); void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate);
void gst_pad_set_activatepull_function (GstPad *pad, GstPadActivateModeFunction activatepull); void gst_pad_set_activatemode_function (GstPad *pad, GstPadActivateModeFunction activatemode);
void gst_pad_set_activatepush_function (GstPad *pad, GstPadActivateModeFunction activatepush);
void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain); void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
void gst_pad_set_chain_list_function (GstPad *pad, GstPadChainListFunction chainlist); void gst_pad_set_chain_list_function (GstPad *pad, GstPadChainListFunction chainlist);
void gst_pad_set_getrange_function (GstPad *pad, GstPadGetRangeFunction get); void gst_pad_set_getrange_function (GstPad *pad, GstPadGetRangeFunction get);

View file

@ -376,10 +376,8 @@ static GstIndex *gst_base_parse_get_index (GstElement * element);
static gboolean gst_base_parse_sink_activate (GstPad * sinkpad, static gboolean gst_base_parse_sink_activate (GstPad * sinkpad,
GstObject * parent); GstObject * parent);
static gboolean gst_base_parse_sink_activate_push (GstPad * pad, static gboolean gst_base_parse_sink_activate_mode (GstPad * pad,
GstObject * parent, gboolean active); GstObject * parent, GstPadMode mode, gboolean active);
static gboolean gst_base_parse_sink_activate_pull (GstPad * pad,
GstObject * parent, gboolean active);
static gboolean gst_base_parse_handle_seek (GstBaseParse * parse, static gboolean gst_base_parse_handle_seek (GstBaseParse * parse,
GstEvent * event); GstEvent * event);
static void gst_base_parse_handle_tag (GstBaseParse * parse, GstEvent * event); static void gst_base_parse_handle_tag (GstBaseParse * parse, GstEvent * event);
@ -535,10 +533,8 @@ gst_base_parse_init (GstBaseParse * parse, GstBaseParseClass * bclass)
GST_DEBUG_FUNCPTR (gst_base_parse_chain)); GST_DEBUG_FUNCPTR (gst_base_parse_chain));
gst_pad_set_activate_function (parse->sinkpad, gst_pad_set_activate_function (parse->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_parse_sink_activate)); GST_DEBUG_FUNCPTR (gst_base_parse_sink_activate));
gst_pad_set_activatepush_function (parse->sinkpad, gst_pad_set_activatemode_function (parse->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_parse_sink_activate_push)); GST_DEBUG_FUNCPTR (gst_base_parse_sink_activate_mode));
gst_pad_set_activatepull_function (parse->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_parse_sink_activate_pull));
gst_element_add_pad (GST_ELEMENT (parse), parse->sinkpad); gst_element_add_pad (GST_ELEMENT (parse), parse->sinkpad);
GST_DEBUG_OBJECT (parse, "sinkpad created"); GST_DEBUG_OBJECT (parse, "sinkpad created");
@ -2957,10 +2953,10 @@ gst_base_parse_sink_activate (GstPad * sinkpad, GstObject * parent)
if (pull_mode) { if (pull_mode) {
GST_DEBUG_OBJECT (parse, "trying to activate in pull mode"); GST_DEBUG_OBJECT (parse, "trying to activate in pull mode");
result = gst_pad_activate_pull (sinkpad, TRUE); result = gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
} else { } else {
GST_DEBUG_OBJECT (parse, "trying to activate in push mode"); GST_DEBUG_OBJECT (parse, "trying to activate in push mode");
result = gst_pad_activate_push (sinkpad, TRUE); result = gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
} }
GST_DEBUG_OBJECT (parse, "sink activate return %d", result); GST_DEBUG_OBJECT (parse, "sink activate return %d", result);
@ -3000,59 +2996,43 @@ gst_base_parse_activate (GstBaseParse * parse, gboolean active)
} }
static gboolean static gboolean
gst_base_parse_sink_activate_push (GstPad * pad, GstObject * parent, gst_base_parse_sink_activate_mode (GstPad * pad, GstObject * parent,
gboolean active) GstPadMode mode, gboolean active)
{ {
gboolean result = TRUE; gboolean result = TRUE;
GstBaseParse *parse; GstBaseParse *parse;
parse = GST_BASE_PARSE (parent); parse = GST_BASE_PARSE (parent);
GST_DEBUG_OBJECT (parse, "sink activate push %d", active); GST_DEBUG_OBJECT (parse, "sink activate mode %d, %d", mode, active);
result = gst_base_parse_activate (parse, active);
if (result)
parse->priv->pad_mode = active ? GST_PAD_MODE_PUSH : GST_PAD_MODE_NONE;
GST_DEBUG_OBJECT (parse, "sink activate push return: %d", result);
return result;
}
static gboolean
gst_base_parse_sink_activate_pull (GstPad * sinkpad, GstObject * parent,
gboolean active)
{
gboolean result = FALSE;
GstBaseParse *parse;
parse = GST_BASE_PARSE (parent);
GST_DEBUG_OBJECT (parse, "activate pull %d", active);
result = gst_base_parse_activate (parse, active); result = gst_base_parse_activate (parse, active);
if (result) { if (result) {
switch (mode) {
case GST_PAD_MODE_PULL:
if (active) { if (active) {
parse->priv->pending_segment = gst_event_new_segment (&parse->segment); parse->priv->pending_segment =
gst_event_new_segment (&parse->segment);
result &= result &=
gst_pad_start_task (sinkpad, (GstTaskFunction) gst_base_parse_loop, gst_pad_start_task (pad, (GstTaskFunction) gst_base_parse_loop,
sinkpad); pad);
} else { } else {
result &= gst_pad_stop_task (sinkpad); result &= gst_pad_stop_task (pad);
}
break;
default:
break;
} }
} }
if (result) if (result)
parse->priv->pad_mode = active ? GST_PAD_MODE_PULL : GST_PAD_MODE_NONE; parse->priv->pad_mode = active ? mode : GST_PAD_MODE_NONE;
GST_DEBUG_OBJECT (parse, "sink activate pull return: %d", result); GST_DEBUG_OBJECT (parse, "sink activate return: %d", result);
return result; return result;
} }
/** /**
* gst_base_parse_set_duration: * gst_base_parse_set_duration:
* @parse: #GstBaseParse. * @parse: #GstBaseParse.

View file

@ -394,10 +394,8 @@ static GstFlowReturn gst_base_sink_chain_list (GstPad * pad, GstObject * parent,
static void gst_base_sink_loop (GstPad * pad); static void gst_base_sink_loop (GstPad * pad);
static gboolean gst_base_sink_pad_activate (GstPad * pad, GstObject * parent); static gboolean gst_base_sink_pad_activate (GstPad * pad, GstObject * parent);
static gboolean gst_base_sink_pad_activate_push (GstPad * pad, static gboolean gst_base_sink_pad_activate_mode (GstPad * pad,
GstObject * parent, gboolean active); GstObject * parent, GstPadMode mode, gboolean active);
static gboolean gst_base_sink_pad_activate_pull (GstPad * pad,
GstObject * parent, gboolean active);
static gboolean gst_base_sink_event (GstPad * pad, GstObject * parent, static gboolean gst_base_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event); GstEvent * event);
@ -559,8 +557,7 @@ gst_base_sink_class_init (GstBaseSinkClass * klass)
/* Registering debug symbols for function pointers */ /* Registering debug symbols for function pointers */
GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_fixate); GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_fixate);
GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_pad_activate); GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_pad_activate);
GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_pad_activate_push); GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_pad_activate_mode);
GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_pad_activate_pull);
GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_event); GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_event);
GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_chain); GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_chain);
GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_chain_list); GST_DEBUG_REGISTER_FUNCPTR (gst_base_sink_chain_list);
@ -643,10 +640,8 @@ gst_base_sink_init (GstBaseSink * basesink, gpointer g_class)
basesink->sinkpad = gst_pad_new_from_template (pad_template, "sink"); basesink->sinkpad = gst_pad_new_from_template (pad_template, "sink");
gst_pad_set_activate_function (basesink->sinkpad, gst_base_sink_pad_activate); gst_pad_set_activate_function (basesink->sinkpad, gst_base_sink_pad_activate);
gst_pad_set_activatepush_function (basesink->sinkpad, gst_pad_set_activatemode_function (basesink->sinkpad,
gst_base_sink_pad_activate_push); gst_base_sink_pad_activate_mode);
gst_pad_set_activatepull_function (basesink->sinkpad,
gst_base_sink_pad_activate_pull);
gst_pad_set_query_function (basesink->sinkpad, gst_base_sink_sink_query); gst_pad_set_query_function (basesink->sinkpad, gst_base_sink_sink_query);
gst_pad_set_event_function (basesink->sinkpad, gst_base_sink_event); gst_pad_set_event_function (basesink->sinkpad, gst_base_sink_event);
gst_pad_set_chain_function (basesink->sinkpad, gst_base_sink_chain); gst_pad_set_chain_function (basesink->sinkpad, gst_base_sink_chain);
@ -4165,7 +4160,7 @@ gst_base_sink_pad_activate (GstPad * pad, GstObject * parent)
} }
/* ok activate now */ /* ok activate now */
if (!gst_pad_activate_pull (pad, TRUE)) { if (!gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE)) {
/* clear any pending caps */ /* clear any pending caps */
GST_OBJECT_LOCK (basesink); GST_OBJECT_LOCK (basesink);
gst_caps_replace (&basesink->priv->pull_caps, NULL); gst_caps_replace (&basesink->priv->pull_caps, NULL);
@ -4181,7 +4176,7 @@ gst_base_sink_pad_activate (GstPad * pad, GstObject * parent)
/* push mode fallback */ /* push mode fallback */
fallback: fallback:
GST_DEBUG_OBJECT (basesink, "Falling back to push mode"); GST_DEBUG_OBJECT (basesink, "Falling back to push mode");
if ((result = gst_pad_activate_push (pad, TRUE))) { if ((result = gst_pad_activate_mode (pad, GST_PAD_MODE_PUSH, TRUE))) {
GST_DEBUG_OBJECT (basesink, "Success activating push mode"); GST_DEBUG_OBJECT (basesink, "Success activating push mode");
} }
@ -4359,6 +4354,27 @@ activate_failed:
} }
} }
static gboolean
gst_base_sink_pad_activate_mode (GstPad * pad, GstObject * parent,
GstPadMode mode, gboolean active)
{
gboolean res;
switch (mode) {
case GST_PAD_MODE_PULL:
res = gst_base_sink_pad_activate_pull (pad, parent, active);
break;
case GST_PAD_MODE_PUSH:
res = gst_base_sink_pad_activate_push (pad, parent, active);
break;
default:
GST_LOG_OBJECT (pad, "unknown activation mode %d", mode);
res = FALSE;
break;
}
return res;
}
/* send an event to our sinkpad peer. */ /* send an event to our sinkpad peer. */
static gboolean static gboolean
gst_base_sink_send_event (GstElement * element, GstEvent * event) gst_base_sink_send_event (GstElement * element, GstEvent * event)

View file

@ -284,10 +284,8 @@ static void gst_base_src_default_fixate (GstBaseSrc * src, GstCaps * caps);
static void gst_base_src_fixate (GstBaseSrc * src, GstCaps * caps); static void gst_base_src_fixate (GstBaseSrc * src, GstCaps * caps);
static gboolean gst_base_src_is_random_access (GstBaseSrc * src); static gboolean gst_base_src_is_random_access (GstBaseSrc * src);
static gboolean gst_base_src_activate_push (GstPad * pad, GstObject * parent, static gboolean gst_base_src_activate_mode (GstPad * pad, GstObject * parent,
gboolean active); GstPadMode mode, gboolean active);
static gboolean gst_base_src_activate_pull (GstPad * pad, GstObject * parent,
gboolean active);
static void gst_base_src_set_property (GObject * object, guint prop_id, static void gst_base_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec); const GValue * value, GParamSpec * pspec);
static void gst_base_src_get_property (GObject * object, guint prop_id, static void gst_base_src_get_property (GObject * object, guint prop_id,
@ -384,8 +382,7 @@ gst_base_src_class_init (GstBaseSrcClass * klass)
klass->alloc = GST_DEBUG_FUNCPTR (gst_base_src_default_alloc); klass->alloc = GST_DEBUG_FUNCPTR (gst_base_src_default_alloc);
/* Registering debug symbols for function pointers */ /* Registering debug symbols for function pointers */
GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_activate_push); GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_activate_mode);
GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_activate_pull);
GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_event); GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_event);
GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_query); GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_query);
GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_getrange); GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_getrange);
@ -416,8 +413,7 @@ gst_base_src_init (GstBaseSrc * basesrc, gpointer g_class)
pad = gst_pad_new_from_template (pad_template, "src"); pad = gst_pad_new_from_template (pad_template, "src");
GST_DEBUG_OBJECT (basesrc, "setting functions on src pad"); GST_DEBUG_OBJECT (basesrc, "setting functions on src pad");
gst_pad_set_activatepush_function (pad, gst_base_src_activate_push); gst_pad_set_activatemode_function (pad, gst_base_src_activate_mode);
gst_pad_set_activatepull_function (pad, gst_base_src_activate_pull);
gst_pad_set_event_function (pad, gst_base_src_event); gst_pad_set_event_function (pad, gst_base_src_event);
gst_pad_set_query_function (pad, gst_base_src_query); gst_pad_set_query_function (pad, gst_base_src_query);
gst_pad_set_getrange_function (pad, gst_base_src_getrange); gst_pad_set_getrange_function (pad, gst_base_src_getrange);
@ -3182,6 +3178,28 @@ error_stop:
} }
} }
static gboolean
gst_base_src_activate_mode (GstPad * pad, GstObject * parent,
GstPadMode mode, gboolean active)
{
gboolean res;
switch (mode) {
case GST_PAD_MODE_PULL:
res = gst_base_src_activate_pull (pad, parent, active);
break;
case GST_PAD_MODE_PUSH:
res = gst_base_src_activate_push (pad, parent, active);
break;
default:
GST_LOG_OBJECT (pad, "unknown activation mode %d");
res = FALSE;
break;
}
return res;
}
static GstStateChangeReturn static GstStateChangeReturn
gst_base_src_change_state (GstElement * element, GstStateChange transition) gst_base_src_change_state (GstElement * element, GstStateChange transition)
{ {

View file

@ -298,10 +298,10 @@ static void gst_base_transform_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec); const GValue * value, GParamSpec * pspec);
static void gst_base_transform_get_property (GObject * object, guint prop_id, static void gst_base_transform_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec); GValue * value, GParamSpec * pspec);
static gboolean gst_base_transform_src_activate_pull (GstPad * pad, static gboolean gst_base_transform_src_activate_mode (GstPad * pad,
GstObject * parent, gboolean active); GstObject * parent, GstPadMode mode, gboolean active);
static gboolean gst_base_transform_sink_activate_push (GstPad * pad, static gboolean gst_base_transform_sink_activate_mode (GstPad * pad,
GstObject * parent, gboolean active); GstObject * parent, GstPadMode mode, gboolean active);
static gboolean gst_base_transform_activate (GstBaseTransform * trans, static gboolean gst_base_transform_activate (GstBaseTransform * trans,
gboolean active); gboolean active);
static gboolean gst_base_transform_get_unit_size (GstBaseTransform * trans, static gboolean gst_base_transform_get_unit_size (GstBaseTransform * trans,
@ -418,8 +418,8 @@ gst_base_transform_init (GstBaseTransform * trans,
GST_DEBUG_FUNCPTR (gst_base_transform_sink_event)); GST_DEBUG_FUNCPTR (gst_base_transform_sink_event));
gst_pad_set_chain_function (trans->sinkpad, gst_pad_set_chain_function (trans->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_transform_chain)); GST_DEBUG_FUNCPTR (gst_base_transform_chain));
gst_pad_set_activatepush_function (trans->sinkpad, gst_pad_set_activatemode_function (trans->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_transform_sink_activate_push)); GST_DEBUG_FUNCPTR (gst_base_transform_sink_activate_mode));
gst_pad_set_query_function (trans->sinkpad, gst_pad_set_query_function (trans->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_transform_query)); GST_DEBUG_FUNCPTR (gst_base_transform_query));
gst_element_add_pad (GST_ELEMENT (trans), trans->sinkpad); gst_element_add_pad (GST_ELEMENT (trans), trans->sinkpad);
@ -432,8 +432,8 @@ gst_base_transform_init (GstBaseTransform * trans,
GST_DEBUG_FUNCPTR (gst_base_transform_src_event)); GST_DEBUG_FUNCPTR (gst_base_transform_src_event));
gst_pad_set_getrange_function (trans->srcpad, gst_pad_set_getrange_function (trans->srcpad,
GST_DEBUG_FUNCPTR (gst_base_transform_getrange)); GST_DEBUG_FUNCPTR (gst_base_transform_getrange));
gst_pad_set_activatepull_function (trans->srcpad, gst_pad_set_activatemode_function (trans->srcpad,
GST_DEBUG_FUNCPTR (gst_base_transform_src_activate_pull)); GST_DEBUG_FUNCPTR (gst_base_transform_src_activate_mode));
gst_pad_set_query_function (trans->srcpad, gst_pad_set_query_function (trans->srcpad,
GST_DEBUG_FUNCPTR (gst_base_transform_query)); GST_DEBUG_FUNCPTR (gst_base_transform_query));
gst_element_add_pad (GST_ELEMENT (trans), trans->srcpad); gst_element_add_pad (GST_ELEMENT (trans), trans->srcpad);
@ -2152,38 +2152,57 @@ gst_base_transform_activate (GstBaseTransform * trans, gboolean active)
} }
static gboolean static gboolean
gst_base_transform_sink_activate_push (GstPad * pad, GstObject * parent, gst_base_transform_sink_activate_mode (GstPad * pad, GstObject * parent,
gboolean active) GstPadMode mode, gboolean active)
{
gboolean result = TRUE;
GstBaseTransform *trans;
trans = GST_BASE_TRANSFORM (parent);
result = gst_base_transform_activate (trans, active);
if (result)
trans->priv->pad_mode = active ? GST_PAD_MODE_PUSH : GST_PAD_MODE_NONE;
return result;
}
static gboolean
gst_base_transform_src_activate_pull (GstPad * pad, GstObject * parent,
gboolean active)
{ {
gboolean result = FALSE; gboolean result = FALSE;
GstBaseTransform *trans; GstBaseTransform *trans;
trans = GST_BASE_TRANSFORM (parent); trans = GST_BASE_TRANSFORM (parent);
result = gst_pad_activate_pull (trans->sinkpad, active); switch (mode) {
case GST_PAD_MODE_PUSH:
{
result = gst_base_transform_activate (trans, active);
if (result)
trans->priv->pad_mode = active ? GST_PAD_MODE_PUSH : GST_PAD_MODE_NONE;
break;
}
default:
result = TRUE;
break;
}
return result;
}
static gboolean
gst_base_transform_src_activate_mode (GstPad * pad, GstObject * parent,
GstPadMode mode, gboolean active)
{
gboolean result = FALSE;
GstBaseTransform *trans;
trans = GST_BASE_TRANSFORM (parent);
switch (mode) {
case GST_PAD_MODE_PULL:
{
result =
gst_pad_activate_mode (trans->sinkpad, GST_PAD_MODE_PULL, active);
if (result) if (result)
result &= gst_base_transform_activate (trans, active); result &= gst_base_transform_activate (trans, active);
if (result) if (result)
trans->priv->pad_mode = active ? GST_PAD_MODE_PULL : GST_PAD_MODE_NONE; trans->priv->pad_mode = active ? mode : GST_PAD_MODE_NONE;
break;
}
default:
result = TRUE;
break;
}
return result; return result;
} }

View file

@ -1383,13 +1383,16 @@ was_eos:
} }
static gboolean static gboolean
gst_multi_queue_sink_activate_push (GstPad * pad, GstObject * parent, gst_multi_queue_sink_activate_mode (GstPad * pad, GstObject * parent,
gboolean active) GstPadMode mode, gboolean active)
{ {
gboolean res;
GstSingleQueue *sq; GstSingleQueue *sq;
sq = (GstSingleQueue *) gst_pad_get_element_private (pad); sq = (GstSingleQueue *) gst_pad_get_element_private (pad);
switch (mode) {
case GST_PAD_MODE_PUSH:
if (active) { if (active) {
/* All pads start off linked until they push one buffer */ /* All pads start off linked until they push one buffer */
sq->srcresult = GST_FLOW_OK; sq->srcresult = GST_FLOW_OK;
@ -1397,7 +1400,13 @@ gst_multi_queue_sink_activate_push (GstPad * pad, GstObject * parent,
sq->srcresult = GST_FLOW_WRONG_STATE; sq->srcresult = GST_FLOW_WRONG_STATE;
gst_data_queue_flush (sq->queue); gst_data_queue_flush (sq->queue);
} }
return TRUE; res = TRUE;
break;
default:
res = FALSE;
break;
}
return res;
} }
static gboolean static gboolean
@ -1520,18 +1529,20 @@ gst_multi_queue_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
} }
static gboolean static gboolean
gst_multi_queue_src_activate_push (GstPad * pad, GstObject * parent, gst_multi_queue_src_activate_mode (GstPad * pad, GstObject * parent,
gboolean active) GstPadMode mode, gboolean active)
{ {
GstMultiQueue *mq; GstMultiQueue *mq;
GstSingleQueue *sq; GstSingleQueue *sq;
gboolean result = FALSE; gboolean result;
sq = (GstSingleQueue *) gst_pad_get_element_private (pad); sq = (GstSingleQueue *) gst_pad_get_element_private (pad);
mq = sq->mqueue; mq = sq->mqueue;
GST_DEBUG_OBJECT (mq, "SingleQueue %d", sq->id); GST_DEBUG_OBJECT (mq, "SingleQueue %d", sq->id);
switch (mode) {
case GST_PAD_MODE_PUSH:
if (active) { if (active) {
result = gst_single_queue_flush (mq, sq, FALSE); result = gst_single_queue_flush (mq, sq, FALSE);
} else { } else {
@ -1539,6 +1550,11 @@ gst_multi_queue_src_activate_push (GstPad * pad, GstObject * parent,
/* make sure streaming finishes */ /* make sure streaming finishes */
result |= gst_pad_stop_task (pad); result |= gst_pad_stop_task (pad);
} }
break;
default:
result = FALSE;
break;
}
return result; return result;
} }
@ -1899,8 +1915,8 @@ gst_single_queue_new (GstMultiQueue * mqueue, guint id)
gst_pad_set_chain_function (sq->sinkpad, gst_pad_set_chain_function (sq->sinkpad,
GST_DEBUG_FUNCPTR (gst_multi_queue_chain)); GST_DEBUG_FUNCPTR (gst_multi_queue_chain));
gst_pad_set_activatepush_function (sq->sinkpad, gst_pad_set_activatemode_function (sq->sinkpad,
GST_DEBUG_FUNCPTR (gst_multi_queue_sink_activate_push)); GST_DEBUG_FUNCPTR (gst_multi_queue_sink_activate_mode));
gst_pad_set_event_function (sq->sinkpad, gst_pad_set_event_function (sq->sinkpad,
GST_DEBUG_FUNCPTR (gst_multi_queue_sink_event)); GST_DEBUG_FUNCPTR (gst_multi_queue_sink_event));
gst_pad_set_query_function (sq->sinkpad, gst_pad_set_query_function (sq->sinkpad,
@ -1913,8 +1929,8 @@ gst_single_queue_new (GstMultiQueue * mqueue, guint id)
sq->srcpad = gst_pad_new_from_static_template (&srctemplate, name); sq->srcpad = gst_pad_new_from_static_template (&srctemplate, name);
g_free (name); g_free (name);
gst_pad_set_activatepush_function (sq->srcpad, gst_pad_set_activatemode_function (sq->srcpad,
GST_DEBUG_FUNCPTR (gst_multi_queue_src_activate_push)); GST_DEBUG_FUNCPTR (gst_multi_queue_src_activate_mode));
gst_pad_set_event_function (sq->srcpad, gst_pad_set_event_function (sq->srcpad,
GST_DEBUG_FUNCPTR (gst_multi_queue_src_event)); GST_DEBUG_FUNCPTR (gst_multi_queue_src_event));
gst_pad_set_query_function (sq->srcpad, gst_pad_set_query_function (sq->srcpad,

View file

@ -211,10 +211,10 @@ static GstPadLinkReturn gst_queue_link_sink (GstPad * pad, GstPad * peer);
static GstPadLinkReturn gst_queue_link_src (GstPad * pad, GstPad * peer); static GstPadLinkReturn gst_queue_link_src (GstPad * pad, GstPad * peer);
static void gst_queue_locked_flush (GstQueue * queue); static void gst_queue_locked_flush (GstQueue * queue);
static gboolean gst_queue_src_activate_push (GstPad * pad, GstObject * parent, static gboolean gst_queue_src_activate_mode (GstPad * pad, GstObject * parent,
gboolean active); GstPadMode mode, gboolean active);
static gboolean gst_queue_sink_activate_push (GstPad * pad, GstObject * parent, static gboolean gst_queue_sink_activate_mode (GstPad * pad, GstObject * parent,
gboolean active); GstPadMode mode, gboolean active);
static gboolean gst_queue_is_empty (GstQueue * queue); static gboolean gst_queue_is_empty (GstQueue * queue);
static gboolean gst_queue_is_filled (GstQueue * queue); static gboolean gst_queue_is_filled (GstQueue * queue);
@ -373,8 +373,7 @@ gst_queue_class_init (GstQueueClass * klass)
gst_static_pad_template_get (&sinktemplate)); gst_static_pad_template_get (&sinktemplate));
/* Registering debug symbols for function pointers */ /* Registering debug symbols for function pointers */
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_src_activate_push); GST_DEBUG_REGISTER_FUNCPTR (gst_queue_src_activate_mode);
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_sink_activate_push);
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_link_sink); GST_DEBUG_REGISTER_FUNCPTR (gst_queue_link_sink);
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_link_src); GST_DEBUG_REGISTER_FUNCPTR (gst_queue_link_src);
GST_DEBUG_REGISTER_FUNCPTR (gst_queue_handle_sink_event); GST_DEBUG_REGISTER_FUNCPTR (gst_queue_handle_sink_event);
@ -390,8 +389,8 @@ gst_queue_init (GstQueue * queue)
queue->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink"); queue->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink");
gst_pad_set_chain_function (queue->sinkpad, gst_queue_chain); gst_pad_set_chain_function (queue->sinkpad, gst_queue_chain);
gst_pad_set_activatepush_function (queue->sinkpad, gst_pad_set_activatemode_function (queue->sinkpad,
gst_queue_sink_activate_push); gst_queue_sink_activate_mode);
gst_pad_set_event_function (queue->sinkpad, gst_queue_handle_sink_event); 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_query_function (queue->sinkpad, gst_queue_handle_sink_query);
gst_pad_set_link_function (queue->sinkpad, gst_queue_link_sink); gst_pad_set_link_function (queue->sinkpad, gst_queue_link_sink);
@ -399,8 +398,8 @@ gst_queue_init (GstQueue * queue)
queue->srcpad = gst_pad_new_from_static_template (&srctemplate, "src"); queue->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
gst_pad_set_activatepush_function (queue->srcpad, gst_pad_set_activatemode_function (queue->srcpad,
gst_queue_src_activate_push); gst_queue_src_activate_mode);
gst_pad_set_link_function (queue->srcpad, gst_queue_link_src); gst_pad_set_link_function (queue->srcpad, gst_queue_link_src);
gst_pad_set_event_function (queue->srcpad, gst_queue_handle_src_event); gst_pad_set_event_function (queue->srcpad, gst_queue_handle_src_event);
gst_pad_set_query_function (queue->srcpad, gst_queue_handle_src_query); gst_pad_set_query_function (queue->srcpad, gst_queue_handle_src_query);
@ -1283,13 +1282,16 @@ gst_queue_handle_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
} }
static gboolean static gboolean
gst_queue_sink_activate_push (GstPad * pad, GstObject * parent, gboolean active) gst_queue_sink_activate_mode (GstPad * pad, GstObject * parent, GstPadMode mode,
gboolean active)
{ {
gboolean result = TRUE; gboolean result;
GstQueue *queue; GstQueue *queue;
queue = GST_QUEUE (parent); queue = GST_QUEUE (parent);
switch (mode) {
case GST_PAD_MODE_PUSH:
if (active) { if (active) {
GST_QUEUE_MUTEX_LOCK (queue); GST_QUEUE_MUTEX_LOCK (queue);
queue->srcresult = GST_FLOW_OK; queue->srcresult = GST_FLOW_OK;
@ -1303,18 +1305,26 @@ gst_queue_sink_activate_push (GstPad * pad, GstObject * parent, gboolean active)
gst_queue_locked_flush (queue); gst_queue_locked_flush (queue);
GST_QUEUE_MUTEX_UNLOCK (queue); GST_QUEUE_MUTEX_UNLOCK (queue);
} }
result = TRUE;
break;
default:
result = FALSE;
break;
}
return result; return result;
} }
static gboolean static gboolean
gst_queue_src_activate_push (GstPad * pad, GstObject * parent, gboolean active) gst_queue_src_activate_mode (GstPad * pad, GstObject * parent, GstPadMode mode,
gboolean active)
{ {
gboolean result = FALSE; gboolean result;
GstQueue *queue; GstQueue *queue;
queue = GST_QUEUE (parent); queue = GST_QUEUE (parent);
switch (mode) {
case GST_PAD_MODE_PUSH:
if (active) { if (active) {
GST_QUEUE_MUTEX_LOCK (queue); GST_QUEUE_MUTEX_LOCK (queue);
queue->srcresult = GST_FLOW_OK; queue->srcresult = GST_FLOW_OK;
@ -1322,7 +1332,8 @@ gst_queue_src_activate_push (GstPad * pad, GstObject * parent, gboolean active)
queue->unexpected = FALSE; queue->unexpected = FALSE;
/* we do not start the task yet if the pad is not connected */ /* we do not start the task yet if the pad is not connected */
if (gst_pad_is_linked (pad)) if (gst_pad_is_linked (pad))
result = gst_pad_start_task (pad, (GstTaskFunction) gst_queue_loop, pad); result =
gst_pad_start_task (pad, (GstTaskFunction) gst_queue_loop, pad);
else { else {
GST_INFO_OBJECT (queue, "not starting task as pad is not linked"); GST_INFO_OBJECT (queue, "not starting task as pad is not linked");
result = TRUE; result = TRUE;
@ -1339,7 +1350,11 @@ gst_queue_src_activate_push (GstPad * pad, GstObject * parent, gboolean active)
/* step 2, make sure streaming finishes */ /* step 2, make sure streaming finishes */
result = gst_pad_stop_task (pad); result = gst_pad_stop_task (pad);
} }
break;
default:
result = FALSE;
break;
}
return result; return result;
} }

View file

@ -243,12 +243,10 @@ static gboolean gst_queue2_handle_query (GstElement * element,
static GstFlowReturn gst_queue2_get_range (GstPad * pad, GstObject * parent, static GstFlowReturn gst_queue2_get_range (GstPad * pad, GstObject * parent,
guint64 offset, guint length, GstBuffer ** buffer); guint64 offset, guint length, GstBuffer ** buffer);
static gboolean gst_queue2_src_activate_pull (GstPad * pad, GstObject * parent, static gboolean gst_queue2_src_activate_mode (GstPad * pad, GstObject * parent,
gboolean active); GstPadMode mode, gboolean active);
static gboolean gst_queue2_src_activate_push (GstPad * pad, GstObject * parent, static gboolean gst_queue2_sink_activate_mode (GstPad * pad, GstObject * parent,
gboolean active); GstPadMode mode, gboolean active);
static gboolean gst_queue2_sink_activate_push (GstPad * pad, GstObject * parent,
gboolean active);
static GstStateChangeReturn gst_queue2_change_state (GstElement * element, static GstStateChangeReturn gst_queue2_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
@ -381,8 +379,8 @@ gst_queue2_init (GstQueue2 * queue)
gst_pad_set_chain_function (queue->sinkpad, gst_pad_set_chain_function (queue->sinkpad,
GST_DEBUG_FUNCPTR (gst_queue2_chain)); GST_DEBUG_FUNCPTR (gst_queue2_chain));
gst_pad_set_activatepush_function (queue->sinkpad, gst_pad_set_activatemode_function (queue->sinkpad,
GST_DEBUG_FUNCPTR (gst_queue2_sink_activate_push)); GST_DEBUG_FUNCPTR (gst_queue2_sink_activate_mode));
gst_pad_set_event_function (queue->sinkpad, gst_pad_set_event_function (queue->sinkpad,
GST_DEBUG_FUNCPTR (gst_queue2_handle_sink_event)); GST_DEBUG_FUNCPTR (gst_queue2_handle_sink_event));
gst_pad_set_query_function (queue->sinkpad, gst_pad_set_query_function (queue->sinkpad,
@ -392,10 +390,8 @@ gst_queue2_init (GstQueue2 * queue)
queue->srcpad = gst_pad_new_from_static_template (&srctemplate, "src"); queue->srcpad = gst_pad_new_from_static_template (&srctemplate, "src");
gst_pad_set_activatepull_function (queue->srcpad, gst_pad_set_activatemode_function (queue->srcpad,
GST_DEBUG_FUNCPTR (gst_queue2_src_activate_pull)); GST_DEBUG_FUNCPTR (gst_queue2_src_activate_mode));
gst_pad_set_activatepush_function (queue->srcpad,
GST_DEBUG_FUNCPTR (gst_queue2_src_activate_push));
gst_pad_set_getrange_function (queue->srcpad, gst_pad_set_getrange_function (queue->srcpad,
GST_DEBUG_FUNCPTR (gst_queue2_get_range)); GST_DEBUG_FUNCPTR (gst_queue2_get_range));
gst_pad_set_event_function (queue->srcpad, gst_pad_set_event_function (queue->srcpad,
@ -2668,14 +2664,16 @@ out_unexpected:
/* sink currently only operates in push mode */ /* sink currently only operates in push mode */
static gboolean static gboolean
gst_queue2_sink_activate_push (GstPad * pad, GstObject * parent, gst_queue2_sink_activate_mode (GstPad * pad, GstObject * parent,
gboolean active) GstPadMode mode, gboolean active)
{ {
gboolean result = TRUE; gboolean result;
GstQueue2 *queue; GstQueue2 *queue;
queue = GST_QUEUE2 (parent); queue = GST_QUEUE2 (parent);
switch (mode) {
case GST_PAD_MODE_PUSH:
if (active) { if (active) {
GST_QUEUE2_MUTEX_LOCK (queue); GST_QUEUE2_MUTEX_LOCK (queue);
GST_DEBUG_OBJECT (queue, "activating push mode"); GST_DEBUG_OBJECT (queue, "activating push mode");
@ -2694,7 +2692,12 @@ gst_queue2_sink_activate_push (GstPad * pad, GstObject * parent,
gst_queue2_locked_flush (queue); gst_queue2_locked_flush (queue);
GST_QUEUE2_MUTEX_UNLOCK (queue); GST_QUEUE2_MUTEX_UNLOCK (queue);
} }
result = TRUE;
break;
default:
result = FALSE;
break;
}
return result; return result;
} }
@ -2786,6 +2789,27 @@ gst_queue2_src_activate_pull (GstPad * pad, GstObject * parent, gboolean active)
return result; return result;
} }
static gboolean
gst_queue2_src_activate_mode (GstPad * pad, GstObject * parent, GstPadMode mode,
gboolean active)
{
gboolean res;
switch (mode) {
case GST_PAD_MODE_PULL:
res = gst_queue2_src_activate_pull (pad, parent, active);
break;
case GST_PAD_MODE_PUSH:
res = gst_queue2_src_activate_push (pad, parent, active);
break;
default:
GST_LOG_OBJECT (pad, "unknown activation mode %d");
res = FALSE;
break;
}
return res;
}
static GstStateChangeReturn static GstStateChangeReturn
gst_queue2_change_state (GstElement * element, GstStateChange transition) gst_queue2_change_state (GstElement * element, GstStateChange transition)
{ {

View file

@ -144,12 +144,12 @@ static gboolean gst_tee_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event); GstEvent * event);
static gboolean gst_tee_sink_query (GstPad * pad, GstObject * parent, static gboolean gst_tee_sink_query (GstPad * pad, GstObject * parent,
GstQuery * query); GstQuery * query);
static gboolean gst_tee_sink_activate_push (GstPad * pad, GstObject * parent, static gboolean gst_tee_sink_activate_mode (GstPad * pad, GstObject * parent,
gboolean active); GstPadMode mode, gboolean active);
static gboolean gst_tee_src_query (GstPad * pad, GstObject * parent, static gboolean gst_tee_src_query (GstPad * pad, GstObject * parent,
GstQuery * query); GstQuery * query);
static gboolean gst_tee_src_activate_pull (GstPad * pad, GstObject * parent, static gboolean gst_tee_src_activate_mode (GstPad * pad, GstObject * parent,
gboolean active); GstPadMode mode, gboolean active);
static GstFlowReturn gst_tee_src_get_range (GstPad * pad, GstObject * parent, static GstFlowReturn gst_tee_src_get_range (GstPad * pad, GstObject * parent,
guint64 offset, guint length, GstBuffer ** buf); guint64 offset, guint length, GstBuffer ** buf);
@ -258,8 +258,8 @@ gst_tee_init (GstTee * tee)
GST_DEBUG_FUNCPTR (gst_tee_sink_event)); GST_DEBUG_FUNCPTR (gst_tee_sink_event));
gst_pad_set_query_function (tee->sinkpad, gst_pad_set_query_function (tee->sinkpad,
GST_DEBUG_FUNCPTR (gst_tee_sink_query)); GST_DEBUG_FUNCPTR (gst_tee_sink_query));
gst_pad_set_activatepush_function (tee->sinkpad, gst_pad_set_activatemode_function (tee->sinkpad,
GST_DEBUG_FUNCPTR (gst_tee_sink_activate_push)); GST_DEBUG_FUNCPTR (gst_tee_sink_activate_mode));
gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain)); gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain));
gst_pad_set_chain_list_function (tee->sinkpad, gst_pad_set_chain_list_function (tee->sinkpad,
GST_DEBUG_FUNCPTR (gst_tee_chain_list)); GST_DEBUG_FUNCPTR (gst_tee_chain_list));
@ -327,7 +327,7 @@ gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ,
/* we already have a src pad in pull mode, and our pull mode can only be /* we already have a src pad in pull mode, and our pull mode can only be
SINGLE, so fall through to activate this new pad in push mode */ SINGLE, so fall through to activate this new pad in push mode */
case GST_PAD_MODE_PUSH: case GST_PAD_MODE_PUSH:
res = gst_pad_activate_push (srcpad, TRUE); res = gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE);
break; break;
default: default:
res = TRUE; res = TRUE;
@ -337,8 +337,8 @@ gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ,
if (!res) if (!res)
goto activate_failed; goto activate_failed;
gst_pad_set_activatepull_function (srcpad, gst_pad_set_activatemode_function (srcpad,
GST_DEBUG_FUNCPTR (gst_tee_src_activate_pull)); GST_DEBUG_FUNCPTR (gst_tee_src_activate_mode));
gst_pad_set_query_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_src_query)); gst_pad_set_query_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_src_query));
gst_pad_set_getrange_function (srcpad, gst_pad_set_getrange_function (srcpad,
GST_DEBUG_FUNCPTR (gst_tee_src_get_range)); GST_DEBUG_FUNCPTR (gst_tee_src_get_range));
@ -727,20 +727,31 @@ gst_tee_chain_list (GstPad * pad, GstObject * parent, GstBufferList * list)
} }
static gboolean static gboolean
gst_tee_sink_activate_push (GstPad * pad, GstObject * parent, gboolean active) gst_tee_sink_activate_mode (GstPad * pad, GstObject * parent, GstPadMode mode,
gboolean active)
{ {
gboolean res;
GstTee *tee; GstTee *tee;
tee = GST_TEE (parent); tee = GST_TEE (parent);
switch (mode) {
case GST_PAD_MODE_PUSH:
{
GST_OBJECT_LOCK (tee); GST_OBJECT_LOCK (tee);
tee->sink_mode = active && GST_PAD_MODE_PUSH; tee->sink_mode = active ? mode : GST_PAD_MODE_NONE;
if (active && !tee->has_chain) if (active && !tee->has_chain)
goto no_chain; goto no_chain;
GST_OBJECT_UNLOCK (tee); GST_OBJECT_UNLOCK (tee);
res = TRUE;
return TRUE; break;
}
default:
res = FALSE;
break;
}
return res;
/* ERRORS */ /* ERRORS */
no_chain: no_chain:
@ -753,7 +764,8 @@ no_chain:
} }
static gboolean static gboolean
gst_tee_src_activate_pull (GstPad * pad, GstObject * parent, gboolean active) gst_tee_src_activate_mode (GstPad * pad, GstObject * parent, GstPadMode mode,
gboolean active)
{ {
GstTee *tee; GstTee *tee;
gboolean res; gboolean res;
@ -761,6 +773,9 @@ gst_tee_src_activate_pull (GstPad * pad, GstObject * parent, gboolean active)
tee = GST_TEE (parent); tee = GST_TEE (parent);
switch (mode) {
case GST_PAD_MODE_PULL:
{
GST_OBJECT_LOCK (tee); GST_OBJECT_LOCK (tee);
if (tee->pull_mode == GST_TEE_PULL_MODE_NEVER) if (tee->pull_mode == GST_TEE_PULL_MODE_NEVER)
@ -773,7 +788,7 @@ gst_tee_src_activate_pull (GstPad * pad, GstObject * parent, gboolean active)
GST_OBJECT_UNLOCK (tee); GST_OBJECT_UNLOCK (tee);
res = gst_pad_activate_pull (sinkpad, active); res = gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, active);
gst_object_unref (sinkpad); gst_object_unref (sinkpad);
if (!res) if (!res)
@ -789,7 +804,12 @@ gst_tee_src_activate_pull (GstPad * pad, GstObject * parent, gboolean active)
} }
tee->sink_mode = active & GST_PAD_MODE_PULL; tee->sink_mode = active & GST_PAD_MODE_PULL;
GST_OBJECT_UNLOCK (tee); GST_OBJECT_UNLOCK (tee);
break;
}
default:
res = TRUE;
break;
}
return res; return res;
/* ERRORS */ /* ERRORS */

View file

@ -159,8 +159,8 @@ gst_type_find_element_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
static gboolean gst_type_find_element_activate (GstPad * pad, static gboolean gst_type_find_element_activate (GstPad * pad,
GstObject * parent); GstObject * parent);
static gboolean gst_type_find_element_activate_src_pull (GstPad * pad, static gboolean gst_type_find_element_activate_src_mode (GstPad * pad,
GstObject * parent, gboolean active); GstObject * parent, GstPadMode mode, gboolean active);
static GstFlowReturn static GstFlowReturn
gst_type_find_element_chain_do_typefinding (GstTypeFindElement * typefind, gst_type_find_element_chain_do_typefinding (GstTypeFindElement * typefind,
gboolean check_avail); gboolean check_avail);
@ -271,8 +271,8 @@ gst_type_find_element_init (GstTypeFindElement * typefind)
typefind->src = typefind->src =
gst_pad_new_from_static_template (&type_find_element_src_template, "src"); gst_pad_new_from_static_template (&type_find_element_src_template, "src");
gst_pad_set_activatepull_function (typefind->src, gst_pad_set_activatemode_function (typefind->src,
GST_DEBUG_FUNCPTR (gst_type_find_element_activate_src_pull)); GST_DEBUG_FUNCPTR (gst_type_find_element_activate_src_mode));
gst_pad_set_getrange_function (typefind->src, gst_pad_set_getrange_function (typefind->src,
GST_DEBUG_FUNCPTR (gst_type_find_element_getrange)); GST_DEBUG_FUNCPTR (gst_type_find_element_getrange));
gst_pad_set_event_function (typefind->src, gst_pad_set_event_function (typefind->src,
@ -872,14 +872,23 @@ gst_type_find_element_getrange (GstPad * srcpad, GstObject * parent,
} }
static gboolean static gboolean
gst_type_find_element_activate_src_pull (GstPad * pad, GstObject * parent, gst_type_find_element_activate_src_mode (GstPad * pad, GstObject * parent,
gboolean active) GstPadMode mode, gboolean active)
{ {
gboolean res;
GstTypeFindElement *typefind; GstTypeFindElement *typefind;
typefind = GST_TYPE_FIND_ELEMENT (parent); typefind = GST_TYPE_FIND_ELEMENT (parent);
return gst_pad_activate_pull (typefind->sink, active); switch (mode) {
case GST_PAD_MODE_PULL:
res = gst_pad_activate_mode (typefind->sink, mode, active);
break;
default:
res = TRUE;
break;
}
return res;
} }
static gboolean static gboolean
@ -929,7 +938,7 @@ gst_type_find_element_activate (GstPad * pad, GstObject * parent)
if (!pull_mode) if (!pull_mode)
goto typefind_push; goto typefind_push;
if (!gst_pad_activate_pull (pad, TRUE)) if (!gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE))
goto typefind_push; goto typefind_push;
/* 2 */ /* 2 */
@ -946,7 +955,7 @@ gst_type_find_element_activate (GstPad * pad, GstObject * parent)
if (!gst_pad_query_duration (peer, GST_FORMAT_BYTES, &size)) { if (!gst_pad_query_duration (peer, GST_FORMAT_BYTES, &size)) {
GST_WARNING_OBJECT (typefind, "Could not query upstream length!"); GST_WARNING_OBJECT (typefind, "Could not query upstream length!");
gst_object_unref (peer); gst_object_unref (peer);
gst_pad_activate_pull (pad, FALSE); gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, FALSE);
return FALSE; return FALSE;
} }
@ -956,7 +965,7 @@ gst_type_find_element_activate (GstPad * pad, GstObject * parent)
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND,
(_("Stream contains no data.")), ("Can't typefind empty stream")); (_("Stream contains no data.")), ("Can't typefind empty stream"));
gst_object_unref (peer); gst_object_unref (peer);
gst_pad_activate_pull (pad, FALSE); gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, FALSE);
return FALSE; return FALSE;
} }
ext = gst_type_find_get_extension (typefind, pad); ext = gst_type_find_get_extension (typefind, pad);
@ -989,12 +998,12 @@ gst_type_find_element_activate (GstPad * pad, GstObject * parent)
/* 3 */ /* 3 */
GST_DEBUG ("Deactivate pull mode"); GST_DEBUG ("Deactivate pull mode");
gst_pad_activate_pull (pad, FALSE); gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, FALSE);
#if 0 #if 0
/* 4 */ /* 4 */
GST_DEBUG ("Deactivate push mode mode"); GST_DEBUG ("Deactivate push mode mode");
gst_pad_activate_push (typefind->src, FALSE); gst_pad_activate_mode (typefind->src, GST_PAD_MODE_PUSH, FALSE);
#endif #endif
/* 5 */ /* 5 */
@ -1027,14 +1036,14 @@ really_done:
gboolean ret; gboolean ret;
GST_DEBUG ("Activating in push mode"); GST_DEBUG ("Activating in push mode");
ret = gst_pad_activate_push (typefind->src, TRUE); ret = gst_pad_activate_mode (typefind->src, GST_PAD_MODE_PUSH, TRUE);
ret &= gst_pad_activate_push (pad, TRUE); ret &= gst_pad_activate_mode (pad, GST_PAD_MODE_PUSH, TRUE);
return ret; return ret;
} }
typefind_push: typefind_push:
{ {
start_typefinding (typefind); start_typefinding (typefind);
return gst_pad_activate_push (pad, TRUE); return gst_pad_activate_mode (pad, GST_PAD_MODE_PUSH, TRUE);
} }
} }

View file

@ -186,7 +186,7 @@ GST_START_TEST (test_pull)
fail_unless (pad != NULL); fail_unless (pad != NULL);
/* activate the pad in pull mode */ /* activate the pad in pull mode */
res = gst_pad_activate_pull (pad, TRUE); res = gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE);
fail_unless (res == TRUE); fail_unless (res == TRUE);
/* not start playing */ /* not start playing */