Index: content/renderer/media/crypto/ppapi_decryptor.cc |
diff --git a/content/renderer/media/crypto/ppapi_decryptor.cc b/content/renderer/media/crypto/ppapi_decryptor.cc |
index 8b8836203585963ed69cf63f8d189706917c121b..12e82d745a3bec294e2658e18ebf1427f88f26c0 100644 |
--- a/content/renderer/media/crypto/ppapi_decryptor.cc |
+++ b/content/renderer/media/crypto/ppapi_decryptor.cc |
@@ -91,6 +91,8 @@ scoped_ptr<PpapiDecryptor> PpapiDecryptor::Create( |
const GURL& security_origin, |
const CreatePepperCdmCB& create_pepper_cdm_cb, |
const media::SessionMessageCB& session_message_cb, |
+ const media::SessionKeysChangeCB& session_keys_change_cb, |
+ const media::SessionExpirationChangeCB& session_expiration_change_cb, |
const media::SessionReadyCB& session_ready_cb, |
const media::SessionClosedCB& session_closed_cb, |
const media::SessionErrorCB& session_error_cb) { |
@@ -107,6 +109,8 @@ scoped_ptr<PpapiDecryptor> PpapiDecryptor::Create( |
new PpapiDecryptor(key_system, |
pepper_cdm_wrapper.Pass(), |
session_message_cb, |
+ session_keys_change_cb, |
+ session_expiration_change_cb, |
session_ready_cb, |
session_closed_cb, |
session_error_cb)); |
@@ -116,11 +120,15 @@ PpapiDecryptor::PpapiDecryptor( |
const std::string& key_system, |
scoped_ptr<PepperCdmWrapper> pepper_cdm_wrapper, |
const media::SessionMessageCB& session_message_cb, |
+ const media::SessionKeysChangeCB& session_keys_change_cb, |
+ const media::SessionExpirationChangeCB& session_expiration_change_cb, |
const media::SessionReadyCB& session_ready_cb, |
const media::SessionClosedCB& session_closed_cb, |
const media::SessionErrorCB& session_error_cb) |
: pepper_cdm_wrapper_(pepper_cdm_wrapper.Pass()), |
session_message_cb_(session_message_cb), |
+ session_keys_change_cb_(session_keys_change_cb), |
+ session_expiration_change_cb_(session_expiration_change_cb), |
session_ready_cb_(session_ready_cb), |
session_closed_cb_(session_closed_cb), |
session_error_cb_(session_error_cb), |
@@ -128,6 +136,8 @@ PpapiDecryptor::PpapiDecryptor( |
weak_ptr_factory_(this) { |
DCHECK(pepper_cdm_wrapper_.get()); |
DCHECK(!session_message_cb_.is_null()); |
+ DCHECK(!session_keys_change_cb.is_null()); |
+ DCHECK(!session_expiration_change_cb.is_null()); |
DCHECK(!session_ready_cb_.is_null()); |
DCHECK(!session_closed_cb_.is_null()); |
DCHECK(!session_error_cb_.is_null()); |
@@ -136,6 +146,8 @@ PpapiDecryptor::PpapiDecryptor( |
CdmDelegate()->Initialize( |
key_system, |
base::Bind(&PpapiDecryptor::OnSessionMessage, weak_this), |
+ base::Bind(&PpapiDecryptor::OnSessionKeysChange, weak_this), |
+ base::Bind(&PpapiDecryptor::OnSessionExpirationChange, weak_this), |
base::Bind(&PpapiDecryptor::OnSessionReady, weak_this), |
base::Bind(&PpapiDecryptor::OnSessionClosed, weak_this), |
base::Bind(&PpapiDecryptor::OnSessionError, weak_this), |
@@ -146,6 +158,22 @@ PpapiDecryptor::~PpapiDecryptor() { |
pepper_cdm_wrapper_.reset(); |
} |
+void PpapiDecryptor::SetServerCertificate( |
+ const uint8* certificate_data, |
+ int certificate_data_length, |
+ scoped_ptr<media::SimpleCdmPromise> promise) { |
+ DVLOG(2) << __FUNCTION__; |
+ DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
+ |
+ if (!CdmDelegate()) { |
+ promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); |
+ return; |
+ } |
+ |
+ CdmDelegate()->SetServerCertificate( |
+ certificate_data, certificate_data_length, promise.Pass()); |
+} |
+ |
void PpapiDecryptor::CreateSession( |
const std::string& init_data_type, |
const uint8* init_data, |
@@ -211,7 +239,19 @@ void PpapiDecryptor::UpdateSession( |
session_updated_promise.PassAs<media::SimpleCdmPromise>()); |
} |
-void PpapiDecryptor::ReleaseSession( |
+void PpapiDecryptor::CloseSession(const std::string& web_session_id, |
+ scoped_ptr<media::SimpleCdmPromise> promise) { |
+ DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
+ |
+ if (!CdmDelegate()) { |
+ promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); |
+ return; |
+ } |
+ |
+ CdmDelegate()->CloseSession(web_session_id, promise.Pass()); |
+} |
+ |
+void PpapiDecryptor::RemoveSession( |
const std::string& web_session_id, |
scoped_ptr<media::SimpleCdmPromise> promise) { |
DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
@@ -221,7 +261,19 @@ void PpapiDecryptor::ReleaseSession( |
return; |
} |
- CdmDelegate()->CloseSession(web_session_id, promise.Pass()); |
+ CdmDelegate()->RemoveSession(web_session_id, promise.Pass()); |
+} |
+ |
+void PpapiDecryptor::GetUsableKeyIds(const std::string& web_session_id, |
+ scoped_ptr<media::KeyIdsPromise> promise) { |
+ DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
+ |
+ if (!CdmDelegate()) { |
+ promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); |
+ return; |
+ } |
+ |
+ CdmDelegate()->GetUsableKeyIds(web_session_id, promise.Pass()); |
} |
media::Decryptor* PpapiDecryptor::GetDecryptor() { |
@@ -436,6 +488,23 @@ void PpapiDecryptor::OnSessionMessage(const std::string& web_session_id, |
session_message_cb_.Run(web_session_id, message, destination_url); |
} |
+void PpapiDecryptor::OnSessionKeysChange(const std::string& web_session_id, |
+ bool has_additional_usable_key) { |
+ DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
+ |
+ if (has_additional_usable_key) |
+ ResumePlayback(); |
ddorwin
2014/09/10 22:58:38
Why is this here instead of in a more general loca
jrummell
2014/09/11 21:21:54
Maybe the name ResumePlayback is wrong? It simply
ddorwin
2014/09/11 23:31:11
As discussed offline, the intent is that we can re
|
+ |
+ session_keys_change_cb_.Run(web_session_id, has_additional_usable_key); |
+} |
+ |
+void PpapiDecryptor::OnSessionExpirationChange( |
+ const std::string& web_session_id, |
+ double new_expiry_time) { |
+ DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
+ session_expiration_change_cb_.Run(web_session_id, new_expiry_time); |
+} |
+ |
void PpapiDecryptor::OnSessionReady(const std::string& web_session_id) { |
DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |