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 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
(...skipping 15 matching lines...) Expand all Loading... | |
26 #include "media/base/video_util.h" | 26 #include "media/base/video_util.h" |
27 #include "media/formats/mp4/box_definitions.h" | 27 #include "media/formats/mp4/box_definitions.h" |
28 #include "media/formats/mp4/box_reader.h" | 28 #include "media/formats/mp4/box_reader.h" |
29 #include "media/formats/mp4/es_descriptor.h" | 29 #include "media/formats/mp4/es_descriptor.h" |
30 #include "media/formats/mp4/rcheck.h" | 30 #include "media/formats/mp4/rcheck.h" |
31 #include "media/formats/mpeg/adts_constants.h" | 31 #include "media/formats/mpeg/adts_constants.h" |
32 | 32 |
33 namespace media { | 33 namespace media { |
34 namespace mp4 { | 34 namespace mp4 { |
35 | 35 |
36 namespace { | |
37 const int kMaxEmptySampleLogs = 20; | |
38 } | |
wolenetz
2016/09/23 19:14:54
nit: // namespace
| |
39 | |
36 MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types, | 40 MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types, |
37 bool has_sbr) | 41 bool has_sbr) |
38 : state_(kWaitingForInit), | 42 : state_(kWaitingForInit), |
39 moof_head_(0), | 43 moof_head_(0), |
40 mdat_tail_(0), | 44 mdat_tail_(0), |
41 highest_end_offset_(0), | 45 highest_end_offset_(0), |
42 has_audio_(false), | 46 has_audio_(false), |
43 has_video_(false), | 47 has_video_(false), |
44 audio_object_types_(audio_object_types), | 48 audio_object_types_(audio_object_types), |
45 has_sbr_(has_sbr), | 49 has_sbr_(has_sbr), |
46 num_top_level_box_skipped_(0) { | 50 num_top_level_box_skipped_(0), |
wolenetz
2016/09/23 19:14:54
aside: this other counter is no longer used. we sh
| |
47 } | 51 num_emtpy_samples_skipped_(0) {} |
48 | 52 |
49 MP4StreamParser::~MP4StreamParser() {} | 53 MP4StreamParser::~MP4StreamParser() {} |
50 | 54 |
51 void MP4StreamParser::Init( | 55 void MP4StreamParser::Init( |
52 const InitCB& init_cb, | 56 const InitCB& init_cb, |
53 const NewConfigCB& config_cb, | 57 const NewConfigCB& config_cb, |
54 const NewBuffersCB& new_buffers_cb, | 58 const NewBuffersCB& new_buffers_cb, |
55 bool /* ignore_text_tracks */, | 59 bool /* ignore_text_tracks */, |
56 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, | 60 const EncryptedMediaInitDataCB& encrypted_media_init_data_cb, |
57 const NewMediaSegmentCB& new_segment_cb, | 61 const NewMediaSegmentCB& new_segment_cb, |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 if (runs_->AuxInfoNeedsToBeCached()) { | 554 if (runs_->AuxInfoNeedsToBeCached()) { |
551 queue_.PeekAt(runs_->aux_info_offset() + moof_head_, &buf, &buf_size); | 555 queue_.PeekAt(runs_->aux_info_offset() + moof_head_, &buf, &buf_size); |
552 if (buf_size < runs_->aux_info_size()) return false; | 556 if (buf_size < runs_->aux_info_size()) return false; |
553 *err = !runs_->CacheAuxInfo(buf, buf_size); | 557 *err = !runs_->CacheAuxInfo(buf, buf_size); |
554 return !*err; | 558 return !*err; |
555 } | 559 } |
556 | 560 |
557 queue_.PeekAt(runs_->sample_offset() + moof_head_, &buf, &buf_size); | 561 queue_.PeekAt(runs_->sample_offset() + moof_head_, &buf, &buf_size); |
558 if (buf_size < runs_->sample_size()) return false; | 562 if (buf_size < runs_->sample_size()) return false; |
559 | 563 |
564 if (runs_->sample_size() == 0) { | |
565 // Generally not expected, but spec allows it. Code below this block assumes | |
566 // the current sample is not empty. | |
567 LIMITED_MEDIA_LOG(DEBUG, media_log_, num_emtpy_samples_skipped_, | |
568 kMaxEmptySampleLogs) | |
569 << " Skipping 'trun' sample with size of 0."; | |
570 runs_->AdvanceSample(); | |
571 return true; | |
572 } | |
573 | |
560 std::unique_ptr<DecryptConfig> decrypt_config; | 574 std::unique_ptr<DecryptConfig> decrypt_config; |
561 std::vector<SubsampleEntry> subsamples; | 575 std::vector<SubsampleEntry> subsamples; |
562 if (runs_->is_encrypted()) { | 576 if (runs_->is_encrypted()) { |
563 decrypt_config = runs_->GetDecryptConfig(); | 577 decrypt_config = runs_->GetDecryptConfig(); |
564 if (!decrypt_config) { | 578 if (!decrypt_config) { |
565 *err = true; | 579 *err = true; |
566 return false; | 580 return false; |
567 } | 581 } |
568 subsamples = decrypt_config->subsamples(); | 582 subsamples = decrypt_config->subsamples(); |
569 } | 583 } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
704 runs.AdvanceSample(); | 718 runs.AdvanceSample(); |
705 } | 719 } |
706 runs.AdvanceRun(); | 720 runs.AdvanceRun(); |
707 } | 721 } |
708 | 722 |
709 return true; | 723 return true; |
710 } | 724 } |
711 | 725 |
712 } // namespace mp4 | 726 } // namespace mp4 |
713 } // namespace media | 727 } // namespace media |
OLD | NEW |