Chromium Code Reviews| Index: media/cdm/ppapi/cdm_wrapper.h |
| diff --git a/media/cdm/ppapi/cdm_wrapper.h b/media/cdm/ppapi/cdm_wrapper.h |
| index 99e5c0468410587a6d793d6ccab264aee9d39491..69b279927583634ebde92db664fbee95ec3493bc 100644 |
| --- a/media/cdm/ppapi/cdm_wrapper.h |
| +++ b/media/cdm/ppapi/cdm_wrapper.h |
| @@ -52,11 +52,17 @@ class CdmWrapper { |
| virtual ~CdmWrapper() {}; |
| + // The CDM interface version this CDM implements. |
|
ddorwin
2014/02/10 19:05:25
This probably shouldn't be exposed. I think a temp
xhwang
2014/02/10 22:30:55
Done.
|
| + virtual int GetCdmVersion() = 0; |
| + |
| virtual void CreateSession(uint32_t session_id, |
| - const char* type, |
| - uint32_t type_size, |
| + const char* content_type, |
| + uint32_t content_type_size, |
| const uint8_t* init_data, |
| uint32_t init_data_size) = 0; |
| + virtual void LoadSession(uint32_t session_id, |
| + const char* web_session_id, |
| + uint32_t web_session_id_size) = 0; |
| virtual Result UpdateSession(uint32_t session_id, |
| const uint8_t* response, |
| uint32_t response_size) = 0; |
| @@ -147,29 +153,21 @@ class CdmWrapperImpl : public CdmWrapper { |
| cdm_->Destroy(); |
| } |
| + virtual int GetCdmVersion() OVERRIDE { return CdmInterface::kVersion; } |
| + |
| virtual void CreateSession(uint32_t session_id, |
| - const char* type, |
| - uint32_t type_size, |
| + const char* content_type, |
| + uint32_t content_type_size, |
| const uint8_t* init_data, |
| uint32_t init_data_size) OVERRIDE { |
| - // TODO(xhwang): Update the full MediaKeys stack to support LoadSession. |
| - // See: http://crbug.com/338831 |
| - const uint8_t kPrefixedApiLoadSessionHeader[] = "LOAD_SESSION|"; |
| - const size_t kPrefixedApiLoadSessionHeaderSize = |
| - sizeof(kPrefixedApiLoadSessionHeader) - 1; |
| - |
| - if (init_data_size > kPrefixedApiLoadSessionHeaderSize && |
| - std::equal(init_data, |
| - init_data + kPrefixedApiLoadSessionHeaderSize, |
| - kPrefixedApiLoadSessionHeader)) { |
| - cdm_->LoadSession(session_id, |
| - reinterpret_cast<const char*>( |
| - init_data + kPrefixedApiLoadSessionHeaderSize), |
| - init_data_size - kPrefixedApiLoadSessionHeaderSize); |
| - return; |
| - } |
| + cdm_->CreateSession( |
| + session_id, content_type, content_type_size, init_data, init_data_size); |
| + } |
| - cdm_->CreateSession(session_id, type, type_size, init_data, init_data_size); |
| + virtual void LoadSession(uint32_t session_id, |
| + const char* web_session_id, |
| + uint32_t web_session_id_size) OVERRIDE { |
| + cdm_->LoadSession(session_id, web_session_id, web_session_id_size); |
| } |
| virtual Result UpdateSession(uint32_t session_id, |
| @@ -268,7 +266,8 @@ class CdmWrapperImpl : public CdmWrapper { |
| } |
| const std::string LookupWebSessionId(uint32_t session_id) { |
| - // Session may not exist if error happens during CreateSession(). |
| + // Session may not exist if error happens during CreateSession() or |
| + // LoadSession(). |
| SessionMap::iterator it = session_map_.find(session_id); |
| return (it != session_map_.end()) ? it->second : std::string(); |
| } |
| @@ -284,24 +283,24 @@ class CdmWrapperImpl : public CdmWrapper { |
| }; |
| // For ContentDecryptionModule_1 and ContentDecryptionModule_2, |
| -// CreateSession(), UpdateSession(), and ReleaseSession() call methods |
| -// are incompatible with ContentDecryptionModule_4. Use the following |
| +// CreateSession(), LoadSession(), UpdateSession(), and ReleaseSession() call |
| +// methods are incompatible with ContentDecryptionModule_4. Use the following |
| // templated functions to handle this. |
| template <class CdmInterface> |
| void PrefixedGenerateKeyRequest(CdmWrapper* wrapper, |
| CdmInterface* cdm, |
| uint32_t session_id, |
| - const char* type, |
| - uint32_t type_size, |
| + const char* content_type, |
| + uint32_t content_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 |session_id|. |
| wrapper->current_key_request_session_id_ = session_id; |
| - cdm::Status status = |
| - cdm->GenerateKeyRequest(type, type_size, init_data, init_data_size); |
| + cdm::Status status = cdm->GenerateKeyRequest( |
| + content_type, content_type_size, init_data, init_data_size); |
| PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); |
| if (status != cdm::kSuccess) { |
| // If GenerateKeyRequest() failed, no subsequent asynchronous replies |
| @@ -378,12 +377,25 @@ CdmWrapper::Result PrefixedCancelKeyRequest(CdmWrapper* wrapper, |
| template <> |
| void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::CreateSession( |
| uint32_t session_id, |
| - const char* type, |
| - uint32_t type_size, |
| + const char* content_type, |
| + uint32_t content_type_size, |
| const uint8_t* init_data, |
| uint32_t init_data_size) { |
| - PrefixedGenerateKeyRequest( |
| - this, cdm_, session_id, type, type_size, init_data, init_data_size); |
| + PrefixedGenerateKeyRequest(this, |
| + cdm_, |
| + session_id, |
| + content_type, |
| + content_type_size, |
| + init_data, |
| + init_data_size); |
| +} |
| + |
| +template <> |
| +void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::LoadSession( |
| + uint32_t session_id, |
| + const char* web_session_id, |
| + uint32_t web_session_id_size) { |
| + PP_NOTREACHED(); |
| } |
| template <> |
| @@ -431,12 +443,25 @@ template <> cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_1>:: |
| template <> |
| void CdmWrapperImpl<cdm::ContentDecryptionModule_2>::CreateSession( |
| uint32_t session_id, |
| - const char* type, |
| - uint32_t type_size, |
| + const char* content_type, |
| + uint32_t content_type_size, |
| const uint8_t* init_data, |
| uint32_t init_data_size) { |
| - PrefixedGenerateKeyRequest( |
| - this, cdm_, session_id, type, type_size, init_data, init_data_size); |
| + PrefixedGenerateKeyRequest(this, |
| + cdm_, |
| + session_id, |
| + content_type, |
| + content_type_size, |
| + init_data, |
| + init_data_size); |
| +} |
| + |
| +template <> |
| +void CdmWrapperImpl<cdm::ContentDecryptionModule_2>::LoadSession( |
| + uint32_t session_id, |
| + const char* web_session_id, |
| + uint32_t web_session_id_size) { |
| + PP_NOTREACHED(); |
| } |
| template <> |