Index: media/mp4/mp4_stream_parser.cc |
diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc |
index 9d51959a3a32bbc8d45c0c4db8370c80e1093737..2b5eea3fd91c0ec809fe3082d442911b26ecacab 100644 |
--- a/media/mp4/mp4_stream_parser.cc |
+++ b/media/mp4/mp4_stream_parser.cc |
@@ -80,11 +80,7 @@ bool MP4StreamParser::Parse(const uint8* buf, int size) { |
do { |
if (state_ == kParsingBoxes) { |
- if (mdat_tail_ > queue_.head()) { |
- result = queue_.Trim(mdat_tail_); |
- } else { |
- result = ParseBox(&err); |
- } |
+ result = ParseBox(&err); |
} else { |
DCHECK_EQ(kEmittingSamples, state_); |
result = EnqueueSample(&audio_buffers, &video_buffers, &err); |
@@ -322,6 +318,11 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, |
if (*err) |
return false; |
+ // Remain in kEnqueueingSamples state, discarding data, until the end of |
+ // the current 'mdat' box has been appended to the queue. |
+ if (!queue_.Trim(mdat_tail_)) |
+ return false; |
+ |
ChangeState(kParsingBoxes); |
end_of_segment_cb_.Run(); |
return true; |