update for activation changes

This commit is contained in:
Wim Taymans 2011-11-21 13:37:01 +01:00
parent 6e4fb21331
commit f8e988a94c
6 changed files with 167 additions and 159 deletions

View file

@ -101,10 +101,8 @@ static gboolean gst_avi_demux_handle_seek_push (GstAviDemux * avi, GstPad * pad,
static void gst_avi_demux_loop (GstPad * pad);
static gboolean gst_avi_demux_sink_activate (GstPad * sinkpad,
GstObject * parent);
static gboolean gst_avi_demux_sink_activate_pull (GstPad * sinkpad,
GstObject * parent, gboolean active);
static gboolean gst_avi_demux_activate_push (GstPad * pad, GstObject * parent,
gboolean active);
static gboolean gst_avi_demux_sink_activate_mode (GstPad * sinkpad,
GstObject * parent, GstPadMode mode, gboolean active);
static GstFlowReturn gst_avi_demux_chain (GstPad * pad, GstObject * parent,
GstBuffer * buf);
@ -176,10 +174,8 @@ gst_avi_demux_init (GstAviDemux * avi)
avi->sinkpad = gst_pad_new_from_static_template (&sink_templ, "sink");
gst_pad_set_activate_function (avi->sinkpad,
GST_DEBUG_FUNCPTR (gst_avi_demux_sink_activate));
gst_pad_set_activatepull_function (avi->sinkpad,
GST_DEBUG_FUNCPTR (gst_avi_demux_sink_activate_pull));
gst_pad_set_activatepush_function (avi->sinkpad,
GST_DEBUG_FUNCPTR (gst_avi_demux_activate_push));
gst_pad_set_activatemode_function (avi->sinkpad,
GST_DEBUG_FUNCPTR (gst_avi_demux_sink_activate_mode));
gst_pad_set_chain_function (avi->sinkpad,
GST_DEBUG_FUNCPTR (gst_avi_demux_chain));
gst_pad_set_event_function (avi->sinkpad,
@ -5286,55 +5282,46 @@ gst_avi_demux_sink_activate (GstPad * sinkpad, GstObject * parent)
goto activate_push;
GST_DEBUG_OBJECT (sinkpad, "activating pull");
return gst_pad_activate_pull (sinkpad, TRUE);
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
activate_push:
{
GST_DEBUG_OBJECT (sinkpad, "activating push");
return gst_pad_activate_push (sinkpad, TRUE);
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
}
}
static gboolean
gst_avi_demux_sink_activate_pull (GstPad * sinkpad, GstObject * parent,
gboolean active)
gst_avi_demux_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
GstPadMode mode, gboolean active)
{
gboolean res;
GstAviDemux *avi = GST_AVI_DEMUX (parent);
if (active) {
avi->streaming = FALSE;
return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_avi_demux_loop,
sinkpad);
} else {
return gst_pad_stop_task (sinkpad);
switch (mode) {
case GST_PAD_MODE_PULL:
if (active) {
avi->streaming = FALSE;
res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_avi_demux_loop,
sinkpad);
} else {
res = gst_pad_stop_task (sinkpad);
}
break;
case GST_PAD_MODE_PUSH:
if (active) {
GST_DEBUG ("avi: activating push/chain function");
avi->streaming = TRUE;
} else {
GST_DEBUG ("avi: deactivating push/chain function");
}
res = TRUE;
break;
default:
res = FALSE;
break;
}
}
static gboolean
gst_avi_demux_activate_push (GstPad * pad, GstObject * parent, gboolean active)
{
GstAviDemux *avi = GST_AVI_DEMUX (parent);
if (active) {
GST_DEBUG ("avi: activating push/chain function");
avi->streaming = TRUE;
#if 0
/* create index for some push based seeking if not provided */
GST_OBJECT_LOCK (avi);
if (!avi->element_index) {
GST_DEBUG_OBJECT (avi, "creating index");
avi->element_index = gst_index_factory_make ("memindex");
}
GST_OBJECT_UNLOCK (avi);
/* object lock might be taken again */
gst_index_get_writer_id (avi->element_index, GST_OBJECT_CAST (avi),
&avi->index_id);
#endif
} else {
GST_DEBUG ("avi: deactivating push/chain function");
}
return TRUE;
return res;
}
static void

View file

@ -86,8 +86,8 @@ static void gst_rnd_buffer_size_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_rnd_buffer_size_activate (GstPad * pad, GstObject * parent);
static gboolean gst_rnd_buffer_size_activate_pull (GstPad * pad,
GstObject * parent, gboolean active);
static gboolean gst_rnd_buffer_size_activate_mode (GstPad * pad,
GstObject * parent, GstPadMode mode, gboolean active);
static void gst_rnd_buffer_size_loop (GstRndBufferSize * self);
static GstStateChangeReturn gst_rnd_buffer_size_change_state (GstElement *
element, GstStateChange transition);
@ -145,8 +145,8 @@ gst_rnd_buffer_size_init (GstRndBufferSize * self)
self->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
gst_pad_set_activate_function (self->sinkpad,
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate));
gst_pad_set_activatepull_function (self->sinkpad,
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate_pull));
gst_pad_set_activatemode_function (self->sinkpad,
GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate_mode));
gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
self->srcpad = gst_pad_new_from_static_template (&src_template, "src");
@ -234,7 +234,7 @@ gst_rnd_buffer_size_activate (GstPad * pad, GstObject * parent)
goto no_pull;
GST_DEBUG_OBJECT (pad, "activating pull");
return gst_pad_activate_pull (pad, TRUE);
return gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE);
/* ERRORS */
no_pull:
@ -246,19 +246,29 @@ no_pull:
static gboolean
gst_rnd_buffer_size_activate_pull (GstPad * pad, GstObject * parent,
gboolean active)
gst_rnd_buffer_size_activate_mode (GstPad * pad, GstObject * parent,
GstPadMode mode, gboolean active)
{
gboolean res;
GstRndBufferSize *self = GST_RND_BUFFER_SIZE (parent);
if (active) {
GST_INFO_OBJECT (self, "starting pull");
return gst_pad_start_task (pad, (GstTaskFunction) gst_rnd_buffer_size_loop,
self);
} else {
GST_INFO_OBJECT (self, "stopping pull");
return gst_pad_stop_task (pad);
switch (mode) {
case GST_PAD_MODE_PULL:
if (active) {
GST_INFO_OBJECT (self, "starting pull");
res =
gst_pad_start_task (pad, (GstTaskFunction) gst_rnd_buffer_size_loop,
self);
} else {
GST_INFO_OBJECT (self, "stopping pull");
res = gst_pad_stop_task (pad);
}
break;
default:
res = FALSE;
break;
}
return res;
}

View file

@ -2818,49 +2818,44 @@ gst_flv_demux_sink_activate (GstPad * sinkpad, GstObject * parent)
goto activate_push;
GST_DEBUG_OBJECT (sinkpad, "activating pull");
return gst_pad_activate_pull (sinkpad, TRUE);
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
activate_push:
{
GST_DEBUG_OBJECT (sinkpad, "activating push");
return gst_pad_activate_push (sinkpad, TRUE);
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
}
}
/* This function gets called when we activate ourselves in push mode.
* We cannot seek (ourselves) in the stream */
static gboolean
gst_flv_demux_sink_activate_push (GstPad * sinkpad, GstObject * parent,
gboolean active)
gst_flv_demux_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
GstPadMode mode, gboolean active)
{
gboolean res;
GstFlvDemux *demux;
demux = GST_FLV_DEMUX (parent);
demux->random_access = FALSE;
return TRUE;
}
/* this function gets called when we activate ourselves in pull mode.
* We can perform random access to the resource and we start a task
* to start reading */
static gboolean
gst_flv_demux_sink_activate_pull (GstPad * sinkpad, GstObject * parent,
gboolean active)
{
GstFlvDemux *demux;
demux = GST_FLV_DEMUX (parent);
if (active) {
demux->random_access = TRUE;
return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_flv_demux_loop,
sinkpad);
} else {
demux->random_access = FALSE;
return gst_pad_stop_task (sinkpad);
switch (mode) {
case GST_PAD_MODE_PUSH:
demux->random_access = FALSE;
res = TRUE;
break;
case GST_PAD_MODE_PULL:
if (active) {
demux->random_access = TRUE;
res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_flv_demux_loop,
sinkpad);
} else {
demux->random_access = FALSE;
res = gst_pad_stop_task (sinkpad);
}
break;
default:
res = FALSE;
break;
}
return res;
}
static gboolean
@ -3243,10 +3238,8 @@ gst_flv_demux_init (GstFlvDemux * demux)
GST_DEBUG_FUNCPTR (gst_flv_demux_chain));
gst_pad_set_activate_function (demux->sinkpad,
GST_DEBUG_FUNCPTR (gst_flv_demux_sink_activate));
gst_pad_set_activatepull_function (demux->sinkpad,
GST_DEBUG_FUNCPTR (gst_flv_demux_sink_activate_pull));
gst_pad_set_activatepush_function (demux->sinkpad,
GST_DEBUG_FUNCPTR (gst_flv_demux_sink_activate_push));
gst_pad_set_activatemode_function (demux->sinkpad,
GST_DEBUG_FUNCPTR (gst_flv_demux_sink_activate_mode));
gst_element_add_pad (GST_ELEMENT (demux), demux->sinkpad);

