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/time.h" | 10 #include "base/time/time.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
35 audio_object_types_(audio_object_types), | 35 audio_object_types_(audio_object_types), |
36 has_sbr_(has_sbr), | 36 has_sbr_(has_sbr), |
37 is_audio_track_encrypted_(false), | 37 is_audio_track_encrypted_(false), |
38 is_video_track_encrypted_(false) { | 38 is_video_track_encrypted_(false) { |
39 } | 39 } |
40 | 40 |
41 MP4StreamParser::~MP4StreamParser() {} | 41 MP4StreamParser::~MP4StreamParser() {} |
42 | 42 |
43 void MP4StreamParser::Init(const InitCB& init_cb, | 43 void MP4StreamParser::Init(const InitCB& init_cb, |
44 const NewConfigCB& config_cb, | 44 const NewConfigCB& config_cb, |
45 const NewBuffersCB& audio_cb, | 45 const NewBuffersCB& new_buffers_cb, |
46 const NewBuffersCB& video_cb, | |
47 const NewTextBuffersCB& /* text_cb */ , | 46 const NewTextBuffersCB& /* text_cb */ , |
48 const NeedKeyCB& need_key_cb, | 47 const NeedKeyCB& need_key_cb, |
49 const AddTextTrackCB& /* add_text_track_cb */ , | 48 const AddTextTrackCB& /* add_text_track_cb */ , |
50 const NewMediaSegmentCB& new_segment_cb, | 49 const NewMediaSegmentCB& new_segment_cb, |
51 const base::Closure& end_of_segment_cb, | 50 const base::Closure& end_of_segment_cb, |
52 const LogCB& log_cb) { | 51 const LogCB& log_cb) { |
53 DCHECK_EQ(state_, kWaitingForInit); | 52 DCHECK_EQ(state_, kWaitingForInit); |
54 DCHECK(init_cb_.is_null()); | 53 DCHECK(init_cb_.is_null()); |
55 DCHECK(!init_cb.is_null()); | 54 DCHECK(!init_cb.is_null()); |
56 DCHECK(!config_cb.is_null()); | 55 DCHECK(!config_cb.is_null()); |
57 DCHECK(!audio_cb.is_null() || !video_cb.is_null()); | 56 DCHECK(!new_buffers_cb.is_null()); |
58 DCHECK(!need_key_cb.is_null()); | 57 DCHECK(!need_key_cb.is_null()); |
59 DCHECK(!end_of_segment_cb.is_null()); | 58 DCHECK(!end_of_segment_cb.is_null()); |
60 | 59 |
61 ChangeState(kParsingBoxes); | 60 ChangeState(kParsingBoxes); |
62 init_cb_ = init_cb; | 61 init_cb_ = init_cb; |
63 config_cb_ = config_cb; | 62 config_cb_ = config_cb; |
64 audio_cb_ = audio_cb; | 63 new_buffers_cb_ = new_buffers_cb; |
65 video_cb_ = video_cb; | |
66 need_key_cb_ = need_key_cb; | 64 need_key_cb_ = need_key_cb; |
67 new_segment_cb_ = new_segment_cb; | 65 new_segment_cb_ = new_segment_cb; |
68 end_of_segment_cb_ = end_of_segment_cb; | 66 end_of_segment_cb_ = end_of_segment_cb; |
69 log_cb_ = log_cb; | 67 log_cb_ = log_cb; |
70 } | 68 } |
71 | 69 |
72 void MP4StreamParser::Reset() { | 70 void MP4StreamParser::Reset() { |
73 queue_.Reset(); | 71 queue_.Reset(); |
74 runs_.reset(); | 72 runs_.reset(); |
75 moof_head_ = 0; | 73 moof_head_ = 0; |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 } else { | 525 } else { |
528 video_buffers->push_back(stream_buf); | 526 video_buffers->push_back(stream_buf); |
529 } | 527 } |
530 | 528 |
531 runs_->AdvanceSample(); | 529 runs_->AdvanceSample(); |
532 return true; | 530 return true; |
533 } | 531 } |
534 | 532 |
535 bool MP4StreamParser::SendAndFlushSamples(BufferQueue* audio_buffers, | 533 bool MP4StreamParser::SendAndFlushSamples(BufferQueue* audio_buffers, |
536 BufferQueue* video_buffers) { | 534 BufferQueue* video_buffers) { |
537 bool err = false; | 535 if (audio_buffers->empty() && video_buffers->empty()) |
scherkus (not reviewing)
2013/07/24 22:47:41
OOC is there any harm in running the cb w/ empty q
acolwell GONE FROM CHROMIUM
2013/07/25 20:39:33
No. It just violates the contract for the NewBuffe
| |
538 if (!audio_buffers->empty()) { | 536 return true; |
539 err |= (audio_cb_.is_null() || !audio_cb_.Run(*audio_buffers)); | 537 |
540 audio_buffers->clear(); | 538 bool success = new_buffers_cb_.Run(*audio_buffers, *video_buffers); |
541 } | 539 audio_buffers->clear(); |
542 if (!video_buffers->empty()) { | 540 video_buffers->clear(); |
543 err |= (video_cb_.is_null() || !video_cb_.Run(*video_buffers)); | 541 return success; |
544 video_buffers->clear(); | |
545 } | |
546 return !err; | |
547 } | 542 } |
548 | 543 |
549 bool MP4StreamParser::ReadAndDiscardMDATsUntil(const int64 offset) { | 544 bool MP4StreamParser::ReadAndDiscardMDATsUntil(const int64 offset) { |
550 bool err = false; | 545 bool err = false; |
551 while (mdat_tail_ < offset) { | 546 while (mdat_tail_ < offset) { |
552 const uint8* buf; | 547 const uint8* buf; |
553 int size; | 548 int size; |
554 queue_.PeekAt(mdat_tail_, &buf, &size); | 549 queue_.PeekAt(mdat_tail_, &buf, &size); |
555 | 550 |
556 FourCC type; | 551 FourCC type; |
(...skipping 12 matching lines...) Expand all Loading... | |
569 return !err; | 564 return !err; |
570 } | 565 } |
571 | 566 |
572 void MP4StreamParser::ChangeState(State new_state) { | 567 void MP4StreamParser::ChangeState(State new_state) { |
573 DVLOG(2) << "Changing state: " << new_state; | 568 DVLOG(2) << "Changing state: " << new_state; |
574 state_ = new_state; | 569 state_ = new_state; |
575 } | 570 } |
576 | 571 |
577 } // namespace mp4 | 572 } // namespace mp4 |
578 } // namespace media | 573 } // namespace media |
OLD | NEW |