summaryrefslogtreecommitdiffstats
path: root/media/cdm/aes_decryptor.cc
diff options
context:
space:
mode:
authorjrummell <jrummell@chromium.org>2014-09-25 17:10:38 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-26 00:10:48 +0000
commit80428d2eb359a2448c67ae45ece3ea5dbc2f8cef (patch)
tree8336dc22e94a678c64611314f66f7dee6488ab34 /media/cdm/aes_decryptor.cc
parent422b434274e09a95ca778dd29890d51ab2c15ae5 (diff)
downloadchromium_src-80428d2eb359a2448c67ae45ece3ea5dbc2f8cef.zip
chromium_src-80428d2eb359a2448c67ae45ece3ea5dbc2f8cef.tar.gz
chromium_src-80428d2eb359a2448c67ae45ece3ea5dbc2f8cef.tar.bz2
Update MediaKeys interface for EME
To support CDM_6, make the following changes: - add SetServerCertificate - add GetUsableKeyIds - rename ReleaseSession to CloseSession - add RemoveSession - add SessionKeysChange event - add SessionExpirationChange event This gets the new functionality up to the blink boundary. Changes to use these new interfaces in blink in a future CL. For backwards compatibility with existing prefixed EME code, calls to CancelKeyRequest() call RemoveSession() instead of CloseSession(). BUG=358271,417481 TEST=existing EME tests still pass + manual testing Review URL: https://codereview.chromium.org/555223004 Cr-Commit-Position: refs/heads/master@{#296838}
Diffstat (limited to 'media/cdm/aes_decryptor.cc')
-rw-r--r--media/cdm/aes_decryptor.cc69
1 files changed, 49 insertions, 20 deletions
diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc
index b83c9b1..23f41d7 100644
--- a/media/cdm/aes_decryptor.cc
+++ b/media/cdm/aes_decryptor.cc
@@ -224,17 +224,27 @@ static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
}
AesDecryptor::AesDecryptor(const SessionMessageCB& session_message_cb,
- const SessionClosedCB& session_closed_cb)
+ const SessionClosedCB& session_closed_cb,
+ const SessionKeysChangeCB& session_keys_change_cb)
: session_message_cb_(session_message_cb),
- session_closed_cb_(session_closed_cb) {
+ session_closed_cb_(session_closed_cb),
+ session_keys_change_cb_(session_keys_change_cb) {
DCHECK(!session_message_cb_.is_null());
DCHECK(!session_closed_cb_.is_null());
+ DCHECK(!session_keys_change_cb_.is_null());
}
AesDecryptor::~AesDecryptor() {
key_map_.clear();
}
+void AesDecryptor::SetServerCertificate(const uint8* certificate_data,
+ int certificate_data_length,
+ scoped_ptr<SimpleCdmPromise> promise) {
+ promise->reject(
+ NOT_SUPPORTED_ERROR, 0, "SetServerCertificate() is not supported.");
+}
+
void AesDecryptor::CreateSession(const std::string& init_data_type,
const uint8* init_data,
int init_data_length,
@@ -318,6 +328,43 @@ void AesDecryptor::UpdateSession(const std::string& web_session_id,
}
promise->resolve();
+
+ // Assume that at least 1 new key has been successfully added and thus
+ // sending true.
+ session_keys_change_cb_.Run(web_session_id, true);
+}
+
+void AesDecryptor::CloseSession(const std::string& web_session_id,
+ scoped_ptr<SimpleCdmPromise> promise) {
+ // Validate that this is a reference to an active session and then forget it.
+ std::set<std::string>::iterator it = valid_sessions_.find(web_session_id);
+ DCHECK(it != valid_sessions_.end());
+
+ valid_sessions_.erase(it);
+
+ // Close the session.
+ DeleteKeysForSession(web_session_id);
+ promise->resolve();
+ session_closed_cb_.Run(web_session_id);
+}
+
+void AesDecryptor::RemoveSession(const std::string& web_session_id,
+ scoped_ptr<SimpleCdmPromise> promise) {
+ // AesDecryptor doesn't keep any persistent data, so this should be
+ // NOT_REACHED().
+ // TODO(jrummell): Make sure persistent session types are rejected.
+ // http://crbug.com/384152.
+ //
+ // However, v0.1b calls to CancelKeyRequest() will call this, so close the
+ // session, if it exists.
+ // TODO(jrummell): Remove the close() call when prefixed EME is removed.
+ // http://crbug.com/249976.
+ if (valid_sessions_.find(web_session_id) != valid_sessions_.end()) {
+ CloseSession(web_session_id, promise.Pass());
+ return;
+ }
+
+ promise->reject(INVALID_ACCESS_ERROR, 0, "Session does not exist.");
}
void AesDecryptor::GetUsableKeyIds(const std::string& web_session_id,
@@ -337,24 +384,6 @@ void AesDecryptor::GetUsableKeyIds(const std::string& web_session_id,
promise->resolve(keyids);
}
-void AesDecryptor::ReleaseSession(const std::string& web_session_id,
- scoped_ptr<SimpleCdmPromise> promise) {
- // Validate that this is a reference to an active session and then forget it.
- std::set<std::string>::iterator it = valid_sessions_.find(web_session_id);
- // TODO(jrummell): Convert back to a DCHECK once prefixed EME is removed.
- if (it == valid_sessions_.end()) {
- promise->reject(INVALID_ACCESS_ERROR, 0, "Session does not exist.");
- return;
- }
-
- valid_sessions_.erase(it);
-
- // Close the session.
- DeleteKeysForSession(web_session_id);
- promise->resolve();
- session_closed_cb_.Run(web_session_id);
-}
-
Decryptor* AesDecryptor::GetDecryptor() {
return this;
}