}
bool PpapiDecryptor::CreateSession(uint32 session_id,
- const std::string& type,
+ const std::string& content_type,
const uint8* init_data,
int init_data_length) {
DVLOG(2) << __FUNCTION__;
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
- DCHECK(plugin_cdm_delegate_);
if (!plugin_cdm_delegate_ ||
!plugin_cdm_delegate_->CreateSession(
- session_id, type, init_data, init_data_length)) {
+ session_id, content_type, init_data, init_data_length)) {
ReportFailureToCallPlugin(session_id);
return false;
}
return true;
}
+void PpapiDecryptor::LoadSession(uint32 session_id,
+ const std::string& web_session_id) {
+ DVLOG(2) << __FUNCTION__;
+ DCHECK(render_loop_proxy_->BelongsToCurrentThread());
+
+ if (!plugin_cdm_delegate_) {
+ ReportFailureToCallPlugin(session_id);
+ return;
+ }
+
+ plugin_cdm_delegate_->LoadSession(session_id, web_session_id);
+}
+
void PpapiDecryptor::UpdateSession(uint32 session_id,
const uint8* response,
int response_length) {
if (!plugin_cdm_delegate_ || !plugin_cdm_delegate_->UpdateSession(
session_id, response, response_length)) {
ReportFailureToCallPlugin(session_id);
+ return;
}
-
- if (!new_audio_key_cb_.is_null())
- new_audio_key_cb_.Run();
-
- if (!new_video_key_cb_.is_null())
- new_video_key_cb_.Run();
}
void PpapiDecryptor::ReleaseSession(uint32 session_id) {
if (!plugin_cdm_delegate_ ||
!plugin_cdm_delegate_->ReleaseSession(session_id)) {
ReportFailureToCallPlugin(session_id);
+ return;
}
}
void PpapiDecryptor::OnSessionReady(uint32 session_id) {
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
+
+ // Based on the spec, we need to resume playback when update() completes
+ // successfully, or when a session is successfully loaded. In both cases,
+ // the CDM fires OnSessionReady() event. So we choose to call the NewKeyCBs
+ // here.
+ // TODO(xhwang): Rename OnSessionReady to indicate that the playback may
+ // resume successfully (e.g. a new key is available or available again).
+ if (!new_audio_key_cb_.is_null())
+ new_audio_key_cb_.Run();
+
+ if (!new_video_key_cb_.is_null())
+ new_video_key_cb_.Run();
+
session_ready_cb_.Run(session_id);
}