[MOVED FROM GST-P-FARSIGHT] More Refactoring

20070322113228-65035-bae34a79599e7de5293ed77b022361ccff822bb9.gz
This commit is contained in:
zeeshan.ali@nokia.com 2007-03-22 11:32:28 +00:00 committed by Edward Hervey
parent 750462f540
commit c1bb36b5a3

View file

@ -187,17 +187,9 @@ gst_rtp_dtmf_mux_chain (GstPad * pad, GstBuffer * buffer)
return ret;
}
static gboolean
gst_rtp_dtmf_mux_stream_lock_event_handler (GstRTPDTMFMux *mux, GstPad * pad,
const GstStructure * event_structure)
static void
gst_rtp_dtmf_mux_lock_stream (GstRTPDTMFMux *mux, GstPad * pad)
{
gboolean lock;
if (!gst_structure_get_boolean (event_structure, "lock", &lock))
return FALSE;
GST_OBJECT_LOCK (mux);
if (lock) {
if (mux->special_pad != NULL) {
GST_WARNING_OBJECT (mux,
"Stream lock already acquired by pad %s",
@ -206,9 +198,11 @@ gst_rtp_dtmf_mux_stream_lock_event_handler (GstRTPDTMFMux *mux, GstPad * pad,
else
mux->special_pad = gst_object_ref (pad);
}
}
else {
static void
gst_rtp_dtmf_mux_unlock_stream (GstRTPDTMFMux *mux, GstPad * pad)
{
if (mux->special_pad == NULL) {
GST_WARNING_OBJECT (mux,
"Stream lock not acquired, can't release it");
@ -225,13 +219,58 @@ gst_rtp_dtmf_mux_stream_lock_event_handler (GstRTPDTMFMux *mux, GstPad * pad,
gst_object_unref (mux->special_pad);
mux->special_pad = NULL;
}
}
}
static gboolean
gst_rtp_dtmf_mux_handle_stream_lock_event (GstRTPDTMFMux *mux, GstPad * pad,
const GstStructure * event_structure)
{
gboolean lock;
if (!gst_structure_get_boolean (event_structure, "lock", &lock))
return FALSE;
GST_OBJECT_LOCK (mux);
if (lock)
gst_rtp_dtmf_mux_lock_stream (mux, pad);
else
gst_rtp_dtmf_mux_unlock_stream (mux, pad);
GST_OBJECT_UNLOCK (mux);
return TRUE;
}
static gboolean
gst_rtp_dtmf_mux_handle_downstream_event (GstRTPDTMFMux *mux, GstPad * pad, GstEvent * event)
{
const GstStructure *structure;
gboolean ret = FALSE;
structure = gst_event_get_structure (event);
/* FIXME: is this event generic enough to be given a generic name? */
if (structure && gst_structure_has_name (structure, "stream-lock")) {
ret = gst_rtp_dtmf_mux_handle_stream_lock_event (mux, pad, structure);
}
return ret;
}
static gboolean
gst_rtp_dtmf_mux_ignore_event (GstPad * pad, GstEvent * event)
{
gboolean ret;
if (parent_class->sink_event_func) {
/* Give the parent a chance to handle the event first */
ret = parent_class->sink_event_func (pad, event);
}
else
ret = gst_pad_event_default (pad, event);
return ret;
}
static gboolean
gst_rtp_dtmf_mux_sink_event (GstPad * pad, GstEvent * event)
{
@ -245,33 +284,14 @@ gst_rtp_dtmf_mux_sink_event (GstPad * pad, GstEvent * event)
switch (type) {
case GST_EVENT_CUSTOM_DOWNSTREAM_OOB:
{
const GstStructure *structure;
structure = gst_event_get_structure (event);
/* FIXME: is this event generic enough to be given a generic name? */
if (structure && gst_structure_has_name (structure, "stream-lock")) {
ret = gst_rtp_dtmf_mux_stream_lock_event_handler (mux, pad, structure);
}
ret = TRUE;
ret = gst_rtp_dtmf_mux_handle_downstream_event (mux, pad, event);
break;
}
default:
{
if (parent_class->sink_event_func) {
/* Give the parent a chance to handle the event first */
ret = parent_class->sink_event_func (pad, event);
}
else
ret = gst_pad_event_default (pad, event);
ret = gst_rtp_dtmf_mux_ignore_event (pad, event);
break;
}
}
gst_object_unref (mux);
return ret;
}