Skip to content

Commit

Permalink
Replace EncryptionScheme with EncryptionMode for mp4
Browse files Browse the repository at this point in the history
Bug: 825041
Test: CQ, build
Change-Id: Ieeda5d967ed6ba77334b432810f88a6e01a492bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1881688
Commit-Queue: Yuchen Liu <yucliu@chromium.org>
Auto-Submit: Yuchen Liu <yucliu@chromium.org>
Reviewed-by: John Rummell <jrummell@chromium.org>
Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710019}
  • Loading branch information
Yuchen Liu authored and Commit Bot committed Oct 28, 2019
1 parent ca89ad0 commit 9981a89
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions media/formats/mp4/mp4_stream_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const int kMaxVideoKeyframeMismatchLogs = 10;

// Caller should be prepared to handle return of Unencrypted() in case of
// unsupported scheme.
// TODO(crbug.com/825041): Remove pattern from this function.
EncryptionScheme GetEncryptionScheme(const ProtectionSchemeInfo& sinf) {
if (!sinf.HasSupportedScheme())
return Unencrypted();
Expand Down
32 changes: 18 additions & 14 deletions media/formats/mp4/track_run_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "base/stl_util.h"
#include "media/base/decrypt_config.h"
#include "media/base/demuxer_memory_limit.h"
#include "media/base/encryption_scheme.h"
#include "media/base/encryption_pattern.h"
#include "media/base/media_util.h"
#include "media/base/timestamp_constants.h"
#include "media/formats/mp4/rcheck.h"
Expand Down Expand Up @@ -55,7 +56,10 @@ struct TrackRunInfo {
std::vector<uint8_t> aux_info_sizes; // Populated if default_size == 0.
int aux_info_total_size;

EncryptionScheme encryption_scheme;
EncryptionMode encryption_mode;
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
EncryptionPattern encryption_pattern;
#endif // BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)

std::vector<CencSampleEncryptionInfoEntry> fragment_sample_encryption_info;

Expand Down Expand Up @@ -370,18 +374,18 @@ bool TrackRunIterator::Init(const MovieFragment& moof) {
}

if (!sinf->HasSupportedScheme()) {
tri.encryption_scheme = Unencrypted();
tri.encryption_mode = EncryptionMode::kUnencrypted;
} else {
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
tri.encryption_scheme = EncryptionScheme(
sinf->IsCbcsEncryptionScheme()
? EncryptionScheme::CIPHER_MODE_AES_CBC
: EncryptionScheme::CIPHER_MODE_AES_CTR,
tri.encryption_mode = sinf->IsCbcsEncryptionScheme()
? EncryptionMode::kCbcs
: EncryptionMode::kCenc;
tri.encryption_pattern =
EncryptionPattern(track_encryption->default_crypt_byte_block,
track_encryption->default_skip_byte_block));
track_encryption->default_skip_byte_block);
#else
DCHECK(!sinf->IsCbcsEncryptionScheme());
tri.encryption_scheme = AesCtrEncryptionScheme();
tri.encryption_mode = EncryptionMode::kCenc;
#endif
}

Expand Down Expand Up @@ -755,16 +759,16 @@ std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() {
std::string iv(reinterpret_cast<const char*>(
sample_encryption_entry.initialization_vector),
base::size(sample_encryption_entry.initialization_vector));
switch (run_itr_->encryption_scheme.mode()) {
case EncryptionScheme::CIPHER_MODE_UNENCRYPTED:
switch (run_itr_->encryption_mode) {
case EncryptionMode::kUnencrypted:
return nullptr;
case EncryptionScheme::CIPHER_MODE_AES_CTR:
case EncryptionMode::kCenc:
return DecryptConfig::CreateCencConfig(
key_id, iv, sample_encryption_entry.subsamples);
case EncryptionScheme::CIPHER_MODE_AES_CBC:
case EncryptionMode::kCbcs:
return DecryptConfig::CreateCbcsConfig(
key_id, iv, sample_encryption_entry.subsamples,
run_itr_->encryption_scheme.pattern());
run_itr_->encryption_pattern);
}
}
#endif
Expand Down

0 comments on commit 9981a89

Please sign in to comment.