From d502325ee96bf176a539edecfc25036c540edabc Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 13 Feb 2006 10:43:15 +0000 Subject: [PATCH] gst/avi/gstavidemux.c: Properly handle end of segment. Closes #330885. Original commit message from CVS: Reviewed by: Edward Hervey * gst/avi/gstavidemux.c: (gst_avi_demux_process_next_entry): Properly handle end of segment. Closes #330885. --- ChangeLog | 7 +++++++ gst/avi/gstavidemux.c | 30 ++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 31d6f32f50..dccb29c5b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-02-13 Mark Nauwelaerts + + Reviewed by: Edward Hervey + + * gst/avi/gstavidemux.c: (gst_avi_demux_process_next_entry): + Properly handle end of segment. Closes #330885. + 2006-02-13 Wim Taymans * gst/rtp/gstrtpmp4gpay.h: diff --git a/gst/avi/gstavidemux.c b/gst/avi/gstavidemux.c index d4e22a1d35..cc6d9e7341 100644 --- a/gst/avi/gstavidemux.c +++ b/gst/avi/gstavidemux.c @@ -2268,14 +2268,7 @@ gst_avi_demux_process_next_entry (GstAviDemux * avi) if (avi->current_entry >= avi->index_size) { GST_LOG_OBJECT (avi, "Handled last index entry, setting EOS (%d > %d)", avi->current_entry, avi->index_size); - if (avi->segment_flags & GST_SEEK_FLAG_SEGMENT) - gst_element_post_message - (GST_ELEMENT (avi), - gst_message_new_segment_done (GST_OBJECT (avi), GST_FORMAT_TIME, - avi->segment_stop)); - else - gst_avi_demux_send_event (avi, gst_event_new_eos ()); - return GST_FLOW_WRONG_STATE; + goto eos; } else { GstBuffer *buf; gst_avi_index_entry *entry = &avi->index_entries[avi->current_entry++]; @@ -2287,6 +2280,16 @@ gst_avi_demux_process_next_entry (GstAviDemux * avi) continue; } + if ((entry->flags & GST_RIFF_IF_KEYFRAME) + && GST_CLOCK_TIME_IS_VALID (entry->ts) + && GST_CLOCK_TIME_IS_VALID (avi->segment_stop) + && (entry->ts > avi->segment_stop)) { + GST_LOG_OBJECT (avi, "Found keyframe after segment," + " setting EOS (%" GST_TIME_FORMAT " > %" GST_TIME_FORMAT ")", + GST_TIME_ARGS (entry->ts), GST_TIME_ARGS (avi->segment_stop)); + goto eos; + } + stream = &avi->stream[entry->stream_nr]; if (entry->size == 0 || !stream->pad) { @@ -2327,6 +2330,17 @@ gst_avi_demux_process_next_entry (GstAviDemux * avi) } while (!processed); return GST_FLOW_OK; + +eos: + /* handle end-of-stream/segment */ + if (avi->segment_flags & GST_SEEK_FLAG_SEGMENT) + gst_element_post_message + (GST_ELEMENT (avi), + gst_message_new_segment_done (GST_OBJECT (avi), GST_FORMAT_TIME, + avi->segment_stop)); + else + gst_avi_demux_send_event (avi, gst_event_new_eos ()); + return GST_FLOW_WRONG_STATE; } /*