Commit 9981a89a authored by Yuchen Liu's avatar Yuchen Liu Committed by Commit Bot

Replace EncryptionScheme with EncryptionMode for mp4

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: default avatarJohn Rummell <jrummell@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710019}
parent ca89ad00
...@@ -44,6 +44,7 @@ const int kMaxVideoKeyframeMismatchLogs = 10; ...@@ -44,6 +44,7 @@ const int kMaxVideoKeyframeMismatchLogs = 10;
// Caller should be prepared to handle return of Unencrypted() in case of // Caller should be prepared to handle return of Unencrypted() in case of
// unsupported scheme. // unsupported scheme.
// TODO(crbug.com/825041): Remove pattern from this function.
EncryptionScheme GetEncryptionScheme(const ProtectionSchemeInfo& sinf) { EncryptionScheme GetEncryptionScheme(const ProtectionSchemeInfo& sinf) {
if (!sinf.HasSupportedScheme()) if (!sinf.HasSupportedScheme())
return Unencrypted(); return Unencrypted();
......
...@@ -13,8 +13,9 @@ ...@@ -13,8 +13,9 @@
#include "base/numerics/checked_math.h" #include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "media/base/decrypt_config.h"
#include "media/base/demuxer_memory_limit.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/media_util.h"
#include "media/base/timestamp_constants.h" #include "media/base/timestamp_constants.h"
#include "media/formats/mp4/rcheck.h" #include "media/formats/mp4/rcheck.h"
...@@ -55,7 +56,10 @@ struct TrackRunInfo { ...@@ -55,7 +56,10 @@ struct TrackRunInfo {
std::vector<uint8_t> aux_info_sizes; // Populated if default_size == 0. std::vector<uint8_t> aux_info_sizes; // Populated if default_size == 0.
int aux_info_total_size; 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; std::vector<CencSampleEncryptionInfoEntry> fragment_sample_encryption_info;
...@@ -370,18 +374,18 @@ bool TrackRunIterator::Init(const MovieFragment& moof) { ...@@ -370,18 +374,18 @@ bool TrackRunIterator::Init(const MovieFragment& moof) {
} }
if (!sinf->HasSupportedScheme()) { if (!sinf->HasSupportedScheme()) {
tri.encryption_scheme = Unencrypted(); tri.encryption_mode = EncryptionMode::kUnencrypted;
} else { } else {
#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME) #if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
tri.encryption_scheme = EncryptionScheme( tri.encryption_mode = sinf->IsCbcsEncryptionScheme()
sinf->IsCbcsEncryptionScheme() ? EncryptionMode::kCbcs
? EncryptionScheme::CIPHER_MODE_AES_CBC : EncryptionMode::kCenc;
: EncryptionScheme::CIPHER_MODE_AES_CTR, tri.encryption_pattern =
EncryptionPattern(track_encryption->default_crypt_byte_block, EncryptionPattern(track_encryption->default_crypt_byte_block,
track_encryption->default_skip_byte_block)); track_encryption->default_skip_byte_block);
#else #else
DCHECK(!sinf->IsCbcsEncryptionScheme()); DCHECK(!sinf->IsCbcsEncryptionScheme());
tri.encryption_scheme = AesCtrEncryptionScheme(); tri.encryption_mode = EncryptionMode::kCenc;
#endif #endif
} }
...@@ -755,16 +759,16 @@ std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() { ...@@ -755,16 +759,16 @@ std::unique_ptr<DecryptConfig> TrackRunIterator::GetDecryptConfig() {
std::string iv(reinterpret_cast<const char*>( std::string iv(reinterpret_cast<const char*>(
sample_encryption_entry.initialization_vector), sample_encryption_entry.initialization_vector),
base::size(sample_encryption_entry.initialization_vector)); base::size(sample_encryption_entry.initialization_vector));
switch (run_itr_->encryption_scheme.mode()) { switch (run_itr_->encryption_mode) {
case EncryptionScheme::CIPHER_MODE_UNENCRYPTED: case EncryptionMode::kUnencrypted:
return nullptr; return nullptr;
case EncryptionScheme::CIPHER_MODE_AES_CTR: case EncryptionMode::kCenc:
return DecryptConfig::CreateCencConfig( return DecryptConfig::CreateCencConfig(
key_id, iv, sample_encryption_entry.subsamples); key_id, iv, sample_encryption_entry.subsamples);
case EncryptionScheme::CIPHER_MODE_AES_CBC: case EncryptionMode::kCbcs:
return DecryptConfig::CreateCbcsConfig( return DecryptConfig::CreateCbcsConfig(
key_id, iv, sample_encryption_entry.subsamples, key_id, iv, sample_encryption_entry.subsamples,
run_itr_->encryption_scheme.pattern()); run_itr_->encryption_pattern);
} }
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment