diff options
author | jrummell <jrummell@chromium.org> | 2015-04-02 22:03:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-03 05:04:44 +0000 |
commit | cf78967cb40c1f7c27230c1fa995b5da21b5b788 (patch) | |
tree | d1886593de947e7747f45b36d72bf46100d1290f /media | |
parent | a6183ddaf42f671645dd39ebe03db0acbc8458b3 (diff) | |
download | chromium_src-cf78967cb40c1f7c27230c1fa995b5da21b5b788.zip chromium_src-cf78967cb40c1f7c27230c1fa995b5da21b5b788.tar.gz chromium_src-cf78967cb40c1f7c27230c1fa995b5da21b5b788.tar.bz2 |
OnEncrypted event to use enum for |init_data_type|
BUG=469228
TEST=EME layout tests pass
Review URL: https://codereview.chromium.org/1051143002
Cr-Commit-Position: refs/heads/master@{#323595}
Diffstat (limited to 'media')
26 files changed, 63 insertions, 114 deletions
diff --git a/media/base/demuxer.h b/media/base/demuxer.h index 950b027..3075b59 100644 --- a/media/base/demuxer.h +++ b/media/base/demuxer.h @@ -11,6 +11,7 @@ #include "media/base/data_source.h" #include "media/base/demuxer_stream.h" #include "media/base/demuxer_stream_provider.h" +#include "media/base/eme_constants.h" #include "media/base/media_export.h" #include "media/base/pipeline_status.h" @@ -48,7 +49,7 @@ class MEDIA_EXPORT Demuxer : public DemuxerStreamProvider { // A new potentially encrypted stream has been parsed. // First parameter - The type of initialization data. // Second parameter - The initialization data associated with the stream. - typedef base::Callback<void(const std::string& type, + typedef base::Callback<void(EmeInitDataType type, const std::vector<uint8>& init_data)> EncryptedMediaInitDataCB; diff --git a/media/base/demuxer_perftest.cc b/media/base/demuxer_perftest.cc index 42fc6e8..9708e58 100644 --- a/media/base/demuxer_perftest.cc +++ b/media/base/demuxer_perftest.cc @@ -43,7 +43,7 @@ static void QuitLoopWithStatus(base::MessageLoop* message_loop, message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); } -static void OnEncryptedMediaInitData(const std::string& init_data_type, +static void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::vector<uint8>& init_data) { VLOG(0) << "File is encrypted."; } diff --git a/media/base/key_systems.cc b/media/base/key_systems.cc index 565aa08c..511a6ef 100644 --- a/media/base/key_systems.cc +++ b/media/base/key_systems.cc @@ -29,18 +29,6 @@ const char kUnsupportedClearKeyKeySystem[] = "unsupported-org.w3.clearkey"; const char kClearKeyKeySystemNameForUMA[] = "ClearKey"; const char kUnknownKeySystemNameForUMA[] = "Unknown"; -struct NamedInitDataType { - const char* name; - EmeInitDataType type; -}; - -// Mapping between initialization data types names and enum values. -static NamedInitDataType kInitDataTypeNames[] = { - {"webm", EmeInitDataType::WEBM}, - {"cenc", EmeInitDataType::CENC}, - {"keyids", EmeInitDataType::KEYIDS}, -}; - struct NamedCodec { const char* name; EmeCodec type; @@ -255,9 +243,6 @@ class KeySystemsImpl : public KeySystems { const std::string& key_system, EmeFeatureRequirement requirement) const override; - EmeInitDataType GetInitDataTypeForName( - const std::string& init_data_type) const; - private: void InitializeUMAInfo(); @@ -309,7 +294,6 @@ class KeySystemsImpl : public KeySystems { KeySystemsSupportUMA key_systems_support_uma_; - InitDataTypesMap init_data_type_name_map_; ContainerCodecsMap container_to_codec_mask_map_; CodecsMap codec_string_map_; KeySystemNameForUMAMap key_system_name_for_uma_map_; @@ -337,11 +321,6 @@ KeySystemsImpl& KeySystemsImpl::GetInstance() { KeySystemsImpl::KeySystemsImpl() : audio_codec_mask_(EME_CODEC_AUDIO_ALL), video_codec_mask_(EME_CODEC_VIDEO_ALL) { - for (size_t i = 0; i < arraysize(kInitDataTypeNames); ++i) { - const std::string& name = kInitDataTypeNames[i].name; - DCHECK(!init_data_type_name_map_.count(name)); - init_data_type_name_map_[name] = kInitDataTypeNames[i].type; - } for (size_t i = 0; i < arraysize(kContainerToCodecMasks); ++i) { const std::string& name = kContainerToCodecMasks[i].name; DCHECK(!container_to_codec_mask_map_.count(name)); @@ -359,15 +338,6 @@ KeySystemsImpl::KeySystemsImpl() : UpdateSupportedKeySystems(); } -EmeInitDataType KeySystemsImpl::GetInitDataTypeForName( - const std::string& init_data_type) const { - InitDataTypesMap::const_iterator iter = - init_data_type_name_map_.find(init_data_type); - if (iter != init_data_type_name_map_.end()) - return iter->second; - return EmeInitDataType::UNKNOWN; -} - SupportedCodecs KeySystemsImpl::GetCodecMaskForContainer( const std::string& container) const { ContainerCodecsMap::const_iterator iter = @@ -1010,10 +980,6 @@ std::string GetPepperType(const std::string& concrete_key_system) { } #endif -EmeInitDataType GetInitDataTypeForName(const std::string& init_data_type) { - return KeySystemsImpl::GetInstance().GetInitDataTypeForName(init_data_type); -} - // These two functions are for testing purpose only. The declaration in the // header file is guarded by "#if defined(UNIT_TEST)" so that they can be used // by tests but not non-test code. However, this .cc file is compiled as part of diff --git a/media/base/key_systems.h b/media/base/key_systems.h index ebc9d4f..d7dee41 100644 --- a/media/base/key_systems.h +++ b/media/base/key_systems.h @@ -122,10 +122,6 @@ MEDIA_EXPORT std::string GetPepperType( const std::string& concrete_key_system); #endif -// Gets the Initialization Data Type for |init_data_type|. -MEDIA_EXPORT EmeInitDataType -GetInitDataTypeForName(const std::string& init_data_type); - #if defined(UNIT_TEST) // Helper functions to add container/codec types for testing purposes. MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask); diff --git a/media/base/stream_parser.h b/media/base/stream_parser.h index dd5a31b..c777a16 100644 --- a/media/base/stream_parser.h +++ b/media/base/stream_parser.h @@ -15,6 +15,7 @@ #include "base/memory/scoped_ptr.h" #include "base/time/time.h" #include "media/base/demuxer_stream.h" +#include "media/base/eme_constants.h" #include "media/base/media_export.h" #include "media/base/media_log.h" @@ -105,7 +106,7 @@ class MEDIA_EXPORT StreamParser { // First parameter - The type of the initialization data associated with the // stream. // Second parameter - The initialization data associated with the stream. - typedef base::Callback<void(const std::string&, const std::vector<uint8>&)> + typedef base::Callback<void(EmeInitDataType, const std::vector<uint8>&)> EncryptedMediaInitDataCB; StreamParser(); diff --git a/media/blink/encrypted_media_player_support.cc b/media/blink/encrypted_media_player_support.cc index 7b7669d..c5f7e0a 100644 --- a/media/blink/encrypted_media_player_support.cc +++ b/media/blink/encrypted_media_player_support.cc @@ -103,13 +103,13 @@ static void ReportMediaKeyExceptionToUMA(const std::string& method, // Guess the type of |init_data|. This is only used to handle some corner cases // so we keep it as simple as possible without breaking major use cases. -static std::string GuessInitDataType(const unsigned char* init_data, - unsigned init_data_length) { +static EmeInitDataType GuessInitDataType(const unsigned char* init_data, + unsigned init_data_length) { // Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes. if (init_data_length == 16) - return "webm"; + return EmeInitDataType::WEBM; - return "cenc"; + return EmeInitDataType::CENC; } EncryptedMediaPlayerSupport::EncryptedMediaPlayerSupport( @@ -120,6 +120,7 @@ EncryptedMediaPlayerSupport::EncryptedMediaPlayerSupport( : cdm_factory_(cdm_factory.Pass()), client_(client), media_permission_(media_permission), + init_data_type_(EmeInitDataType::UNKNOWN), set_cdm_context_cb_(set_cdm_context_cb) { } @@ -182,8 +183,8 @@ EncryptedMediaPlayerSupport::GenerateKeyRequestInternal( return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; } - std::string init_data_type = init_data_type_; - if (init_data_type.empty()) + EmeInitDataType init_data_type = init_data_type_; + if (init_data_type == EmeInitDataType::UNKNOWN) init_data_type = GuessInitDataType(init_data, init_data_length); if (!proxy_decryptor_->GenerateKeyRequest(init_data_type, init_data, @@ -277,12 +278,12 @@ EncryptedMediaPlayerSupport::CancelKeyRequestInternal( } void EncryptedMediaPlayerSupport::SetInitDataType( - const std::string& init_data_type) { - DCHECK(!init_data_type.empty()); - DLOG_IF(WARNING, - !init_data_type_.empty() && init_data_type != init_data_type_) + EmeInitDataType init_data_type) { + DCHECK(init_data_type != EmeInitDataType::UNKNOWN); + DLOG_IF(WARNING, init_data_type_ != EmeInitDataType::UNKNOWN && + init_data_type != init_data_type_) << "Mixed init data type not supported. The new type is ignored."; - if (init_data_type_.empty()) + if (init_data_type_ == EmeInitDataType::UNKNOWN) init_data_type_ = init_data_type; } diff --git a/media/blink/encrypted_media_player_support.h b/media/blink/encrypted_media_player_support.h index c512026..fe8771a 100644 --- a/media/blink/encrypted_media_player_support.h +++ b/media/blink/encrypted_media_player_support.h @@ -14,6 +14,7 @@ #include "media/base/cdm_context.h" #include "media/base/cdm_factory.h" #include "media/base/demuxer.h" +#include "media/base/eme_constants.h" #include "media/cdm/proxy_decryptor.h" #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" #include "third_party/WebKit/public/platform/WebMediaPlayer.h" @@ -63,7 +64,7 @@ class EncryptedMediaPlayerSupport const blink::WebString& key_system, const blink::WebString& session_id); - void SetInitDataType(const std::string& init_data_type); + void SetInitDataType(EmeInitDataType init_data_type); void OnPipelineDecryptError(); @@ -106,7 +107,7 @@ class EncryptedMediaPlayerSupport // We assume all streams are from the same container, thus have the same // init data type. - std::string init_data_type_; + EmeInitDataType init_data_type_; SetCdmContextCB set_cdm_context_cb_; diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc index 360b94f..86b19e67 100644 --- a/media/blink/webmediaplayer_impl.cc +++ b/media/blink/webmediaplayer_impl.cc @@ -26,7 +26,6 @@ #include "media/audio/null_audio_sink.h" #include "media/base/bind_to_current_loop.h" #include "media/base/cdm_context.h" -#include "media/base/key_systems.h" #include "media/base/limits.h" #include "media/base/media_log.h" #include "media/base/pipeline.h" @@ -665,11 +664,10 @@ void WebMediaPlayerImpl::setContentDecryptionModule( BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result)); } -// TODO(jrummell): |init_data_type| should be an enum. http://crbug.com/417440 void WebMediaPlayerImpl::OnEncryptedMediaInitData( - const std::string& init_data_type, + EmeInitDataType init_data_type, const std::vector<uint8>& init_data) { - DCHECK(!init_data_type.empty()); + DCHECK(init_data_type != EmeInitDataType::UNKNOWN); // Do not fire "encrypted" event if encrypted media is not enabled. // TODO(xhwang): Handle this in |client_|. @@ -683,10 +681,9 @@ void WebMediaPlayerImpl::OnEncryptedMediaInitData( encrypted_media_support_.SetInitDataType(init_data_type); - client_->encrypted( - ConvertToWebInitDataType(GetInitDataTypeForName(init_data_type)), - vector_as_array(&init_data), - base::saturated_cast<unsigned int>(init_data.size())); + client_->encrypted(ConvertToWebInitDataType(init_data_type), + vector_as_array(&init_data), + base::saturated_cast<unsigned int>(init_data.size())); } void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { diff --git a/media/blink/webmediaplayer_impl.h b/media/blink/webmediaplayer_impl.h index 8823d42..11e8c816 100644 --- a/media/blink/webmediaplayer_impl.h +++ b/media/blink/webmediaplayer_impl.h @@ -217,7 +217,7 @@ class MEDIA_EXPORT WebMediaPlayerImpl scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor(); // Called when the demuxer encounters encrypted streams. - void OnEncryptedMediaInitData(const std::string& init_data_type, + void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::vector<uint8>& init_data); // Called when a decoder detects that the key needed to decrypt the stream diff --git a/media/cdm/proxy_decryptor.cc b/media/cdm/proxy_decryptor.cc index b9f3b78..944b614 100644 --- a/media/cdm/proxy_decryptor.cc +++ b/media/cdm/proxy_decryptor.cc @@ -80,7 +80,7 @@ void StripHeader(std::vector<uint8>& data, size_t length) { data.erase(data.begin(), data.begin() + length); } -bool ProxyDecryptor::GenerateKeyRequest(const std::string& init_data_type, +bool ProxyDecryptor::GenerateKeyRequest(EmeInitDataType init_data_type, const uint8* init_data, int init_data_length) { DVLOG(1) << "GenerateKeyRequest()"; @@ -146,7 +146,7 @@ bool ProxyDecryptor::GenerateKeyRequest(const std::string& init_data_type, void ProxyDecryptor::OnPermissionStatus( MediaKeys::SessionType session_type, - const std::string& init_data_type, + EmeInitDataType init_data_type, const std::vector<uint8>& init_data, scoped_ptr<NewSessionCdmPromise> promise, bool granted) { @@ -157,8 +157,8 @@ void ProxyDecryptor::OnPermissionStatus( DVLOG_IF(1, !granted) << "Permission request rejected."; media_keys_->CreateSessionAndGenerateRequest( - session_type, GetInitDataTypeForName(init_data_type), - vector_as_array(&init_data), init_data.size(), promise.Pass()); + session_type, init_data_type, vector_as_array(&init_data), + init_data.size(), promise.Pass()); } void ProxyDecryptor::AddKey(const uint8* key, diff --git a/media/cdm/proxy_decryptor.h b/media/cdm/proxy_decryptor.h index 16c2f92..ff611ad 100644 --- a/media/cdm/proxy_decryptor.h +++ b/media/cdm/proxy_decryptor.h @@ -13,6 +13,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "media/base/decryptor.h" +#include "media/base/eme_constants.h" #include "media/base/media_export.h" #include "media/base/media_keys.h" #include "url/gurl.h" @@ -56,7 +57,7 @@ class MEDIA_EXPORT ProxyDecryptor { const GURL& security_origin); // May only be called after InitializeCDM() succeeds. - bool GenerateKeyRequest(const std::string& init_data_type, + bool GenerateKeyRequest(EmeInitDataType init_data_type, const uint8* init_data, int init_data_length); void AddKey(const uint8* key, int key_length, @@ -90,7 +91,7 @@ class MEDIA_EXPORT ProxyDecryptor { // Callback for permission request. void OnPermissionStatus(MediaKeys::SessionType session_type, - const std::string& init_data_type, + EmeInitDataType init_data_type, const std::vector<uint8>& init_data, scoped_ptr<NewSessionCdmPromise> promise, bool granted); diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc index 1d58c08..16ddff5 100644 --- a/media/filters/chunk_demuxer_unittest.cc +++ b/media/filters/chunk_demuxer_unittest.cc @@ -19,7 +19,6 @@ #include "media/filters/chunk_demuxer.h" #include "media/formats/webm/cluster_builder.h" #include "media/formats/webm/webm_constants.h" -#include "media/formats/webm/webm_crypto_helpers.h" #include "testing/gtest/include/gtest/gtest.h" using ::testing::AnyNumber; @@ -1159,7 +1158,7 @@ class ChunkDemuxerTest : public ::testing::Test { MOCK_METHOD0(DemuxerOpened, void()); MOCK_METHOD2(OnEncryptedMediaInitData, - void(const std::string& init_data_type, + void(EmeInitDataType init_data_type, const std::vector<uint8>& init_data)); MOCK_METHOD0(InitSegmentReceived, void(void)); @@ -1222,7 +1221,7 @@ TEST_F(ChunkDemuxerTest, Init) { int need_key_count = (is_audio_encrypted ? 1 : 0) + (is_video_encrypted ? 1 : 0); EXPECT_CALL(*this, OnEncryptedMediaInitData( - kWebMInitDataType, + EmeInitDataType::WEBM, std::vector<uint8>( kEncryptedMediaInitData, kEncryptedMediaInitData + diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc index 535bbcd..7cb05d7 100644 --- a/media/filters/ffmpeg_demuxer.cc +++ b/media/filters/ffmpeg_demuxer.cc @@ -165,7 +165,7 @@ FFmpegDemuxerStream::FFmpegDemuxerStream(FFmpegDemuxer* demuxer, return; encryption_key_id_.assign(enc_key_id); - demuxer_->OnEncryptedMediaInitData(kWebMInitDataType, enc_key_id); + demuxer_->OnEncryptedMediaInitData(EmeInitDataType::WEBM, enc_key_id); } } @@ -1259,7 +1259,7 @@ void FFmpegDemuxer::StreamHasEnded() { } void FFmpegDemuxer::OnEncryptedMediaInitData( - const std::string& init_data_type, + EmeInitDataType init_data_type, const std::string& encryption_key_id) { std::vector<uint8> key_id_local(encryption_key_id.begin(), encryption_key_id.end()); diff --git a/media/filters/ffmpeg_demuxer.h b/media/filters/ffmpeg_demuxer.h index bcb7c31..329364f 100644 --- a/media/filters/ffmpeg_demuxer.h +++ b/media/filters/ffmpeg_demuxer.h @@ -180,7 +180,7 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer { // Calls |encrypted_media_init_data_cb_| with the initialization data // encountered in the file. - void OnEncryptedMediaInitData(const std::string& init_data_type, + void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::string& encryption_key_id); // Allow FFmpegDemuxerStream to notify us when there is updated information diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc index b32718c..15f53fb 100644 --- a/media/filters/ffmpeg_demuxer_unittest.cc +++ b/media/filters/ffmpeg_demuxer_unittest.cc @@ -19,7 +19,6 @@ #include "media/filters/ffmpeg_demuxer.h" #include "media/filters/file_data_source.h" #include "media/formats/mp4/avc.h" -#include "media/formats/webm/webm_crypto_helpers.h" #include "testing/gtest/include/gtest/gtest.h" using ::testing::AnyNumber; @@ -184,7 +183,7 @@ class FFmpegDemuxerTest : public testing::Test { } MOCK_METHOD2(OnEncryptedMediaInitData, - void(const std::string& init_data_type, + void(EmeInitDataType init_data_type, const std::vector<uint8>& init_data)); // Accessor to demuxer internals. @@ -378,7 +377,7 @@ TEST_F(FFmpegDemuxerTest, Initialize_MultitrackText) { TEST_F(FFmpegDemuxerTest, Initialize_Encrypted) { EXPECT_CALL(*this, OnEncryptedMediaInitData( - kWebMInitDataType, + EmeInitDataType::WEBM, std::vector<uint8>(kEncryptedMediaInitData, kEncryptedMediaInitData + arraysize(kEncryptedMediaInitData)))) diff --git a/media/formats/common/stream_parser_test_base.cc b/media/formats/common/stream_parser_test_base.cc index 3a8b5f2..f47a87d 100644 --- a/media/formats/common/stream_parser_test_base.cc +++ b/media/formats/common/stream_parser_test_base.cc @@ -108,9 +108,10 @@ bool StreamParserTestBase::OnNewBuffers( return true; } -void StreamParserTestBase::OnKeyNeeded(const std::string& type, +void StreamParserTestBase::OnKeyNeeded(EmeInitDataType type, const std::vector<uint8>& init_data) { - DVLOG(1) << __FUNCTION__ << "(" << type << ", " << init_data.size() << ")"; + DVLOG(1) << __FUNCTION__ << "(" << static_cast<int>(type) << ", " + << init_data.size() << ")"; } void StreamParserTestBase::OnNewSegment() { diff --git a/media/formats/common/stream_parser_test_base.h b/media/formats/common/stream_parser_test_base.h index 1e3cd73..ea61dd3 100644 --- a/media/formats/common/stream_parser_test_base.h +++ b/media/formats/common/stream_parser_test_base.h @@ -57,8 +57,7 @@ class StreamParserTestBase { bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers, const StreamParser::BufferQueue& video_buffers, const StreamParser::TextBufferQueueMap& text_map); - void OnKeyNeeded(const std::string& type, - const std::vector<uint8>& init_data); + void OnKeyNeeded(EmeInitDataType type, const std::vector<uint8>& init_data); void OnNewSegment(); void OnEndOfSegment(); diff --git a/media/formats/mp2t/mp2t_stream_parser_unittest.cc b/media/formats/mp2t/mp2t_stream_parser_unittest.cc index 866c25e..263f117 100644 --- a/media/formats/mp2t/mp2t_stream_parser_unittest.cc +++ b/media/formats/mp2t/mp2t_stream_parser_unittest.cc @@ -171,8 +171,7 @@ class Mp2tStreamParserTest : public testing::Test { return true; } - void OnKeyNeeded(const std::string& type, - const std::vector<uint8>& init_data) { + void OnKeyNeeded(EmeInitDataType type, const std::vector<uint8>& init_data) { NOTREACHED() << "OnKeyNeeded not expected in the Mpeg2 TS parser"; } diff --git a/media/formats/mp4/mp4_stream_parser.cc b/media/formats/mp4/mp4_stream_parser.cc index 20bd0b8..e48b582 100644 --- a/media/formats/mp4/mp4_stream_parser.cc +++ b/media/formats/mp4/mp4_stream_parser.cc @@ -22,8 +22,6 @@ namespace media { namespace mp4 { -static const char kCencInitDataType[] = "cenc"; - MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types, bool has_sbr) : state_(kWaitingForInit), @@ -357,7 +355,7 @@ void MP4StreamParser::OnEncryptedMediaInitData( headers[i].raw_box.size()); pos += headers[i].raw_box.size(); } - encrypted_media_init_data_cb_.Run(kCencInitDataType, init_data); + encrypted_media_init_data_cb_.Run(EmeInitDataType::CENC, init_data); } bool MP4StreamParser::PrepareAVCBuffer( diff --git a/media/formats/mp4/mp4_stream_parser_unittest.cc b/media/formats/mp4/mp4_stream_parser_unittest.cc index c82d67b..8ebc124 100644 --- a/media/formats/mp4/mp4_stream_parser_unittest.cc +++ b/media/formats/mp4/mp4_stream_parser_unittest.cc @@ -25,8 +25,6 @@ using base::TimeDelta; namespace media { namespace mp4 { -static const char kCencInitDataType[] = "cenc"; - class MP4StreamParserTest : public testing::Test { public: MP4StreamParserTest() @@ -117,10 +115,9 @@ class MP4StreamParserTest : public testing::Test { return true; } - void KeyNeededF(const std::string& type, - const std::vector<uint8>& init_data) { + void KeyNeededF(EmeInitDataType type, const std::vector<uint8>& init_data) { DVLOG(1) << "KeyNeededF: " << init_data.size(); - EXPECT_EQ(kCencInitDataType, type); + EXPECT_EQ(EmeInitDataType::CENC, type); EXPECT_FALSE(init_data.empty()); } diff --git a/media/formats/webm/webm_crypto_helpers.h b/media/formats/webm/webm_crypto_helpers.h index f7703ea..41ad5b1 100644 --- a/media/formats/webm/webm_crypto_helpers.h +++ b/media/formats/webm/webm_crypto_helpers.h @@ -11,8 +11,6 @@ namespace media { -const char kWebMInitDataType[] = "webm"; - // Fills an initialized DecryptConfig, which can be sent to the Decryptor if // the stream has potentially encrypted frames. Also sets |data_offset| which // indicates where the encrypted data starts. Leaving the IV empty will tell diff --git a/media/formats/webm/webm_stream_parser.cc b/media/formats/webm/webm_stream_parser.cc index edbdc42..95a4eb0 100644 --- a/media/formats/webm/webm_stream_parser.cc +++ b/media/formats/webm/webm_stream_parser.cc @@ -12,7 +12,6 @@ #include "media/formats/webm/webm_cluster_parser.h" #include "media/formats/webm/webm_constants.h" #include "media/formats/webm/webm_content_encodings.h" -#include "media/formats/webm/webm_crypto_helpers.h" #include "media/formats/webm/webm_info_parser.h" #include "media/formats/webm/webm_tracks_parser.h" @@ -279,7 +278,7 @@ int WebMStreamParser::ParseCluster(const uint8* data, int size) { void WebMStreamParser::OnEncryptedMediaInitData(const std::string& key_id) { std::vector<uint8> key_id_vector(key_id.begin(), key_id.end()); - encrypted_media_init_data_cb_.Run(kWebMInitDataType, key_id_vector); + encrypted_media_init_data_cb_.Run(EmeInitDataType::WEBM, key_id_vector); } } // namespace media diff --git a/media/test/pipeline_integration_test.cc b/media/test/pipeline_integration_test.cc index 118f1f7..cea6fdc 100644 --- a/media/test/pipeline_integration_test.cc +++ b/media/test/pipeline_integration_test.cc @@ -11,7 +11,6 @@ #include "media/base/cdm_context.h" #include "media/base/cdm_key_information.h" #include "media/base/decoder_buffer.h" -#include "media/base/key_systems.h" #include "media/base/media.h" #include "media/base/media_keys.h" #include "media/base/media_switches.h" @@ -56,7 +55,6 @@ using testing::SaveArg; namespace media { const char kSourceId[] = "SourceId"; -const char kCencInitDataType[] = "cenc"; const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; @@ -165,7 +163,7 @@ class FakeEncryptedMedia { FAIL() << "Unexpected Key Error"; } - virtual void OnEncryptedMediaInitData(const std::string& init_data_type, + virtual void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::vector<uint8>& init_data, AesDecryptor* decryptor) = 0; }; @@ -210,7 +208,7 @@ class FakeEncryptedMedia { error_message); } - void OnEncryptedMediaInitData(const std::string& init_data_type, + void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::vector<uint8>& init_data) { app_->OnEncryptedMediaInitData(init_data_type, init_data, &decryptor_); } @@ -298,7 +296,7 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase { EXPECT_EQ(has_additional_usable_key, true); } - void OnEncryptedMediaInitData(const std::string& init_data_type, + void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::vector<uint8>& init_data, AesDecryptor* decryptor) override { // Since only 1 session is created, skip the request if the |init_data| @@ -308,7 +306,7 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase { prev_init_data_ = init_data; if (current_session_id_.empty()) { - if (init_data_type == kCencInitDataType) { + if (init_data_type == EmeInitDataType::CENC) { // Since the 'cenc' files are not created with proper 'pssh' boxes, // simply pretend that this is a webm file and pass the expected // key ID as the init_data. @@ -318,8 +316,7 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase { arraysize(kKeyId), CreateSessionPromise(RESOLVED)); } else { decryptor->CreateSessionAndGenerateRequest( - MediaKeys::TEMPORARY_SESSION, - media::GetInitDataTypeForName(init_data_type), + MediaKeys::TEMPORARY_SESSION, init_data_type, vector_as_array(&init_data), init_data.size(), CreateSessionPromise(RESOLVED)); } @@ -331,7 +328,7 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase { // 'pssh' box). Therefore, provide the correct key ID. const uint8* key_id = vector_as_array(&init_data); size_t key_id_length = init_data.size(); - if (init_data_type == kCencInitDataType) { + if (init_data_type == EmeInitDataType::CENC) { key_id = kKeyId; key_id_length = arraysize(kKeyId); } @@ -358,7 +355,7 @@ class RotatingKeyProvidingApp : public KeyProvidingApp { EXPECT_GT(num_distint_need_key_calls_, 1u); } - void OnEncryptedMediaInitData(const std::string& init_data_type, + void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::vector<uint8>& init_data, AesDecryptor* decryptor) override { // Skip the request if the |init_data| has been seen. @@ -371,7 +368,7 @@ class RotatingKeyProvidingApp : public KeyProvidingApp { std::vector<uint8> key; EXPECT_TRUE(GetKeyAndKeyId(init_data, &key, &key_id)); - if (init_data_type == kCencInitDataType) { + if (init_data_type == EmeInitDataType::CENC) { // Since the 'cenc' files are not created with proper 'pssh' boxes, // simply pretend that this is a webm file and pass the expected // key ID as the init_data. @@ -382,8 +379,7 @@ class RotatingKeyProvidingApp : public KeyProvidingApp { CreateSessionPromise(RESOLVED)); } else { decryptor->CreateSessionAndGenerateRequest( - MediaKeys::TEMPORARY_SESSION, - media::GetInitDataTypeForName(init_data_type), + MediaKeys::TEMPORARY_SESSION, init_data_type, vector_as_array(&init_data), init_data.size(), CreateSessionPromise(RESOLVED)); } @@ -457,7 +453,7 @@ class NoResponseApp : public FakeEncryptedMedia::AppBase { EXPECT_EQ(has_additional_usable_key, true); } - void OnEncryptedMediaInitData(const std::string& init_data_type, + void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::vector<uint8>& init_data, AesDecryptor* decryptor) override {} }; @@ -601,7 +597,7 @@ class MockMediaSource { AppendData(initial_append_size_); } - void OnEncryptedMediaInitData(const std::string& init_data_type, + void OnEncryptedMediaInitData(EmeInitDataType init_data_type, const std::vector<uint8>& init_data) { DCHECK(!init_data.empty()); CHECK(!encrypted_media_init_data_cb_.is_null()); diff --git a/media/test/pipeline_integration_test_base.cc b/media/test/pipeline_integration_test_base.cc index e122d9a..da3a9f8 100644 --- a/media/test/pipeline_integration_test_base.cc +++ b/media/test/pipeline_integration_test_base.cc @@ -66,7 +66,7 @@ void PipelineIntegrationTestBase::OnStatusCallback( } void PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB( - const std::string& type, + EmeInitDataType type, const std::vector<uint8>& init_data) { DCHECK(!init_data.empty()); CHECK(!encrypted_media_init_data_cb_.is_null()); diff --git a/media/test/pipeline_integration_test_base.h b/media/test/pipeline_integration_test_base.h index 716e27c..c8ca915 100644 --- a/media/test/pipeline_integration_test_base.h +++ b/media/test/pipeline_integration_test_base.h @@ -115,7 +115,7 @@ class PipelineIntegrationTestBase { void OnSeeked(base::TimeDelta seek_time, PipelineStatus status); void OnStatusCallback(PipelineStatus status); - void DemuxerEncryptedMediaInitDataCB(const std::string& type, + void DemuxerEncryptedMediaInitDataCB(EmeInitDataType type, const std::vector<uint8>& init_data); void set_encrypted_media_init_data_cb( const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { diff --git a/media/tools/player_x11/player_x11.cc b/media/tools/player_x11/player_x11.cc index 60eb45c..d149ca4 100644 --- a/media/tools/player_x11/player_x11.cc +++ b/media/tools/player_x11/player_x11.cc @@ -95,7 +95,7 @@ static void OnAddTextTrack(const media::TextTrackConfig& config, const media::AddTextTrackDoneCB& done_cb) { } -static void OnEncryptedMediaInitData(const std::string& init_data_type, +static void OnEncryptedMediaInitData(media::EmeInitDataType init_data_type, const std::vector<uint8>& init_data) { std::cout << "File is encrypted." << std::endl; } |