mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 23:18:52 +00:00
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:
parent
768037487d
commit
96d17a3410
7 changed files with 95 additions and 94 deletions
17
ChangeLog
17
ChangeLog
|
@ -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>
|
2005-03-31 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
|
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
|
||||||
|
|
|
@ -324,22 +324,23 @@ gst_base_transform_get_property (GObject * object, guint prop_id,
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_base_transform_sink_activate (GstPad * pad, GstActivateMode mode)
|
gst_base_transform_sink_activate (GstPad * pad, GstActivateMode mode)
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result = TRUE;
|
||||||
GstBaseTransform *trans;
|
GstBaseTransform *trans;
|
||||||
|
GstBaseTransformClass *bclass;
|
||||||
|
|
||||||
trans = GST_BASE_TRANSFORM (GST_OBJECT_PARENT (pad));
|
trans = GST_BASE_TRANSFORM (GST_OBJECT_PARENT (pad));
|
||||||
|
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case GST_ACTIVATE_PUSH:
|
case GST_ACTIVATE_PUSH:
|
||||||
result = TRUE;
|
|
||||||
break;
|
|
||||||
case GST_ACTIVATE_PULL:
|
case GST_ACTIVATE_PULL:
|
||||||
result = TRUE;
|
if (bclass->start)
|
||||||
|
result = bclass->start (trans);
|
||||||
break;
|
break;
|
||||||
case GST_ACTIVATE_NONE:
|
case GST_ACTIVATE_NONE:
|
||||||
result = TRUE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,10 +371,13 @@ static GstElementStateReturn
|
||||||
gst_base_transform_change_state (GstElement * element)
|
gst_base_transform_change_state (GstElement * element)
|
||||||
{
|
{
|
||||||
GstBaseTransform *trans;
|
GstBaseTransform *trans;
|
||||||
|
GstBaseTransformClass *bclass;
|
||||||
GstElementState transition;
|
GstElementState transition;
|
||||||
GstElementStateReturn result;
|
GstElementStateReturn result;
|
||||||
|
|
||||||
trans = GST_BASE_TRANSFORM (element);
|
trans = GST_BASE_TRANSFORM (element);
|
||||||
|
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
|
||||||
|
|
||||||
transition = GST_STATE_TRANSITION (element);
|
transition = GST_STATE_TRANSITION (element);
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
|
@ -393,6 +397,8 @@ gst_base_transform_change_state (GstElement * element)
|
||||||
case GST_STATE_PLAYING_TO_PAUSED:
|
case GST_STATE_PLAYING_TO_PAUSED:
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED_TO_READY:
|
case GST_STATE_PAUSED_TO_READY:
|
||||||
|
if (bclass->stop)
|
||||||
|
result = bclass->stop (trans);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_READY_TO_NULL:
|
case GST_STATE_READY_TO_NULL:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -56,6 +56,9 @@ struct _GstBaseTransformClass {
|
||||||
|
|
||||||
gboolean (*set_caps) (GstBaseTransform *trans, GstCaps *caps);
|
gboolean (*set_caps) (GstBaseTransform *trans, GstCaps *caps);
|
||||||
|
|
||||||
|
gboolean (*start) (GstBaseTransform *trans);
|
||||||
|
gboolean (*stop) (GstBaseTransform *trans);
|
||||||
|
|
||||||
gboolean (*event) (GstBaseTransform *trans, GstEvent *event);
|
gboolean (*event) (GstBaseTransform *trans, GstEvent *event);
|
||||||
GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf, GstBuffer **outbuf);
|
GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf, GstBuffer **outbuf);
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,11 +96,12 @@ static void gst_identity_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_identity_get_property (GObject * object, guint prop_id,
|
static void gst_identity_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
static GstElementStateReturn gst_identity_change_state (GstElement * element);
|
|
||||||
|
|
||||||
static gboolean gst_identity_event (GstBaseTransform * trans, GstEvent * event);
|
static gboolean gst_identity_event (GstBaseTransform * trans, GstEvent * event);
|
||||||
static GstFlowReturn gst_identity_transform (GstBaseTransform * trans,
|
static GstFlowReturn gst_identity_transform (GstBaseTransform * trans,
|
||||||
GstBuffer * inbuf, GstBuffer ** outbuf);
|
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 };
|
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);
|
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->event = GST_DEBUG_FUNCPTR (gst_identity_event);
|
||||||
gstbasetrans_class->transform = GST_DEBUG_FUNCPTR (gst_identity_transform);
|
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
|
static void
|
||||||
|
@ -443,47 +443,30 @@ gst_identity_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstElementStateReturn
|
static gboolean
|
||||||
gst_identity_change_state (GstElement * element)
|
gst_identity_start (GstBaseTransform * trans)
|
||||||
{
|
{
|
||||||
GstIdentity *identity;
|
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);
|
|
||||||
|
|
||||||
switch (transition) {
|
|
||||||
case GST_STATE_NULL_TO_READY:
|
|
||||||
break;
|
|
||||||
case GST_STATE_READY_TO_PAUSED:
|
|
||||||
identity->offset = 0;
|
identity->offset = 0;
|
||||||
identity->prev_timestamp = GST_CLOCK_TIME_NONE;
|
identity->prev_timestamp = GST_CLOCK_TIME_NONE;
|
||||||
identity->prev_duration = GST_CLOCK_TIME_NONE;
|
identity->prev_duration = GST_CLOCK_TIME_NONE;
|
||||||
identity->prev_offset_end = -1;
|
identity->prev_offset_end = -1;
|
||||||
break;
|
|
||||||
case GST_STATE_PAUSED_TO_PLAYING:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_identity_stop (GstBaseTransform * trans)
|
||||||
|
{
|
||||||
|
GstIdentity *identity;
|
||||||
|
|
||||||
|
identity = GST_IDENTITY (trans);
|
||||||
|
|
||||||
switch (transition) {
|
|
||||||
case GST_STATE_PLAYING_TO_PAUSED:
|
|
||||||
break;
|
|
||||||
case GST_STATE_PAUSED_TO_READY:
|
|
||||||
g_free (identity->last_message);
|
g_free (identity->last_message);
|
||||||
identity->last_message = NULL;
|
identity->last_message = NULL;
|
||||||
break;
|
|
||||||
case GST_STATE_READY_TO_NULL:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,22 +324,23 @@ gst_base_transform_get_property (GObject * object, guint prop_id,
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_base_transform_sink_activate (GstPad * pad, GstActivateMode mode)
|
gst_base_transform_sink_activate (GstPad * pad, GstActivateMode mode)
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result = TRUE;
|
||||||
GstBaseTransform *trans;
|
GstBaseTransform *trans;
|
||||||
|
GstBaseTransformClass *bclass;
|
||||||
|
|
||||||
trans = GST_BASE_TRANSFORM (GST_OBJECT_PARENT (pad));
|
trans = GST_BASE_TRANSFORM (GST_OBJECT_PARENT (pad));
|
||||||
|
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case GST_ACTIVATE_PUSH:
|
case GST_ACTIVATE_PUSH:
|
||||||
result = TRUE;
|
|
||||||
break;
|
|
||||||
case GST_ACTIVATE_PULL:
|
case GST_ACTIVATE_PULL:
|
||||||
result = TRUE;
|
if (bclass->start)
|
||||||
|
result = bclass->start (trans);
|
||||||
break;
|
break;
|
||||||
case GST_ACTIVATE_NONE:
|
case GST_ACTIVATE_NONE:
|
||||||
result = TRUE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,10 +371,13 @@ static GstElementStateReturn
|
||||||
gst_base_transform_change_state (GstElement * element)
|
gst_base_transform_change_state (GstElement * element)
|
||||||
{
|
{
|
||||||
GstBaseTransform *trans;
|
GstBaseTransform *trans;
|
||||||
|
GstBaseTransformClass *bclass;
|
||||||
GstElementState transition;
|
GstElementState transition;
|
||||||
GstElementStateReturn result;
|
GstElementStateReturn result;
|
||||||
|
|
||||||
trans = GST_BASE_TRANSFORM (element);
|
trans = GST_BASE_TRANSFORM (element);
|
||||||
|
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
|
||||||
|
|
||||||
transition = GST_STATE_TRANSITION (element);
|
transition = GST_STATE_TRANSITION (element);
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
|
@ -393,6 +397,8 @@ gst_base_transform_change_state (GstElement * element)
|
||||||
case GST_STATE_PLAYING_TO_PAUSED:
|
case GST_STATE_PLAYING_TO_PAUSED:
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED_TO_READY:
|
case GST_STATE_PAUSED_TO_READY:
|
||||||
|
if (bclass->stop)
|
||||||
|
result = bclass->stop (trans);
|
||||||
break;
|
break;
|
||||||
case GST_STATE_READY_TO_NULL:
|
case GST_STATE_READY_TO_NULL:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -56,6 +56,9 @@ struct _GstBaseTransformClass {
|
||||||
|
|
||||||
gboolean (*set_caps) (GstBaseTransform *trans, GstCaps *caps);
|
gboolean (*set_caps) (GstBaseTransform *trans, GstCaps *caps);
|
||||||
|
|
||||||
|
gboolean (*start) (GstBaseTransform *trans);
|
||||||
|
gboolean (*stop) (GstBaseTransform *trans);
|
||||||
|
|
||||||
gboolean (*event) (GstBaseTransform *trans, GstEvent *event);
|
gboolean (*event) (GstBaseTransform *trans, GstEvent *event);
|
||||||
GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf, GstBuffer **outbuf);
|
GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf, GstBuffer **outbuf);
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,11 +96,12 @@ static void gst_identity_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_identity_get_property (GObject * object, guint prop_id,
|
static void gst_identity_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
static GstElementStateReturn gst_identity_change_state (GstElement * element);
|
|
||||||
|
|
||||||
static gboolean gst_identity_event (GstBaseTransform * trans, GstEvent * event);
|
static gboolean gst_identity_event (GstBaseTransform * trans, GstEvent * event);
|
||||||
static GstFlowReturn gst_identity_transform (GstBaseTransform * trans,
|
static GstFlowReturn gst_identity_transform (GstBaseTransform * trans,
|
||||||
GstBuffer * inbuf, GstBuffer ** outbuf);
|
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 };
|
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);
|
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->event = GST_DEBUG_FUNCPTR (gst_identity_event);
|
||||||
gstbasetrans_class->transform = GST_DEBUG_FUNCPTR (gst_identity_transform);
|
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
|
static void
|
||||||
|
@ -443,47 +443,30 @@ gst_identity_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstElementStateReturn
|
static gboolean
|
||||||
gst_identity_change_state (GstElement * element)
|
gst_identity_start (GstBaseTransform * trans)
|
||||||
{
|
{
|
||||||
GstIdentity *identity;
|
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);
|
|
||||||
|
|
||||||
switch (transition) {
|
|
||||||
case GST_STATE_NULL_TO_READY:
|
|
||||||
break;
|
|
||||||
case GST_STATE_READY_TO_PAUSED:
|
|
||||||
identity->offset = 0;
|
identity->offset = 0;
|
||||||
identity->prev_timestamp = GST_CLOCK_TIME_NONE;
|
identity->prev_timestamp = GST_CLOCK_TIME_NONE;
|
||||||
identity->prev_duration = GST_CLOCK_TIME_NONE;
|
identity->prev_duration = GST_CLOCK_TIME_NONE;
|
||||||
identity->prev_offset_end = -1;
|
identity->prev_offset_end = -1;
|
||||||
break;
|
|
||||||
case GST_STATE_PAUSED_TO_PLAYING:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_identity_stop (GstBaseTransform * trans)
|
||||||
|
{
|
||||||
|
GstIdentity *identity;
|
||||||
|
|
||||||
|
identity = GST_IDENTITY (trans);
|
||||||
|
|
||||||
switch (transition) {
|
|
||||||
case GST_STATE_PLAYING_TO_PAUSED:
|
|
||||||
break;
|
|
||||||
case GST_STATE_PAUSED_TO_READY:
|
|
||||||
g_free (identity->last_message);
|
g_free (identity->last_message);
|
||||||
identity->last_message = NULL;
|
identity->last_message = NULL;
|
||||||
break;
|
|
||||||
case GST_STATE_READY_TO_NULL:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue