OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/mp4/mp4_stream_parser.h" | 5 #include "media/mp4/mp4_stream_parser.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 | 73 |
74 queue_.Push(buf, size); | 74 queue_.Push(buf, size); |
75 | 75 |
76 BufferQueue audio_buffers; | 76 BufferQueue audio_buffers; |
77 BufferQueue video_buffers; | 77 BufferQueue video_buffers; |
78 | 78 |
79 bool result, err = false; | 79 bool result, err = false; |
80 | 80 |
81 do { | 81 do { |
82 if (state_ == kParsingBoxes) { | 82 if (state_ == kParsingBoxes) { |
83 if (mdat_tail_ > queue_.head()) { | 83 result = ParseBox(&err); |
84 result = queue_.Trim(mdat_tail_); | |
85 } else { | |
86 result = ParseBox(&err); | |
87 } | |
88 } else { | 84 } else { |
89 DCHECK_EQ(kEmittingSamples, state_); | 85 DCHECK_EQ(kEmittingSamples, state_); |
90 result = EnqueueSample(&audio_buffers, &video_buffers, &err); | 86 result = EnqueueSample(&audio_buffers, &video_buffers, &err); |
91 if (result) { | 87 if (result) { |
92 int64 max_clear = runs_->GetMaxClearOffset() + moof_head_; | 88 int64 max_clear = runs_->GetMaxClearOffset() + moof_head_; |
93 DCHECK(max_clear <= queue_.tail()); | 89 DCHECK(max_clear <= queue_.tail()); |
94 err = !(ReadMDATsUntil(max_clear) && queue_.Trim(max_clear)); | 90 err = !(ReadMDATsUntil(max_clear) && queue_.Trim(max_clear)); |
95 } | 91 } |
96 } | 92 } |
97 } while (result && !err); | 93 } while (result && !err); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, | 311 bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, |
316 BufferQueue* video_buffers, | 312 BufferQueue* video_buffers, |
317 bool* err) { | 313 bool* err) { |
318 if (!runs_->IsRunValid()) { | 314 if (!runs_->IsRunValid()) { |
319 // Flush any buffers we've gotten in this chunk so that buffers don't | 315 // Flush any buffers we've gotten in this chunk so that buffers don't |
320 // cross NewSegment() calls | 316 // cross NewSegment() calls |
321 *err = !SendAndFlushSamples(audio_buffers, video_buffers); | 317 *err = !SendAndFlushSamples(audio_buffers, video_buffers); |
322 if (*err) | 318 if (*err) |
323 return false; | 319 return false; |
324 | 320 |
321 // Remain in kEnqueueingSamples state, discarding data, until the end of | |
322 // the current 'mdat' box has been appended to the queue. | |
323 if (!queue_.Trim(mdat_tail_)) return false; | |
acolwell GONE FROM CHROMIUM
2012/07/30 15:45:50
nit: Put return on its own line.
strobe_
2012/07/30 16:33:38
Done.
| |
324 | |
325 ChangeState(kParsingBoxes); | 325 ChangeState(kParsingBoxes); |
326 end_of_segment_cb_.Run(); | 326 end_of_segment_cb_.Run(); |
327 return true; | 327 return true; |
328 } | 328 } |
329 | 329 |
330 if (!runs_->IsSampleValid()) { | 330 if (!runs_->IsSampleValid()) { |
331 runs_->AdvanceRun(); | 331 runs_->AdvanceRun(); |
332 return true; | 332 return true; |
333 } | 333 } |
334 | 334 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 return true; | 456 return true; |
457 } | 457 } |
458 | 458 |
459 void MP4StreamParser::ChangeState(State new_state) { | 459 void MP4StreamParser::ChangeState(State new_state) { |
460 DVLOG(2) << "Changing state: " << new_state; | 460 DVLOG(2) << "Changing state: " << new_state; |
461 state_ = new_state; | 461 state_ = new_state; |
462 } | 462 } |
463 | 463 |
464 } // namespace mp4 | 464 } // namespace mp4 |
465 } // namespace media | 465 } // namespace media |
OLD | NEW |