View file

@ -401,10 +401,8 @@ static GstIndex *gst_qtdemux_get_index (GstElement * element);
static GstStateChangeReturn gst_qtdemux_change_state (GstElement * element,
GstStateChange transition);
static gboolean qtdemux_sink_activate (GstPad * sinkpad, GstObject * parent);
static gboolean qtdemux_sink_activate_pull (GstPad * sinkpad,
GstObject * parent, gboolean active);
static gboolean qtdemux_sink_activate_push (GstPad * sinkpad,
GstObject * parent, gboolean active);
static gboolean qtdemux_sink_activate_mode (GstPad * sinkpad,
GstObject * parent, GstPadMode mode, gboolean active);
static void gst_qtdemux_loop (GstPad * pad);
static GstFlowReturn gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent,
@ -476,10 +474,8 @@ gst_qtdemux_init (GstQTDemux * qtdemux)
qtdemux->sinkpad =
gst_pad_new_from_static_template (&gst_qtdemux_sink_template, "sink");
gst_pad_set_activate_function (qtdemux->sinkpad, qtdemux_sink_activate);
gst_pad_set_activatepull_function (qtdemux->sinkpad,
qtdemux_sink_activate_pull);
gst_pad_set_activatepush_function (qtdemux->sinkpad,
qtdemux_sink_activate_push);
gst_pad_set_activatemode_function (qtdemux->sinkpad,
qtdemux_sink_activate_mode);
gst_pad_set_chain_function (qtdemux->sinkpad, gst_qtdemux_chain);
gst_pad_set_event_function (qtdemux->sinkpad, gst_qtdemux_handle_sink_event);
gst_element_add_pad (GST_ELEMENT_CAST (qtdemux), qtdemux->sinkpad);
@ -4441,39 +4437,41 @@ qtdemux_sink_activate (GstPad * sinkpad, GstObject * parent)
goto activate_push;
GST_DEBUG_OBJECT (sinkpad, "activating pull");
return gst_pad_activate_pull (sinkpad, TRUE);
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
activate_push:
{
GST_DEBUG_OBJECT (sinkpad, "activating push");
return gst_pad_activate_push (sinkpad, TRUE);
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
}
}
static gboolean
qtdemux_sink_activate_pull (GstPad * sinkpad, GstObject * parent,
gboolean active)
qtdemux_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
GstPadMode mode, gboolean active)
{
gboolean res;
GstQTDemux *demux = GST_QTDEMUX (parent);
if (active) {
demux->pullbased = TRUE;
return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_qtdemux_loop,
sinkpad);
} else {
return gst_pad_stop_task (sinkpad);
switch (mode) {
case GST_PAD_MODE_PUSH:
demux->pullbased = FALSE;
res = TRUE;
break;
case GST_PAD_MODE_PULL:
if (active) {
demux->pullbased = TRUE;
res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_qtdemux_loop,
sinkpad);
} else {
res = gst_pad_stop_task (sinkpad);
}
break;
default:
res = FALSE;
break;
}
}
static gboolean
qtdemux_sink_activate_push (GstPad * sinkpad, GstObject * parent,
gboolean active)
{
GstQTDemux *demux = GST_QTDEMUX (parent);
demux->pullbased = FALSE;
return TRUE;
return res;
}
#ifdef HAVE_ZLIB

