libs/gst/base/gstbasetransform.c (gst_base_transform_activate): Factor start/stop into this private function instead ...

Original commit message from CVS:
2007-01-12  Andy Wingo  <wingo@pobox.com>

* libs/gst/base/gstbasetransform.c (gst_base_transform_activate):
Factor start/stop into this private function instead of partially
in activate functions and partially in the change_state function.
Fixes setup before the element has changed from READY->PAUSED, as
is the case in pull-mode pipelines.
(gst_base_transform_sink_activate_push)
(gst_base_transform_src_activate_pull): Refactor to use
gst_base_transform_activate().
(gst_base_transform_change_state): Removed, not needed any more.

* libs/gst/base/gstbasesink.c (gst_base_sink_negotiate_pull):
Truncate before fixating.
This commit is contained in:
Andy Wingo 2007-01-12 21:13:32 +00:00
parent 5cd94e7afc
commit 3482d79879
3 changed files with 72 additions and 92 deletions

View file

@ -1,11 +1,24 @@
2007-01-12 Andy Wingo <wingo@pobox.com>
* libs/gst/base/gstbasetransform.c (gst_base_transform_activate):
Factor start/stop into this private function instead of partially
in activate functions and partially in the change_state function.
Fixes setup before the element has changed from READY->PAUSED, as
is the case in pull-mode pipelines.
(gst_base_transform_sink_activate_push)
(gst_base_transform_src_activate_pull): Refactor to use
gst_base_transform_activate().
(gst_base_transform_change_state): Removed, not needed any more.
* libs/gst/base/gstbasesink.c (gst_base_sink_negotiate_pull):
Truncate before fixating.
* libs/gst/base/gstbasesink.c (gst_base_sink_negotiate_pull):
Don't set_caps() if the result of fixating is ANY, as it's not
supported, and not necessary in the case of a link with no
template caps on either side. Fixes tests/check/libs/basesrc in
some pull-mode tests.
* libs/gst/base/gstbasetransform.c (_GstBaseTransformPrivate):
(gst_base_transform_init, gst_base_transform_sink_activate_push)
(gst_base_transform_src_activate_pull):

View file

@ -2249,6 +2249,7 @@ gst_base_sink_negotiate_pull (GstBaseSink * basesink)
goto no_caps_possible;
caps = gst_caps_make_writable (caps);
gst_caps_truncate (caps);
gst_pad_fixate_caps (pad, caps);
if (gst_caps_is_any (caps)) {

View file

@ -276,12 +276,11 @@ static gboolean gst_base_transform_src_activate_pull (GstPad * pad,
gboolean active);
static gboolean gst_base_transform_sink_activate_push (GstPad * pad,
gboolean active);
static gboolean gst_base_transform_activate (GstBaseTransform * trans,
gboolean active);
static gboolean gst_base_transform_get_unit_size (GstBaseTransform * trans,
GstCaps * caps, guint * size);
static GstStateChangeReturn gst_base_transform_change_state (GstElement *
element, GstStateChange transition);
static gboolean gst_base_transform_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_base_transform_src_eventfunc (GstBaseTransform * trans,
GstEvent * event);
@ -322,10 +321,8 @@ static void
gst_base_transform_class_init (GstBaseTransformClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = G_OBJECT_CLASS (klass);
gstelement_class = GST_ELEMENT_CLASS (klass);
g_type_class_add_private (klass, sizeof (GstBaseTransformPrivate));
@ -342,9 +339,6 @@ gst_base_transform_class_init (GstBaseTransformClass * klass)
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_base_transform_finalize);
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_base_transform_change_state);
klass->passthrough_on_same_caps = FALSE;
klass->event = GST_DEBUG_FUNCPTR (gst_base_transform_sink_eventfunc);
klass->src_event = GST_DEBUG_FUNCPTR (gst_base_transform_src_eventfunc);
@ -1602,24 +1596,64 @@ gst_base_transform_get_property (GObject * object, guint prop_id,
}
}
/* not a vmethod of anything, just an internal method */
static gboolean
gst_base_transform_activate (GstBaseTransform * trans, gboolean active)
{
GstBaseTransformClass *bclass;
gboolean result = TRUE;
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
if (active) {
if (trans->priv->pad_mode == GST_ACTIVATE_NONE && bclass->start)
result &= bclass->start (trans);
GST_OBJECT_LOCK (trans);
if (GST_PAD_CAPS (trans->sinkpad) && GST_PAD_CAPS (trans->srcpad))
trans->have_same_caps =
gst_caps_is_equal (GST_PAD_CAPS (trans->sinkpad),
GST_PAD_CAPS (trans->srcpad)) || trans->passthrough;
else
trans->have_same_caps = trans->passthrough;
GST_DEBUG_OBJECT (trans, "have_same_caps %d", trans->have_same_caps);
trans->negotiated = FALSE;
trans->have_newsegment = FALSE;
gst_segment_init (&trans->segment, GST_FORMAT_UNDEFINED);
trans->priv->proportion = 1.0;
trans->priv->earliest_time = -1;
GST_OBJECT_UNLOCK (trans);
} else {
trans->have_same_caps = FALSE;
/* We can only reset the passthrough mode if the instance told us to
handle it in configure_caps */
if (bclass->passthrough_on_same_caps) {
gst_base_transform_set_passthrough (trans, FALSE);
}
gst_caps_replace (&trans->cache_caps1, NULL);
gst_caps_replace (&trans->cache_caps2, NULL);
if (trans->priv->pad_mode != GST_ACTIVATE_NONE && bclass->stop)
result &= bclass->stop (trans);
}
return result;
}
static gboolean
gst_base_transform_sink_activate_push (GstPad * pad, gboolean active)
{
gboolean result = TRUE;
GstBaseTransform *trans;
GstBaseTransformClass *bclass;
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
if (active) {
if (bclass->start)
result = bclass->start (trans);
if (result)
trans->priv->pad_mode = GST_ACTIVATE_PUSH;
} else {
trans->priv->pad_mode = GST_ACTIVATE_NONE;
}
result = gst_base_transform_activate (trans, active);
if (result)
trans->priv->pad_mode = active ? GST_ACTIVATE_PUSH : GST_ACTIVATE_NONE;
gst_object_unref (trans);
@ -1631,90 +1665,22 @@ gst_base_transform_src_activate_pull (GstPad * pad, gboolean active)
{
gboolean result = FALSE;
GstBaseTransform *trans;
GstBaseTransformClass *bclass;
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
result = gst_pad_activate_pull (trans->sinkpad, active);
if (active) {
if (result && bclass->start)
result &= bclass->start (trans);
if (result)
trans->priv->pad_mode = GST_ACTIVATE_PULL;
} else {
trans->priv->pad_mode = GST_ACTIVATE_NONE;
}
if (result)
result &= gst_base_transform_activate (trans, active);
if (result)
trans->priv->pad_mode = active ? GST_ACTIVATE_PULL : GST_ACTIVATE_NONE;
gst_object_unref (trans);
return result;
}
static GstStateChangeReturn
gst_base_transform_change_state (GstElement * element,
GstStateChange transition)
{
GstBaseTransform *trans;
GstBaseTransformClass *bclass;
GstStateChangeReturn result;
trans = GST_BASE_TRANSFORM (element);
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
GST_OBJECT_LOCK (trans);
if (GST_PAD_CAPS (trans->sinkpad) && GST_PAD_CAPS (trans->srcpad))
trans->have_same_caps =
gst_caps_is_equal (GST_PAD_CAPS (trans->sinkpad),
GST_PAD_CAPS (trans->srcpad)) || trans->passthrough;
else
trans->have_same_caps = trans->passthrough;
GST_DEBUG_OBJECT (trans, "have_same_caps %d", trans->have_same_caps);
trans->negotiated = FALSE;
trans->have_newsegment = FALSE;
gst_segment_init (&trans->segment, GST_FORMAT_UNDEFINED);
trans->priv->proportion = 1.0;
trans->priv->earliest_time = -1;
GST_OBJECT_UNLOCK (trans);
break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break;
default:
break;
}
result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
trans->have_same_caps = FALSE;
/* We can only reset the passthrough mode if the instance told us to
handle it in configure_caps */
if (bclass->passthrough_on_same_caps) {
gst_base_transform_set_passthrough (trans, FALSE);
}
gst_caps_replace (&trans->cache_caps1, NULL);
gst_caps_replace (&trans->cache_caps2, NULL);
if (bclass->stop)
result = bclass->stop (trans);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
}
return result;
}
/**
* gst_base_transform_set_passthrough:
* @trans: the #GstBaseTransform to set