| Index: media/formats/mp4/mp4_stream_parser.cc
|
| diff --git a/media/formats/mp4/mp4_stream_parser.cc b/media/formats/mp4/mp4_stream_parser.cc
|
| index dbd736df941a6542415faa81490e0bb290ec448f..dc785d2ee87c5beb322abd7e863ea36240dc302e 100644
|
| --- a/media/formats/mp4/mp4_stream_parser.cc
|
| +++ b/media/formats/mp4/mp4_stream_parser.cc
|
| @@ -17,6 +17,7 @@
|
| #include "base/time/time.h"
|
| #include "build/build_config.h"
|
| #include "media/base/audio_decoder_config.h"
|
| +#include "media/base/encryption_scheme.h"
|
| #include "media/base/media_tracks.h"
|
| #include "media/base/media_util.h"
|
| #include "media/base/stream_parser_buffer.h"
|
| @@ -33,6 +34,41 @@
|
| namespace media {
|
| namespace mp4 {
|
|
|
| +namespace {
|
| +
|
| +EncryptionScheme GetEncryptionScheme(const ProtectionSchemeInfo& sinf) {
|
| + if (!sinf.HasSupportedScheme())
|
| + return Unencrypted();
|
| + FourCC fourCC = sinf.type.type;
|
| + EncryptionScheme::CipherMode mode = EncryptionScheme::CIPHER_MODE_UNENCRYPTED;
|
| + EncryptionScheme::Pattern pattern;
|
| + bool pattern_encryption = false;
|
| + switch (fourCC) {
|
| + case FOURCC_CENC:
|
| + mode = EncryptionScheme::CIPHER_MODE_AES_CTR;
|
| + break;
|
| +#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
|
| + case FOURCC_CBCS:
|
| + mode = EncryptionScheme::CIPHER_MODE_AES_CBC;
|
| + pattern_encryption = true;
|
| + break;
|
| +#endif
|
| + default:
|
| + DLOG(WARNING) << "Unsupported encryption scheme: " << fourCC;
|
| + break;
|
| + }
|
| +#if BUILDFLAG(ENABLE_CBCS_ENCRYPTION_SCHEME)
|
| + if (pattern_encryption) {
|
| + uint8_t crypt = sinf.info.track_encryption.default_crypt_byte_block;
|
| + uint8_t skip = sinf.info.track_encryption.default_skip_byte_block;
|
| + pattern = EncryptionScheme::Pattern(crypt, skip);
|
| + }
|
| +#endif
|
| + return EncryptionScheme(mode, pattern);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types,
|
| bool has_sbr)
|
| : state_(kWaitingForInit),
|
| @@ -316,7 +352,8 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) {
|
| DVLOG(1) << "is_audio_track_encrypted_: " << is_audio_track_encrypted_;
|
| audio_config.Initialize(
|
| codec, sample_format, channel_layout, sample_per_second, extra_data,
|
| - is_audio_track_encrypted_ ? AesCtrEncryptionScheme() : Unencrypted(),
|
| + is_audio_track_encrypted_ ? GetEncryptionScheme(entry.sinf)
|
| + : Unencrypted(),
|
| base::TimeDelta(), 0);
|
| has_audio_ = true;
|
| audio_track_id_ = track->header.track_id;
|
| @@ -368,7 +405,8 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) {
|
| // No decoder-specific buffer needed for AVC;
|
| // SPS/PPS are embedded in the video stream
|
| EmptyExtraData(),
|
| - is_video_track_encrypted_ ? AesCtrEncryptionScheme() : Unencrypted());
|
| + is_video_track_encrypted_ ? GetEncryptionScheme(entry.sinf)
|
| + : Unencrypted());
|
| has_video_ = true;
|
| video_track_id_ = track->header.track_id;
|
| media_tracks->AddVideoTrack(
|
| @@ -574,11 +612,9 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers,
|
|
|
| if (decrypt_config) {
|
| if (!subsamples.empty()) {
|
| - // Create a new config with the updated subsamples.
|
| - decrypt_config.reset(new DecryptConfig(
|
| - decrypt_config->key_id(),
|
| - decrypt_config->iv(),
|
| - subsamples));
|
| + // Create a new config with the updated subsamples.
|
| + decrypt_config.reset(new DecryptConfig(decrypt_config->key_id(),
|
| + decrypt_config->iv(), subsamples));
|
| }
|
| // else, use the existing config.
|
| } else if ((audio && is_audio_track_encrypted_) ||
|
|
|