From 26209707d9d78de860effd25e4c777a5d9ac65bb Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 8 Oct 2008 13:59:57 +0000 Subject: [PATCH] ext/mad/gstmad.*: track discont on incomming buffers and set discont on outgoing buffers. Original commit message from CVS: * ext/mad/gstmad.c: (gst_mad_src_event), (gst_mad_chain), (gst_mad_change_state): * ext/mad/gstmad.h: track discont on incomming buffers and set discont on outgoing buffers. Pass unknown events upstreams instead of dropping them. --- ChangeLog | 9 +++++++++ common | 2 +- ext/mad/gstmad.c | 30 +++++++++++++++++++++++++----- ext/mad/gstmad.h | 1 + 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3cc1d09..208cee0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-10-08 Wim Taymans + + * ext/mad/gstmad.c: (gst_mad_src_event), (gst_mad_chain), + (gst_mad_change_state): + * ext/mad/gstmad.h: + track discont on incomming buffers and set discont on outgoing + buffers. + Pass unknown events upstreams instead of dropping them. + 2008-09-28 Sebastian Dröge Patch by: Sameer Naik diff --git a/common b/common index 1ff63d8..46eefd2 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 1ff63d8f92c36bf207434436f4ce75f2a4ea11a4 +Subproject commit 46eefd2f8474ee748864c59635be87b5a29317d1 diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c index 4b4c9fd..59a6f26 100644 --- a/ext/mad/gstmad.c +++ b/ext/mad/gstmad.c @@ -811,10 +811,10 @@ gst_mad_src_event (GstPad * pad, GstEvent * event) mad = GST_MAD (GST_PAD_PARENT (pad)); switch (GST_EVENT_TYPE (event)) { - /* the all-formats seek logic */ case GST_EVENT_SEEK: + /* the all-formats seek logic, ref the event, we need it later */ gst_event_ref (event); - if (!(res = gst_pad_event_default (pad, event))) { + if (!(res = gst_pad_push_event (mad->sinkpad, event))) { #ifndef GST_DISABLE_INDEX if (mad->index) res = index_seek (mad, pad, event); @@ -822,14 +822,13 @@ gst_mad_src_event (GstPad * pad, GstEvent * event) #endif res = normal_seek (mad, pad, event); } + gst_event_unref (event); break; - default: - res = FALSE; + res = gst_pad_push_event (mad->sinkpad, event); break; } - gst_event_unref (event); return res; } @@ -1289,6 +1288,7 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) guint8 *data; glong size, tempsize; gboolean new_pts = FALSE; + gboolean discont; GstClockTime timestamp; GstFlowReturn result = GST_FLOW_OK; @@ -1300,6 +1300,9 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) GST_DEBUG ("mad restarted"); } + /* take discont flag */ + discont = GST_BUFFER_IS_DISCONT (buffer); + timestamp = GST_BUFFER_TIMESTAMP (buffer); GST_DEBUG ("mad in timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (timestamp)); @@ -1335,6 +1338,10 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) gint tocopy; guchar *mad_input_buffer; /* convenience pointer to tempbuffer */ + if (mad->tempsize == 0 && discont) { + mad->discont = TRUE; + discont = FALSE; + } tocopy = MIN (MAD_BUFFER_MDLEN, MIN (size, MAD_BUFFER_MDLEN * 3 - mad->tempsize)); @@ -1626,6 +1633,7 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) GST_BUFFER_TIMESTAMP (outbuffer) = time_offset; GST_BUFFER_DURATION (outbuffer) = time_duration; GST_BUFFER_OFFSET (outbuffer) = mad->total_samples; + GST_BUFFER_OFFSET_END (outbuffer) = mad->total_samples + nsamples; /* output sample(s) in 16-bit signed native-endian PCM */ if (mad->channels == 1) { @@ -1649,6 +1657,13 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) "pushing buffer, off=%" G_GUINT64_FORMAT ", ts=%" GST_TIME_FORMAT, GST_BUFFER_OFFSET (outbuffer), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuffer))); + + /* apply discont */ + if (mad->discont) { + GST_BUFFER_FLAG_SET (outbuffer, GST_BUFFER_FLAG_DISCONT); + mad->discont = FALSE; + } + mad->segment.last_stop = GST_BUFFER_TIMESTAMP (outbuffer); result = gst_pad_push (mad->srcpad, outbuffer); if (result != GST_FLOW_OK) { @@ -1672,6 +1687,10 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) mad->bytes_consumed = 0; } tempsize = 0; + if (discont) { + mad->discont = TRUE; + discont = FALSE; + } if (gst_mad_check_restart (mad)) { goto end; @@ -1723,6 +1742,7 @@ gst_mad_change_state (GstElement * element, GstStateChange transition) mad_frame_init (&mad->frame); mad_synth_init (&mad->synth); mad->tempsize = 0; + mad->discont = TRUE; mad->total_samples = 0; mad->rate = 0; mad->channels = 0; diff --git a/ext/mad/gstmad.h b/ext/mad/gstmad.h index b652ac2..55bc92e 100644 --- a/ext/mad/gstmad.h +++ b/ext/mad/gstmad.h @@ -63,6 +63,7 @@ struct _GstMad gboolean in_error; /* set when mad's in an error state */ gboolean restart; + gboolean discont; guint64 segment_start; GstSegment segment; gboolean need_newsegment; -- 2.7.4