gst/: Added start/stop methods to transform base class so subclasses don't need to deal with state changes even.

Original commit message from CVS:
* gst/base/gstbasetransform.c: (gst_base_transform_base_init),
(gst_base_transform_class_init), (gst_base_transform_init),
(gst_base_transform_setcaps), (gst_base_transform_handle_buffer),
(gst_base_transform_get_property),
(gst_base_transform_sink_activate),
(gst_base_transform_src_activate),
(gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/elements/gstidentity.c: (gst_identity_class_init),
(gst_identity_event), (gst_identity_check_perfect),
(gst_identity_transform), (gst_identity_start),
(gst_identity_stop):
Added start/stop methods to transform base class so subclasses
don't need to deal with state changes even.
This commit is contained in:
Wim Taymans 2005-03-31 10:10:55 +00:00
parent 768037487d
commit 96d17a3410
7 changed files with 95 additions and 94 deletions

View file

@ -1,3 +1,20 @@
2005-03-31 Wim Taymans <wim@fluendo.com>
* gst/base/gstbasetransform.c: (gst_base_transform_base_init),
(gst_base_transform_class_init), (gst_base_transform_init),
(gst_base_transform_setcaps), (gst_base_transform_handle_buffer),
(gst_base_transform_get_property),
(gst_base_transform_sink_activate),
(gst_base_transform_src_activate),
(gst_base_transform_change_state):
* gst/base/gstbasetransform.h:
* gst/elements/gstidentity.c: (gst_identity_class_init),
(gst_identity_event), (gst_identity_check_perfect),
(gst_identity_transform), (gst_identity_start),
(gst_identity_stop):
Added start/stop methods to transform base class so subclasses
don't need to deal with state changes even.
2005-03-31 Wim Taymans <wim@fluendo.com>
* gst/gstevent.c: (gst_event_new_discontinuous_valist),

View file

@ -324,22 +324,23 @@ gst_base_transform_get_property (GObject * object, guint prop_id,
static gboolean
gst_base_transform_sink_activate (GstPad * pad, GstActivateMode mode)
{
gboolean result = FALSE;
gboolean result = TRUE;
GstBaseTransform *trans;
GstBaseTransformClass *bclass;
trans = GST_BASE_TRANSFORM (GST_OBJECT_PARENT (pad));
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
switch (mode) {
case GST_ACTIVATE_PUSH:
result = TRUE;
break;
case GST_ACTIVATE_PULL:
result = TRUE;
if (bclass->start)
result = bclass->start (trans);
break;
case GST_ACTIVATE_NONE:
result = TRUE;
break;
}
return result;
}
@ -370,10 +371,13 @@ static GstElementStateReturn
gst_base_transform_change_state (GstElement * element)
{
GstBaseTransform *trans;
GstBaseTransformClass *bclass;
GstElementState transition;
GstElementStateReturn result;
trans = GST_BASE_TRANSFORM (element);
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
transition = GST_STATE_TRANSITION (element);
switch (transition) {
@ -393,6 +397,8 @@ gst_base_transform_change_state (GstElement * element)
case GST_STATE_PLAYING_TO_PAUSED:
break;
case GST_STATE_PAUSED_TO_READY:
if (bclass->stop)
result = bclass->stop (trans);
break;
case GST_STATE_READY_TO_NULL:
break;

View file

@ -56,6 +56,9 @@ struct _GstBaseTransformClass {
gboolean (*set_caps) (GstBaseTransform *trans, GstCaps *caps);
gboolean (*start) (GstBaseTransform *trans);
gboolean (*stop) (GstBaseTransform *trans);
gboolean (*event) (GstBaseTransform *trans, GstEvent *event);
GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf, GstBuffer **outbuf);
};

View file

@ -96,11 +96,12 @@ static void gst_identity_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_identity_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstElementStateReturn gst_identity_change_state (GstElement * element);
static gboolean gst_identity_event (GstBaseTransform * trans, GstEvent * event);
static GstFlowReturn gst_identity_transform (GstBaseTransform * trans,
GstBuffer * inbuf, GstBuffer ** outbuf);
static gboolean gst_identity_start (GstBaseTransform * trans);
static gboolean gst_identity_stop (GstBaseTransform * trans);
static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
@ -186,11 +187,10 @@ gst_identity_class_init (GstIdentityClass * klass)
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_identity_finalize);
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_identity_change_state);
gstbasetrans_class->event = GST_DEBUG_FUNCPTR (gst_identity_event);
gstbasetrans_class->transform = GST_DEBUG_FUNCPTR (gst_identity_transform);
gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_identity_start);
gstbasetrans_class->stop = GST_DEBUG_FUNCPTR (gst_identity_stop);
}
static void
@ -443,47 +443,30 @@ gst_identity_get_property (GObject * object, guint prop_id, GValue * value,
}
}
static GstElementStateReturn
gst_identity_change_state (GstElement * element)
static gboolean
gst_identity_start (GstBaseTransform * trans)
{
GstIdentity *identity;
GstElementState transition;
GstElementStateReturn result;
g_return_val_if_fail (GST_IS_IDENTITY (element), GST_STATE_FAILURE);
identity = GST_IDENTITY (trans);
identity = GST_IDENTITY (element);
transition = GST_STATE_TRANSITION (element);
identity->offset = 0;
identity->prev_timestamp = GST_CLOCK_TIME_NONE;
identity->prev_duration = GST_CLOCK_TIME_NONE;
identity->prev_offset_end = -1;
switch (transition) {
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
identity->offset = 0;
identity->prev_timestamp = GST_CLOCK_TIME_NONE;
identity->prev_duration = GST_CLOCK_TIME_NONE;
identity->prev_offset_end = -1;
break;
case GST_STATE_PAUSED_TO_PLAYING:
break;
default:
break;
}
result = GST_ELEMENT_CLASS (parent_class)->change_state (element);
switch (transition) {
case GST_STATE_PLAYING_TO_PAUSED:
break;
case GST_STATE_PAUSED_TO_READY:
g_free (identity->last_message);
identity->last_message = NULL;
break;
case GST_STATE_READY_TO_NULL:
break;
default:
break;
}
return result;
return TRUE;
}
static gboolean
gst_identity_stop (GstBaseTransform * trans)
{
GstIdentity *identity;
identity = GST_IDENTITY (trans);
g_free (identity->last_message);
identity->last_message = NULL;
return TRUE;
}

