diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-11-21 13:36:10 +0100 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-11-21 13:36:10 +0100 |
commit | 03bc286c64321d400bc9b6a6ab946a9438e9fdb4 (patch) | |
tree | 128d05b688cfc6751f3007e752e9d0e95936d115 /gst/realmedia | |
parent | 8eca58a50ed1d649078ccab88d3d4968918bd9d1 (diff) |
update for activation changes
Diffstat (limited to 'gst/realmedia')
-rw-r--r-- | gst/realmedia/rademux.c | 60 | ||||
-rw-r--r-- | gst/realmedia/rdtmanager.c | 92 | ||||
-rw-r--r-- | gst/realmedia/rmdemux.c | 80 |
3 files changed, 112 insertions, 120 deletions
diff --git a/gst/realmedia/rademux.c b/gst/realmedia/rademux.c index 844e7f49..de99a090 100644 --- a/gst/realmedia/rademux.c +++ b/gst/realmedia/rademux.c @@ -77,10 +77,8 @@ static gboolean gst_real_audio_demux_src_query (GstPad * pad, static void gst_real_audio_demux_loop (GstRealAudioDemux * demux); static gboolean gst_real_audio_demux_sink_activate (GstPad * sinkpad, GstObject * parent); -static gboolean gst_real_audio_demux_sink_activate_push (GstPad * sinkpad, - GstObject * parent, gboolean active); -static gboolean gst_real_audio_demux_sink_activate_pull (GstPad * sinkpad, - GstObject * parent, gboolean active); +static gboolean gst_real_audio_demux_sink_activate_mode (GstPad * sinkpad, + GstObject * parent, GstPadMode mode, gboolean active); static void gst_real_audio_demux_finalize (GObject * obj) @@ -169,10 +167,8 @@ gst_real_audio_demux_init (GstRealAudioDemux * demux) GST_DEBUG_FUNCPTR (gst_real_audio_demux_sink_event)); gst_pad_set_activate_function (demux->sinkpad, GST_DEBUG_FUNCPTR (gst_real_audio_demux_sink_activate)); - gst_pad_set_activatepull_function (demux->sinkpad, - GST_DEBUG_FUNCPTR (gst_real_audio_demux_sink_activate_pull)); - gst_pad_set_activatepush_function (demux->sinkpad, - GST_DEBUG_FUNCPTR (gst_real_audio_demux_sink_activate_push)); + gst_pad_set_activatemode_function (demux->sinkpad, + GST_DEBUG_FUNCPTR (gst_real_audio_demux_sink_activate_mode)); gst_element_add_pad (GST_ELEMENT (demux), demux->sinkpad); @@ -200,45 +196,45 @@ gst_real_audio_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_real_audio_demux_sink_activate_push (GstPad * sinkpad, GstObject * parent, - gboolean active) +gst_real_audio_demux_sink_activate_mode (GstPad * sinkpad, GstObject * parent, + GstPadMode mode, gboolean active) { + gboolean res; GstRealAudioDemux *demux; demux = GST_REAL_AUDIO_DEMUX (parent); - demux->seekable = FALSE; - - return TRUE; -} - -static gboolean -gst_real_audio_demux_sink_activate_pull (GstPad * sinkpad, GstObject * parent, - gboolean active) -{ - GstRealAudioDemux *demux; - - demux = GST_REAL_AUDIO_DEMUX (parent); - - if (active) { - demux->seekable = TRUE; + switch (mode) { + case GST_PAD_MODE_PUSH: + demux->seekable = FALSE; + res = TRUE; + break; + case GST_PAD_MODE_PULL: + if (active) { + demux->seekable = TRUE; - return gst_pad_start_task (sinkpad, - (GstTaskFunction) gst_real_audio_demux_loop, demux); - } else { - demux->seekable = FALSE; - return gst_pad_stop_task (sinkpad); + res = gst_pad_start_task (sinkpad, + (GstTaskFunction) gst_real_audio_demux_loop, demux); + } else { + demux->seekable = FALSE; + res = gst_pad_stop_task (sinkpad); + } + break; + default: + res = FALSE; + break; } + return res; } static GstFlowReturn diff --git a/gst/realmedia/rdtmanager.c b/gst/realmedia/rdtmanager.c index 00966f6b..990d1163 100644 --- a/gst/realmedia/rdtmanager.c +++ b/gst/realmedia/rdtmanager.c @@ -122,8 +122,8 @@ static void gst_rdt_manager_get_property (GObject * object, static gboolean gst_rdt_manager_query_src (GstPad * pad, GstObject * parent, GstQuery * query); -static gboolean gst_rdt_manager_src_activate_push (GstPad * pad, - GstObject * parent, gboolean active); +static gboolean gst_rdt_manager_src_activate_mode (GstPad * pad, + GstObject * parent, GstPadMode mode, gboolean active); static GstClock *gst_rdt_manager_provide_clock (GstElement * element); static GstStateChangeReturn gst_rdt_manager_change_state (GstElement * element, @@ -301,8 +301,8 @@ activate_session (GstRDTManager * rdtmanager, GstRDTManagerSession * session, gst_pad_set_element_private (session->recv_rtp_src, session); gst_pad_set_query_function (session->recv_rtp_src, gst_rdt_manager_query_src); - gst_pad_set_activatepush_function (session->recv_rtp_src, - gst_rdt_manager_src_activate_push); + gst_pad_set_activatemode_function (session->recv_rtp_src, + gst_rdt_manager_src_activate_mode); gst_pad_set_active (session->recv_rtp_src, TRUE); gst_element_add_pad (GST_ELEMENT_CAST (rdtmanager), session->recv_rtp_src); @@ -556,52 +556,60 @@ gst_rdt_manager_query_src (GstPad * pad, GstObject * parent, GstQuery * query) } static gboolean -gst_rdt_manager_src_activate_push (GstPad * pad, GstObject * parent, - gboolean active) +gst_rdt_manager_src_activate_mode (GstPad * pad, GstObject * parent, + GstPadMode mode, gboolean active) { - gboolean result = TRUE; + gboolean result; GstRDTManager *rdtmanager; GstRDTManagerSession *session; session = gst_pad_get_element_private (pad); rdtmanager = session->dec; - if (active) { - /* allow data processing */ - JBUF_LOCK (session); - GST_DEBUG_OBJECT (rdtmanager, "Enabling pop on queue"); - /* Mark as non flushing */ - session->srcresult = GST_FLOW_OK; - gst_segment_init (&session->segment, GST_FORMAT_TIME); - session->last_popped_seqnum = -1; - session->last_out_time = -1; - session->next_seqnum = -1; - session->eos = FALSE; - JBUF_UNLOCK (session); - - /* start pushing out buffers */ - GST_DEBUG_OBJECT (rdtmanager, "Starting task on srcpad"); - gst_pad_start_task (pad, (GstTaskFunction) gst_rdt_manager_loop, pad); - } else { - /* make sure all data processing stops ASAP */ - JBUF_LOCK (session); - /* mark ourselves as flushing */ - session->srcresult = GST_FLOW_WRONG_STATE; - GST_DEBUG_OBJECT (rdtmanager, "Disabling pop on queue"); - /* this unblocks any waiting pops on the src pad task */ - JBUF_SIGNAL (session); - /* unlock clock, we just unschedule, the entry will be released by - * the locking streaming thread. */ - if (session->clock_id) - gst_clock_id_unschedule (session->clock_id); - JBUF_UNLOCK (session); - - /* 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 (rdtmanager, "Stopping task on srcpad"); - result = gst_pad_stop_task (pad); + switch (mode) { + case GST_PAD_MODE_PUSH: + if (active) { + /* allow data processing */ + JBUF_LOCK (session); + GST_DEBUG_OBJECT (rdtmanager, "Enabling pop on queue"); + /* Mark as non flushing */ + session->srcresult = GST_FLOW_OK; + gst_segment_init (&session->segment, GST_FORMAT_TIME); + session->last_popped_seqnum = -1; + session->last_out_time = -1; + session->next_seqnum = -1; + session->eos = FALSE; + JBUF_UNLOCK (session); + + /* start pushing out buffers */ + GST_DEBUG_OBJECT (rdtmanager, "Starting task on srcpad"); + result = + gst_pad_start_task (pad, (GstTaskFunction) gst_rdt_manager_loop, + pad); + } else { + /* make sure all data processing stops ASAP */ + JBUF_LOCK (session); + /* mark ourselves as flushing */ + session->srcresult = GST_FLOW_WRONG_STATE; + GST_DEBUG_OBJECT (rdtmanager, "Disabling pop on queue"); + /* this unblocks any waiting pops on the src pad task */ + JBUF_SIGNAL (session); + /* unlock clock, we just unschedule, the entry will be released by + * the locking streaming thread. */ + if (session->clock_id) + gst_clock_id_unschedule (session->clock_id); + JBUF_UNLOCK (session); + + /* 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 (rdtmanager, "Stopping task on srcpad"); + result = gst_pad_stop_task (pad); + } + break; + default: + result = FALSE; + break; } - return result; } diff --git a/gst/realmedia/rmdemux.c b/gst/realmedia/rmdemux.c index d7cf0fbc..742fe3dc 100644 --- a/gst/realmedia/rmdemux.c +++ b/gst/realmedia/rmdemux.c @@ -139,10 +139,8 @@ static GstFlowReturn gst_rmdemux_chain (GstPad * pad, GstObject * parent, static void gst_rmdemux_loop (GstPad * pad); static gboolean gst_rmdemux_sink_activate (GstPad * sinkpad, GstObject * parent); -static gboolean gst_rmdemux_sink_activate_push (GstPad * sinkpad, - GstObject * parent, gboolean active); -static gboolean gst_rmdemux_sink_activate_pull (GstPad * sinkpad, - GstObject * parent, gboolean active); +static gboolean gst_rmdemux_sink_activate_mode (GstPad * sinkpad, + GstObject * parent, GstPadMode mode, gboolean active); static gboolean gst_rmdemux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event); static gboolean gst_rmdemux_src_event (GstPad * pad, GstObject * parent, @@ -255,10 +253,8 @@ gst_rmdemux_init (GstRMDemux * rmdemux) GST_DEBUG_FUNCPTR (gst_rmdemux_chain)); gst_pad_set_activate_function (rmdemux->sinkpad, GST_DEBUG_FUNCPTR (gst_rmdemux_sink_activate)); - gst_pad_set_activatepull_function (rmdemux->sinkpad, - GST_DEBUG_FUNCPTR (gst_rmdemux_sink_activate_pull)); - gst_pad_set_activatepush_function (rmdemux->sinkpad, - GST_DEBUG_FUNCPTR (gst_rmdemux_sink_activate_push)); + gst_pad_set_activatemode_function (rmdemux->sinkpad, + GST_DEBUG_FUNCPTR (gst_rmdemux_sink_activate_mode)); gst_element_add_pad (GST_ELEMENT (rmdemux), rmdemux->sinkpad); @@ -746,7 +742,6 @@ gst_rmdemux_change_state (GstElement * element, GstStateChange transition) static gboolean gst_rmdemux_sink_activate (GstPad * sinkpad, GstObject * parent) { - GstQuery *query; gboolean pull_mode; @@ -764,57 +759,50 @@ gst_rmdemux_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_rmdemux_sink_activate_push (GstPad * pad, GstObject * parent, - gboolean active) +gst_rmdemux_sink_activate_mode (GstPad * sinkpad, GstObject * parent, + GstPadMode mode, gboolean active) { - GstRMDemux *rmdemux; - - rmdemux = GST_RMDEMUX (parent); + gboolean res; + GstRMDemux *demux; - GST_DEBUG_OBJECT (rmdemux, "activate_push"); + demux = GST_RMDEMUX (parent); - rmdemux->seekable = 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_rmdemux_sink_activate_pull (GstPad * pad, GstObject * parent, - gboolean active) -{ - GstRMDemux *rmdemux; - - rmdemux = GST_RMDEMUX (parent); - - GST_DEBUG_OBJECT (rmdemux, "activate_pull"); - - if (active) { - rmdemux->seekable = TRUE; - rmdemux->offset = 0; - rmdemux->loop_state = RMDEMUX_LOOP_STATE_HEADER; - rmdemux->data_offset = G_MAXUINT; - - return gst_pad_start_task (pad, (GstTaskFunction) gst_rmdemux_loop, pad); - } else { - return gst_pad_stop_task (pad); + switch (mode) { + case GST_PAD_MODE_PUSH: + demux->seekable = FALSE; + res = TRUE; + break; + case GST_PAD_MODE_PULL: + if (active) { + demux->seekable = TRUE; + demux->offset = 0; + demux->loop_state = RMDEMUX_LOOP_STATE_HEADER; + demux->data_offset = G_MAXUINT; + res = + gst_pad_start_task (sinkpad, (GstTaskFunction) gst_rmdemux_loop, + sinkpad); + } else { + res = gst_pad_stop_task (sinkpad); + } + break; + default: + res = FALSE; + break; } + return res; } + /* random access mode - just pass over to our chain function */ static void gst_rmdemux_loop (GstPad * pad) |