Chromium Code Reviews| Index: media/formats/mp4/track_run_iterator.cc |
| diff --git a/media/formats/mp4/track_run_iterator.cc b/media/formats/mp4/track_run_iterator.cc |
| index 7193b3d26dd9d5eb03b47ef298bc8d4d99ec11c6..028a87301293d81be4f942bf7bb0f60da3c38449 100644 |
| --- a/media/formats/mp4/track_run_iterator.cc |
| +++ b/media/formats/mp4/track_run_iterator.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/macros.h" |
| #include "media/formats/mp4/rcheck.h" |
| #include "media/formats/mp4/sample_to_group_iterator.h" |
| +#include "media/media_features.h" |
| namespace media { |
| namespace mp4 { |
| @@ -282,11 +283,11 @@ bool TrackRunIterator::Init(const MovieFragment& moof) { |
| const std::vector<uint8_t>& sample_encryption_data = |
| traf.sample_encryption.sample_encryption_data; |
| std::unique_ptr<BufferReader> sample_encryption_reader; |
| - uint32_t sample_encrytion_entries_count = 0; |
| + uint32_t sample_encryption_entries_count = 0; |
| if (!sample_encryption_data.empty()) { |
| sample_encryption_reader.reset(new BufferReader( |
| sample_encryption_data.data(), sample_encryption_data.size())); |
| - RCHECK(sample_encryption_reader->Read4(&sample_encrytion_entries_count)); |
| + RCHECK(sample_encryption_reader->Read4(&sample_encryption_entries_count)); |
| } |
| // Process edit list to remove CTS offset introduced in the presence of |
| @@ -323,26 +324,23 @@ bool TrackRunIterator::Init(const MovieFragment& moof) { |
| tri.fragment_sample_encryption_info = |
| traf.sample_group_description.entries; |
| - uint8_t default_iv_size = 0; |
| + const TrackEncryption* track_encryption; |
| tri.is_audio = (stsd.type == kAudio); |
| if (tri.is_audio) { |
| RCHECK(!stsd.audio_entries.empty()); |
| if (desc_idx > stsd.audio_entries.size()) |
| desc_idx = 0; |
| tri.audio_description = &stsd.audio_entries[desc_idx]; |
| - default_iv_size = |
| - tri.audio_description->sinf.info.track_encryption.default_iv_size; |
| + track_encryption = &tri.audio_description->sinf.info.track_encryption; |
| } else { |
| RCHECK(!stsd.video_entries.empty()); |
| if (desc_idx > stsd.video_entries.size()) |
| desc_idx = 0; |
| tri.video_description = &stsd.video_entries[desc_idx]; |
| - default_iv_size = |
| - tri.video_description->sinf.info.track_encryption.default_iv_size; |
| + track_encryption = &tri.video_description->sinf.info.track_encryption; |
| } |
| - |
| // Initialize aux_info variables only if no sample encryption entries. |
| - if (sample_encrytion_entries_count == 0 && |
| + if (sample_encryption_entries_count == 0 && |
| traf.auxiliary_offset.offsets.size() > j) { |
| // Collect information from the auxiliary_offset entry with the same |
| // index in the 'saiz' container as the current run's index in the |
| @@ -402,18 +400,39 @@ bool TrackRunIterator::Init(const MovieFragment& moof) { |
| RCHECK(GetSampleEncryptionInfoEntry(tri, index)); |
| is_sample_to_group_valid = sample_to_group_itr.Advance(); |
| } |
| - if (sample_encrytion_entries_count > 0) { |
| - RCHECK(sample_encrytion_entries_count >= |
| + if (sample_encryption_entries_count > 0) { |
| + RCHECK(sample_encryption_entries_count >= |
| sample_count_sum + trun.sample_count); |
| tri.sample_encryption_entries.resize(trun.sample_count); |
| for (size_t k = 0; k < trun.sample_count; k++) { |
| uint32_t index = tri.samples[k].cenc_group_description_index; |
| - const uint8_t iv_size = |
| - index == 0 ? default_iv_size |
| - : GetSampleEncryptionInfoEntry(tri, index)->iv_size; |
| - RCHECK(tri.sample_encryption_entries[k].Parse( |
| - sample_encryption_reader.get(), iv_size, |
| - traf.sample_encryption.use_subsample_encryption)); |
| + const CencSampleEncryptionInfoEntry* info_entry = |
| + index == 0 ? nullptr : GetSampleEncryptionInfoEntry(tri, index); |
| + const uint8_t iv_size = index == 0 ? track_encryption->default_iv_size |
| + : info_entry->iv_size; |
| + SampleEncryptionEntry& entry = tri.sample_encryption_entries[k]; |
| + RCHECK(entry.Parse(sample_encryption_reader.get(), iv_size, |
| + traf.sample_encryption.use_subsample_encryption)); |
| +#if BUILDFLAG(ENABLE_CENC_NEW_EDITIONS) |
| + // if we don't have a per-sample IV, get the constant IV. |
| + if (!iv_size) { |
| + const uint8_t constant_iv_size = |
| + index == 0 ? track_encryption->default_constant_iv_size |
| + : info_entry->constant_iv_size; |
| + const uint8_t* constant_iv = |
| + index == 0 ? track_encryption->default_constant_iv |
| + : info_entry->constant_iv; |
|
kqyang
2016/05/23 20:57:34
Add a RCHECK or DCHECK that constant_iv_size != 0?
dougsteed
2016/05/25 17:23:21
Done.
|
| + memcpy(entry.initialization_vector, constant_iv, constant_iv_size); |
| + } |
| + // We only support setting the pattern values in the 'tenc' box for |
| + // the track (not varying on per sample group basis). |
| + // Thus we need to verify that the settings in the sample group match |
| + // those in the 'tenc'. |
| + RCHECK(info_entry->crypt_byte_block == |
| + track_encryption->default_crypt_byte_block); |
| + RCHECK(info_entry->skip_byte_block == |
| + track_encryption->default_skip_byte_block); |
|
kqyang
2016/05/23 20:57:34
The two RCHECKs should be enclosed in index != 0 o
dougsteed
2016/05/25 17:23:21
good catch, thank you.
|
| +#endif |
| } |
| } |
| runs_.push_back(tri); |