Index: media/cdm/ppapi/cdm_wrapper.h |
diff --git a/media/cdm/ppapi/cdm_wrapper.h b/media/cdm/ppapi/cdm_wrapper.h |
index 63d8bbfd7a1065f25a7cb6f7bec377e897ee90fb..d827336a8c6b51c8ddad571bbf7421adaf918d3b 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, |