summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--media/base/decryptor.h5
-rw-r--r--media/base/mock_filters.h2
-rw-r--r--media/crypto/aes_decryptor.cc3
-rw-r--r--media/crypto/aes_decryptor.h2
-rw-r--r--media/crypto/aes_decryptor_unittest.cc3
-rw-r--r--media/filters/pipeline_integration_test.cc4
-rw-r--r--webkit/media/crypto/ppapi_decryptor.cc5
-rw-r--r--webkit/media/crypto/ppapi_decryptor.h2
-rw-r--r--webkit/media/crypto/proxy_decryptor.cc13
-rw-r--r--webkit/media/crypto/proxy_decryptor.h2
-rw-r--r--webkit/media/webmediaplayer_impl.cc8
11 files changed, 33 insertions, 16 deletions
diff --git a/media/base/decryptor.h b/media/base/decryptor.h
index 1186594..f014406 100644
--- a/media/base/decryptor.h
+++ b/media/base/decryptor.h
@@ -42,7 +42,10 @@ class MEDIA_EXPORT Decryptor {
virtual ~Decryptor() {}
// Generates a key request for the |key_system| with |init_data| provided.
- virtual void GenerateKeyRequest(const std::string& key_system,
+ // Returns true if generating key request succeeded, false otherwise.
+ // Note: AddKey() and CancelKeyRequest() should only be called after
+ // GenerateKeyRequest() returns true.
+ virtual bool GenerateKeyRequest(const std::string& key_system,
const uint8* init_data,
int init_data_length) = 0;
diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h
index 99e53c2..ee4513f 100644
--- a/media/base/mock_filters.h
+++ b/media/base/mock_filters.h
@@ -195,7 +195,7 @@ class MockDecryptor : public Decryptor {
MockDecryptor();
virtual ~MockDecryptor();
- MOCK_METHOD3(GenerateKeyRequest, void(const std::string& key_system,
+ MOCK_METHOD3(GenerateKeyRequest, bool(const std::string& key_system,
const uint8* init_data,
int init_data_length));
MOCK_METHOD6(AddKey, void(const std::string& key_system,
diff --git a/media/crypto/aes_decryptor.cc b/media/crypto/aes_decryptor.cc
index bbeab8c..777d79f 100644
--- a/media/crypto/aes_decryptor.cc
+++ b/media/crypto/aes_decryptor.cc
@@ -195,7 +195,7 @@ AesDecryptor::~AesDecryptor() {
STLDeleteValues(&key_map_);
}
-void AesDecryptor::GenerateKeyRequest(const std::string& key_system,
+bool AesDecryptor::GenerateKeyRequest(const std::string& key_system,
const uint8* init_data,
int init_data_length) {
std::string session_id_string(base::UintToString(next_session_id_++));
@@ -207,6 +207,7 @@ void AesDecryptor::GenerateKeyRequest(const std::string& key_system,
client_->KeyMessage(key_system, session_id_string,
message.Pass(), message_length, "");
+ return true;
}
void AesDecryptor::AddKey(const std::string& key_system,
diff --git a/media/crypto/aes_decryptor.h b/media/crypto/aes_decryptor.h
index 0c96efc..d86d4bc 100644
--- a/media/crypto/aes_decryptor.h
+++ b/media/crypto/aes_decryptor.h
@@ -35,7 +35,7 @@ class MEDIA_EXPORT AesDecryptor : public Decryptor {
virtual ~AesDecryptor();
// Decryptor implementation.
- virtual void GenerateKeyRequest(const std::string& key_system,
+ virtual bool GenerateKeyRequest(const std::string& key_system,
const uint8* init_data,
int init_data_length) OVERRIDE;
virtual void AddKey(const std::string& key_system,
diff --git a/media/crypto/aes_decryptor_unittest.cc b/media/crypto/aes_decryptor_unittest.cc
index 373dd4b..95472f1 100644
--- a/media/crypto/aes_decryptor_unittest.cc
+++ b/media/crypto/aes_decryptor_unittest.cc
@@ -256,7 +256,8 @@ class AesDecryptorTest : public testing::Test {
EXPECT_CALL(client_, KeyMessageMock(kClearKeySystem, StrNe(std::string()),
NotNull(), Gt(0), ""))
.WillOnce(SaveArg<1>(&session_id_string_));
- decryptor_.GenerateKeyRequest(kClearKeySystem, key_id, key_id_size);
+ EXPECT_TRUE(decryptor_.GenerateKeyRequest(kClearKeySystem,
+ key_id, key_id_size));
}
void AddKeyAndExpectToSucceed(const uint8* key_id, int key_id_size,
diff --git a/media/filters/pipeline_integration_test.cc b/media/filters/pipeline_integration_test.cc
index 3f00b09..ab43058 100644
--- a/media/filters/pipeline_integration_test.cc
+++ b/media/filters/pipeline_integration_test.cc
@@ -180,8 +180,8 @@ class FakeDecryptorClient : public DecryptorClient {
// session (which will call KeyMessage).
if (current_key_system_.empty()) {
DCHECK(current_session_id_.empty());
- decryptor_.GenerateKeyRequest(kClearKeySystem,
- kInitData, arraysize(kInitData));
+ EXPECT_TRUE(decryptor_.GenerateKeyRequest(
+ kClearKeySystem, kInitData, arraysize(kInitData)));
}
EXPECT_FALSE(current_key_system_.empty());
diff --git a/webkit/media/crypto/ppapi_decryptor.cc b/webkit/media/crypto/ppapi_decryptor.cc
index 70c4b1b..ec19cc1 100644
--- a/webkit/media/crypto/ppapi_decryptor.cc
+++ b/webkit/media/crypto/ppapi_decryptor.cc
@@ -32,7 +32,7 @@ PpapiDecryptor::PpapiDecryptor(
PpapiDecryptor::~PpapiDecryptor() {
}
-void PpapiDecryptor::GenerateKeyRequest(const std::string& key_system,
+bool PpapiDecryptor::GenerateKeyRequest(const std::string& key_system,
const uint8* init_data,
int init_data_length) {
DVLOG(1) << "GenerateKeyRequest()";
@@ -46,7 +46,10 @@ void PpapiDecryptor::GenerateKeyRequest(const std::string& key_system,
std::string(reinterpret_cast<const char*>(init_data),
init_data_length))) {
ReportFailureToCallPlugin(key_system, "");
+ return false;
}
+
+ return true;
}
void PpapiDecryptor::AddKey(const std::string& key_system,
diff --git a/webkit/media/crypto/ppapi_decryptor.h b/webkit/media/crypto/ppapi_decryptor.h
index 841bb30..3326481 100644
--- a/webkit/media/crypto/ppapi_decryptor.h
+++ b/webkit/media/crypto/ppapi_decryptor.h
@@ -37,7 +37,7 @@ class PpapiDecryptor : public media::Decryptor {
virtual ~PpapiDecryptor();
// media::Decryptor implementation.
- virtual void GenerateKeyRequest(const std::string& key_system,
+ virtual bool GenerateKeyRequest(const std::string& key_system,
const uint8* init_data,
int init_data_length) OVERRIDE;
virtual void AddKey(const std::string& key_system,
diff --git a/webkit/media/crypto/proxy_decryptor.cc b/webkit/media/crypto/proxy_decryptor.cc
index 203c146..bdbabbf 100644
--- a/webkit/media/crypto/proxy_decryptor.cc
+++ b/webkit/media/crypto/proxy_decryptor.cc
@@ -72,7 +72,7 @@ ProxyDecryptor::ProxyDecryptor(
ProxyDecryptor::~ProxyDecryptor() {
}
-void ProxyDecryptor::GenerateKeyRequest(const std::string& key_system,
+bool ProxyDecryptor::GenerateKeyRequest(const std::string& key_system,
const uint8* init_data,
int init_data_length) {
// We do not support run-time switching of decryptors. GenerateKeyRequest()
@@ -85,10 +85,15 @@ void ProxyDecryptor::GenerateKeyRequest(const std::string& key_system,
if (!decryptor_.get()) {
client_->KeyError(key_system, "", media::Decryptor::kUnknownError, 0);
- return;
+ return false;
+ }
+
+ if(!decryptor_->GenerateKeyRequest(key_system, init_data, init_data_length)) {
+ decryptor_.reset();
+ return false;
}
- decryptor_->GenerateKeyRequest(key_system, init_data, init_data_length);
+ return true;
}
void ProxyDecryptor::AddKey(const std::string& key_system,
@@ -162,7 +167,7 @@ void ProxyDecryptor::Decrypt(
}
void ProxyDecryptor::Stop() {
- DVLOG(1) << "AddKey()";
+ DVLOG(1) << "Stop()";
std::vector<base::Closure> closures_to_run;
{
diff --git a/webkit/media/crypto/proxy_decryptor.h b/webkit/media/crypto/proxy_decryptor.h
index cc590cc..4d42ea9 100644
--- a/webkit/media/crypto/proxy_decryptor.h
+++ b/webkit/media/crypto/proxy_decryptor.h
@@ -43,7 +43,7 @@ class ProxyDecryptor : public media::Decryptor {
}
// media::Decryptor implementation.
- virtual void GenerateKeyRequest(const std::string& key_system,
+ virtual bool GenerateKeyRequest(const std::string& key_system,
const uint8* init_data,
int init_data_length) OVERRIDE;
virtual void AddKey(const std::string& key_system,
diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc
index 0b9cc7a7..030e57a 100644
--- a/webkit/media/webmediaplayer_impl.cc
+++ b/webkit/media/webmediaplayer_impl.cc
@@ -724,8 +724,12 @@ WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system,
<< std::string(reinterpret_cast<const char*>(init_data),
static_cast<size_t>(init_data_length));
- decryptor_.GenerateKeyRequest(key_system.utf8(),
- init_data, init_data_length);
+ if (!decryptor_.GenerateKeyRequest(key_system.utf8(),
+ init_data, init_data_length)) {
+ current_key_system_.reset();
+ return WebKit::WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported;
+ }
+
return WebKit::WebMediaPlayer::MediaKeyExceptionNoError;
}