Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: media/formats/mp4/track_run_iterator.cc

Issue 1874413003: Convert media/formats to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <iomanip> 8 #include <iomanip>
9 #include <limits> 9 #include <limits>
10 #include <memory>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "media/formats/mp4/rcheck.h" 13 #include "media/formats/mp4/rcheck.h"
13 #include "media/formats/mp4/sample_to_group_iterator.h" 14 #include "media/formats/mp4/sample_to_group_iterator.h"
14 15
15 namespace media { 16 namespace media {
16 namespace mp4 { 17 namespace mp4 {
17 18
18 struct SampleInfo { 19 struct SampleInfo {
19 int size; 20 int size;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 DVLOG(1) << "Skipping unhandled track type"; 274 DVLOG(1) << "Skipping unhandled track type";
274 continue; 275 continue;
275 } 276 }
276 size_t desc_idx = traf.header.sample_description_index; 277 size_t desc_idx = traf.header.sample_description_index;
277 if (!desc_idx) desc_idx = trex->default_sample_description_index; 278 if (!desc_idx) desc_idx = trex->default_sample_description_index;
278 RCHECK(desc_idx > 0); // Descriptions are one-indexed in the file 279 RCHECK(desc_idx > 0); // Descriptions are one-indexed in the file
279 desc_idx -= 1; 280 desc_idx -= 1;
280 281
281 const std::vector<uint8_t>& sample_encryption_data = 282 const std::vector<uint8_t>& sample_encryption_data =
282 traf.sample_encryption.sample_encryption_data; 283 traf.sample_encryption.sample_encryption_data;
283 scoped_ptr<BufferReader> sample_encryption_reader; 284 std::unique_ptr<BufferReader> sample_encryption_reader;
284 uint32_t sample_encrytion_entries_count = 0; 285 uint32_t sample_encrytion_entries_count = 0;
285 if (!sample_encryption_data.empty()) { 286 if (!sample_encryption_data.empty()) {
286 sample_encryption_reader.reset(new BufferReader( 287 sample_encryption_reader.reset(new BufferReader(
287 sample_encryption_data.data(), sample_encryption_data.size())); 288 sample_encryption_data.data(), sample_encryption_data.size()));
288 RCHECK(sample_encryption_reader->Read4(&sample_encrytion_entries_count)); 289 RCHECK(sample_encryption_reader->Read4(&sample_encrytion_entries_count));
289 } 290 }
290 291
291 // Process edit list to remove CTS offset introduced in the presence of 292 // Process edit list to remove CTS offset introduced in the presence of
292 // B-frames (those that contain a single edit with a nonnegative media 293 // B-frames (those that contain a single edit with a nonnegative media
293 // time). Other uses of edit lists are not supported, as they are 294 // time). Other uses of edit lists are not supported, as they are
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 DCHECK(IsSampleValid()); 583 DCHECK(IsSampleValid());
583 return sample_itr_->is_keyframe; 584 return sample_itr_->is_keyframe;
584 } 585 }
585 586
586 const TrackEncryption& TrackRunIterator::track_encryption() const { 587 const TrackEncryption& TrackRunIterator::track_encryption() const {
587 if (is_audio()) 588 if (is_audio())
588 return audio_description().sinf.info.track_encryption; 589 return audio_description().sinf.info.track_encryption;
589 return video_description().sinf.info.track_encryption; 590 return video_description().sinf.info.track_encryption;
590 } 591 }
591 592
592 scoped_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() { 593 std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() {
593 DCHECK(is_encrypted()); 594 DCHECK(is_encrypted());
594 595
595 if (run_itr_->sample_encryption_entries.empty()) { 596 if (run_itr_->sample_encryption_entries.empty()) {
596 DCHECK_EQ(0, aux_info_size()); 597 DCHECK_EQ(0, aux_info_size());
597 MEDIA_LOG(ERROR, media_log_) << "Sample encryption info is not available."; 598 MEDIA_LOG(ERROR, media_log_) << "Sample encryption info is not available.";
598 return scoped_ptr<DecryptConfig>(); 599 return std::unique_ptr<DecryptConfig>();
599 } 600 }
600 601
601 size_t sample_idx = sample_itr_ - run_itr_->samples.begin(); 602 size_t sample_idx = sample_itr_ - run_itr_->samples.begin();
602 DCHECK_LT(sample_idx, run_itr_->sample_encryption_entries.size()); 603 DCHECK_LT(sample_idx, run_itr_->sample_encryption_entries.size());
603 const SampleEncryptionEntry& sample_encryption_entry = 604 const SampleEncryptionEntry& sample_encryption_entry =
604 run_itr_->sample_encryption_entries[sample_idx]; 605 run_itr_->sample_encryption_entries[sample_idx];
605 606
606 size_t total_size = 0; 607 size_t total_size = 0;
607 if (!sample_encryption_entry.subsamples.empty() && 608 if (!sample_encryption_entry.subsamples.empty() &&
608 (!sample_encryption_entry.GetTotalSizeOfSubsamples(&total_size) || 609 (!sample_encryption_entry.GetTotalSizeOfSubsamples(&total_size) ||
609 total_size != static_cast<size_t>(sample_size()))) { 610 total_size != static_cast<size_t>(sample_size()))) {
610 MEDIA_LOG(ERROR, media_log_) << "Incorrect CENC subsample size."; 611 MEDIA_LOG(ERROR, media_log_) << "Incorrect CENC subsample size.";
611 return scoped_ptr<DecryptConfig>(); 612 return std::unique_ptr<DecryptConfig>();
612 } 613 }
613 614
614 const std::vector<uint8_t>& kid = GetKeyId(sample_idx); 615 const std::vector<uint8_t>& kid = GetKeyId(sample_idx);
615 return scoped_ptr<DecryptConfig>(new DecryptConfig( 616 return std::unique_ptr<DecryptConfig>(new DecryptConfig(
616 std::string(reinterpret_cast<const char*>(&kid[0]), kid.size()), 617 std::string(reinterpret_cast<const char*>(&kid[0]), kid.size()),
617 std::string(reinterpret_cast<const char*>( 618 std::string(reinterpret_cast<const char*>(
618 sample_encryption_entry.initialization_vector), 619 sample_encryption_entry.initialization_vector),
619 arraysize(sample_encryption_entry.initialization_vector)), 620 arraysize(sample_encryption_entry.initialization_vector)),
620 sample_encryption_entry.subsamples)); 621 sample_encryption_entry.subsamples));
621 } 622 }
622 623
623 uint32_t TrackRunIterator::GetGroupDescriptionIndex( 624 uint32_t TrackRunIterator::GetGroupDescriptionIndex(
624 uint32_t sample_index) const { 625 uint32_t sample_index) const {
625 DCHECK(IsRunValid()); 626 DCHECK(IsRunValid());
(...skipping 16 matching lines...) Expand all
642 } 643 }
643 644
644 uint8_t TrackRunIterator::GetIvSize(size_t sample_index) const { 645 uint8_t TrackRunIterator::GetIvSize(size_t sample_index) const {
645 uint32_t index = GetGroupDescriptionIndex(sample_index); 646 uint32_t index = GetGroupDescriptionIndex(sample_index);
646 return (index == 0) ? track_encryption().default_iv_size 647 return (index == 0) ? track_encryption().default_iv_size
647 : GetSampleEncryptionInfoEntry(*run_itr_, index)->iv_size; 648 : GetSampleEncryptionInfoEntry(*run_itr_, index)->iv_size;
648 } 649 }
649 650
650 } // namespace mp4 651 } // namespace mp4
651 } // namespace media 652 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698