Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc

Issue 166273009: PpapiDecryptor: Call NewKeyCB on OnSessionReady(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
diff --git a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
index 63d1066e7922151d6df9594a8ca829a3097326c1..d6da86dd60eaf3efcde86453ee7561a820e66853 100644
--- a/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
+++ b/media/cdm/ppapi/external_clear_key/clear_key_cdm.cc
@@ -5,6 +5,7 @@
#include "media/cdm/ppapi/external_clear_key/clear_key_cdm.h"
#include <algorithm>
+#include <cstring>
#include <sstream>
#include <string>
#include <vector>
@@ -196,7 +197,7 @@ ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, const std::string& key_system)
last_session_id_(MediaKeys::kInvalidSessionId),
session_id_for_emulated_loadsession_(MediaKeys::kInvalidSessionId),
timer_delay_ms_(kInitialTimerDelayMs),
- timer_set_(false) {
+ heartbeat_timer_set_(false) {
#if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER)
channel_count_ = 0;
bits_per_channel_ = 0;
@@ -250,9 +251,9 @@ void ClearKeyCdm::UpdateSession(uint32 session_id,
DVLOG(1) << __FUNCTION__;
decryptor_.UpdateSession(session_id, response, response_size);
- if (!timer_set_) {
+ if (!heartbeat_timer_set_) {
ScheduleNextHeartBeat();
- timer_set_ = true;
+ heartbeat_timer_set_ = true;
}
}
@@ -262,6 +263,11 @@ void ClearKeyCdm::ReleaseSession(uint32 session_id) {
}
void ClearKeyCdm::TimerExpired(void* context) {
+ if (context == &session_id_for_emulated_loadsession_) {
+ UpdateLoadableSession();
+ return;
+ }
+
std::string heartbeat_message;
ddorwin 2014/02/19 00:04:09 Should we add this before this line? DCHECK(heartb
xhwang 2014/02/19 00:24:23 Done.
if (!next_heartbeat_message_.empty() &&
context == &next_heartbeat_message_[0]) {
@@ -538,18 +544,29 @@ void ClearKeyCdm::OnSessionCreated(uint32 session_id,
std::string new_web_session_id = web_session_id;
if (session_id == session_id_for_emulated_loadsession_) {
- new_web_session_id = kLoadableWebSessionId;
- UpdateLoadableSession();
- session_id_for_emulated_loadsession_ = MediaKeys::kInvalidSessionId;
+ // Delay UpdateLoadableSession() to test the case where Decrypt*() calls are
+ // made before the session is fully loaded.
+ const int64 kDelayToLoadSessionMs = 500;
xhwang 2014/02/18 23:19:16 Ideally we should keep the old test (where the del
+ host_->SetTimer(kDelayToLoadSessionMs,
+ &session_id_for_emulated_loadsession_);
ddorwin 2014/02/19 00:04:09 It might be nice to clarify somewhere that we're u
xhwang 2014/02/19 00:24:23 Done.
+ // Defer OnSessionCreated until the session is updated with
ddorwin 2014/02/19 00:04:09 ... until the loadable session is initialized?
xhwang 2014/02/19 00:24:23 Done.
+ // kLoadableSessionKey.
+ return;
}
host_->OnSessionCreated(
- session_id, new_web_session_id.data(), new_web_session_id.size());
+ session_id, web_session_id.data(), web_session_id.size());
}
void ClearKeyCdm::OnSessionMessage(uint32 session_id,
const std::vector<uint8>& message,
const std::string& destination_url) {
+ DVLOG(1) << "OnSessionMessage: " << message.size();
+
+ // Ignore the Message when we are waiting to update the loadable session.
ddorwin 2014/02/19 00:04:09 nit: Is upper case 'M' intentional?
xhwang 2014/02/19 00:24:23 Done.
+ if (session_id == session_id_for_emulated_loadsession_)
+ return;
+
host_->OnSessionMessage(session_id,
reinterpret_cast<const char*>(message.data()),
message.size(),
@@ -558,6 +575,12 @@ void ClearKeyCdm::OnSessionMessage(uint32 session_id,
}
void ClearKeyCdm::OnSessionReady(uint32 session_id) {
+ if (session_id == session_id_for_emulated_loadsession_) {
+ session_id_for_emulated_loadsession_ = MediaKeys::kInvalidSessionId;
+ host_->OnSessionCreated(
+ session_id, kLoadableWebSessionId, strlen(kLoadableWebSessionId));
+ }
+
host_->OnSessionReady(session_id);
}

Powered by Google App Engine
This is Rietveld 408576698