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

Unified Diff: media/formats/mp4/mp4_stream_parser.cc

Issue 1998333002: MP4 support for Common Encryption 'cbcs' scheme. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix a problem in hasty change before upload Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
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..a4502ef10b544046cf6c94f0d22fd8cdae3d4260 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,46 @@
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_CENC_NEW_EDITIONS)
+ case FOURCC_CENS:
+ mode = EncryptionScheme::CIPHER_MODE_AES_CTR;
+ pattern_encryption = true;
+ break;
+ case FOURCC_CBC1:
+ mode = EncryptionScheme::CIPHER_MODE_AES_CBC;
+ break;
+ case FOURCC_CBCS:
+ mode = EncryptionScheme::CIPHER_MODE_AES_CBC;
+ pattern_encryption = true;
+ break;
+#endif
+ default:
+ break;
ddorwin 2016/05/24 23:25:03 Should this be a DLOG that we don't recognize the
dougsteed 2016/05/25 17:23:21 Done.
+ }
+#if BUILDFLAG(ENABLE_CENC_NEW_EDITIONS)
+ 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);
+}
+}
kqyang 2016/05/23 20:57:34 nit: } // namespace
dougsteed 2016/05/25 17:23:21 Done.
+
MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types,
bool has_sbr)
: state_(kWaitingForInit),
@@ -316,7 +357,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 +410,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 +617,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_) ||

Powered by Google App Engine
This is Rietveld 408576698