View file

@ -324,22 +324,23 @@ gst_base_transform_get_property (GObject * object, guint prop_id,
static gboolean
gst_base_transform_sink_activate (GstPad * pad, GstActivateMode mode)
{
gboolean result = FALSE;
gboolean result = TRUE;
GstBaseTransform *trans;
GstBaseTransformClass *bclass;
trans = GST_BASE_TRANSFORM (GST_OBJECT_PARENT (pad));
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
switch (mode) {
case GST_ACTIVATE_PUSH:
result = TRUE;
break;
case GST_ACTIVATE_PULL:
result = TRUE;
if (bclass->start)
result = bclass->start (trans);
break;
case GST_ACTIVATE_NONE:
result = TRUE;
break;
}
return result;
}
@ -370,10 +371,13 @@ static GstElementStateReturn
gst_base_transform_change_state (GstElement * element)
{
GstBaseTransform *trans;
GstBaseTransformClass *bclass;
GstElementState transition;
GstElementStateReturn result;
trans = GST_BASE_TRANSFORM (element);
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
transition = GST_STATE_TRANSITION (element);
switch (transition) {
@ -393,6 +397,8 @@ gst_base_transform_change_state (GstElement * element)
case GST_STATE_PLAYING_TO_PAUSED:
break;
case GST_STATE_PAUSED_TO_READY:
if (bclass->stop)
result = bclass->stop (trans);
break;
case GST_STATE_READY_TO_NULL:
break;

View file

@ -56,6 +56,9 @@ struct _GstBaseTransformClass {
gboolean (*set_caps) (GstBaseTransform *trans, GstCaps *caps);
gboolean (*start) (GstBaseTransform *trans);
gboolean (*stop) (GstBaseTransform *trans);
gboolean (*event) (GstBaseTransform *trans, GstEvent *event);
GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf, GstBuffer **outbuf);
};

View file

@ -96,11 +96,12 @@ static void gst_identity_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_identity_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstElementStateReturn gst_identity_change_state (GstElement * element);
static gboolean gst_identity_event (GstBaseTransform * trans, GstEvent * event);
static GstFlowReturn gst_identity_transform (GstBaseTransform * trans,
GstBuffer * inbuf, GstBuffer ** outbuf);
static gboolean gst_identity_start (GstBaseTransform * trans);
static gboolean gst_identity_stop (GstBaseTransform * trans);
static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
@ -186,11 +187,10 @@ gst_identity_class_init (GstIdentityClass * klass)
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_identity_finalize);
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_identity_change_state);
gstbasetrans_class->event = GST_DEBUG_FUNCPTR (gst_identity_event);
gstbasetrans_class->transform = GST_DEBUG_FUNCPTR (gst_identity_transform);
gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_identity_start);
gstbasetrans_class->stop = GST_DEBUG_FUNCPTR (gst_identity_stop);
}
static void
@ -443,47 +443,30 @@ gst_identity_get_property (GObject * object, guint prop_id, GValue * value,
}
}
static GstElementStateReturn
gst_identity_change_state (GstElement * element)
static gboolean
gst_identity_start (GstBaseTransform * trans)
{
GstIdentity *identity;
GstElementState transition;
GstElementStateReturn result;
g_return_val_if_fail (GST_IS_IDENTITY (element), GST_STATE_FAILURE);
identity = GST_IDENTITY (trans);
identity = GST_IDENTITY (element);
transition = GST_STATE_TRANSITION (element);
identity->offset = 0;
identity->prev_timestamp = GST_CLOCK_TIME_NONE;
identity->prev_duration = GST_CLOCK_TIME_NONE;
identity->prev_offset_end = -1;
switch (transition) {
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
identity->offset = 0;
identity->prev_timestamp = GST_CLOCK_TIME_NONE;
identity->prev_duration = GST_CLOCK_TIME_NONE;
identity->prev_offset_end = -1;
break;
case GST_STATE_PAUSED_TO_PLAYING:
break;
default:
break;
}
result = GST_ELEMENT_CLASS (parent_class)->change_state (element);
switch (transition) {
case GST_STATE_PLAYING_TO_PAUSED:
break;
case GST_STATE_PAUSED_TO_READY:
g_free (identity->last_message);
identity->last_message = NULL;
break;
case GST_STATE_READY_TO_NULL:
break;
default:
break;
}
return result;
return TRUE;
}
static gboolean
gst_identity_stop (GstBaseTransform * trans)
{
GstIdentity *identity;
identity = GST_IDENTITY (trans);
g_free (identity->last_message);
identity->last_message = NULL;
return TRUE;
}