Index: media/cdm/ppapi/cdm_wrapper.h |
diff --git a/media/cdm/ppapi/cdm_wrapper.h b/media/cdm/ppapi/cdm_wrapper.h |
index 665b6b68dadf76dd05c0eb7987407b935d3bfb0b..c6cff0a3f7a7e141dd7171ebfe749fd9bbdb225c 100644 |
--- a/media/cdm/ppapi/cdm_wrapper.h |
+++ b/media/cdm/ppapi/cdm_wrapper.h |
@@ -56,9 +56,15 @@ class CdmWrapper { |
uint32_t web_session_id_size, |
const uint8_t* response, |
uint32_t response_size) = 0; |
- virtual void ReleaseSession(uint32_t promise_id, |
- const char* web_session_id, |
- uint32_t web_session_id_size) = 0; |
+ virtual bool GetUsableKeyIds(uint32_t promise_id, |
ddorwin
2014/08/07 01:34:44
nit: After RemoveSession to match CDM_6 (and keeps
jrummell
2014/08/07 20:44:31
Done.
|
+ const char* web_session_id, |
+ uint32_t web_session_id_size) = 0; |
+ virtual void CloseSession(uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) = 0; |
+ virtual bool RemoveSession(uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) = 0; |
virtual void TimerExpired(void* context) = 0; |
virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, |
cdm::DecryptedBlock* decrypted_buffer) = 0; |
@@ -95,6 +101,17 @@ class CdmWrapper { |
virtual std::string LookupWebSessionId(uint32_t session_id) = 0; |
virtual void DropWebSessionId(std::string web_session_id) = 0; |
+ // Helper functions for the cdm::Host_4 and cdm::Host_5 methods. |
+ // In cdm::Host_6, resolving LoadSession() and UpdateSession() calls will |
ddorwin
2014/08/07 01:34:44
Isn't this more like the following?
CDMs using Hos
jrummell
2014/08/07 20:44:30
Done.
|
+ // also generate an OnSessionUsableKeys() event. This needs to be simulated |
+ // for the older calls. |
+ virtual bool SessionUsableKeysEventNeeded(uint32_t promise_id, |
ddorwin
2014/08/07 01:34:44
// These must not be called for Host_6 and later.
jrummell
2014/08/07 20:44:30
Done.
|
+ std::string* web_session_id) = 0; |
+ virtual void SetSessionUsableKeysEventNeeded( |
+ uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) = 0; |
+ |
protected: |
CdmWrapper() {} |
@@ -158,10 +175,24 @@ class CdmWrapperImpl : public CdmWrapper { |
response_size); |
} |
- virtual void ReleaseSession(uint32_t promise_id, |
- const char* web_session_id, |
- uint32_t web_session_id_size) OVERRIDE { |
- cdm_->ReleaseSession(promise_id, web_session_id, web_session_id_size); |
+ virtual bool GetUsableKeyIds(uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) OVERRIDE { |
+ cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size); |
+ return true; |
+ } |
+ |
+ virtual void CloseSession(uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) OVERRIDE { |
+ cdm_->CloseSession(promise_id, web_session_id, web_session_id_size); |
+ } |
+ |
+ virtual bool RemoveSession(uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) OVERRIDE { |
+ cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size); |
+ return true; |
} |
virtual void TimerExpired(void* context) OVERRIDE { |
@@ -261,6 +292,24 @@ class CdmWrapperImpl : public CdmWrapper { |
web_session_to_session_id_map_.erase(web_session_id); |
} |
+ virtual bool SessionUsableKeysEventNeeded(uint32_t promise_id, |
+ std::string* web_session_id) { |
+ std::map<uint32_t, std::string>::iterator it = |
+ session_usable_keys_event_needed_.find(promise_id); |
+ if (it == session_usable_keys_event_needed_.end()) |
+ return false; |
+ web_session_id->swap(it->second); |
+ session_usable_keys_event_needed_.erase(it); |
+ return true; |
+ } |
+ |
+ virtual void SetSessionUsableKeysEventNeeded(uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) { |
+ session_usable_keys_event_needed_.insert(std::make_pair( |
+ promise_id, std::string(web_session_id, web_session_id_size))); |
+ } |
+ |
private: |
CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm), next_session_id_(100) { |
PP_DCHECK(cdm_); |
@@ -272,9 +321,61 @@ class CdmWrapperImpl : public CdmWrapper { |
uint32_t next_session_id_; |
std::map<std::string, uint32_t> web_session_to_session_id_map_; |
+ std::map<uint32_t, std::string> session_usable_keys_event_needed_; |
ddorwin
2014/08/07 01:34:44
promises_needing_usable_....?
jrummell
2014/08/07 20:44:30
Done.
|
+ |
DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl); |
}; |
+// Overrides for the cdm::Host_5 methods. |
ddorwin
2014/08/07 01:34:44
Why does 5 come before 4?
jrummell
2014/08/07 20:44:30
Done.
|
+// TODO(jrummell): Remove these once Host_5 interface is removed. |
+ |
+template <> |
+void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::LoadSession( |
+ uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) { |
+ SetSessionUsableKeysEventNeeded( |
+ promise_id, web_session_id, web_session_id_size); |
+ cdm_->LoadSession(promise_id, web_session_id, web_session_id_size); |
+} |
+ |
+template <> |
+void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::UpdateSession( |
+ uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size, |
+ const uint8_t* response, |
+ uint32_t response_size) { |
+ SetSessionUsableKeysEventNeeded( |
ddorwin
2014/08/07 01:34:44
This may be overly aggressive in firing events, bu
jrummell
2014/08/07 20:44:30
Acknowledged.
|
+ promise_id, web_session_id, web_session_id_size); |
+ cdm_->UpdateSession( |
+ promise_id, web_session_id, web_session_id_size, response, response_size); |
+} |
+ |
+template <> |
+bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::GetUsableKeyIds( |
ddorwin
2014/08/07 01:34:44
nit: ditto on order
jrummell
2014/08/07 20:44:30
Done.
|
+ uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) { |
+ return false; |
+} |
+ |
+template <> |
+void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CloseSession( |
+ uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) { |
+ cdm_->ReleaseSession(promise_id, web_session_id, web_session_id_size); |
+} |
+ |
+template <> |
+bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::RemoveSession( |
+ uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) { |
+ return false; |
+} |
+ |
// Overrides for the cdm::Host_4 methods. Calls to CreateSession(), |
// LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids, |
// but the CDM interface needs session ids. For create and load, we need to |
@@ -308,6 +409,8 @@ void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::LoadSession( |
uint32_t web_session_id_size) { |
uint32_t session_id = CreateSessionId(); |
RegisterPromise(session_id, promise_id); |
+ SetSessionUsableKeysEventNeeded( |
ddorwin
2014/08/07 01:34:44
ditto here and below.
jrummell
2014/08/07 20:44:30
Acknowledged.
|
+ promise_id, web_session_id, web_session_id_size); |
cdm_->LoadSession(session_id, web_session_id, web_session_id_size); |
} |
@@ -321,11 +424,21 @@ void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::UpdateSession( |
std::string web_session_str(web_session_id, web_session_id_size); |
uint32_t session_id = LookupSessionId(web_session_str); |
RegisterPromise(session_id, promise_id); |
+ SetSessionUsableKeysEventNeeded( |
+ promise_id, web_session_id, web_session_id_size); |
cdm_->UpdateSession(session_id, response, response_size); |
} |
template <> |
-void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::ReleaseSession( |
+bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::GetUsableKeyIds( |
ddorwin
2014/08/07 01:34:44
nit: ditto on order
jrummell
2014/08/07 20:44:30
Done.
|
+ uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) { |
+ return false; |
+} |
+ |
+template <> |
+void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CloseSession( |
uint32_t promise_id, |
const char* web_session_id, |
uint32_t web_session_id_size) { |
@@ -335,12 +448,20 @@ void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::ReleaseSession( |
cdm_->ReleaseSession(session_id); |
} |
+template <> |
+bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::RemoveSession( |
+ uint32_t promise_id, |
+ const char* web_session_id, |
+ uint32_t web_session_id_size) { |
+ return false; |
+} |
+ |
CdmWrapper* CdmWrapper::Create(const char* key_system, |
uint32_t key_system_size, |
GetCdmHostFunc get_cdm_host_func, |
void* user_data) { |
COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == |
- cdm::ContentDecryptionModule_5::kVersion, |
+ cdm::ContentDecryptionModule_6::kVersion, |
update_code_below); |
// Ensure IsSupportedCdmInterfaceVersion() matches this implementation. |
@@ -365,6 +486,11 @@ CdmWrapper* CdmWrapper::Create(const char* key_system, |
// If |cdm_wrapper| is NULL, try to create the CDM using older supported |
// versions of the CDM interface. |
+ cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Create( |
+ key_system, key_system_size, get_cdm_host_func, user_data); |
+ if (cdm_wrapper) |
+ return cdm_wrapper; |
+ |
cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Create( |
key_system, key_system_size, get_cdm_host_func, user_data); |
return cdm_wrapper; |
@@ -375,7 +501,7 @@ CdmWrapper* CdmWrapper::Create(const char* key_system, |
// does not have. |
// Also update supported_cdm_versions.h. |
COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == |
- cdm::ContentDecryptionModule_5::kVersion, |
+ cdm::ContentDecryptionModule_6::kVersion, |
ensure_cdm_wrapper_templates_have_old_version_support); |
} // namespace media |