View file

@ -259,8 +259,8 @@ static gboolean gst_rtp_jitter_buffer_sink_query (GstPad * pad,
/* srcpad overrides */
static gboolean gst_rtp_jitter_buffer_src_event (GstPad * pad,
GstObject * parent, GstEvent * event);
static gboolean gst_rtp_jitter_buffer_src_activate_push (GstPad * pad,
GstObject * parent, gboolean active);
static gboolean gst_rtp_jitter_buffer_src_activate_mode (GstPad * pad,
GstObject * parent, GstPadMode mode, gboolean active);
static void gst_rtp_jitter_buffer_loop (GstRtpJitterBuffer * jitterbuffer);
static gboolean gst_rtp_jitter_buffer_src_query (GstPad * pad,
GstObject * parent, GstQuery * query);
@ -475,8 +475,8 @@ gst_rtp_jitter_buffer_init (GstRtpJitterBuffer * jitterbuffer)
gst_pad_new_from_static_template (&gst_rtp_jitter_buffer_src_template,
"src");
gst_pad_set_activatepush_function (priv->srcpad,
GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_src_activate_push));
gst_pad_set_activatemode_function (priv->srcpad,
GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_src_activate_mode));
gst_pad_set_query_function (priv->srcpad,
GST_DEBUG_FUNCPTR (gst_rtp_jitter_buffer_src_query));
gst_pad_set_event_function (priv->srcpad,
@ -882,32 +882,38 @@ gst_rtp_jitter_buffer_flush_stop (GstRtpJitterBuffer * jitterbuffer)
}
static gboolean
gst_rtp_jitter_buffer_src_activate_push (GstPad * pad, GstObject * parent,
gboolean active)
gst_rtp_jitter_buffer_src_activate_mode (GstPad * pad, GstObject * parent,
GstPadMode mode, gboolean active)
{
gboolean result = TRUE;
gboolean result;
GstRtpJitterBuffer *jitterbuffer = NULL;
jitterbuffer = GST_RTP_JITTER_BUFFER (parent);
if (active) {
/* allow data processing */
gst_rtp_jitter_buffer_flush_stop (jitterbuffer);
switch (mode) {
case GST_PAD_MODE_PUSH:
if (active) {
/* allow data processing */
gst_rtp_jitter_buffer_flush_stop (jitterbuffer);
/* start pushing out buffers */
GST_DEBUG_OBJECT (jitterbuffer, "Starting task on srcpad");
gst_pad_start_task (jitterbuffer->priv->srcpad,
(GstTaskFunction) gst_rtp_jitter_buffer_loop, jitterbuffer);
} else {
/* make sure all data processing stops ASAP */
gst_rtp_jitter_buffer_flush_start (jitterbuffer);
/* start pushing out buffers */
GST_DEBUG_OBJECT (jitterbuffer, "Starting task on srcpad");
result = gst_pad_start_task (jitterbuffer->priv->srcpad,
(GstTaskFunction) gst_rtp_jitter_buffer_loop, jitterbuffer);
} else {
/* make sure all data processing stops ASAP */
gst_rtp_jitter_buffer_flush_start (jitterbuffer);
/* NOTE this will hardlock if the state change is called from the src pad
* task thread because we will _join() the thread. */
GST_DEBUG_OBJECT (jitterbuffer, "Stopping task on srcpad");
result = gst_pad_stop_task (pad);
/* NOTE this will hardlock if the state change is called from the src pad
* task thread because we will _join() the thread. */
GST_DEBUG_OBJECT (jitterbuffer, "Stopping task on srcpad");
result = gst_pad_stop_task (pad);
}
break;
default:
result = FALSE;
break;
}
return result;
}
@ -1069,7 +1075,8 @@ gst_rtp_jitter_buffer_sink_event (GstPad * pad, GstObject * parent,
case GST_EVENT_FLUSH_STOP:
ret = gst_pad_push_event (priv->srcpad, event);
ret =
gst_rtp_jitter_buffer_src_activate_push (priv->srcpad, parent, TRUE);
gst_rtp_jitter_buffer_src_activate_mode (priv->srcpad, parent,
GST_PAD_MODE_PUSH, TRUE);
break;
case GST_EVENT_EOS:
{

View file

@ -65,8 +65,8 @@ static void gst_wavparse_dispose (GObject * object);
static gboolean gst_wavparse_sink_activate (GstPad * sinkpad,
GstObject * parent);
static gboolean gst_wavparse_sink_activate_pull (GstPad * sinkpad,
GstObject * parent, gboolean active);
static gboolean gst_wavparse_sink_activate_mode (GstPad * sinkpad,
GstObject * parent, GstPadMode mode, gboolean active);
static gboolean gst_wavparse_send_event (GstElement * element,
GstEvent * event);
static GstStateChangeReturn gst_wavparse_change_state (GstElement * element,
@ -192,8 +192,8 @@ gst_wavparse_init (GstWavParse * wavparse)
gst_pad_new_from_static_template (&sink_template_factory, "sink");
gst_pad_set_activate_function (wavparse->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavparse_sink_activate));
gst_pad_set_activatepull_function (wavparse->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavparse_sink_activate_pull));
gst_pad_set_activatemode_function (wavparse->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavparse_sink_activate_mode));
gst_pad_set_chain_function (wavparse->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavparse_chain));
gst_pad_set_event_function (wavparse->sinkpad,
@ -2565,30 +2565,43 @@ gst_wavparse_sink_activate (GstPad * sinkpad, GstObject * parent)
GST_DEBUG_OBJECT (sinkpad, "activating pull");
wav->streaming = FALSE;
return gst_pad_activate_pull (sinkpad, TRUE);
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
activate_push:
{
GST_DEBUG_OBJECT (sinkpad, "activating push");
wav->streaming = TRUE;
wav->adapter = gst_adapter_new ();
return gst_pad_activate_push (sinkpad, TRUE);
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
}
}
static gboolean
gst_wavparse_sink_activate_pull (GstPad * sinkpad, GstObject * parent,
gboolean active)
gst_wavparse_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
GstPadMode mode, gboolean active)
{
if (active) {
/* if we have a scheduler we can start the task */
return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_wavparse_loop,
sinkpad);
} else {
return gst_pad_stop_task (sinkpad);
gboolean res;
switch (mode) {
case GST_PAD_MODE_PUSH:
res = TRUE;
break;
case GST_PAD_MODE_PULL:
if (active) {
/* if we have a scheduler we can start the task */
res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_wavparse_loop,
sinkpad);
} else {
res = gst_pad_stop_task (sinkpad);
}
break;
default:
res = FALSE;
break;
}
};
return res;
}
static GstStateChangeReturn
gst_wavparse_change_state (GstElement * element, GstStateChange transition)