Index: media/mp4/mp4_stream_parser.cc |
diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc |
index 05b18c137d8a4b4e888d791ee85ecdc40cad0c35..e3aef869b465a4a1eb18dfb4fa88391c81e4cd41 100644 |
--- a/media/mp4/mp4_stream_parser.cc |
+++ b/media/mp4/mp4_stream_parser.cc |
@@ -37,13 +37,15 @@ void MP4StreamParser::Init(const InitCB& init_cb, |
const NewBuffersCB& audio_cb, |
const NewBuffersCB& video_cb, |
const NeedKeyCB& need_key_cb, |
- const NewMediaSegmentCB& new_segment_cb) { |
+ const NewMediaSegmentCB& new_segment_cb, |
+ const base::Closure& end_of_segment_cb) { |
DCHECK_EQ(state_, kWaitingForInit); |
DCHECK(init_cb_.is_null()); |
DCHECK(!init_cb.is_null()); |
DCHECK(!config_cb.is_null()); |
DCHECK(!audio_cb.is_null() || !video_cb.is_null()); |
DCHECK(!need_key_cb.is_null()); |
+ DCHECK(!end_of_segment_cb.is_null()); |
ChangeState(kParsingBoxes); |
init_cb_ = init_cb; |
@@ -52,6 +54,7 @@ void MP4StreamParser::Init(const InitCB& init_cb, |
video_cb_ = video_cb; |
need_key_cb_ = need_key_cb; |
new_segment_cb_ = new_segment_cb; |
+ end_of_segment_cb_ = end_of_segment_cb; |
} |
void MP4StreamParser::Flush() { |
@@ -261,8 +264,11 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, |
// Flush any buffers we've gotten in this chunk so that buffers don't |
// cross NewSegment() calls |
*err = !SendAndFlushSamples(audio_buffers, video_buffers); |
- if (*err) return false; |
+ if (*err) |
+ return false; |
+ |
ChangeState(kParsingBoxes); |
+ end_of_segment_cb_.Run(); |
return true; |
} |
@@ -276,16 +282,19 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, |
const uint8* buf; |
int size; |
queue_.Peek(&buf, &size); |
- if (!size) return false; |
+ if (!size) |
+ return false; |
bool audio = has_audio_ && audio_track_id_ == runs_->track_id(); |
bool video = has_video_ && video_track_id_ == runs_->track_id(); |
// Skip this entire track if it's not one we're interested in |
- if (!audio && !video) runs_->AdvanceRun(); |
+ if (!audio && !video) |
+ runs_->AdvanceRun(); |
queue_.PeekAt(runs_->sample_offset() + moof_head_, &buf, &size); |
- if (size < runs_->sample_size()) return false; |
+ if (size < runs_->sample_size()) |
+ return false; |
std::vector<uint8> frame_buf(buf, buf + runs_->sample_size()); |
if (video) { |