summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorjrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-10 07:25:54 +0000
committerjrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-10 07:25:54 +0000
commita267ff14ffc271d52522affde71803bd29bca3e3 (patch)
treec7db4579831244d8071ee8d9205ce571d39d371c /media
parent6718537577fc2e16f92beecd8163c3cad95c0ca6 (diff)
downloadchromium_src-a267ff14ffc271d52522affde71803bd29bca3e3.zip
chromium_src-a267ff14ffc271d52522affde71803bd29bca3e3.tar.gz
chromium_src-a267ff14ffc271d52522affde71803bd29bca3e3.tar.bz2
Rename EME WD call parameters
Rename parameters on EME WD calls to be consistent. BUG=224786 TEST=compiles Review URL: https://codereview.chromium.org/105383002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239698 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/android/media_drm_bridge.cc53
-rw-r--r--media/base/android/media_drm_bridge.h20
-rw-r--r--media/base/android/media_player_manager.h12
-rw-r--r--media/base/android/media_source_player_unittest.cc14
-rw-r--r--media/base/media_keys.h23
-rw-r--r--media/cdm/aes_decryptor.cc24
-rw-r--r--media/cdm/aes_decryptor.h13
-rw-r--r--media/cdm/aes_decryptor_unittest.cc67
-rw-r--r--media/cdm/ppapi/cdm_adapter.cc90
-rw-r--r--media/cdm/ppapi/cdm_adapter.h32
-rw-r--r--media/cdm/ppapi/cdm_wrapper.h151
-rw-r--r--media/cdm/ppapi/clear_key_cdm.cc34
-rw-r--r--media/cdm/ppapi/clear_key_cdm.h16
-rw-r--r--media/filters/pipeline_integration_test.cc147
14 files changed, 346 insertions, 350 deletions
diff --git a/media/base/android/media_drm_bridge.cc b/media/base/android/media_drm_bridge.cc
index e898816..37eaa33 100644
--- a/media/base/android/media_drm_bridge.cc
+++ b/media/base/android/media_drm_bridge.cc
@@ -236,7 +236,7 @@ MediaDrmBridge::~MediaDrmBridge() {
Java_MediaDrmBridge_release(env, j_media_drm_.obj());
}
-bool MediaDrmBridge::CreateSession(uint32 reference_id,
+bool MediaDrmBridge::CreateSession(uint32 session_id,
const std::string& type,
const uint8* init_data,
int init_data_length) {
@@ -248,13 +248,13 @@ bool MediaDrmBridge::CreateSession(uint32 reference_id,
ScopedJavaLocalRef<jbyteArray> j_pssh_data =
base::android::ToJavaByteArray(env, &pssh_data[0], pssh_data.size());
ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, type);
- pending_key_request_reference_ids_.push(reference_id);
+ pending_key_request_session_ids_.push(session_id);
Java_MediaDrmBridge_generateKeyRequest(
env, j_media_drm_.obj(), j_pssh_data.obj(), j_mime.obj());
return true;
}
-void MediaDrmBridge::UpdateSession(uint32 reference_id,
+void MediaDrmBridge::UpdateSession(uint32 session_id,
const uint8* response,
int response_length) {
DVLOG(1) << __FUNCTION__;
@@ -262,16 +262,16 @@ void MediaDrmBridge::UpdateSession(uint32 reference_id,
ScopedJavaLocalRef<jbyteArray> j_response =
base::android::ToJavaByteArray(env, response, response_length);
ScopedJavaLocalRef<jstring> j_session_id =
- ConvertUTF8ToJavaString(env, LookupSessionId(reference_id));
+ ConvertUTF8ToJavaString(env, LookupWebSessionId(session_id));
// TODO(jrummell): Update Android names to match new functionality.
Java_MediaDrmBridge_addKey(
env, j_media_drm_.obj(), j_session_id.obj(), j_response.obj());
}
-void MediaDrmBridge::ReleaseSession(uint32 reference_id) {
+void MediaDrmBridge::ReleaseSession(uint32 session_id) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jstring> j_session_id =
- ConvertUTF8ToJavaString(env, LookupSessionId(reference_id));
+ ConvertUTF8ToJavaString(env, LookupWebSessionId(session_id));
Java_MediaDrmBridge_cancelKeyRequest(
env, j_media_drm_.obj(), j_session_id.obj());
}
@@ -303,29 +303,29 @@ void MediaDrmBridge::OnKeyMessage(JNIEnv* env,
jstring j_session_id,
jbyteArray j_message,
jstring j_destination_url) {
- std::string session_id = ConvertJavaStringToUTF8(env, j_session_id);
- uint32_t reference_id = DetermineReferenceId(session_id);
+ std::string web_session_id = ConvertJavaStringToUTF8(env, j_session_id);
+ uint32_t session_id = LookupSessionId(web_session_id);
std::vector<uint8> message;
JavaByteArrayToByteVector(env, j_message, &message);
std::string destination_url = ConvertJavaStringToUTF8(env, j_destination_url);
- manager_->OnSessionCreated(media_keys_id_, reference_id, session_id);
+ manager_->OnSessionCreated(media_keys_id_, session_id, web_session_id);
manager_->OnSessionMessage(
- media_keys_id_, reference_id, message, destination_url);
+ media_keys_id_, session_id, message, destination_url);
}
void MediaDrmBridge::OnKeyAdded(JNIEnv* env, jobject, jstring j_session_id) {
- std::string session_id = ConvertJavaStringToUTF8(env, j_session_id);
- uint32_t reference_id = DetermineReferenceId(session_id);
- manager_->OnSessionReady(media_keys_id_, reference_id);
+ std::string web_session_id = ConvertJavaStringToUTF8(env, j_session_id);
+ uint32_t session_id = LookupSessionId(web_session_id);
+ manager_->OnSessionReady(media_keys_id_, session_id);
}
void MediaDrmBridge::OnKeyError(JNIEnv* env, jobject, jstring j_session_id) {
// |j_session_id| can be NULL, in which case we'll return an empty string.
- std::string session_id = ConvertJavaStringToUTF8(env, j_session_id);
- uint32 reference_id = DetermineReferenceId(session_id);
+ std::string web_session_id = ConvertJavaStringToUTF8(env, j_session_id);
+ uint32 session_id = LookupSessionId(web_session_id);
manager_->OnSessionError(
- media_keys_id_, reference_id, MediaKeys::kUnknownError, 0);
+ media_keys_id_, session_id, MediaKeys::kUnknownError, 0);
}
ScopedJavaLocalRef<jobject> MediaDrmBridge::GetMediaCrypto() {
@@ -364,7 +364,7 @@ void MediaDrmBridge::OnResetDeviceCredentialsCompleted(
base::ResetAndReturn(&reset_credentials_cb_).Run(success);
}
-uint32_t MediaDrmBridge::DetermineReferenceId(const std::string& session_id) {
+uint32_t MediaDrmBridge::LookupSessionId(const std::string& session_id) {
for (SessionMap::iterator it = session_map_.begin();
it != session_map_.end();
++it) {
@@ -374,25 +374,24 @@ uint32_t MediaDrmBridge::DetermineReferenceId(const std::string& session_id) {
// There is no entry in the map; assume it came from the oldest
// GenerateKeyRequest() call.
- DCHECK(!pending_key_request_reference_ids_.empty());
- uint32 reference_id = pending_key_request_reference_ids_.front();
- pending_key_request_reference_ids_.pop();
+ DCHECK(!pending_key_request_session_ids_.empty());
+ uint32 session_reference_id = pending_key_request_session_ids_.front();
+ pending_key_request_session_ids_.pop();
// If this is a valid |session_id|, add it to the list. Otherwise, avoid
// adding empty string as a mapping to prevent future calls with an empty
- // string from using the wrong reference_id.
+ // string from using the wrong session_reference_id.
if (!session_id.empty()) {
- DCHECK(session_map_.find(reference_id) == session_map_.end());
- DCHECK(!session_id.empty());
- session_map_[reference_id] = session_id;
+ DCHECK(session_map_.find(session_reference_id) == session_map_.end());
+ session_map_[session_reference_id] = session_id;
}
- return reference_id;
+ return session_reference_id;
}
-const std::string& MediaDrmBridge::LookupSessionId(uint32 reference_id) {
+const std::string& MediaDrmBridge::LookupWebSessionId(uint32 session_id) {
// Session may not exist if error happens during GenerateKeyRequest().
- SessionMap::iterator it = session_map_.find(reference_id);
+ SessionMap::iterator it = session_map_.find(session_id);
return (it != session_map_.end()) ? it->second : base::EmptyString();
}
diff --git a/media/base/android/media_drm_bridge.h b/media/base/android/media_drm_bridge.h
index 7581291..9a5f693 100644
--- a/media/base/android/media_drm_bridge.h
+++ b/media/base/android/media_drm_bridge.h
@@ -61,14 +61,14 @@ class MEDIA_EXPORT MediaDrmBridge : public MediaKeys {
static bool RegisterMediaDrmBridge(JNIEnv* env);
// MediaKeys implementations.
- virtual bool CreateSession(uint32 reference_id,
+ virtual bool CreateSession(uint32 session_id,
const std::string& type,
const uint8* init_data,
int init_data_length) OVERRIDE;
- virtual void UpdateSession(uint32 reference_id,
+ virtual void UpdateSession(uint32 session_id,
const uint8* response,
int response_length) OVERRIDE;
- virtual void ReleaseSession(uint32 reference_id) OVERRIDE;
+ virtual void ReleaseSession(uint32 session_id) OVERRIDE;
// Returns a MediaCrypto object if it's already created. Returns a null object
// otherwise.
@@ -106,7 +106,7 @@ class MEDIA_EXPORT MediaDrmBridge : public MediaKeys {
GURL frame_url() const { return frame_url_; }
private:
- // Map between session_id and reference_id.
+ // Map between session_id and web_session_id.
typedef std::map<uint32_t, std::string> SessionMap;
static bool IsSecureDecoderRequired(SecurityLevel security_level);
@@ -120,12 +120,12 @@ class MEDIA_EXPORT MediaDrmBridge : public MediaKeys {
// Get the security level of the media.
SecurityLevel GetSecurityLevel();
- // Determine the corresponding reference_id for |session_id|.
- uint32_t DetermineReferenceId(const std::string& session_id);
+ // Determine the corresponding session_id for |web_session_id|.
+ uint32_t LookupSessionId(const std::string& web_session_id);
- // Determine the corresponding session_id for |reference_id|. The returned
+ // Determine the corresponding web_session_id for |session_id|. The returned
// value is only valid on the main thread, and should be stored by copy.
- const std::string& LookupSessionId(uint32_t reference_id);
+ const std::string& LookupWebSessionId(uint32_t session_id);
// ID of the MediaKeys object.
int media_keys_id_;
@@ -151,8 +151,8 @@ class MEDIA_EXPORT MediaDrmBridge : public MediaKeys {
// As the response from GenerateKeyRequest() will be asynchronous, add this
// request to a queue and assume that the subsequent responses come back in
// the order issued.
- // TODO(jrummell): Remove once the Java interface supports reference_id.
- std::queue<uint32_t> pending_key_request_reference_ids_;
+ // TODO(jrummell): Remove once the Java interface supports session_id.
+ std::queue<uint32_t> pending_key_request_session_ids_;
DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge);
};
diff --git a/media/base/android/media_player_manager.h b/media/base/android/media_player_manager.h
index ce4a196..c215df5 100644
--- a/media/base/android/media_player_manager.h
+++ b/media/base/android/media_player_manager.h
@@ -94,24 +94,24 @@ class MEDIA_EXPORT MediaPlayerManager {
// Called when MediaDrmBridge determines a SessionId.
virtual void OnSessionCreated(int media_keys_id,
- uint32 reference_id,
- const std::string& session_id) = 0;
+ uint32 session_id,
+ const std::string& web_session_id) = 0;
// Called when MediaDrmBridge wants to send a Message event.
virtual void OnSessionMessage(int media_keys_id,
- uint32 reference_id,
+ uint32 session_id,
const std::vector<uint8>& message,
const std::string& destination_url) = 0;
// Called when MediaDrmBridge wants to send a Ready event.
- virtual void OnSessionReady(int media_keys_id, uint32 reference_id) = 0;
+ virtual void OnSessionReady(int media_keys_id, uint32 session_id) = 0;
// Called when MediaDrmBridge wants to send a Closed event.
- virtual void OnSessionClosed(int media_keys_id, uint32 reference_id) = 0;
+ virtual void OnSessionClosed(int media_keys_id, uint32 session_id) = 0;
// Called when MediaDrmBridge wants to send an Error event.
virtual void OnSessionError(int media_keys_id,
- uint32 reference_id,
+ uint32 session_id,
media::MediaKeys::KeyError error_code,
int system_code) = 0;
};
diff --git a/media/base/android/media_source_player_unittest.cc b/media/base/android/media_source_player_unittest.cc
index 1da6641..6b3a66c 100644
--- a/media/base/android/media_source_player_unittest.cc
+++ b/media/base/android/media_source_player_unittest.cc
@@ -74,18 +74,16 @@ class MockMediaPlayerManager : public MediaPlayerManager {
}
virtual void OnProtectedSurfaceRequested(int player_id) OVERRIDE {}
virtual void OnSessionCreated(int media_keys_id,
- uint32 reference_id,
- const std::string& session_id) OVERRIDE {}
+ uint32 session_id,
+ const std::string& web_session_id) OVERRIDE {}
virtual void OnSessionMessage(int media_keys_id,
- uint32 reference_id,
+ uint32 session_id,
const std::vector<uint8>& message,
const std::string& destination_url) OVERRIDE {}
- virtual void OnSessionReady(int media_keys_id,
- uint32 reference_id) OVERRIDE {}
- virtual void OnSessionClosed(int media_keys_id,
- uint32 reference_id) OVERRIDE {}
+ virtual void OnSessionReady(int media_keys_id, uint32 session_id) OVERRIDE {}
+ virtual void OnSessionClosed(int media_keys_id, uint32 session_id) OVERRIDE {}
virtual void OnSessionError(int media_keys_id,
- uint32 reference_id,
+ uint32 session_id,
media::MediaKeys::KeyError error_code,
int system_code) OVERRIDE {}
diff --git a/media/base/media_keys.h b/media/base/media_keys.h
index a17fc85..0d86948 100644
--- a/media/base/media_keys.h
+++ b/media/base/media_keys.h
@@ -37,7 +37,7 @@ class MEDIA_EXPORT MediaKeys {
kMaxKeyError // Must be last and greater than any legit value.
};
- const static uint32 kInvalidReferenceId = 0;
+ const static uint32 kInvalidSessionId = 0;
MediaKeys();
virtual ~MediaKeys();
@@ -47,18 +47,18 @@ class MEDIA_EXPORT MediaKeys {
// Note: UpdateSession() and ReleaseSession() should only be called after
// CreateSession() returns true.
// TODO(jrummell): Remove return value when prefixed API is removed.
- virtual bool CreateSession(uint32 reference_id,
+ virtual bool CreateSession(uint32 session_id,
const std::string& type,
const uint8* init_data,
int init_data_length) = 0;
- // Updates a session specified by |reference_id| with |response|.
- virtual void UpdateSession(uint32 reference_id,
+ // Updates a session specified by |session_id| with |response|.
+ virtual void UpdateSession(uint32 session_id,
const uint8* response,
int response_length) = 0;
- // Releases the session specified by |reference_id|.
- virtual void ReleaseSession(uint32 reference_id) = 0;
+ // Releases the session specified by |session_id|.
+ virtual void ReleaseSession(uint32 session_id) = 0;
// Gets the Decryptor object associated with the MediaKeys. Returns NULL if
// no Decryptor object is associated. The returned object is only guaranteed
@@ -71,19 +71,20 @@ class MEDIA_EXPORT MediaKeys {
// Key event callbacks. See the spec for details:
// https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#event-summary
-typedef base::Callback<void(uint32 reference_id, const std::string& session_id)>
+typedef base::Callback<
+ void(uint32 session_id, const std::string& web_session_id)>
SessionCreatedCB;
-typedef base::Callback<void(uint32 reference_id,
+typedef base::Callback<void(uint32 session_id,
const std::vector<uint8>& message,
const std::string& destination_url)>
SessionMessageCB;
-typedef base::Callback<void(uint32 reference_id)> SessionReadyCB;
+typedef base::Callback<void(uint32 session_id)> SessionReadyCB;
-typedef base::Callback<void(uint32 reference_id)> SessionClosedCB;
+typedef base::Callback<void(uint32 session_id)> SessionClosedCB;
-typedef base::Callback<void(uint32 reference_id,
+typedef base::Callback<void(uint32 session_id,
media::MediaKeys::KeyError error_code,
int system_code)> SessionErrorCB;
diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc
index ee4b987..bdcc27e 100644
--- a/media/cdm/aes_decryptor.cc
+++ b/media/cdm/aes_decryptor.cc
@@ -20,7 +20,7 @@
namespace media {
-uint32 AesDecryptor::next_session_id_ = 1;
+uint32 AesDecryptor::next_web_session_id_ = 1;
enum ClearBytesBufferSel {
kSrcContainsClearBytes,
@@ -157,11 +157,11 @@ AesDecryptor::~AesDecryptor() {
STLDeleteValues(&key_map_);
}
-bool AesDecryptor::CreateSession(uint32 reference_id,
+bool AesDecryptor::CreateSession(uint32 session_id,
const std::string& type,
const uint8* init_data,
int init_data_length) {
- std::string session_id_string(base::UintToString(next_session_id_++));
+ std::string web_session_id_string(base::UintToString(next_web_session_id_++));
// For now, the AesDecryptor does not care about |type|;
// just fire the event with the |init_data| as the request.
@@ -169,12 +169,12 @@ bool AesDecryptor::CreateSession(uint32 reference_id,
if (init_data && init_data_length)
message.assign(init_data, init_data + init_data_length);
- session_created_cb_.Run(reference_id, session_id_string);
- session_message_cb_.Run(reference_id, message, std::string());
+ session_created_cb_.Run(session_id, web_session_id_string);
+ session_message_cb_.Run(session_id, message, std::string());
return true;
}
-void AesDecryptor::UpdateSession(uint32 reference_id,
+void AesDecryptor::UpdateSession(uint32 session_id,
const uint8* response,
int response_length) {
CHECK(response);
@@ -184,13 +184,13 @@ void AesDecryptor::UpdateSession(uint32 reference_id,
response_length);
KeyIdAndKeyPairs keys;
if (!ExtractKeysFromJWKSet(key_string, &keys)) {
- session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
+ session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0);
return;
}
// Make sure that at least one key was extracted.
if (keys.empty()) {
- session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
+ session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0);
return;
}
@@ -198,11 +198,11 @@ void AesDecryptor::UpdateSession(uint32 reference_id,
if (it->second.length() !=
static_cast<size_t>(DecryptConfig::kDecryptionKeySize)) {
DVLOG(1) << "Invalid key length: " << key_string.length();
- session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
+ session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0);
return;
}
if (!AddDecryptionKey(it->first, it->second)) {
- session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
+ session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0);
return;
}
}
@@ -213,10 +213,10 @@ void AesDecryptor::UpdateSession(uint32 reference_id,
if (!new_video_key_cb_.is_null())
new_video_key_cb_.Run();
- session_ready_cb_.Run(reference_id);
+ session_ready_cb_.Run(session_id);
}
-void AesDecryptor::ReleaseSession(uint32 reference_id) {
+void AesDecryptor::ReleaseSession(uint32 session_id) {
// TODO: Implement: http://crbug.com/313412.
}
diff --git a/media/cdm/aes_decryptor.h b/media/cdm/aes_decryptor.h
index 8e03106..35b1488 100644
--- a/media/cdm/aes_decryptor.h
+++ b/media/cdm/aes_decryptor.h
@@ -35,14 +35,14 @@ class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor {
virtual ~AesDecryptor();
// MediaKeys implementation.
- virtual bool CreateSession(uint32 reference_id,
+ virtual bool CreateSession(uint32 session_id,
const std::string& type,
const uint8* init_data,
int init_data_length) OVERRIDE;
- virtual void UpdateSession(uint32 reference_id,
+ virtual void UpdateSession(uint32 session_id,
const uint8* response,
int response_length) OVERRIDE;
- virtual void ReleaseSession(uint32 reference_id) OVERRIDE;
+ virtual void ReleaseSession(uint32 session_id) OVERRIDE;
virtual Decryptor* GetDecryptor() OVERRIDE;
// Decryptor implementation.
@@ -115,10 +115,9 @@ class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor {
KeyMap key_map_; // Protected by the |key_map_lock_|.
mutable base::Lock key_map_lock_; // Protects the |key_map_|.
- // Make session ID unique per renderer by making it static.
- // TODO(xhwang): Make session ID more strictly defined if needed:
- // https://www.w3.org/Bugs/Public/show_bug.cgi?id=16739#c0
- static uint32 next_session_id_;
+ // Make web session ID unique per renderer by making it static. Web session
+ // IDs seen by the app will be "1", "2", etc.
+ static uint32 next_web_session_id_;
NewKeyCB new_audio_key_cb_;
NewKeyCB new_video_key_cb_;
diff --git a/media/cdm/aes_decryptor_unittest.cc b/media/cdm/aes_decryptor_unittest.cc
index cd0d460..53c7f1a8 100644
--- a/media/cdm/aes_decryptor_unittest.cc
+++ b/media/cdm/aes_decryptor_unittest.cc
@@ -195,7 +195,7 @@ class AesDecryptorTest : public testing::Test {
base::Unretained(this)),
base::Bind(&AesDecryptorTest::OnSessionError,
base::Unretained(this))),
- reference_id_(MediaKeys::kInvalidReferenceId),
+ session_id_(MediaKeys::kInvalidSessionId),
decrypt_cb_(base::Bind(&AesDecryptorTest::BufferDecrypted,
base::Unretained(this))),
original_data_(kOriginalData, kOriginalData + kOriginalDataSize),
@@ -213,12 +213,12 @@ class AesDecryptorTest : public testing::Test {
protected:
void CreateSession(const std::vector<uint8>& key_id) {
- reference_id_ = 6;
+ session_id_ = 6;
DCHECK(!key_id.empty());
- EXPECT_CALL(*this, OnSessionCreated(reference_id_, StrNe(std::string())));
- EXPECT_CALL(*this, OnSessionMessage(reference_id_, key_id, ""));
+ EXPECT_CALL(*this, OnSessionCreated(session_id_, StrNe(std::string())));
+ EXPECT_CALL(*this, OnSessionMessage(session_id_, key_id, ""));
EXPECT_TRUE(decryptor_.CreateSession(
- reference_id_, std::string(), &key_id[0], key_id.size()));
+ session_id_, std::string(), &key_id[0], key_id.size()));
}
enum AddKeyExpectation {
@@ -230,17 +230,16 @@ class AesDecryptorTest : public testing::Test {
DCHECK(!key.empty());
if (result == KEY_ADDED) {
- EXPECT_CALL(*this, OnSessionReady(reference_id_));
+ EXPECT_CALL(*this, OnSessionReady(session_id_));
} else if (result == KEY_ERROR) {
EXPECT_CALL(*this,
- OnSessionError(reference_id_, MediaKeys::kUnknownError, 0));
+ OnSessionError(session_id_, MediaKeys::kUnknownError, 0));
} else {
NOTREACHED();
}
- decryptor_.UpdateSession(reference_id_,
- reinterpret_cast<const uint8*>(key.c_str()),
- key.length());
+ decryptor_.UpdateSession(
+ session_id_, reinterpret_cast<const uint8*>(key.c_str()), key.length());
}
MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status,
@@ -292,18 +291,18 @@ class AesDecryptorTest : public testing::Test {
}
MOCK_METHOD2(OnSessionCreated,
- void(uint32 reference_id, const std::string& session_id));
+ void(uint32 session_id, const std::string& web_session_id));
MOCK_METHOD3(OnSessionMessage,
- void(uint32 reference_id,
+ void(uint32 session_id,
const std::vector<uint8>& message,
const std::string& default_url));
- MOCK_METHOD1(OnSessionReady, void(uint32 reference_id));
- MOCK_METHOD1(OnSessionClosed, void(uint32 reference_id));
+ MOCK_METHOD1(OnSessionReady, void(uint32 session_id));
+ MOCK_METHOD1(OnSessionClosed, void(uint32 session_id));
MOCK_METHOD3(OnSessionError,
- void(uint32 reference_id, MediaKeys::KeyError, int system_code));
+ void(uint32 session_id, MediaKeys::KeyError, int system_code));
AesDecryptor decryptor_;
- uint32 reference_id_;
+ uint32 session_id_;
AesDecryptor::DecryptCB decrypt_cb_;
// Constants for testing.
@@ -317,27 +316,27 @@ class AesDecryptorTest : public testing::Test {
};
TEST_F(AesDecryptorTest, CreateSessionWithNullInitData) {
- reference_id_ = 8;
- EXPECT_CALL(*this, OnSessionMessage(reference_id_, IsEmpty(), ""));
- EXPECT_CALL(*this, OnSessionCreated(reference_id_, StrNe(std::string())));
- EXPECT_TRUE(decryptor_.CreateSession(reference_id_, std::string(), NULL, 0));
+ session_id_ = 8;
+ EXPECT_CALL(*this, OnSessionMessage(session_id_, IsEmpty(), ""));
+ EXPECT_CALL(*this, OnSessionCreated(session_id_, StrNe(std::string())));
+ EXPECT_TRUE(decryptor_.CreateSession(session_id_, std::string(), NULL, 0));
}
TEST_F(AesDecryptorTest, MultipleCreateSession) {
- uint32 reference_id1 = 10;
- EXPECT_CALL(*this, OnSessionMessage(reference_id1, IsEmpty(), ""));
- EXPECT_CALL(*this, OnSessionCreated(reference_id1, StrNe(std::string())));
- EXPECT_TRUE(decryptor_.CreateSession(reference_id1, std::string(), NULL, 0));
-
- uint32 reference_id2 = 11;
- EXPECT_CALL(*this, OnSessionMessage(reference_id2, IsEmpty(), ""));
- EXPECT_CALL(*this, OnSessionCreated(reference_id2, StrNe(std::string())));
- EXPECT_TRUE(decryptor_.CreateSession(reference_id2, std::string(), NULL, 0));
-
- uint32 reference_id3 = 23;
- EXPECT_CALL(*this, OnSessionMessage(reference_id3, IsEmpty(), ""));
- EXPECT_CALL(*this, OnSessionCreated(reference_id3, StrNe(std::string())));
- EXPECT_TRUE(decryptor_.CreateSession(reference_id3, std::string(), NULL, 0));
+ uint32 session_id1 = 10;
+ EXPECT_CALL(*this, OnSessionMessage(session_id1, IsEmpty(), ""));
+ EXPECT_CALL(*this, OnSessionCreated(session_id1, StrNe(std::string())));
+ EXPECT_TRUE(decryptor_.CreateSession(session_id1, std::string(), NULL, 0));
+
+ uint32 session_id2 = 11;
+ EXPECT_CALL(*this, OnSessionMessage(session_id2, IsEmpty(), ""));
+ EXPECT_CALL(*this, OnSessionCreated(session_id2, StrNe(std::string())));
+ EXPECT_TRUE(decryptor_.CreateSession(session_id2, std::string(), NULL, 0));
+
+ uint32 session_id3 = 23;
+ EXPECT_CALL(*this, OnSessionMessage(session_id3, IsEmpty(), ""));
+ EXPECT_CALL(*this, OnSessionCreated(session_id3, StrNe(std::string())));
+ EXPECT_TRUE(decryptor_.CreateSession(session_id3, std::string(), NULL, 0));
}
TEST_F(AesDecryptorTest, NormalDecryption) {
diff --git a/media/cdm/ppapi/cdm_adapter.cc b/media/cdm/ppapi/cdm_adapter.cc
index 489eb1d..209335b 100644
--- a/media/cdm/ppapi/cdm_adapter.cc
+++ b/media/cdm/ppapi/cdm_adapter.cc
@@ -247,13 +247,13 @@ void CdmAdapter::Initialize(const std::string& key_system) {
key_system_ = key_system;
}
-void CdmAdapter::CreateSession(uint32_t reference_id,
+void CdmAdapter::CreateSession(uint32_t session_id,
const std::string& type,
pp::VarArrayBuffer init_data) {
// Initialize() doesn't report an error, so CreateSession() can be called
// even if Initialize() failed.
if (!cdm_) {
- OnSessionError(reference_id, cdm::kUnknownError, 0);
+ OnSessionError(session_id, cdm::kUnknownError, 0);
return;
}
@@ -261,7 +261,7 @@ void CdmAdapter::CreateSession(uint32_t reference_id,
PP_URLComponents_Dev url_components = {};
const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get();
if (!url_util) {
- OnSessionError(reference_id, cdm::kUnknownError, 0);
+ OnSessionError(session_id, cdm::kUnknownError, 0);
return;
}
pp::Var href = url_util->GetDocumentURL(
@@ -272,19 +272,19 @@ void CdmAdapter::CreateSession(uint32_t reference_id,
PP_DCHECK(0 < url_components.host.len);
#endif // defined(CHECK_DOCUMENT_URL)
- cdm_->CreateSession(reference_id,
+ cdm_->CreateSession(session_id,
type.data(),
type.size(),
static_cast<const uint8_t*>(init_data.Map()),
init_data.ByteLength());
}
-void CdmAdapter::UpdateSession(uint32_t reference_id,
+void CdmAdapter::UpdateSession(uint32_t session_id,
pp::VarArrayBuffer response) {
// TODO(jrummell): In EME WD, AddKey() can only be called on valid sessions.
// We should be able to DCHECK(cdm_) when addressing http://crbug.com/249976.
if (!cdm_) {
- OnSessionError(reference_id, cdm::kUnknownError, 0);
+ OnSessionError(session_id, cdm::kUnknownError, 0);
return;
}
@@ -292,32 +292,32 @@ void CdmAdapter::UpdateSession(uint32_t reference_id,
const uint32_t response_size = response.ByteLength();
if (!response_ptr || response_size <= 0) {
- OnSessionError(reference_id, cdm::kUnknownError, 0);
+ OnSessionError(session_id, cdm::kUnknownError, 0);
return;
}
CdmWrapper::Result result =
- cdm_->UpdateSession(reference_id, response_ptr, response_size);
+ cdm_->UpdateSession(session_id, response_ptr, response_size);
switch (result) {
case CdmWrapper::NO_ACTION:
break;
case CdmWrapper::CALL_KEY_ADDED:
- OnSessionReady(reference_id);
+ OnSessionReady(session_id);
break;
case CdmWrapper::CALL_KEY_ERROR:
- OnSessionError(reference_id, cdm::kUnknownError, 0);
+ OnSessionError(session_id, cdm::kUnknownError, 0);
break;
}
}
-void CdmAdapter::ReleaseSession(uint32_t reference_id) {
+void CdmAdapter::ReleaseSession(uint32_t session_id) {
// TODO(jrummell): In EME WD, AddKey() can only be called on valid sessions.
// We should be able to DCHECK(cdm_) when addressing http://crbug.com/249976.
if (!cdm_) {
- OnSessionError(reference_id, cdm::kUnknownError, 0);
+ OnSessionError(session_id, cdm::kUnknownError, 0);
return;
}
- CdmWrapper::Result result = cdm_->ReleaseSession(reference_id);
+ CdmWrapper::Result result = cdm_->ReleaseSession(session_id);
switch (result) {
case CdmWrapper::NO_ACTION:
break;
@@ -325,7 +325,7 @@ void CdmAdapter::ReleaseSession(uint32_t reference_id) {
PP_NOTREACHED();
break;
case CdmWrapper::CALL_KEY_ERROR:
- OnSessionError(reference_id, cdm::kUnknownError, 0);
+ OnSessionError(session_id, cdm::kUnknownError, 0);
break;
}
}
@@ -536,11 +536,12 @@ void CdmAdapter::SendKeyMessage(
std::string session_id_str(session_id, session_id_length);
PP_DCHECK(!session_id_str.empty());
- uint32_t reference_id = cdm_->DetermineReferenceId(session_id_str);
+ uint32_t session_reference_id = cdm_->LookupSessionId(session_id_str);
- OnSessionCreated(reference_id, session_id, session_id_length);
- OnSessionMessage(
- reference_id, message, message_length, default_url, default_url_length);
+ OnSessionCreated(session_reference_id, session_id, session_id_length);
+ OnSessionMessage(session_reference_id,
+ message, message_length,
+ default_url, default_url_length);
}
void CdmAdapter::SendKeyError(const char* session_id,
@@ -548,8 +549,8 @@ void CdmAdapter::SendKeyError(const char* session_id,
cdm::MediaKeyError error_code,
uint32_t system_code) {
std::string session_id_str(session_id, session_id_length);
- uint32_t reference_id = cdm_->DetermineReferenceId(session_id_str);
- OnSessionError(reference_id, error_code, system_code);
+ uint32_t session_reference_id = cdm_->LookupSessionId(session_id_str);
+ OnSessionError(session_reference_id, error_code, system_code);
}
void CdmAdapter::GetPrivateData(int32_t* instance,
@@ -558,56 +559,56 @@ void CdmAdapter::GetPrivateData(int32_t* instance,
*get_interface = pp::Module::Get()->get_browser_interface();
}
-void CdmAdapter::OnSessionCreated(uint32_t reference_id,
- const char* session_id,
- uint32_t session_id_length) {
+void CdmAdapter::OnSessionCreated(uint32_t session_id,
+ const char* web_session_id,
+ uint32_t web_session_id_length) {
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendSessionCreatedInternal,
- reference_id,
- std::string(session_id, session_id_length)));
+ session_id,
+ std::string(web_session_id, web_session_id_length)));
}
-void CdmAdapter::OnSessionMessage(uint32_t reference_id,
+void CdmAdapter::OnSessionMessage(uint32_t session_id,
const char* message,
uint32_t message_length,
const char* destination_url,
uint32_t destination_url_length) {
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendSessionMessageInternal,
- reference_id,
+ session_id,
std::vector<uint8>(message, message + message_length),
std::string(destination_url, destination_url_length)));
}
-void CdmAdapter::OnSessionReady(uint32_t reference_id) {
+void CdmAdapter::OnSessionReady(uint32_t session_id) {
PostOnMain(callback_factory_.NewCallback(
- &CdmAdapter::SendSessionReadyInternal, reference_id));
+ &CdmAdapter::SendSessionReadyInternal, session_id));
}
-void CdmAdapter::OnSessionClosed(uint32_t reference_id) {
+void CdmAdapter::OnSessionClosed(uint32_t session_id) {
PostOnMain(callback_factory_.NewCallback(
- &CdmAdapter::SendSessionClosedInternal, reference_id));
+ &CdmAdapter::SendSessionClosedInternal, session_id));
}
-void CdmAdapter::OnSessionError(uint32_t reference_id,
+void CdmAdapter::OnSessionError(uint32_t session_id,
cdm::MediaKeyError error_code,
uint32_t system_code) {
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendSessionErrorInternal,
- reference_id,
+ session_id,
error_code,
system_code));
}
void CdmAdapter::SendSessionCreatedInternal(int32_t result,
- uint32_t reference_id,
- const std::string& session_id) {
+ uint32_t session_id,
+ const std::string& web_session_id) {
PP_DCHECK(result == PP_OK);
- pp::ContentDecryptor_Private::SessionCreated(reference_id, session_id);
+ pp::ContentDecryptor_Private::SessionCreated(session_id, web_session_id);
}
void CdmAdapter::SendSessionMessageInternal(int32_t result,
- uint32_t reference_id,
+ uint32_t session_id,
const std::vector<uint8>& message,
const std::string& default_url) {
PP_DCHECK(result == PP_OK);
@@ -618,28 +619,27 @@ void CdmAdapter::SendSessionMessageInternal(int32_t result,
}
pp::ContentDecryptor_Private::SessionMessage(
- reference_id, message_array_buffer, default_url);
+ session_id, message_array_buffer, default_url);
}
-void CdmAdapter::SendSessionReadyInternal(int32_t result,
- uint32_t reference_id) {
+void CdmAdapter::SendSessionReadyInternal(int32_t result, uint32_t session_id) {
PP_DCHECK(result == PP_OK);
- pp::ContentDecryptor_Private::SessionReady(reference_id);
+ pp::ContentDecryptor_Private::SessionReady(session_id);
}
void CdmAdapter::SendSessionClosedInternal(int32_t result,
- uint32_t reference_id) {
+ uint32_t session_id) {
PP_DCHECK(result == PP_OK);
- pp::ContentDecryptor_Private::SessionClosed(reference_id);
+ pp::ContentDecryptor_Private::SessionClosed(session_id);
}
void CdmAdapter::SendSessionErrorInternal(int32_t result,
- uint32_t reference_id,
+ uint32_t session_id,
cdm::MediaKeyError error_code,
uint32_t system_code) {
PP_DCHECK(result == PP_OK);
pp::ContentDecryptor_Private::SessionError(
- reference_id, error_code, system_code);
+ session_id, error_code, system_code);
}
void CdmAdapter::DeliverBlock(int32_t result,
diff --git a/media/cdm/ppapi/cdm_adapter.h b/media/cdm/ppapi/cdm_adapter.h
index 57e7524..ec7145d 100644
--- a/media/cdm/ppapi/cdm_adapter.h
+++ b/media/cdm/ppapi/cdm_adapter.h
@@ -53,12 +53,12 @@ class CdmAdapter : public pp::Instance,
// Note: Results of calls to these methods must be reported through the
// PPB_ContentDecryptor_Private interface.
virtual void Initialize(const std::string& key_system) OVERRIDE;
- virtual void CreateSession(uint32_t reference_id,
+ virtual void CreateSession(uint32_t session_id,
const std::string& type,
pp::VarArrayBuffer init_data) OVERRIDE;
- virtual void UpdateSession(uint32_t reference_id,
+ virtual void UpdateSession(uint32_t session_id,
pp::VarArrayBuffer response) OVERRIDE;
- virtual void ReleaseSession(uint32_t reference_id) OVERRIDE;
+ virtual void ReleaseSession(uint32_t session_id) OVERRIDE;
virtual void Decrypt(
pp::Buffer_Dev encrypted_buffer,
const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
@@ -104,17 +104,17 @@ class CdmAdapter : public pp::Instance,
cdm::Status decoder_status) OVERRIDE;
// cdm::Host_3 implementation.
- virtual void OnSessionCreated(uint32_t reference_id,
- const char* session_id,
- uint32_t session_id_length) OVERRIDE;
- virtual void OnSessionMessage(uint32_t reference_id,
+ virtual void OnSessionCreated(uint32_t session_id,
+ const char* web_session_id,
+ uint32_t web_session_id_length) OVERRIDE;
+ virtual void OnSessionMessage(uint32_t session_id,
const char* message,
uint32_t message_length,
const char* destination_url,
uint32_t destination_url_length) OVERRIDE;
- virtual void OnSessionReady(uint32_t reference_id) OVERRIDE;
- virtual void OnSessionClosed(uint32_t reference_id) OVERRIDE;
- virtual void OnSessionError(uint32_t reference_id,
+ virtual void OnSessionReady(uint32_t session_id) OVERRIDE;
+ virtual void OnSessionClosed(uint32_t session_id) OVERRIDE;
+ virtual void OnSessionError(uint32_t session_id,
cdm::MediaKeyError error_code,
uint32_t system_code) OVERRIDE;
@@ -129,16 +129,16 @@ class CdmAdapter : public pp::Instance,
// <code>callback_factory_</code> to ensure that calls into
// <code>PPP_ContentDecryptor_Private</code> are asynchronous.
void SendSessionCreatedInternal(int32_t result,
- uint32_t reference_id,
- const std::string& session_id);
+ uint32_t session_id,
+ const std::string& web_session_id);
void SendSessionMessageInternal(int32_t result,
- uint32_t reference_id,
+ uint32_t session_id,
const std::vector<uint8>& message,
const std::string& default_url);
- void SendSessionReadyInternal(int32_t result, uint32_t reference_id);
- void SendSessionClosedInternal(int32_t result, uint32_t reference_id);
+ void SendSessionReadyInternal(int32_t result, uint32_t session_id);
+ void SendSessionClosedInternal(int32_t result, uint32_t session_id);
void SendSessionErrorInternal(int32_t result,
- uint32_t reference_id,
+ uint32_t session_id,
cdm::MediaKeyError error_code,
uint32_t system_code);
diff --git a/media/cdm/ppapi/cdm_wrapper.h b/media/cdm/ppapi/cdm_wrapper.h
index 63d8bbf..d827336 100644
--- a/media/cdm/ppapi/cdm_wrapper.h
+++ b/media/cdm/ppapi/cdm_wrapper.h
@@ -52,15 +52,15 @@ class CdmWrapper {
virtual ~CdmWrapper() {};
- virtual void CreateSession(uint32_t reference_id,
+ virtual void CreateSession(uint32_t session_id,
const char* type,
uint32_t type_size,
const uint8_t* init_data,
uint32_t init_data_size) = 0;
- virtual Result UpdateSession(uint32_t reference_id,
+ virtual Result UpdateSession(uint32_t session_id,
const uint8_t* response,
uint32_t response_size) = 0;
- virtual Result ReleaseSession(uint32_t reference_id) = 0;
+ virtual Result ReleaseSession(uint32_t session_id) = 0;
virtual void TimerExpired(void* context) = 0;
virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
cdm::DecryptedBlock* decrypted_buffer) = 0;
@@ -84,40 +84,40 @@ class CdmWrapper {
// ContentDecryptionModule_1 and ContentDecryptionModule_2 interface methods
// AddKey() and CancelKeyRequest() (older versions of UpdateSession() and
- // ReleaseSession(), respectively) pass in the session_id rather than the
- // reference_id. As well, Host_1 and Host_2 callbacks SendKeyMessage() and
- // SendKeyError() include the session ID, but the actual callbacks need the
- // reference ID.
+ // ReleaseSession(), respectively) pass in the web_session_id rather than the
+ // session_id. As well, Host_1 and Host_2 callbacks SendKeyMessage() and
+ // SendKeyError() include the web_session_id, but the actual callbacks need
+ // session_id.
//
- // The following functions maintain the reference_id <-> session_id mapping.
+ // The following functions maintain the session_id <-> web_session_id mapping.
// These can be removed once _1 and _2 interfaces are no longer supported.
- // Determine the corresponding reference_id for |session_id|.
- virtual uint32_t DetermineReferenceId(const std::string& session_id) = 0;
+ // Determine the corresponding session_id for |web_session_id|.
+ virtual uint32_t LookupSessionId(const std::string& web_session_id) = 0;
- // Determine the corresponding session_id for |reference_id|.
- virtual const std::string LookupSessionId(uint32_t reference_id) = 0;
+ // Determine the corresponding session_id for |session_id|.
+ virtual const std::string LookupWebSessionId(uint32_t session_id) = 0;
+ // Map between session_id and web_session_id.
// TODO(jrummell): The following can be removed once CDM_1 and CDM_2 are
// no longer supported.
typedef std::map<uint32_t, std::string> SessionMap;
- static const uint32_t kInvalidReferenceId = 0;
-
- // Map between session_id and reference_id.
SessionMap session_map_;
+ static const uint32_t kInvalidSessionId = 0;
+
// As the response from PrefixedGenerateKeyRequest() may be synchronous or
// asynchronous, keep track of the current request during the call to handle
// synchronous responses or errors. If no response received, add this request
// to a queue and assume that the subsequent responses come back in the order
// issued.
// TODO(jrummell): Remove once all supported CDM host interfaces support
- // reference_id.
- uint32_t current_key_request_reference_id_;
- std::queue<uint32_t> pending_key_request_reference_ids_;
+ // session_id.
+ uint32_t current_key_request_session_id_;
+ std::queue<uint32_t> pending_key_request_session_ids_;
protected:
- CdmWrapper() : current_key_request_reference_id_(kInvalidReferenceId) {}
+ CdmWrapper() : current_key_request_session_id_(kInvalidSessionId) {}
private:
DISALLOW_COPY_AND_ASSIGN(CdmWrapper);
@@ -147,24 +147,23 @@ class CdmWrapperImpl : public CdmWrapper {
cdm_->Destroy();
}
- virtual void CreateSession(uint32_t reference_id,
+ virtual void CreateSession(uint32_t session_id,
const char* type,
uint32_t type_size,
const uint8_t* init_data,
uint32_t init_data_size) OVERRIDE {
- cdm_->CreateSession(
- reference_id, type, type_size, init_data, init_data_size);
+ cdm_->CreateSession(session_id, type, type_size, init_data, init_data_size);
}
- virtual Result UpdateSession(uint32_t reference_id,
+ virtual Result UpdateSession(uint32_t session_id,
const uint8_t* response,
uint32_t response_size) OVERRIDE {
- cdm_->UpdateSession(reference_id, response, response_size);
+ cdm_->UpdateSession(session_id, response, response_size);
return NO_ACTION;
}
- virtual Result ReleaseSession(uint32_t reference_id) OVERRIDE {
- cdm_->ReleaseSession(reference_id);
+ virtual Result ReleaseSession(uint32_t session_id) OVERRIDE {
+ cdm_->ReleaseSession(session_id);
return NO_ACTION;
}
@@ -218,43 +217,42 @@ class CdmWrapperImpl : public CdmWrapper {
cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask);
}
- uint32_t DetermineReferenceId(const std::string& session_id) {
+ uint32_t LookupSessionId(const std::string& web_session_id) {
for (SessionMap::iterator it = session_map_.begin();
it != session_map_.end();
++it) {
- if (it->second == session_id)
+ if (it->second == web_session_id)
return it->first;
}
// There is no entry in the map; assume it came from the current
// PrefixedGenerateKeyRequest() call (if possible). If no current request,
// assume it came from the oldest PrefixedGenerateKeyRequest() call.
- uint32_t reference_id = current_key_request_reference_id_;
- if (current_key_request_reference_id_) {
+ uint32_t session_id = current_key_request_session_id_;
+ if (current_key_request_session_id_) {
// Only 1 response is allowed for the current
// PrefixedGenerateKeyRequest().
- current_key_request_reference_id_ = kInvalidReferenceId;
+ current_key_request_session_id_ = kInvalidSessionId;
} else {
- PP_DCHECK(!pending_key_request_reference_ids_.empty());
- reference_id = pending_key_request_reference_ids_.front();
- pending_key_request_reference_ids_.pop();
+ PP_DCHECK(!pending_key_request_session_ids_.empty());
+ session_id = pending_key_request_session_ids_.front();
+ pending_key_request_session_ids_.pop();
}
// If this is a valid |session_id|, add it to the list. Otherwise, avoid
// adding empty string as a mapping to prevent future calls with an empty
- // string from using the wrong reference_id.
- if (!session_id.empty()) {
- PP_DCHECK(session_map_.find(reference_id) == session_map_.end());
- PP_DCHECK(!session_id.empty());
- session_map_[reference_id] = session_id;
+ // string from using the wrong session_id.
+ if (!web_session_id.empty()) {
+ PP_DCHECK(session_map_.find(session_id) == session_map_.end());
+ session_map_[session_id] = web_session_id;
}
- return reference_id;
+ return session_id;
}
- const std::string LookupSessionId(uint32_t reference_id) {
+ const std::string LookupWebSessionId(uint32_t session_id) {
// Session may not exist if error happens during CreateSession().
- SessionMap::iterator it = session_map_.find(reference_id);
+ SessionMap::iterator it = session_map_.find(session_id);
return (it != session_map_.end()) ? it->second : std::string();
}
@@ -276,14 +274,14 @@ class CdmWrapperImpl : public CdmWrapper {
template <class CdmInterface>
void PrefixedGenerateKeyRequest(CdmWrapper* wrapper,
CdmInterface* cdm,
- uint32_t reference_id,
+ uint32_t session_id,
const char* type,
uint32_t type_size,
const uint8_t* init_data,
uint32_t init_data_size) {
// As it is possible for CDMs to reply synchronously during the call to
- // GenerateKeyRequest(), keep track of |reference_id|.
- wrapper->current_key_request_reference_id_ = reference_id;
+ // GenerateKeyRequest(), keep track of |session_id|.
+ wrapper->current_key_request_session_id_ = session_id;
cdm::Status status =
cdm->GenerateKeyRequest(type, type_size, init_data, init_data_size);
@@ -291,42 +289,41 @@ void PrefixedGenerateKeyRequest(CdmWrapper* wrapper,
if (status != cdm::kSuccess) {
// If GenerateKeyRequest() failed, no subsequent asynchronous replies
// will be sent. Verify that a response was sent synchronously.
- PP_DCHECK(wrapper->current_key_request_reference_id_ ==
- CdmWrapper::kInvalidReferenceId);
- wrapper->current_key_request_reference_id_ =
- CdmWrapper::kInvalidReferenceId;
+ PP_DCHECK(wrapper->current_key_request_session_id_ ==
+ CdmWrapper::kInvalidSessionId);
+ wrapper->current_key_request_session_id_ = CdmWrapper::kInvalidSessionId;
return;
}
- if (wrapper->current_key_request_reference_id_) {
+ if (wrapper->current_key_request_session_id_) {
// If this request is still pending (SendKeyMessage() or SendKeyError()
- // not called synchronously), add |reference_id| to the end of the queue.
+ // not called synchronously), add |session_id| to the end of the queue.
// Without CDM support, it is impossible to match SendKeyMessage()
- // (or SendKeyError()) responses to the |reference_id|. Doing the best
+ // (or SendKeyError()) responses to the |session_id|. Doing the best
// we can by keeping track of this in a queue, and assuming the responses
// come back in order.
- wrapper->pending_key_request_reference_ids_.push(reference_id);
- wrapper->current_key_request_reference_id_ =
- CdmWrapper::kInvalidReferenceId;
+ wrapper->pending_key_request_session_ids_.push(session_id);
+ wrapper->current_key_request_session_id_ = CdmWrapper::kInvalidSessionId;
}
}
template <class CdmInterface>
CdmWrapper::Result PrefixedAddKey(CdmWrapper* wrapper,
CdmInterface* cdm,
- uint32_t reference_id,
+ uint32_t session_id,
const uint8_t* response,
uint32_t response_size) {
- const std::string session_id = wrapper->LookupSessionId(reference_id);
- if (session_id.empty()) {
+ const std::string web_session_id = wrapper->LookupWebSessionId(session_id);
+ if (web_session_id.empty()) {
// Possible if UpdateSession() called before CreateSession().
return CdmWrapper::CALL_KEY_ERROR;
}
// CDM_1 and CDM_2 accept initdata, which is no longer needed.
// In it's place pass in NULL.
- cdm::Status status = cdm->AddKey(
- session_id.data(), session_id.size(), response, response_size, NULL, 0);
+ cdm::Status status = cdm->AddKey(web_session_id.data(), web_session_id.size(),
+ response, response_size,
+ NULL, 0);
PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError);
if (status != cdm::kSuccess) {
// Some CDMs using Host_1/2 don't call keyerror, so send one.
@@ -339,16 +336,16 @@ CdmWrapper::Result PrefixedAddKey(CdmWrapper* wrapper,
template <class CdmInterface>
CdmWrapper::Result PrefixedCancelKeyRequest(CdmWrapper* wrapper,
CdmInterface* cdm,
- uint32_t reference_id) {
- const std::string session_id = wrapper->LookupSessionId(reference_id);
- if (session_id.empty()) {
+ uint32_t session_id) {
+ const std::string web_session_id = wrapper->LookupWebSessionId(session_id);
+ if (web_session_id.empty()) {
// Possible if ReleaseSession() called before CreateSession().
return CdmWrapper::CALL_KEY_ERROR;
}
- wrapper->session_map_.erase(reference_id);
+ wrapper->session_map_.erase(session_id);
cdm::Status status =
- cdm->CancelKeyRequest(session_id.data(), session_id.size());
+ cdm->CancelKeyRequest(web_session_id.data(), web_session_id.size());
PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError);
if (status != cdm::kSuccess) {
@@ -363,27 +360,27 @@ CdmWrapper::Result PrefixedCancelKeyRequest(CdmWrapper* wrapper,
template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::CreateSession(
- uint32_t reference_id,
+ uint32_t session_id,
const char* type,
uint32_t type_size,
const uint8_t* init_data,
uint32_t init_data_size) {
PrefixedGenerateKeyRequest(
- this, cdm_, reference_id, type, type_size, init_data, init_data_size);
+ this, cdm_, session_id, type, type_size, init_data, init_data_size);
}
template <>
CdmWrapper::Result CdmWrapperImpl<
- cdm::ContentDecryptionModule_1>::UpdateSession(uint32_t reference_id,
+ cdm::ContentDecryptionModule_1>::UpdateSession(uint32_t session_id,
const uint8_t* response,
uint32_t response_size) {
- return PrefixedAddKey(this, cdm_, reference_id, response, response_size);
+ return PrefixedAddKey(this, cdm_, session_id, response, response_size);
}
template <>
CdmWrapper::Result CdmWrapperImpl<
- cdm::ContentDecryptionModule_1>::ReleaseSession(uint32_t reference_id) {
- return PrefixedCancelKeyRequest(this, cdm_, reference_id);
+ cdm::ContentDecryptionModule_1>::ReleaseSession(uint32_t session_id) {
+ return PrefixedCancelKeyRequest(this, cdm_, session_id);
}
template <> void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::
@@ -416,27 +413,27 @@ template <> cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_1>::
template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_2>::CreateSession(
- uint32_t reference_id,
+ uint32_t session_id,
const char* type,
uint32_t type_size,
const uint8_t* init_data,
uint32_t init_data_size) {
PrefixedGenerateKeyRequest(
- this, cdm_, reference_id, type, type_size, init_data, init_data_size);
+ this, cdm_, session_id, type, type_size, init_data, init_data_size);
}
template <>
CdmWrapper::Result CdmWrapperImpl<
- cdm::ContentDecryptionModule_2>::UpdateSession(uint32_t reference_id,
+ cdm::ContentDecryptionModule_2>::UpdateSession(uint32_t session_id,
const uint8_t* response,
uint32_t response_size) {
- return PrefixedAddKey(this, cdm_, reference_id, response, response_size);
+ return PrefixedAddKey(this, cdm_, session_id, response, response_size);
}
template <>
CdmWrapper::Result CdmWrapperImpl<
- cdm::ContentDecryptionModule_2>::ReleaseSession(uint32_t reference_id) {
- return PrefixedCancelKeyRequest(this, cdm_, reference_id);
+ cdm::ContentDecryptionModule_2>::ReleaseSession(uint32_t session_id) {
+ return PrefixedCancelKeyRequest(this, cdm_, session_id);
}
CdmWrapper* CdmWrapper::Create(const char* key_system,
diff --git a/media/cdm/ppapi/clear_key_cdm.cc b/media/cdm/ppapi/clear_key_cdm.cc
index 3fc10e1..6d3a68c 100644
--- a/media/cdm/ppapi/clear_key_cdm.cc
+++ b/media/cdm/ppapi/clear_key_cdm.cc
@@ -159,9 +159,9 @@ const char* GetCdmVersion() {
namespace media {
// Since all the calls to AesDecryptor are synchronous, pass a dummy value for
-// reference_id that is never exposed outside this class.
+// session_id that is never exposed outside this class.
// TODO(jrummell): Remove usage of this when the CDM interface is updated
-// to use reference_id.
+// to use session_id.
ClearKeyCdm::Client::Client()
: status_(kNone), error_code_(MediaKeys::kUnknownError), system_code_(0) {}
@@ -170,20 +170,20 @@ ClearKeyCdm::Client::~Client() {}
void ClearKeyCdm::Client::Reset() {
status_ = kNone;
- session_id_.clear();
+ web_session_id_.clear();
message_.clear();
destination_url_.clear();
error_code_ = MediaKeys::kUnknownError;
system_code_ = 0;
}
-void ClearKeyCdm::Client::OnSessionCreated(uint32 reference_id,
- const std::string& session_id) {
+void ClearKeyCdm::Client::OnSessionCreated(uint32 session_id,
+ const std::string& web_session_id) {
status_ = static_cast<Status>(status_ | kCreated);
- session_id_ = session_id;
+ web_session_id_ = web_session_id;
}
-void ClearKeyCdm::Client::OnSessionMessage(uint32 reference_id,
+void ClearKeyCdm::Client::OnSessionMessage(uint32 session_id,
const std::vector<uint8>& message,
const std::string& destination_url) {
status_ = static_cast<Status>(status_ | kMessage);
@@ -191,15 +191,15 @@ void ClearKeyCdm::Client::OnSessionMessage(uint32 reference_id,
destination_url_ = destination_url;
}
-void ClearKeyCdm::Client::OnSessionReady(uint32 reference_id) {
+void ClearKeyCdm::Client::OnSessionReady(uint32 session_id) {
status_ = static_cast<Status>(status_ | kReady);
}
-void ClearKeyCdm::Client::OnSessionClosed(uint32 reference_id) {
+void ClearKeyCdm::Client::OnSessionClosed(uint32 session_id) {
status_ = static_cast<Status>(status_ | kClosed);
}
-void ClearKeyCdm::Client::OnSessionError(uint32 reference_id,
+void ClearKeyCdm::Client::OnSessionError(uint32 session_id,
media::MediaKeys::KeyError error_code,
int system_code) {
status_ = static_cast<Status>(status_ | kError);
@@ -236,27 +236,27 @@ cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* type,
DVLOG(1) << "GenerateKeyRequest()";
base::AutoLock auto_lock(client_lock_);
ScopedResetter<Client> auto_resetter(&client_);
- decryptor_.CreateSession(MediaKeys::kInvalidReferenceId,
+ decryptor_.CreateSession(MediaKeys::kInvalidSessionId,
std::string(type, type_size),
init_data, init_data_size);
if (client_.status() != (Client::kMessage | Client::kCreated)) {
// Use values returned to client if possible.
- host_->SendKeyError(client_.session_id().data(),
- client_.session_id().size(),
+ host_->SendKeyError(client_.web_session_id().data(),
+ client_.web_session_id().size(),
static_cast<cdm::MediaKeyError>(client_.error_code()),
client_.system_code());
return cdm::kSessionError;
}
host_->SendKeyMessage(
- client_.session_id().data(), client_.session_id().size(),
+ client_.web_session_id().data(), client_.web_session_id().size(),
reinterpret_cast<const char*>(&client_.message()[0]),
client_.message().size(),
client_.destination_url().data(), client_.destination_url().size());
// Only save the latest session ID for heartbeat messages.
- heartbeat_session_id_ = client_.session_id();
+ heartbeat_session_id_ = client_.web_session_id();
return cdm::kSuccess;
}
@@ -271,7 +271,7 @@ cdm::Status ClearKeyCdm::AddKey(const char* session_id,
DCHECK(!key_id && !key_id_size);
base::AutoLock auto_lock(client_lock_);
ScopedResetter<Client> auto_resetter(&client_);
- decryptor_.UpdateSession(MediaKeys::kInvalidReferenceId, key, key_size);
+ decryptor_.UpdateSession(MediaKeys::kInvalidSessionId, key, key_size);
if (client_.status() != Client::kReady) {
host_->SendKeyError(session_id, session_id_size,
@@ -293,7 +293,7 @@ cdm::Status ClearKeyCdm::CancelKeyRequest(const char* session_id,
DVLOG(1) << "CancelKeyRequest()";
base::AutoLock auto_lock(client_lock_);
ScopedResetter<Client> auto_resetter(&client_);
- decryptor_.ReleaseSession(MediaKeys::kInvalidReferenceId);
+ decryptor_.ReleaseSession(MediaKeys::kInvalidSessionId);
// No message normally sent by Release(), but if an error occurred,
// report it as a failure.
diff --git a/media/cdm/ppapi/clear_key_cdm.h b/media/cdm/ppapi/clear_key_cdm.h
index 4c5cb34..0ec18a1 100644
--- a/media/cdm/ppapi/clear_key_cdm.h
+++ b/media/cdm/ppapi/clear_key_cdm.h
@@ -72,7 +72,7 @@ class ClearKeyCdm : public ClearKeyCdmInterface {
class Client {
public:
// TODO(jrummell): Remove bitmask and rename kNone to kInvalid once CDM
- // interface supports reference_id passing completely.
+ // interface supports session_id passing completely.
enum Status {
kNone = 0,
kCreated = 1 << 0,
@@ -86,7 +86,7 @@ class ClearKeyCdm : public ClearKeyCdmInterface {
virtual ~Client();
Status status() { return status_; }
- const std::string& session_id() { return session_id_; }
+ const std::string& web_session_id() { return web_session_id_; }
const std::vector<uint8>& message() { return message_; }
const std::string& destination_url() { return destination_url_; }
MediaKeys::KeyError error_code() { return error_code_; }
@@ -95,19 +95,19 @@ class ClearKeyCdm : public ClearKeyCdmInterface {
// Resets the Client to a clean state.
void Reset();
- void OnSessionCreated(uint32 reference_id, const std::string& session_id);
- void OnSessionMessage(uint32 reference_id,
+ void OnSessionCreated(uint32 session_id, const std::string& web_session_id);
+ void OnSessionMessage(uint32 session_id,
const std::vector<uint8>& message,
const std::string& destination_url);
- void OnSessionReady(uint32 reference_id);
- void OnSessionClosed(uint32 reference_id);
- void OnSessionError(uint32 reference_id,
+ void OnSessionReady(uint32 session_id);
+ void OnSessionClosed(uint32 session_id);
+ void OnSessionError(uint32 session_id,
MediaKeys::KeyError error_code,
int system_code);
private:
Status status_;
- std::string session_id_;
+ std::string web_session_id_;
std::vector<uint8> message_;
std::string destination_url_;
MediaKeys::KeyError error_code_;
diff --git a/media/filters/pipeline_integration_test.cc b/media/filters/pipeline_integration_test.cc
index 06566ec..f828402 100644
--- a/media/filters/pipeline_integration_test.cc
+++ b/media/filters/pipeline_integration_test.cc
@@ -80,21 +80,21 @@ class FakeEncryptedMedia {
public:
virtual ~AppBase() {}
- virtual void SetSession(uint32 reference_id,
- const std::string& session_id) = 0;
+ virtual void OnSessionCreated(uint32 session_id,
+ const std::string& web_session_id) = 0;
- virtual void Message(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& destination_url) = 0;
+ virtual void OnSessionMessage(uint32 session_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url) = 0;
- virtual void Ready(uint32 reference_id) = 0;
+ virtual void OnSessionReady(uint32 session_id) = 0;
- virtual void Closed(uint32 reference_id) = 0;
+ virtual void OnSessionClosed(uint32 session_id) = 0;
// Errors are not expected unless overridden.
- virtual void Error(uint32 reference_id,
- MediaKeys::KeyError error_code,
- int system_code) {
+ virtual void OnSessionError(uint32 session_id,
+ MediaKeys::KeyError error_code,
+ int system_code) {
FAIL() << "Unexpected Key Error";
}
@@ -104,42 +104,45 @@ class FakeEncryptedMedia {
};
FakeEncryptedMedia(AppBase* app)
- : decryptor_(
- base::Bind(&FakeEncryptedMedia::SetSession, base::Unretained(this)),
- base::Bind(&FakeEncryptedMedia::Message, base::Unretained(this)),
- base::Bind(&FakeEncryptedMedia::Ready, base::Unretained(this)),
- base::Bind(&FakeEncryptedMedia::Closed, base::Unretained(this)),
- base::Bind(&FakeEncryptedMedia::Error, base::Unretained(this))),
- app_(app) {
- }
+ : decryptor_(base::Bind(&FakeEncryptedMedia::OnSessionCreated,
+ base::Unretained(this)),
+ base::Bind(&FakeEncryptedMedia::OnSessionMessage,
+ base::Unretained(this)),
+ base::Bind(&FakeEncryptedMedia::OnSessionReady,
+ base::Unretained(this)),
+ base::Bind(&FakeEncryptedMedia::OnSessionClosed,
+ base::Unretained(this)),
+ base::Bind(&FakeEncryptedMedia::OnSessionError,
+ base::Unretained(this))),
+ app_(app) {}
AesDecryptor* decryptor() {
return &decryptor_;
}
// Callbacks for firing session events. Delegate to |app_|.
- void SetSession(uint32 reference_id, const std::string& session_id) {
- app_->SetSession(reference_id, session_id);
+ void OnSessionCreated(uint32 session_id, const std::string& web_session_id) {
+ app_->OnSessionCreated(session_id, web_session_id);
}
- void Message(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& destination_url) {
- app_->Message(reference_id, message, destination_url);
+ void OnSessionMessage(uint32 session_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url) {
+ app_->OnSessionMessage(session_id, message, destination_url);
}
- void Ready(uint32 reference_id) {
- app_->Ready(reference_id);
+ void OnSessionReady(uint32 session_id) {
+ app_->OnSessionReady(session_id);
}
- void Closed(uint32 reference_id) {
- app_->Closed(reference_id);
+ void OnSessionClosed(uint32 session_id) {
+ app_->OnSessionClosed(session_id);
}
- void Error(uint32 reference_id,
- MediaKeys::KeyError error_code,
- int system_code) {
- app_->Error(reference_id, error_code, system_code);
+ void OnSessionError(uint32 session_id,
+ MediaKeys::KeyError error_code,
+ int system_code) {
+ app_->OnSessionError(session_id, error_code, system_code);
}
void NeedKey(const std::string& type,
@@ -155,40 +158,40 @@ class FakeEncryptedMedia {
// Provides |kSecretKey| in response to needkey.
class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
public:
- KeyProvidingApp() : current_reference_id_(0) {}
+ KeyProvidingApp() : current_session_id_(0) {}
- virtual void SetSession(uint32 reference_id,
- const std::string& session_id) OVERRIDE {
- EXPECT_GT(reference_id, 0u);
- EXPECT_FALSE(session_id.empty());
+ virtual void OnSessionCreated(uint32 session_id,
+ const std::string& web_session_id) OVERRIDE {
+ EXPECT_GT(session_id, 0u);
+ EXPECT_FALSE(web_session_id.empty());
}
- virtual void Message(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url) OVERRIDE {
- EXPECT_GT(reference_id, 0u);
+ virtual void OnSessionMessage(uint32 session_id,
+ const std::vector<uint8>& message,
+ const std::string& default_url) OVERRIDE {
+ EXPECT_GT(session_id, 0u);
EXPECT_FALSE(message.empty());
- current_reference_id_ = reference_id;
+ current_session_id_ = session_id;
}
- virtual void Ready(uint32 reference_id) OVERRIDE {
- EXPECT_GT(reference_id, 0u);
+ virtual void OnSessionReady(uint32 session_id) OVERRIDE {
+ EXPECT_GT(session_id, 0u);
}
- virtual void Closed(uint32 reference_id) OVERRIDE {
- EXPECT_GT(reference_id, 0u);
+ virtual void OnSessionClosed(uint32 session_id) OVERRIDE {
+ EXPECT_GT(session_id, 0u);
}
virtual void NeedKey(const std::string& type,
const std::vector<uint8>& init_data,
AesDecryptor* decryptor) OVERRIDE {
- if (current_reference_id_ == 0u) {
+ if (current_session_id_ == 0u) {
EXPECT_TRUE(
decryptor->CreateSession(12, type, kInitData, arraysize(kInitData)));
}
- EXPECT_EQ(current_reference_id_, 12u);
+ EXPECT_EQ(current_session_id_, 12u);
// Clear Key really needs the key ID in |init_data|. For WebM, they are the
// same, but this is not the case for ISO CENC. Therefore, provide the
@@ -203,40 +206,40 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
// Convert key into a JSON structure and then add it.
std::string jwk = GenerateJWKSet(
kSecretKey, arraysize(kSecretKey), key_id, key_id_length);
- decryptor->UpdateSession(current_reference_id_,
+ decryptor->UpdateSession(current_session_id_,
reinterpret_cast<const uint8*>(jwk.data()),
jwk.size());
}
- uint32 current_reference_id_;
+ uint32 current_session_id_;
};
// Ignores needkey and does not perform a license request
class NoResponseApp : public FakeEncryptedMedia::AppBase {
public:
- virtual void SetSession(uint32 reference_id,
- const std::string& session_id) OVERRIDE {
- EXPECT_GT(reference_id, 0u);
- EXPECT_FALSE(session_id.empty());
- }
+ virtual void OnSessionCreated(uint32 session_id,
+ const std::string& web_session_id) OVERRIDE {
+ EXPECT_GT(session_id, 0u);
+ EXPECT_FALSE(web_session_id.empty());
+ }
- virtual void Message(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url) OVERRIDE {
- EXPECT_GT(reference_id, 0u);
- EXPECT_FALSE(message.empty());
- FAIL() << "Unexpected KeyMessage";
- }
-
- virtual void Ready(uint32 reference_id) OVERRIDE {
- EXPECT_GT(reference_id, 0u);
- FAIL() << "Unexpected Ready";
- }
-
- virtual void Closed(uint32 reference_id) OVERRIDE {
- EXPECT_GT(reference_id, 0u);
- FAIL() << "Unexpected Closed";
- }
+ virtual void OnSessionMessage(uint32 session_id,
+ const std::vector<uint8>& message,
+ const std::string& default_url) OVERRIDE {
+ EXPECT_GT(session_id, 0u);
+ EXPECT_FALSE(message.empty());
+ FAIL() << "Unexpected KeyMessage";
+ }
+
+ virtual void OnSessionReady(uint32 session_id) OVERRIDE {
+ EXPECT_GT(session_id, 0u);
+ FAIL() << "Unexpected Ready";
+ }
+
+ virtual void OnSessionClosed(uint32 session_id) OVERRIDE {
+ EXPECT_GT(session_id, 0u);
+ FAIL() << "Unexpected Closed";
+ }
virtual void NeedKey(const std::string& type,
const std::vector<uint8>& init_data,