static gboolean 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); switch (mode) { case GST_PAD_MODE_PUSH: demux->seekable = FALSE; res = TRUE; break; case GST_PAD_MODE_PULL: if (active) { demux->seekable = TRUE; res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_real_audio_demux_loop, demux, NULL); } else { demux->seekable = FALSE; res = gst_pad_stop_task (sinkpad); } break; default: res = FALSE; break; } return res; }
static GstFlowReturn gst_real_audio_demux_chain (GstPad * pad, GstBuffer * buf) { GstRealAudioDemux *demux; demux = GST_REAL_AUDIO_DEMUX (GST_PAD_PARENT (pad)); return gst_real_audio_demux_handle_buffer (demux, buf); }
static void gst_real_audio_demux_finalize (GObject * obj) { GstRealAudioDemux *demux = GST_REAL_AUDIO_DEMUX (obj); g_object_unref (demux->adapter); G_OBJECT_CLASS (parent_class)->finalize (obj); }
static GstFlowReturn gst_real_audio_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) { GstRealAudioDemux *demux; demux = GST_REAL_AUDIO_DEMUX (parent); return gst_real_audio_demux_handle_buffer (demux, buf); }
static gboolean gst_real_audio_demux_sink_activate_push (GstPad * sinkpad, gboolean active) { GstRealAudioDemux *demux; demux = GST_REAL_AUDIO_DEMUX (GST_OBJECT_PARENT (sinkpad)); demux->seekable = FALSE; return TRUE; }
static gboolean gst_real_audio_demux_sink_activate_pull (GstPad * sinkpad, gboolean active) { GstRealAudioDemux *demux; demux = GST_REAL_AUDIO_DEMUX (GST_OBJECT_PARENT (sinkpad)); 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); } }
static gboolean gst_real_audio_demux_src_query (GstPad * pad, GstQuery * query) { GstRealAudioDemux *demux; gboolean ret = FALSE; demux = GST_REAL_AUDIO_DEMUX (gst_pad_get_parent (pad)); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_DURATION:{ GstFormat format; gst_query_parse_duration (query, &format, NULL); if (format == GST_FORMAT_TIME && demux->duration > 0) { gst_query_set_duration (query, GST_FORMAT_TIME, demux->duration); ret = TRUE; } else if (format == GST_FORMAT_BYTES && demux->upstream_size > 0) { gst_query_set_duration (query, GST_FORMAT_BYTES, demux->upstream_size - demux->data_offset); ret = TRUE; } break; } case GST_QUERY_SEEKING:{ GstFormat format; gboolean seekable; gst_query_parse_seeking (query, &format, NULL, NULL, NULL); seekable = (format == GST_FORMAT_TIME && demux->seekable); gst_query_set_seeking (query, format, seekable, 0, (format == GST_FORMAT_TIME) ? demux->duration : -1); ret = TRUE; break; } default: ret = gst_pad_query_default (pad, query); break; } gst_object_unref (demux); return ret; }
static GstStateChangeReturn gst_real_audio_demux_change_state (GstElement * element, GstStateChange transition) { GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; GstRealAudioDemux *demux = GST_REAL_AUDIO_DEMUX (element); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: break; case GST_STATE_CHANGE_READY_TO_PAUSED: demux->state = REAL_AUDIO_DEMUX_STATE_MARKER; demux->segment_running = FALSE; gst_segment_init (&demux->segment, GST_FORMAT_TIME); gst_adapter_clear (demux->adapter); break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: break; default: break; } ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: break; case GST_STATE_CHANGE_PAUSED_TO_READY:{ gst_real_audio_demux_reset (demux); gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED); break; } case GST_STATE_CHANGE_READY_TO_NULL: break; default: break; } return ret; }
static gboolean gst_real_audio_demux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) { GstRealAudioDemux *demux; gboolean ret; demux = GST_REAL_AUDIO_DEMUX (parent); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_SEGMENT:{ /* FIXME */ gst_event_unref (event); demux->need_newsegment = TRUE; ret = TRUE; break; } default: ret = gst_pad_event_default (pad, parent, event); break; } return ret; }
static gboolean gst_real_audio_demux_src_event (GstPad * pad, GstEvent * event) { GstRealAudioDemux *demux; gboolean ret = FALSE; demux = GST_REAL_AUDIO_DEMUX (gst_pad_get_parent (pad)); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_QOS: gst_event_unref (event); break; case GST_EVENT_SEEK: ret = gst_real_audio_demux_handle_seek (demux, event); gst_event_unref (event); break; default: ret = gst_pad_event_default (pad, event); break; } gst_object_unref (demux); return ret; }
static gboolean gst_real_audio_demux_src_query (GstPad * pad, GstObject * parent, GstQuery * query) { GstRealAudioDemux *demux; gboolean ret = FALSE; demux = GST_REAL_AUDIO_DEMUX (parent); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_DURATION:{ GstFormat format; gst_query_parse_duration (query, &format, NULL); if (format == GST_FORMAT_TIME && demux->duration > 0) { gst_query_set_duration (query, GST_FORMAT_TIME, demux->duration); ret = TRUE; } else if (format == GST_FORMAT_BYTES && demux->upstream_size > 0) { gst_query_set_duration (query, GST_FORMAT_BYTES, demux->upstream_size - demux->data_offset); ret = TRUE; } break; } case GST_QUERY_SEEKING:{ GstFormat format; gboolean seekable; gst_query_parse_seeking (query, &format, NULL, NULL, NULL); seekable = (format == GST_FORMAT_TIME && demux->seekable); gst_query_set_seeking (query, format, seekable, 0, (format == GST_FORMAT_TIME) ? demux->duration : -1); ret = TRUE; break; } case GST_QUERY_SEGMENT: { GstFormat format; gint64 start, stop; format = demux->segment.format; start = gst_segment_to_stream_time (&demux->segment, format, demux->segment.start); if ((stop = demux->segment.stop) == -1) stop = demux->segment.duration; else stop = gst_segment_to_stream_time (&demux->segment, format, stop); gst_query_set_segment (query, demux->segment.rate, format, start, stop); ret = TRUE; break; } default: ret = gst_pad_query_default (pad, parent, query); break; } return ret; }