diff options
author | jrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 07:25:54 +0000 |
---|---|---|
committer | jrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 07:25:54 +0000 |
commit | a267ff14ffc271d52522affde71803bd29bca3e3 (patch) | |
tree | c7db4579831244d8071ee8d9205ce571d39d371c /media/cdm | |
parent | 6718537577fc2e16f92beecd8163c3cad95c0ca6 (diff) | |
download | chromium_src-a267ff14ffc271d52522affde71803bd29bca3e3.zip chromium_src-a267ff14ffc271d52522affde71803bd29bca3e3.tar.gz chromium_src-a267ff14ffc271d52522affde71803bd29bca3e3.tar.bz2 |
Rename EME WD call parameters
Rename parameters on EME WD calls to be consistent.
BUG=224786
TEST=compiles
Review URL: https://codereview.chromium.org/105383002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239698 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cdm')
-rw-r--r-- | media/cdm/aes_decryptor.cc | 24 | ||||
-rw-r--r-- | media/cdm/aes_decryptor.h | 13 | ||||
-rw-r--r-- | media/cdm/aes_decryptor_unittest.cc | 67 | ||||
-rw-r--r-- | media/cdm/ppapi/cdm_adapter.cc | 90 | ||||
-rw-r--r-- | media/cdm/ppapi/cdm_adapter.h | 32 | ||||
-rw-r--r-- | media/cdm/ppapi/cdm_wrapper.h | 151 | ||||
-rw-r--r-- | media/cdm/ppapi/clear_key_cdm.cc | 34 | ||||
-rw-r--r-- | media/cdm/ppapi/clear_key_cdm.h | 16 |
8 files changed, 211 insertions, 216 deletions
diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc index ee4b987..bdcc27e 100644 --- a/media/cdm/aes_decryptor.cc +++ b/media/cdm/aes_decryptor.cc @@ -20,7 +20,7 @@ namespace media { -uint32 AesDecryptor::next_session_id_ = 1; +uint32 AesDecryptor::next_web_session_id_ = 1; enum ClearBytesBufferSel { kSrcContainsClearBytes, @@ -157,11 +157,11 @@ AesDecryptor::~AesDecryptor() { STLDeleteValues(&key_map_); } -bool AesDecryptor::CreateSession(uint32 reference_id, +bool AesDecryptor::CreateSession(uint32 session_id, const std::string& type, const uint8* init_data, int init_data_length) { - std::string session_id_string(base::UintToString(next_session_id_++)); + std::string web_session_id_string(base::UintToString(next_web_session_id_++)); // For now, the AesDecryptor does not care about |type|; // just fire the event with the |init_data| as the request. @@ -169,12 +169,12 @@ bool AesDecryptor::CreateSession(uint32 reference_id, if (init_data && init_data_length) message.assign(init_data, init_data + init_data_length); - session_created_cb_.Run(reference_id, session_id_string); - session_message_cb_.Run(reference_id, message, std::string()); + session_created_cb_.Run(session_id, web_session_id_string); + session_message_cb_.Run(session_id, message, std::string()); return true; } -void AesDecryptor::UpdateSession(uint32 reference_id, +void AesDecryptor::UpdateSession(uint32 session_id, const uint8* response, int response_length) { CHECK(response); @@ -184,13 +184,13 @@ void AesDecryptor::UpdateSession(uint32 reference_id, response_length); KeyIdAndKeyPairs keys; if (!ExtractKeysFromJWKSet(key_string, &keys)) { - session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0); + session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0); return; } // Make sure that at least one key was extracted. if (keys.empty()) { - session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0); + session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0); return; } @@ -198,11 +198,11 @@ void AesDecryptor::UpdateSession(uint32 reference_id, if (it->second.length() != static_cast<size_t>(DecryptConfig::kDecryptionKeySize)) { DVLOG(1) << "Invalid key length: " << key_string.length(); - session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0); + session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0); return; } if (!AddDecryptionKey(it->first, it->second)) { - session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0); + session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0); return; } } @@ -213,10 +213,10 @@ void AesDecryptor::UpdateSession(uint32 reference_id, if (!new_video_key_cb_.is_null()) new_video_key_cb_.Run(); - session_ready_cb_.Run(reference_id); + session_ready_cb_.Run(session_id); } -void AesDecryptor::ReleaseSession(uint32 reference_id) { +void AesDecryptor::ReleaseSession(uint32 session_id) { // TODO: Implement: http://crbug.com/313412. } diff --git a/media/cdm/aes_decryptor.h b/media/cdm/aes_decryptor.h index 8e03106..35b1488 100644 --- a/media/cdm/aes_decryptor.h +++ b/media/cdm/aes_decryptor.h @@ -35,14 +35,14 @@ class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor { virtual ~AesDecryptor(); // MediaKeys implementation. - virtual bool CreateSession(uint32 reference_id, + virtual bool CreateSession(uint32 session_id, const std::string& type, const uint8* init_data, int init_data_length) OVERRIDE; - virtual void UpdateSession(uint32 reference_id, + virtual void UpdateSession(uint32 session_id, const uint8* response, int response_length) OVERRIDE; - virtual void ReleaseSession(uint32 reference_id) OVERRIDE; + virtual void ReleaseSession(uint32 session_id) OVERRIDE; virtual Decryptor* GetDecryptor() OVERRIDE; // Decryptor implementation. @@ -115,10 +115,9 @@ class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor { KeyMap key_map_; // Protected by the |key_map_lock_|. mutable base::Lock key_map_lock_; // Protects the |key_map_|. - // Make session ID unique per renderer by making it static. - // TODO(xhwang): Make session ID more strictly defined if needed: - // https://www.w3.org/Bugs/Public/show_bug.cgi?id=16739#c0 - static uint32 next_session_id_; + // Make web session ID unique per renderer by making it static. Web session + // IDs seen by the app will be "1", "2", etc. + static uint32 next_web_session_id_; NewKeyCB new_audio_key_cb_; NewKeyCB new_video_key_cb_; diff --git a/media/cdm/aes_decryptor_unittest.cc b/media/cdm/aes_decryptor_unittest.cc index cd0d460..53c7f1a8 100644 --- a/media/cdm/aes_decryptor_unittest.cc +++ b/media/cdm/aes_decryptor_unittest.cc @@ -195,7 +195,7 @@ class AesDecryptorTest : public testing::Test { base::Unretained(this)), base::Bind(&AesDecryptorTest::OnSessionError, base::Unretained(this))), - reference_id_(MediaKeys::kInvalidReferenceId), + session_id_(MediaKeys::kInvalidSessionId), decrypt_cb_(base::Bind(&AesDecryptorTest::BufferDecrypted, base::Unretained(this))), original_data_(kOriginalData, kOriginalData + kOriginalDataSize), @@ -213,12 +213,12 @@ class AesDecryptorTest : public testing::Test { protected: void CreateSession(const std::vector<uint8>& key_id) { - reference_id_ = 6; + session_id_ = 6; DCHECK(!key_id.empty()); - EXPECT_CALL(*this, OnSessionCreated(reference_id_, StrNe(std::string()))); - EXPECT_CALL(*this, OnSessionMessage(reference_id_, key_id, "")); + EXPECT_CALL(*this, OnSessionCreated(session_id_, StrNe(std::string()))); + EXPECT_CALL(*this, OnSessionMessage(session_id_, key_id, "")); EXPECT_TRUE(decryptor_.CreateSession( - reference_id_, std::string(), &key_id[0], key_id.size())); + session_id_, std::string(), &key_id[0], key_id.size())); } enum AddKeyExpectation { @@ -230,17 +230,16 @@ class AesDecryptorTest : public testing::Test { DCHECK(!key.empty()); if (result == KEY_ADDED) { - EXPECT_CALL(*this, OnSessionReady(reference_id_)); + EXPECT_CALL(*this, OnSessionReady(session_id_)); } else if (result == KEY_ERROR) { EXPECT_CALL(*this, - OnSessionError(reference_id_, MediaKeys::kUnknownError, 0)); + OnSessionError(session_id_, MediaKeys::kUnknownError, 0)); } else { NOTREACHED(); } - decryptor_.UpdateSession(reference_id_, - reinterpret_cast<const uint8*>(key.c_str()), - key.length()); + decryptor_.UpdateSession( + session_id_, reinterpret_cast<const uint8*>(key.c_str()), key.length()); } MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status, @@ -292,18 +291,18 @@ class AesDecryptorTest : public testing::Test { } MOCK_METHOD2(OnSessionCreated, - void(uint32 reference_id, const std::string& session_id)); + void(uint32 session_id, const std::string& web_session_id)); MOCK_METHOD3(OnSessionMessage, - void(uint32 reference_id, + void(uint32 session_id, const std::vector<uint8>& message, const std::string& default_url)); - MOCK_METHOD1(OnSessionReady, void(uint32 reference_id)); - MOCK_METHOD1(OnSessionClosed, void(uint32 reference_id)); + MOCK_METHOD1(OnSessionReady, void(uint32 session_id)); + MOCK_METHOD1(OnSessionClosed, void(uint32 session_id)); MOCK_METHOD3(OnSessionError, - void(uint32 reference_id, MediaKeys::KeyError, int system_code)); + void(uint32 session_id, MediaKeys::KeyError, int system_code)); AesDecryptor decryptor_; - uint32 reference_id_; + uint32 session_id_; AesDecryptor::DecryptCB decrypt_cb_; // Constants for testing. @@ -317,27 +316,27 @@ class AesDecryptorTest : public testing::Test { }; TEST_F(AesDecryptorTest, CreateSessionWithNullInitData) { - reference_id_ = 8; - EXPECT_CALL(*this, OnSessionMessage(reference_id_, IsEmpty(), "")); - EXPECT_CALL(*this, OnSessionCreated(reference_id_, StrNe(std::string()))); - EXPECT_TRUE(decryptor_.CreateSession(reference_id_, std::string(), NULL, 0)); + session_id_ = 8; + EXPECT_CALL(*this, OnSessionMessage(session_id_, IsEmpty(), "")); + EXPECT_CALL(*this, OnSessionCreated(session_id_, StrNe(std::string()))); + EXPECT_TRUE(decryptor_.CreateSession(session_id_, std::string(), NULL, 0)); } TEST_F(AesDecryptorTest, MultipleCreateSession) { - uint32 reference_id1 = 10; - EXPECT_CALL(*this, OnSessionMessage(reference_id1, IsEmpty(), "")); - EXPECT_CALL(*this, OnSessionCreated(reference_id1, StrNe(std::string()))); - EXPECT_TRUE(decryptor_.CreateSession(reference_id1, std::string(), NULL, 0)); - - uint32 reference_id2 = 11; - EXPECT_CALL(*this, OnSessionMessage(reference_id2, IsEmpty(), "")); - EXPECT_CALL(*this, OnSessionCreated(reference_id2, StrNe(std::string()))); - EXPECT_TRUE(decryptor_.CreateSession(reference_id2, std::string(), NULL, 0)); - - uint32 reference_id3 = 23; - EXPECT_CALL(*this, OnSessionMessage(reference_id3, IsEmpty(), "")); - EXPECT_CALL(*this, OnSessionCreated(reference_id3, StrNe(std::string()))); - EXPECT_TRUE(decryptor_.CreateSession(reference_id3, std::string(), NULL, 0)); + uint32 session_id1 = 10; + EXPECT_CALL(*this, OnSessionMessage(session_id1, IsEmpty(), "")); + EXPECT_CALL(*this, OnSessionCreated(session_id1, StrNe(std::string()))); + EXPECT_TRUE(decryptor_.CreateSession(session_id1, std::string(), NULL, 0)); + + uint32 session_id2 = 11; + EXPECT_CALL(*this, OnSessionMessage(session_id2, IsEmpty(), "")); + EXPECT_CALL(*this, OnSessionCreated(session_id2, StrNe(std::string()))); + EXPECT_TRUE(decryptor_.CreateSession(session_id2, std::string(), NULL, 0)); + + uint32 session_id3 = 23; + EXPECT_CALL(*this, OnSessionMessage(session_id3, IsEmpty(), "")); + EXPECT_CALL(*this, OnSessionCreated(session_id3, StrNe(std::string()))); + EXPECT_TRUE(decryptor_.CreateSession(session_id3, std::string(), NULL, 0)); } TEST_F(AesDecryptorTest, NormalDecryption) { diff --git a/media/cdm/ppapi/cdm_adapter.cc b/media/cdm/ppapi/cdm_adapter.cc index 489eb1d..209335b 100644 --- a/media/cdm/ppapi/cdm_adapter.cc +++ b/media/cdm/ppapi/cdm_adapter.cc @@ -247,13 +247,13 @@ void CdmAdapter::Initialize(const std::string& key_system) { key_system_ = key_system; } -void CdmAdapter::CreateSession(uint32_t reference_id, +void CdmAdapter::CreateSession(uint32_t session_id, const std::string& type, pp::VarArrayBuffer init_data) { // Initialize() doesn't report an error, so CreateSession() can be called // even if Initialize() failed. if (!cdm_) { - OnSessionError(reference_id, cdm::kUnknownError, 0); + OnSessionError(session_id, cdm::kUnknownError, 0); return; } @@ -261,7 +261,7 @@ void CdmAdapter::CreateSession(uint32_t reference_id, PP_URLComponents_Dev url_components = {}; const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get(); if (!url_util) { - OnSessionError(reference_id, cdm::kUnknownError, 0); + OnSessionError(session_id, cdm::kUnknownError, 0); return; } pp::Var href = url_util->GetDocumentURL( @@ -272,19 +272,19 @@ void CdmAdapter::CreateSession(uint32_t reference_id, PP_DCHECK(0 < url_components.host.len); #endif // defined(CHECK_DOCUMENT_URL) - cdm_->CreateSession(reference_id, + cdm_->CreateSession(session_id, type.data(), type.size(), static_cast<const uint8_t*>(init_data.Map()), init_data.ByteLength()); } -void CdmAdapter::UpdateSession(uint32_t reference_id, +void CdmAdapter::UpdateSession(uint32_t session_id, pp::VarArrayBuffer response) { // TODO(jrummell): In EME WD, AddKey() can only be called on valid sessions. // We should be able to DCHECK(cdm_) when addressing http://crbug.com/249976. if (!cdm_) { - OnSessionError(reference_id, cdm::kUnknownError, 0); + OnSessionError(session_id, cdm::kUnknownError, 0); return; } @@ -292,32 +292,32 @@ void CdmAdapter::UpdateSession(uint32_t reference_id, const uint32_t response_size = response.ByteLength(); if (!response_ptr || response_size <= 0) { - OnSessionError(reference_id, cdm::kUnknownError, 0); + OnSessionError(session_id, cdm::kUnknownError, 0); return; } CdmWrapper::Result result = - cdm_->UpdateSession(reference_id, response_ptr, response_size); + cdm_->UpdateSession(session_id, response_ptr, response_size); switch (result) { case CdmWrapper::NO_ACTION: break; case CdmWrapper::CALL_KEY_ADDED: - OnSessionReady(reference_id); + OnSessionReady(session_id); break; case CdmWrapper::CALL_KEY_ERROR: - OnSessionError(reference_id, cdm::kUnknownError, 0); + OnSessionError(session_id, cdm::kUnknownError, 0); break; } } -void CdmAdapter::ReleaseSession(uint32_t reference_id) { +void CdmAdapter::ReleaseSession(uint32_t session_id) { // TODO(jrummell): In EME WD, AddKey() can only be called on valid sessions. // We should be able to DCHECK(cdm_) when addressing http://crbug.com/249976. if (!cdm_) { - OnSessionError(reference_id, cdm::kUnknownError, 0); + OnSessionError(session_id, cdm::kUnknownError, 0); return; } - CdmWrapper::Result result = cdm_->ReleaseSession(reference_id); + CdmWrapper::Result result = cdm_->ReleaseSession(session_id); switch (result) { case CdmWrapper::NO_ACTION: break; @@ -325,7 +325,7 @@ void CdmAdapter::ReleaseSession(uint32_t reference_id) { PP_NOTREACHED(); break; case CdmWrapper::CALL_KEY_ERROR: - OnSessionError(reference_id, cdm::kUnknownError, 0); + OnSessionError(session_id, cdm::kUnknownError, 0); break; } } @@ -536,11 +536,12 @@ void CdmAdapter::SendKeyMessage( std::string session_id_str(session_id, session_id_length); PP_DCHECK(!session_id_str.empty()); - uint32_t reference_id = cdm_->DetermineReferenceId(session_id_str); + uint32_t session_reference_id = cdm_->LookupSessionId(session_id_str); - OnSessionCreated(reference_id, session_id, session_id_length); - OnSessionMessage( - reference_id, message, message_length, default_url, default_url_length); + OnSessionCreated(session_reference_id, session_id, session_id_length); + OnSessionMessage(session_reference_id, + message, message_length, + default_url, default_url_length); } void CdmAdapter::SendKeyError(const char* session_id, @@ -548,8 +549,8 @@ void CdmAdapter::SendKeyError(const char* session_id, cdm::MediaKeyError error_code, uint32_t system_code) { std::string session_id_str(session_id, session_id_length); - uint32_t reference_id = cdm_->DetermineReferenceId(session_id_str); - OnSessionError(reference_id, error_code, system_code); + uint32_t session_reference_id = cdm_->LookupSessionId(session_id_str); + OnSessionError(session_reference_id, error_code, system_code); } void CdmAdapter::GetPrivateData(int32_t* instance, @@ -558,56 +559,56 @@ void CdmAdapter::GetPrivateData(int32_t* instance, *get_interface = pp::Module::Get()->get_browser_interface(); } -void CdmAdapter::OnSessionCreated(uint32_t reference_id, - const char* session_id, - uint32_t session_id_length) { +void CdmAdapter::OnSessionCreated(uint32_t session_id, + const char* web_session_id, + uint32_t web_session_id_length) { PostOnMain(callback_factory_.NewCallback( &CdmAdapter::SendSessionCreatedInternal, - reference_id, - std::string(session_id, session_id_length))); + session_id, + std::string(web_session_id, web_session_id_length))); } -void CdmAdapter::OnSessionMessage(uint32_t reference_id, +void CdmAdapter::OnSessionMessage(uint32_t session_id, const char* message, uint32_t message_length, const char* destination_url, uint32_t destination_url_length) { PostOnMain(callback_factory_.NewCallback( &CdmAdapter::SendSessionMessageInternal, - reference_id, + session_id, std::vector<uint8>(message, message + message_length), std::string(destination_url, destination_url_length))); } -void CdmAdapter::OnSessionReady(uint32_t reference_id) { +void CdmAdapter::OnSessionReady(uint32_t session_id) { PostOnMain(callback_factory_.NewCallback( - &CdmAdapter::SendSessionReadyInternal, reference_id)); + &CdmAdapter::SendSessionReadyInternal, session_id)); } -void CdmAdapter::OnSessionClosed(uint32_t reference_id) { +void CdmAdapter::OnSessionClosed(uint32_t session_id) { PostOnMain(callback_factory_.NewCallback( - &CdmAdapter::SendSessionClosedInternal, reference_id)); + &CdmAdapter::SendSessionClosedInternal, session_id)); } -void CdmAdapter::OnSessionError(uint32_t reference_id, +void CdmAdapter::OnSessionError(uint32_t session_id, cdm::MediaKeyError error_code, uint32_t system_code) { PostOnMain(callback_factory_.NewCallback( &CdmAdapter::SendSessionErrorInternal, - reference_id, + session_id, error_code, system_code)); } void CdmAdapter::SendSessionCreatedInternal(int32_t result, - uint32_t reference_id, - const std::string& session_id) { + uint32_t session_id, + const std::string& web_session_id) { PP_DCHECK(result == PP_OK); - pp::ContentDecryptor_Private::SessionCreated(reference_id, session_id); + pp::ContentDecryptor_Private::SessionCreated(session_id, web_session_id); } void CdmAdapter::SendSessionMessageInternal(int32_t result, - uint32_t reference_id, + uint32_t session_id, const std::vector<uint8>& message, const std::string& default_url) { PP_DCHECK(result == PP_OK); @@ -618,28 +619,27 @@ void CdmAdapter::SendSessionMessageInternal(int32_t result, } pp::ContentDecryptor_Private::SessionMessage( - reference_id, message_array_buffer, default_url); + session_id, message_array_buffer, default_url); } -void CdmAdapter::SendSessionReadyInternal(int32_t result, - uint32_t reference_id) { +void CdmAdapter::SendSessionReadyInternal(int32_t result, uint32_t session_id) { PP_DCHECK(result == PP_OK); - pp::ContentDecryptor_Private::SessionReady(reference_id); + pp::ContentDecryptor_Private::SessionReady(session_id); } void CdmAdapter::SendSessionClosedInternal(int32_t result, - uint32_t reference_id) { + uint32_t session_id) { PP_DCHECK(result == PP_OK); - pp::ContentDecryptor_Private::SessionClosed(reference_id); + pp::ContentDecryptor_Private::SessionClosed(session_id); } void CdmAdapter::SendSessionErrorInternal(int32_t result, - uint32_t reference_id, + uint32_t session_id, cdm::MediaKeyError error_code, uint32_t system_code) { PP_DCHECK(result == PP_OK); pp::ContentDecryptor_Private::SessionError( - reference_id, error_code, system_code); + session_id, error_code, system_code); } void CdmAdapter::DeliverBlock(int32_t result, diff --git a/media/cdm/ppapi/cdm_adapter.h b/media/cdm/ppapi/cdm_adapter.h index 57e7524..ec7145d 100644 --- a/media/cdm/ppapi/cdm_adapter.h +++ b/media/cdm/ppapi/cdm_adapter.h @@ -53,12 +53,12 @@ class CdmAdapter : public pp::Instance, // Note: Results of calls to these methods must be reported through the // PPB_ContentDecryptor_Private interface. virtual void Initialize(const std::string& key_system) OVERRIDE; - virtual void CreateSession(uint32_t reference_id, + virtual void CreateSession(uint32_t session_id, const std::string& type, pp::VarArrayBuffer init_data) OVERRIDE; - virtual void UpdateSession(uint32_t reference_id, + virtual void UpdateSession(uint32_t session_id, pp::VarArrayBuffer response) OVERRIDE; - virtual void ReleaseSession(uint32_t reference_id) OVERRIDE; + virtual void ReleaseSession(uint32_t session_id) OVERRIDE; virtual void Decrypt( pp::Buffer_Dev encrypted_buffer, const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; @@ -104,17 +104,17 @@ class CdmAdapter : public pp::Instance, cdm::Status decoder_status) OVERRIDE; // cdm::Host_3 implementation. - virtual void OnSessionCreated(uint32_t reference_id, - const char* session_id, - uint32_t session_id_length) OVERRIDE; - virtual void OnSessionMessage(uint32_t reference_id, + virtual void OnSessionCreated(uint32_t session_id, + const char* web_session_id, + uint32_t web_session_id_length) OVERRIDE; + virtual void OnSessionMessage(uint32_t session_id, const char* message, uint32_t message_length, const char* destination_url, uint32_t destination_url_length) OVERRIDE; - virtual void OnSessionReady(uint32_t reference_id) OVERRIDE; - virtual void OnSessionClosed(uint32_t reference_id) OVERRIDE; - virtual void OnSessionError(uint32_t reference_id, + virtual void OnSessionReady(uint32_t session_id) OVERRIDE; + virtual void OnSessionClosed(uint32_t session_id) OVERRIDE; + virtual void OnSessionError(uint32_t session_id, cdm::MediaKeyError error_code, uint32_t system_code) OVERRIDE; @@ -129,16 +129,16 @@ class CdmAdapter : public pp::Instance, // <code>callback_factory_</code> to ensure that calls into // <code>PPP_ContentDecryptor_Private</code> are asynchronous. void SendSessionCreatedInternal(int32_t result, - uint32_t reference_id, - const std::string& session_id); + uint32_t session_id, + const std::string& web_session_id); void SendSessionMessageInternal(int32_t result, - uint32_t reference_id, + uint32_t session_id, const std::vector<uint8>& message, const std::string& default_url); - void SendSessionReadyInternal(int32_t result, uint32_t reference_id); - void SendSessionClosedInternal(int32_t result, uint32_t reference_id); + void SendSessionReadyInternal(int32_t result, uint32_t session_id); + void SendSessionClosedInternal(int32_t result, uint32_t session_id); void SendSessionErrorInternal(int32_t result, - uint32_t reference_id, + uint32_t session_id, cdm::MediaKeyError error_code, uint32_t system_code); diff --git a/media/cdm/ppapi/cdm_wrapper.h b/media/cdm/ppapi/cdm_wrapper.h index 63d8bbf..d827336 100644 --- a/media/cdm/ppapi/cdm_wrapper.h +++ b/media/cdm/ppapi/cdm_wrapper.h @@ -52,15 +52,15 @@ class CdmWrapper { virtual ~CdmWrapper() {}; - virtual void CreateSession(uint32_t reference_id, + virtual void CreateSession(uint32_t session_id, const char* type, uint32_t type_size, const uint8_t* init_data, uint32_t init_data_size) = 0; - virtual Result UpdateSession(uint32_t reference_id, + virtual Result UpdateSession(uint32_t session_id, const uint8_t* response, uint32_t response_size) = 0; - virtual Result ReleaseSession(uint32_t reference_id) = 0; + virtual Result ReleaseSession(uint32_t session_id) = 0; virtual void TimerExpired(void* context) = 0; virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, cdm::DecryptedBlock* decrypted_buffer) = 0; @@ -84,40 +84,40 @@ class CdmWrapper { // ContentDecryptionModule_1 and ContentDecryptionModule_2 interface methods // AddKey() and CancelKeyRequest() (older versions of UpdateSession() and - // ReleaseSession(), respectively) pass in the session_id rather than the - // reference_id. As well, Host_1 and Host_2 callbacks SendKeyMessage() and - // SendKeyError() include the session ID, but the actual callbacks need the - // reference ID. + // ReleaseSession(), respectively) pass in the web_session_id rather than the + // session_id. As well, Host_1 and Host_2 callbacks SendKeyMessage() and + // SendKeyError() include the web_session_id, but the actual callbacks need + // session_id. // - // The following functions maintain the reference_id <-> session_id mapping. + // The following functions maintain the session_id <-> web_session_id mapping. // These can be removed once _1 and _2 interfaces are no longer supported. - // Determine the corresponding reference_id for |session_id|. - virtual uint32_t DetermineReferenceId(const std::string& session_id) = 0; + // Determine the corresponding session_id for |web_session_id|. + virtual uint32_t LookupSessionId(const std::string& web_session_id) = 0; - // Determine the corresponding session_id for |reference_id|. - virtual const std::string LookupSessionId(uint32_t reference_id) = 0; + // Determine the corresponding session_id for |session_id|. + virtual const std::string LookupWebSessionId(uint32_t session_id) = 0; + // Map between session_id and web_session_id. // TODO(jrummell): The following can be removed once CDM_1 and CDM_2 are // no longer supported. typedef std::map<uint32_t, std::string> SessionMap; - static const uint32_t kInvalidReferenceId = 0; - - // Map between session_id and reference_id. SessionMap session_map_; + static const uint32_t kInvalidSessionId = 0; + // As the response from PrefixedGenerateKeyRequest() may be synchronous or // asynchronous, keep track of the current request during the call to handle // synchronous responses or errors. If no response received, add this request // to a queue and assume that the subsequent responses come back in the order // issued. // TODO(jrummell): Remove once all supported CDM host interfaces support - // reference_id. - uint32_t current_key_request_reference_id_; - std::queue<uint32_t> pending_key_request_reference_ids_; + // session_id. + uint32_t current_key_request_session_id_; + std::queue<uint32_t> pending_key_request_session_ids_; protected: - CdmWrapper() : current_key_request_reference_id_(kInvalidReferenceId) {} + CdmWrapper() : current_key_request_session_id_(kInvalidSessionId) {} private: DISALLOW_COPY_AND_ASSIGN(CdmWrapper); @@ -147,24 +147,23 @@ class CdmWrapperImpl : public CdmWrapper { cdm_->Destroy(); } - virtual void CreateSession(uint32_t reference_id, + virtual void CreateSession(uint32_t session_id, const char* type, uint32_t type_size, const uint8_t* init_data, uint32_t init_data_size) OVERRIDE { - cdm_->CreateSession( - reference_id, type, type_size, init_data, init_data_size); + cdm_->CreateSession(session_id, type, type_size, init_data, init_data_size); } - virtual Result UpdateSession(uint32_t reference_id, + virtual Result UpdateSession(uint32_t session_id, const uint8_t* response, uint32_t response_size) OVERRIDE { - cdm_->UpdateSession(reference_id, response, response_size); + cdm_->UpdateSession(session_id, response, response_size); return NO_ACTION; } - virtual Result ReleaseSession(uint32_t reference_id) OVERRIDE { - cdm_->ReleaseSession(reference_id); + virtual Result ReleaseSession(uint32_t session_id) OVERRIDE { + cdm_->ReleaseSession(session_id); return NO_ACTION; } @@ -218,43 +217,42 @@ class CdmWrapperImpl : public CdmWrapper { cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask); } - uint32_t DetermineReferenceId(const std::string& session_id) { + uint32_t LookupSessionId(const std::string& web_session_id) { for (SessionMap::iterator it = session_map_.begin(); it != session_map_.end(); ++it) { - if (it->second == session_id) + if (it->second == web_session_id) return it->first; } // There is no entry in the map; assume it came from the current // PrefixedGenerateKeyRequest() call (if possible). If no current request, // assume it came from the oldest PrefixedGenerateKeyRequest() call. - uint32_t reference_id = current_key_request_reference_id_; - if (current_key_request_reference_id_) { + uint32_t session_id = current_key_request_session_id_; + if (current_key_request_session_id_) { // Only 1 response is allowed for the current // PrefixedGenerateKeyRequest(). - current_key_request_reference_id_ = kInvalidReferenceId; + current_key_request_session_id_ = kInvalidSessionId; } else { - PP_DCHECK(!pending_key_request_reference_ids_.empty()); - reference_id = pending_key_request_reference_ids_.front(); - pending_key_request_reference_ids_.pop(); + PP_DCHECK(!pending_key_request_session_ids_.empty()); + session_id = pending_key_request_session_ids_.front(); + pending_key_request_session_ids_.pop(); } // If this is a valid |session_id|, add it to the list. Otherwise, avoid // adding empty string as a mapping to prevent future calls with an empty - // string from using the wrong reference_id. - if (!session_id.empty()) { - PP_DCHECK(session_map_.find(reference_id) == session_map_.end()); - PP_DCHECK(!session_id.empty()); - session_map_[reference_id] = session_id; + // string from using the wrong session_id. + if (!web_session_id.empty()) { + PP_DCHECK(session_map_.find(session_id) == session_map_.end()); + session_map_[session_id] = web_session_id; } - return reference_id; + return session_id; } - const std::string LookupSessionId(uint32_t reference_id) { + const std::string LookupWebSessionId(uint32_t session_id) { // Session may not exist if error happens during CreateSession(). - SessionMap::iterator it = session_map_.find(reference_id); + SessionMap::iterator it = session_map_.find(session_id); return (it != session_map_.end()) ? it->second : std::string(); } @@ -276,14 +274,14 @@ class CdmWrapperImpl : public CdmWrapper { template <class CdmInterface> void PrefixedGenerateKeyRequest(CdmWrapper* wrapper, CdmInterface* cdm, - uint32_t reference_id, + uint32_t session_id, const char* type, uint32_t type_size, const uint8_t* init_data, uint32_t init_data_size) { // As it is possible for CDMs to reply synchronously during the call to - // GenerateKeyRequest(), keep track of |reference_id|. - wrapper->current_key_request_reference_id_ = reference_id; + // GenerateKeyRequest(), keep track of |session_id|. + wrapper->current_key_request_session_id_ = session_id; cdm::Status status = cdm->GenerateKeyRequest(type, type_size, init_data, init_data_size); @@ -291,42 +289,41 @@ void PrefixedGenerateKeyRequest(CdmWrapper* wrapper, if (status != cdm::kSuccess) { // If GenerateKeyRequest() failed, no subsequent asynchronous replies // will be sent. Verify that a response was sent synchronously. - PP_DCHECK(wrapper->current_key_request_reference_id_ == - CdmWrapper::kInvalidReferenceId); - wrapper->current_key_request_reference_id_ = - CdmWrapper::kInvalidReferenceId; + PP_DCHECK(wrapper->current_key_request_session_id_ == + CdmWrapper::kInvalidSessionId); + wrapper->current_key_request_session_id_ = CdmWrapper::kInvalidSessionId; return; } - if (wrapper->current_key_request_reference_id_) { + if (wrapper->current_key_request_session_id_) { // If this request is still pending (SendKeyMessage() or SendKeyError() - // not called synchronously), add |reference_id| to the end of the queue. + // not called synchronously), add |session_id| to the end of the queue. // Without CDM support, it is impossible to match SendKeyMessage() - // (or SendKeyError()) responses to the |reference_id|. Doing the best + // (or SendKeyError()) responses to the |session_id|. Doing the best // we can by keeping track of this in a queue, and assuming the responses // come back in order. - wrapper->pending_key_request_reference_ids_.push(reference_id); - wrapper->current_key_request_reference_id_ = - CdmWrapper::kInvalidReferenceId; + wrapper->pending_key_request_session_ids_.push(session_id); + wrapper->current_key_request_session_id_ = CdmWrapper::kInvalidSessionId; } } template <class CdmInterface> CdmWrapper::Result PrefixedAddKey(CdmWrapper* wrapper, CdmInterface* cdm, - uint32_t reference_id, + uint32_t session_id, const uint8_t* response, uint32_t response_size) { - const std::string session_id = wrapper->LookupSessionId(reference_id); - if (session_id.empty()) { + const std::string web_session_id = wrapper->LookupWebSessionId(session_id); + if (web_session_id.empty()) { // Possible if UpdateSession() called before CreateSession(). return CdmWrapper::CALL_KEY_ERROR; } // CDM_1 and CDM_2 accept initdata, which is no longer needed. // In it's place pass in NULL. - cdm::Status status = cdm->AddKey( - session_id.data(), session_id.size(), response, response_size, NULL, 0); + cdm::Status status = cdm->AddKey(web_session_id.data(), web_session_id.size(), + response, response_size, + NULL, 0); PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); if (status != cdm::kSuccess) { // Some CDMs using Host_1/2 don't call keyerror, so send one. @@ -339,16 +336,16 @@ CdmWrapper::Result PrefixedAddKey(CdmWrapper* wrapper, template <class CdmInterface> CdmWrapper::Result PrefixedCancelKeyRequest(CdmWrapper* wrapper, CdmInterface* cdm, - uint32_t reference_id) { - const std::string session_id = wrapper->LookupSessionId(reference_id); - if (session_id.empty()) { + uint32_t session_id) { + const std::string web_session_id = wrapper->LookupWebSessionId(session_id); + if (web_session_id.empty()) { // Possible if ReleaseSession() called before CreateSession(). return CdmWrapper::CALL_KEY_ERROR; } - wrapper->session_map_.erase(reference_id); + wrapper->session_map_.erase(session_id); cdm::Status status = - cdm->CancelKeyRequest(session_id.data(), session_id.size()); + cdm->CancelKeyRequest(web_session_id.data(), web_session_id.size()); PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); if (status != cdm::kSuccess) { @@ -363,27 +360,27 @@ CdmWrapper::Result PrefixedCancelKeyRequest(CdmWrapper* wrapper, template <> void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::CreateSession( - uint32_t reference_id, + uint32_t session_id, const char* type, uint32_t type_size, const uint8_t* init_data, uint32_t init_data_size) { PrefixedGenerateKeyRequest( - this, cdm_, reference_id, type, type_size, init_data, init_data_size); + this, cdm_, session_id, type, type_size, init_data, init_data_size); } template <> CdmWrapper::Result CdmWrapperImpl< - cdm::ContentDecryptionModule_1>::UpdateSession(uint32_t reference_id, + cdm::ContentDecryptionModule_1>::UpdateSession(uint32_t session_id, const uint8_t* response, uint32_t response_size) { - return PrefixedAddKey(this, cdm_, reference_id, response, response_size); + return PrefixedAddKey(this, cdm_, session_id, response, response_size); } template <> CdmWrapper::Result CdmWrapperImpl< - cdm::ContentDecryptionModule_1>::ReleaseSession(uint32_t reference_id) { - return PrefixedCancelKeyRequest(this, cdm_, reference_id); + cdm::ContentDecryptionModule_1>::ReleaseSession(uint32_t session_id) { + return PrefixedCancelKeyRequest(this, cdm_, session_id); } template <> void CdmWrapperImpl<cdm::ContentDecryptionModule_1>:: @@ -416,27 +413,27 @@ template <> cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_1>:: template <> void CdmWrapperImpl<cdm::ContentDecryptionModule_2>::CreateSession( - uint32_t reference_id, + uint32_t session_id, const char* type, uint32_t type_size, const uint8_t* init_data, uint32_t init_data_size) { PrefixedGenerateKeyRequest( - this, cdm_, reference_id, type, type_size, init_data, init_data_size); + this, cdm_, session_id, type, type_size, init_data, init_data_size); } template <> CdmWrapper::Result CdmWrapperImpl< - cdm::ContentDecryptionModule_2>::UpdateSession(uint32_t reference_id, + cdm::ContentDecryptionModule_2>::UpdateSession(uint32_t session_id, const uint8_t* response, uint32_t response_size) { - return PrefixedAddKey(this, cdm_, reference_id, response, response_size); + return PrefixedAddKey(this, cdm_, session_id, response, response_size); } template <> CdmWrapper::Result CdmWrapperImpl< - cdm::ContentDecryptionModule_2>::ReleaseSession(uint32_t reference_id) { - return PrefixedCancelKeyRequest(this, cdm_, reference_id); + cdm::ContentDecryptionModule_2>::ReleaseSession(uint32_t session_id) { + return PrefixedCancelKeyRequest(this, cdm_, session_id); } CdmWrapper* CdmWrapper::Create(const char* key_system, diff --git a/media/cdm/ppapi/clear_key_cdm.cc b/media/cdm/ppapi/clear_key_cdm.cc index 3fc10e1..6d3a68c 100644 --- a/media/cdm/ppapi/clear_key_cdm.cc +++ b/media/cdm/ppapi/clear_key_cdm.cc @@ -159,9 +159,9 @@ const char* GetCdmVersion() { namespace media { // Since all the calls to AesDecryptor are synchronous, pass a dummy value for -// reference_id that is never exposed outside this class. +// session_id that is never exposed outside this class. // TODO(jrummell): Remove usage of this when the CDM interface is updated -// to use reference_id. +// to use session_id. ClearKeyCdm::Client::Client() : status_(kNone), error_code_(MediaKeys::kUnknownError), system_code_(0) {} @@ -170,20 +170,20 @@ ClearKeyCdm::Client::~Client() {} void ClearKeyCdm::Client::Reset() { status_ = kNone; - session_id_.clear(); + web_session_id_.clear(); message_.clear(); destination_url_.clear(); error_code_ = MediaKeys::kUnknownError; system_code_ = 0; } -void ClearKeyCdm::Client::OnSessionCreated(uint32 reference_id, - const std::string& session_id) { +void ClearKeyCdm::Client::OnSessionCreated(uint32 session_id, + const std::string& web_session_id) { status_ = static_cast<Status>(status_ | kCreated); - session_id_ = session_id; + web_session_id_ = web_session_id; } -void ClearKeyCdm::Client::OnSessionMessage(uint32 reference_id, +void ClearKeyCdm::Client::OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, const std::string& destination_url) { status_ = static_cast<Status>(status_ | kMessage); @@ -191,15 +191,15 @@ void ClearKeyCdm::Client::OnSessionMessage(uint32 reference_id, destination_url_ = destination_url; } -void ClearKeyCdm::Client::OnSessionReady(uint32 reference_id) { +void ClearKeyCdm::Client::OnSessionReady(uint32 session_id) { status_ = static_cast<Status>(status_ | kReady); } -void ClearKeyCdm::Client::OnSessionClosed(uint32 reference_id) { +void ClearKeyCdm::Client::OnSessionClosed(uint32 session_id) { status_ = static_cast<Status>(status_ | kClosed); } -void ClearKeyCdm::Client::OnSessionError(uint32 reference_id, +void ClearKeyCdm::Client::OnSessionError(uint32 session_id, media::MediaKeys::KeyError error_code, int system_code) { status_ = static_cast<Status>(status_ | kError); @@ -236,27 +236,27 @@ cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* type, DVLOG(1) << "GenerateKeyRequest()"; base::AutoLock auto_lock(client_lock_); ScopedResetter<Client> auto_resetter(&client_); - decryptor_.CreateSession(MediaKeys::kInvalidReferenceId, + decryptor_.CreateSession(MediaKeys::kInvalidSessionId, std::string(type, type_size), init_data, init_data_size); if (client_.status() != (Client::kMessage | Client::kCreated)) { // Use values returned to client if possible. - host_->SendKeyError(client_.session_id().data(), - client_.session_id().size(), + host_->SendKeyError(client_.web_session_id().data(), + client_.web_session_id().size(), static_cast<cdm::MediaKeyError>(client_.error_code()), client_.system_code()); return cdm::kSessionError; } host_->SendKeyMessage( - client_.session_id().data(), client_.session_id().size(), + client_.web_session_id().data(), client_.web_session_id().size(), reinterpret_cast<const char*>(&client_.message()[0]), client_.message().size(), client_.destination_url().data(), client_.destination_url().size()); // Only save the latest session ID for heartbeat messages. - heartbeat_session_id_ = client_.session_id(); + heartbeat_session_id_ = client_.web_session_id(); return cdm::kSuccess; } @@ -271,7 +271,7 @@ cdm::Status ClearKeyCdm::AddKey(const char* session_id, DCHECK(!key_id && !key_id_size); base::AutoLock auto_lock(client_lock_); ScopedResetter<Client> auto_resetter(&client_); - decryptor_.UpdateSession(MediaKeys::kInvalidReferenceId, key, key_size); + decryptor_.UpdateSession(MediaKeys::kInvalidSessionId, key, key_size); if (client_.status() != Client::kReady) { host_->SendKeyError(session_id, session_id_size, @@ -293,7 +293,7 @@ cdm::Status ClearKeyCdm::CancelKeyRequest(const char* session_id, DVLOG(1) << "CancelKeyRequest()"; base::AutoLock auto_lock(client_lock_); ScopedResetter<Client> auto_resetter(&client_); - decryptor_.ReleaseSession(MediaKeys::kInvalidReferenceId); + decryptor_.ReleaseSession(MediaKeys::kInvalidSessionId); // No message normally sent by Release(), but if an error occurred, // report it as a failure. diff --git a/media/cdm/ppapi/clear_key_cdm.h b/media/cdm/ppapi/clear_key_cdm.h index 4c5cb34..0ec18a1 100644 --- a/media/cdm/ppapi/clear_key_cdm.h +++ b/media/cdm/ppapi/clear_key_cdm.h @@ -72,7 +72,7 @@ class ClearKeyCdm : public ClearKeyCdmInterface { class Client { public: // TODO(jrummell): Remove bitmask and rename kNone to kInvalid once CDM - // interface supports reference_id passing completely. + // interface supports session_id passing completely. enum Status { kNone = 0, kCreated = 1 << 0, @@ -86,7 +86,7 @@ class ClearKeyCdm : public ClearKeyCdmInterface { virtual ~Client(); Status status() { return status_; } - const std::string& session_id() { return session_id_; } + const std::string& web_session_id() { return web_session_id_; } const std::vector<uint8>& message() { return message_; } const std::string& destination_url() { return destination_url_; } MediaKeys::KeyError error_code() { return error_code_; } @@ -95,19 +95,19 @@ class ClearKeyCdm : public ClearKeyCdmInterface { // Resets the Client to a clean state. void Reset(); - void OnSessionCreated(uint32 reference_id, const std::string& session_id); - void OnSessionMessage(uint32 reference_id, + void OnSessionCreated(uint32 session_id, const std::string& web_session_id); + void OnSessionMessage(uint32 session_id, const std::vector<uint8>& message, const std::string& destination_url); - void OnSessionReady(uint32 reference_id); - void OnSessionClosed(uint32 reference_id); - void OnSessionError(uint32 reference_id, + void OnSessionReady(uint32 session_id); + void OnSessionClosed(uint32 session_id); + void OnSessionError(uint32 session_id, MediaKeys::KeyError error_code, int system_code); private: Status status_; - std::string session_id_; + std::string web_session_id_; std::vector<uint8> message_; std::string destination_url_; MediaKeys::KeyError error_code_; |