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/track_run_iterator.h" | 5 #include "media/formats/mp4/track_run_iterator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
10 #include "media/formats/mp4/rcheck.h" | 10 #include "media/formats/mp4/rcheck.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 case kSampleDependsOnOthers: | 151 case kSampleDependsOnOthers: |
152 sample_info->is_keyframe = false; | 152 sample_info->is_keyframe = false; |
153 break; | 153 break; |
154 | 154 |
155 case kSampleDependsOnNoOther: | 155 case kSampleDependsOnNoOther: |
156 sample_info->is_keyframe = true; | 156 sample_info->is_keyframe = true; |
157 break; | 157 break; |
158 | 158 |
159 case kSampleDependsOnReserved: | 159 case kSampleDependsOnReserved: |
160 MEDIA_LOG(log_cb) << "Reserved value used in sample dependency info."; | 160 MEDIA_LOG(ERROR, log_cb) << "Reserved value used in sample dependency" |
| 161 " info."; |
161 return false; | 162 return false; |
162 } | 163 } |
163 return true; | 164 return true; |
164 } | 165 } |
165 | 166 |
166 // In well-structured encrypted media, each track run will be immediately | 167 // In well-structured encrypted media, each track run will be immediately |
167 // preceded by its auxiliary information; this is the only optimal storage | 168 // preceded by its auxiliary information; this is the only optimal storage |
168 // pattern in terms of minimum number of bytes from a serial stream needed to | 169 // pattern in terms of minimum number of bytes from a serial stream needed to |
169 // begin playback. It also allows us to optimize caching on memory-constrained | 170 // begin playback. It also allows us to optimize caching on memory-constrained |
170 // architectures, because we can cache the relatively small auxiliary | 171 // architectures, because we can cache the relatively small auxiliary |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 if (is_audio()) | 512 if (is_audio()) |
512 return audio_description().sinf.info.track_encryption; | 513 return audio_description().sinf.info.track_encryption; |
513 return video_description().sinf.info.track_encryption; | 514 return video_description().sinf.info.track_encryption; |
514 } | 515 } |
515 | 516 |
516 scoped_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() { | 517 scoped_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() { |
517 DCHECK(is_encrypted()); | 518 DCHECK(is_encrypted()); |
518 | 519 |
519 if (cenc_info_.empty()) { | 520 if (cenc_info_.empty()) { |
520 DCHECK_EQ(0, aux_info_size()); | 521 DCHECK_EQ(0, aux_info_size()); |
521 MEDIA_LOG(log_cb_) << "Aux Info is not available."; | 522 MEDIA_LOG(ERROR, log_cb_) << "Aux Info is not available."; |
522 return scoped_ptr<DecryptConfig>(); | 523 return scoped_ptr<DecryptConfig>(); |
523 } | 524 } |
524 | 525 |
525 size_t sample_idx = sample_itr_ - run_itr_->samples.begin(); | 526 size_t sample_idx = sample_itr_ - run_itr_->samples.begin(); |
526 DCHECK_LT(sample_idx, cenc_info_.size()); | 527 DCHECK_LT(sample_idx, cenc_info_.size()); |
527 const FrameCENCInfo& cenc_info = cenc_info_[sample_idx]; | 528 const FrameCENCInfo& cenc_info = cenc_info_[sample_idx]; |
528 | 529 |
529 size_t total_size = 0; | 530 size_t total_size = 0; |
530 if (!cenc_info.subsamples.empty() && | 531 if (!cenc_info.subsamples.empty() && |
531 (!cenc_info.GetTotalSizeOfSubsamples(&total_size) || | 532 (!cenc_info.GetTotalSizeOfSubsamples(&total_size) || |
532 total_size != static_cast<size_t>(sample_size()))) { | 533 total_size != static_cast<size_t>(sample_size()))) { |
533 MEDIA_LOG(log_cb_) << "Incorrect CENC subsample size."; | 534 MEDIA_LOG(ERROR, log_cb_) << "Incorrect CENC subsample size."; |
534 return scoped_ptr<DecryptConfig>(); | 535 return scoped_ptr<DecryptConfig>(); |
535 } | 536 } |
536 | 537 |
537 const std::vector<uint8>& kid = GetKeyId(sample_idx); | 538 const std::vector<uint8>& kid = GetKeyId(sample_idx); |
538 return scoped_ptr<DecryptConfig>(new DecryptConfig( | 539 return scoped_ptr<DecryptConfig>(new DecryptConfig( |
539 std::string(reinterpret_cast<const char*>(&kid[0]), kid.size()), | 540 std::string(reinterpret_cast<const char*>(&kid[0]), kid.size()), |
540 std::string(reinterpret_cast<const char*>(cenc_info.iv), | 541 std::string(reinterpret_cast<const char*>(cenc_info.iv), |
541 arraysize(cenc_info.iv)), | 542 arraysize(cenc_info.iv)), |
542 cenc_info.subsamples)); | 543 cenc_info.subsamples)); |
543 } | 544 } |
(...skipping 28 matching lines...) Expand all Loading... |
572 } | 573 } |
573 | 574 |
574 uint8 TrackRunIterator::GetIvSize(size_t sample_index) const { | 575 uint8 TrackRunIterator::GetIvSize(size_t sample_index) const { |
575 uint32 index = GetGroupDescriptionIndex(sample_index); | 576 uint32 index = GetGroupDescriptionIndex(sample_index); |
576 return (index == 0) ? track_encryption().default_iv_size | 577 return (index == 0) ? track_encryption().default_iv_size |
577 : GetSampleEncryptionInfoEntry(index).iv_size; | 578 : GetSampleEncryptionInfoEntry(index).iv_size; |
578 } | 579 } |
579 | 580 |
580 } // namespace mp4 | 581 } // namespace mp4 |
581 } // namespace media | 582 } // namespace media |
OLD | NEW |