OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/formats/mp4/mp4_stream_parser.h" | 5 #include "media/formats/mp4/mp4_stream_parser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, | 55 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, |
56 const NewMediaSegmentCB& new_segment_cb, | 56 const NewMediaSegmentCB& new_segment_cb, |
57 const EndMediaSegmentCB& end_of_segment_cb, | 57 const EndMediaSegmentCB& end_of_segment_cb, |
58 const scoped_refptr<MediaLog>& media_log) { | 58 const scoped_refptr<MediaLog>& media_log) { |
59 DCHECK_EQ(state_, kWaitingForInit); | 59 DCHECK_EQ(state_, kWaitingForInit); |
60 DCHECK(init_cb_.is_null()); | 60 DCHECK(init_cb_.is_null()); |
61 DCHECK(!init_cb.is_null()); | 61 DCHECK(!init_cb.is_null()); |
62 DCHECK(!config_cb.is_null()); | 62 DCHECK(!config_cb.is_null()); |
63 DCHECK(!new_buffers_cb.is_null()); | 63 DCHECK(!new_buffers_cb.is_null()); |
64 DCHECK(!encrypted_media_init_data_cb.is_null()); | 64 DCHECK(!encrypted_media_init_data_cb.is_null()); |
65 DCHECK(!new_segment_cb.is_null()); | |
66 DCHECK(!end_of_segment_cb.is_null()); | 65 DCHECK(!end_of_segment_cb.is_null()); |
67 | 66 |
68 ChangeState(kParsingBoxes); | 67 ChangeState(kParsingBoxes); |
69 init_cb_ = init_cb; | 68 init_cb_ = init_cb; |
70 config_cb_ = config_cb; | 69 config_cb_ = config_cb; |
71 new_buffers_cb_ = new_buffers_cb; | 70 new_buffers_cb_ = new_buffers_cb; |
72 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; | 71 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; |
73 new_segment_cb_ = new_segment_cb; | 72 new_segment_cb_ = new_segment_cb; |
74 end_of_segment_cb_ = end_of_segment_cb; | 73 end_of_segment_cb_ = end_of_segment_cb; |
75 media_log_ = media_log; | 74 media_log_ = media_log; |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 return true; | 436 return true; |
438 } | 437 } |
439 | 438 |
440 bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, | 439 bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, |
441 BufferQueue* video_buffers, | 440 BufferQueue* video_buffers, |
442 bool* err) { | 441 bool* err) { |
443 DCHECK_EQ(state_, kEmittingSamples); | 442 DCHECK_EQ(state_, kEmittingSamples); |
444 | 443 |
445 if (!runs_->IsRunValid()) { | 444 if (!runs_->IsRunValid()) { |
446 // Flush any buffers we've gotten in this chunk so that buffers don't | 445 // Flush any buffers we've gotten in this chunk so that buffers don't |
447 // cross |new_segment_cb_| calls | 446 // cross NewSegment() calls |
448 *err = !SendAndFlushSamples(audio_buffers, video_buffers); | 447 *err = !SendAndFlushSamples(audio_buffers, video_buffers); |
449 if (*err) | 448 if (*err) |
450 return false; | 449 return false; |
451 | 450 |
452 // Remain in kEmittingSamples state, discarding data, until the end of | 451 // Remain in kEmittingSamples state, discarding data, until the end of |
453 // the current 'mdat' box has been appended to the queue. | 452 // the current 'mdat' box has been appended to the queue. |
454 if (!queue_.Trim(mdat_tail_)) | 453 if (!queue_.Trim(mdat_tail_)) |
455 return false; | 454 return false; |
456 | 455 |
457 ChangeState(kParsingBoxes); | 456 ChangeState(kParsingBoxes); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 runs.AdvanceSample(); | 655 runs.AdvanceSample(); |
657 } | 656 } |
658 runs.AdvanceRun(); | 657 runs.AdvanceRun(); |
659 } | 658 } |
660 | 659 |
661 return true; | 660 return true; |
662 } | 661 } |
663 | 662 |
664 } // namespace mp4 | 663 } // namespace mp4 |
665 } // namespace media | 664 } // namespace media |
OLD | NEW |