summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-30 05:24:47 +0000
committerjrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-30 05:24:47 +0000
commitda34aa7be7368dc1327a8129b7db0f13b24f5c2b (patch)
tree6340efd5e30735b0bf7352a79dd8e08b54366d6d
parenta6b2aa58719366e64a7fdbde719707304a993a33 (diff)
downloadchromium_src-da34aa7be7368dc1327a8129b7db0f13b24f5c2b.zip
chromium_src-da34aa7be7368dc1327a8129b7db0f13b24f5c2b.tar.gz
chromium_src-da34aa7be7368dc1327a8129b7db0f13b24f5c2b.tar.bz2
Add support for CDM_3.
Changes for CDM_3: - CreateSession() replaces GenerateKeyRequest() - UpdateSession/1 replaces AddKey/2 - ReleaseSession() replaces CancelKeyRequest() - closed event (OnSessionClosed) added. - callbacks renamed (SetSessionId -> OnSessionCreated, SendMessage -> OnSessionMessage, SendReady -> OnSessionReady, SendError -> OnSessionError) Android function names still need to be updated in a separate CL. BUG=224786 TEST=encrypted-media layout tests and browser_tests for encrypted media pass TBR=dmichael Review URL: https://codereview.chromium.org/81803003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237973 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--DEPS2
-rw-r--r--content/browser/media/android/browser_media_player_manager.cc63
-rw-r--r--content/browser/media/android/browser_media_player_manager.h24
-rw-r--r--content/renderer/media/android/proxy_media_keys.cc73
-rw-r--r--content/renderer/media/android/proxy_media_keys.h51
-rw-r--r--content/renderer/media/android/renderer_media_player_manager.cc51
-rw-r--r--content/renderer/media/android/renderer_media_player_manager.h23
-rw-r--r--content/renderer/media/crypto/content_decryption_module_factory.cc53
-rw-r--r--content/renderer/media/crypto/content_decryption_module_factory.h9
-rw-r--r--content/renderer/media/crypto/ppapi_decryptor.cc122
-rw-r--r--content/renderer/media/crypto/ppapi_decryptor.h70
-rw-r--r--content/renderer/media/crypto/proxy_decryptor.cc69
-rw-r--r--content/renderer/media/crypto/proxy_decryptor.h19
-rw-r--r--content/renderer/media/webcontentdecryptionmodule_impl.cc58
-rw-r--r--content/renderer/media/webcontentdecryptionmodulesession_impl.cc64
-rw-r--r--content/renderer/media/webcontentdecryptionmodulesession_impl.h15
-rw-r--r--content/renderer/pepper/content_decryptor_delegate.cc112
-rw-r--r--content/renderer/pepper/content_decryptor_delegate.h56
-rw-r--r--content/renderer/pepper/pepper_plugin_instance_impl.cc40
-rw-r--r--content/renderer/pepper/pepper_plugin_instance_impl.h26
-rw-r--r--media/base/android/media_drm_bridge.cc31
-rw-r--r--media/base/android/media_drm_bridge.h16
-rw-r--r--media/base/android/media_player_manager.h45
-rw-r--r--media/base/android/media_source_player_unittest.cc26
-rw-r--r--media/base/media_keys.h57
-rw-r--r--media/cdm/aes_decryptor.cc66
-rw-r--r--media/cdm/aes_decryptor.h38
-rw-r--r--media/cdm/aes_decryptor_unittest.cc110
-rw-r--r--media/cdm/ppapi/cdm_adapter.cc169
-rw-r--r--media/cdm/ppapi/cdm_adapter.h63
-rw-r--r--media/cdm/ppapi/cdm_wrapper.h297
-rw-r--r--media/cdm/ppapi/clear_key_cdm.cc81
-rw-r--r--media/cdm/ppapi/clear_key_cdm.h34
-rw-r--r--media/cdm/ppapi/clear_key_cdm_common.h2
-rw-r--r--media/cdm/ppapi/supported_cdm_versions.h15
-rw-r--r--media/filters/pipeline_integration_test.cc133
-rw-r--r--ppapi/api/private/ppb_content_decryptor_private.idl100
-rw-r--r--ppapi/api/private/ppp_content_decryptor_private.idl59
-rw-r--r--ppapi/c/private/ppb_content_decryptor_private.h109
-rw-r--r--ppapi/c/private/ppp_content_decryptor_private.h77
-rw-r--r--ppapi/cpp/private/content_decryptor_private.cc95
-rw-r--r--ppapi/cpp/private/content_decryptor_private.h30
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c176
-rw-r--r--ppapi/proxy/ppapi_messages.h30
-rw-r--r--ppapi/proxy/ppb_instance_proxy.cc142
-rw-r--r--ppapi/proxy/ppb_instance_proxy.h53
-rw-r--r--ppapi/proxy/ppp_content_decryptor_private_proxy.cc85
-rw-r--r--ppapi/proxy/ppp_content_decryptor_private_proxy.h18
-rw-r--r--ppapi/thunk/interfaces_ppb_private.h4
-rw-r--r--ppapi/thunk/ppb_content_decryptor_private_thunk.cc73
-rw-r--r--ppapi/thunk/ppb_instance_api.h24
51 files changed, 1755 insertions, 1503 deletions
diff --git a/DEPS b/DEPS
index 739a554..2debcf4 100644
--- a/DEPS
+++ b/DEPS
@@ -264,7 +264,7 @@ deps = {
"/trunk/deps/third_party/opus@237544",
"src/media/cdm/ppapi/api":
- "/trunk/deps/cdm@232829",
+ "/trunk/deps/cdm@237635",
"src/third_party/mesa/src":
"/trunk/deps/third_party/mesa@229994",
diff --git a/content/browser/media/android/browser_media_player_manager.cc b/content/browser/media/android/browser_media_player_manager.cc
index e8d185f..2273b5c 100644
--- a/content/browser/media/android/browser_media_player_manager.cc
+++ b/content/browser/media/android/browser_media_player_manager.cc
@@ -363,34 +363,42 @@ void BrowserMediaPlayerManager::OnProtectedSurfaceRequested(int player_id) {
}
}
-void BrowserMediaPlayerManager::OnKeyAdded(int media_keys_id,
- uint32 reference_id) {
- Send(new MediaKeysMsg_KeyAdded(routing_id(), media_keys_id, reference_id));
-}
+// The following 5 functions are EME MediaKeySession events.
-void BrowserMediaPlayerManager::OnKeyError(
+void BrowserMediaPlayerManager::OnSessionCreated(
int media_keys_id,
uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code) {
- Send(new MediaKeysMsg_KeyError(routing_id(), media_keys_id,
- reference_id, error_code, system_code));
+ const std::string& session_id) {
+ Send(new MediaKeysMsg_SetSessionId(
+ routing_id(), media_keys_id, reference_id, session_id));
}
-void BrowserMediaPlayerManager::OnKeyMessage(
+void BrowserMediaPlayerManager::OnSessionMessage(
int media_keys_id,
uint32 reference_id,
const std::vector<uint8>& message,
const std::string& destination_url) {
- Send(new MediaKeysMsg_KeyMessage(routing_id(), media_keys_id,
- reference_id, message, destination_url));
+ Send(new MediaKeysMsg_KeyMessage(
+ routing_id(), media_keys_id, reference_id, message, destination_url));
}
-void BrowserMediaPlayerManager::OnSetSessionId(int media_keys_id,
- uint32 reference_id,
- const std::string& session_id) {
- Send(new MediaKeysMsg_SetSessionId(
- routing_id(), media_keys_id, reference_id, session_id));
+void BrowserMediaPlayerManager::OnSessionReady(int media_keys_id,
+ uint32 reference_id) {
+ Send(new MediaKeysMsg_KeyAdded(routing_id(), media_keys_id, reference_id));
+}
+
+void BrowserMediaPlayerManager::OnSessionClosed(int media_keys_id,
+ uint32 reference_id) {
+ // TODO(jrummell): Update Android calls and IPC names.
+}
+
+void BrowserMediaPlayerManager::OnSessionError(
+ int media_keys_id,
+ uint32 reference_id,
+ media::MediaKeys::KeyError error_code,
+ int system_code) {
+ Send(new MediaKeysMsg_KeyError(routing_id(), media_keys_id,
+ reference_id, error_code, system_code));
}
#if defined(GOOGLE_TV)
@@ -558,7 +566,8 @@ void BrowserMediaPlayerManager::OnGenerateKeyRequest(
MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id);
if (!drm_bridge) {
DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found";
- OnKeyError(media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0);
+ OnSessionError(
+ media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0);
return;
}
@@ -584,13 +593,13 @@ void BrowserMediaPlayerManager::OnAddKey(int media_keys_id,
MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id);
if (!drm_bridge) {
DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found";
- OnKeyError(media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0);
+ OnSessionError(
+ media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0);
return;
}
- drm_bridge->AddKey(reference_id,
- &key[0], key.size(),
- &init_data[0], init_data.size());
+ DCHECK(init_data.empty());
+ drm_bridge->UpdateSession(reference_id, &key[0], key.size());
// In EME v0.1b MediaKeys lives in the media element. So the |media_keys_id|
// is the same as the |player_id|.
// TODO(xhwang): Separate |media_keys_id| and |player_id|.
@@ -605,11 +614,12 @@ void BrowserMediaPlayerManager::OnCancelKeyRequest(
MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id);
if (!drm_bridge) {
DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found";
- OnKeyError(media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0);
+ OnSessionError(
+ media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0);
return;
}
- drm_bridge->CancelKeyRequest(reference_id);
+ drm_bridge->ReleaseSession(reference_id);
}
void BrowserMediaPlayerManager::AddPlayer(MediaPlayerAndroid* player) {
@@ -716,12 +726,13 @@ void BrowserMediaPlayerManager::GenerateKeyIfAllowed(
MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id);
if (!drm_bridge) {
DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found";
- OnKeyError(media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0);
+ OnSessionError(
+ media_keys_id, reference_id, media::MediaKeys::kUnknownError, 0);
return;
}
media_keys_ids_pending_approval_.erase(media_keys_id);
media_keys_ids_approved_.insert(media_keys_id);
- drm_bridge->GenerateKeyRequest(
+ drm_bridge->CreateSession(
reference_id, type, &init_data[0], init_data.size());
// TODO(qinmin): currently |media_keys_id| and player ID are identical.
diff --git a/content/browser/media/android/browser_media_player_manager.h b/content/browser/media/android/browser_media_player_manager.h
index bd5ad78..cee6be5 100644
--- a/content/browser/media/android/browser_media_player_manager.h
+++ b/content/browser/media/android/browser_media_player_manager.h
@@ -90,19 +90,19 @@ class CONTENT_EXPORT BrowserMediaPlayerManager
virtual media::MediaDrmBridge* GetDrmBridge(int media_keys_id) OVERRIDE;
virtual void DestroyAllMediaPlayers() OVERRIDE;
virtual void OnProtectedSurfaceRequested(int player_id) OVERRIDE;
- virtual void OnKeyAdded(int media_keys_id,
- uint32 reference_id) OVERRIDE;
- virtual void OnKeyError(int media_keys_id,
- uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code) OVERRIDE;
- virtual void OnKeyMessage(int media_keys_id,
- uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& destination_url) OVERRIDE;
- virtual void OnSetSessionId(int media_keys_id,
+ virtual void OnSessionCreated(int media_keys_id,
+ uint32 reference_id,
+ const std::string& session_id) OVERRIDE;
+ virtual void OnSessionMessage(int media_keys_id,
+ uint32 reference_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 OnSessionError(int media_keys_id,
uint32 reference_id,
- const std::string& session_id) OVERRIDE;
+ media::MediaKeys::KeyError error_code,
+ int system_code) OVERRIDE;
#if defined(GOOGLE_TV)
void AttachExternalVideoSurface(int player_id, jobject surface);
diff --git a/content/renderer/media/android/proxy_media_keys.cc b/content/renderer/media/android/proxy_media_keys.cc
index 8310a83..d7bb6cb 100644
--- a/content/renderer/media/android/proxy_media_keys.cc
+++ b/content/renderer/media/android/proxy_media_keys.cc
@@ -13,18 +13,21 @@
namespace content {
-ProxyMediaKeys::ProxyMediaKeys(RendererMediaPlayerManager* manager,
- int media_keys_id,
- const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb)
+ProxyMediaKeys::ProxyMediaKeys(
+ RendererMediaPlayerManager* manager,
+ int media_keys_id,
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb)
: manager_(manager),
media_keys_id_(media_keys_id),
- key_added_cb_(key_added_cb),
- key_error_cb_(key_error_cb),
- key_message_cb_(key_message_cb),
- set_session_id_cb_(set_session_id_cb) {
+ session_created_cb_(session_created_cb),
+ session_message_cb_(session_message_cb),
+ session_ready_cb_(session_ready_cb),
+ session_closed_cb_(session_closed_cb),
+ session_error_cb_(session_error_cb) {
DCHECK(manager_);
}
@@ -42,10 +45,10 @@ void ProxyMediaKeys::InitializeCDM(const std::string& key_system,
#endif
}
-bool ProxyMediaKeys::GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length) {
+bool ProxyMediaKeys::CreateSession(uint32 reference_id,
+ const std::string& type,
+ const uint8* init_data,
+ int init_data_length) {
manager_->GenerateKeyRequest(
media_keys_id_,
reference_id,
@@ -54,38 +57,42 @@ bool ProxyMediaKeys::GenerateKeyRequest(uint32 reference_id,
return true;
}
-void ProxyMediaKeys::AddKey(uint32 reference_id,
- const uint8* key, int key_length,
- const uint8* init_data, int init_data_length) {
+void ProxyMediaKeys::UpdateSession(uint32 reference_id,
+ const uint8* response,
+ int response_length) {
manager_->AddKey(media_keys_id_,
reference_id,
- std::vector<uint8>(key, key + key_length),
- std::vector<uint8>(init_data, init_data + init_data_length));
+ std::vector<uint8>(response, response + response_length),
+ std::vector<uint8>());
}
-void ProxyMediaKeys::CancelKeyRequest(uint32 reference_id) {
+void ProxyMediaKeys::ReleaseSession(uint32 reference_id) {
manager_->CancelKeyRequest(media_keys_id_, reference_id);
}
-void ProxyMediaKeys::OnKeyAdded(uint32 reference_id) {
- key_added_cb_.Run(reference_id);
+void ProxyMediaKeys::OnSessionCreated(uint32 reference_id,
+ const std::string& session_id) {
+ session_created_cb_.Run(reference_id, session_id);
}
-void ProxyMediaKeys::OnKeyError(uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code) {
- key_error_cb_.Run(reference_id, error_code, system_code);
+void ProxyMediaKeys::OnSessionMessage(uint32 reference_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url) {
+ session_message_cb_.Run(reference_id, message, destination_url);
}
-void ProxyMediaKeys::OnKeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& destination_url) {
- key_message_cb_.Run(reference_id, message, destination_url);
+void ProxyMediaKeys::OnSessionReady(uint32 reference_id) {
+ session_ready_cb_.Run(reference_id);
}
-void ProxyMediaKeys::OnSetSessionId(uint32 reference_id,
- const std::string& session_id) {
- set_session_id_cb_.Run(reference_id, session_id);
+void ProxyMediaKeys::OnSessionClosed(uint32 reference_id) {
+ session_closed_cb_.Run(reference_id);
+}
+
+void ProxyMediaKeys::OnSessionError(uint32 reference_id,
+ media::MediaKeys::KeyError error_code,
+ int system_code) {
+ session_error_cb_.Run(reference_id, error_code, system_code);
}
} // namespace content
diff --git a/content/renderer/media/android/proxy_media_keys.h b/content/renderer/media/android/proxy_media_keys.h
index 119418c..43a40605 100644
--- a/content/renderer/media/android/proxy_media_keys.h
+++ b/content/renderer/media/android/proxy_media_keys.h
@@ -22,41 +22,44 @@ class ProxyMediaKeys : public media::MediaKeys {
public:
ProxyMediaKeys(RendererMediaPlayerManager* proxy,
int media_keys_id,
- const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb);
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb);
virtual ~ProxyMediaKeys();
void InitializeCDM(const std::string& key_system, const GURL& frame_url);
// MediaKeys implementation.
- virtual bool GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length) OVERRIDE;
- virtual void AddKey(uint32 reference_id,
- const uint8* key, int key_length,
- const uint8* init_data, int init_data_length) OVERRIDE;
- virtual void CancelKeyRequest(uint32 reference_id) OVERRIDE;
+ virtual bool CreateSession(uint32 reference_id,
+ const std::string& type,
+ const uint8* init_data,
+ int init_data_length) OVERRIDE;
+ virtual void UpdateSession(uint32 reference_id,
+ const uint8* response,
+ int response_length) OVERRIDE;
+ virtual void ReleaseSession(uint32 reference_id) OVERRIDE;
// Callbacks.
- void OnKeyAdded(uint32 reference_id);
- void OnKeyError(uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code);
- void OnKeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& destination_url);
- void OnSetSessionId(uint32 reference_id, const std::string& session_id);
+ void OnSessionCreated(uint32 reference_id, const std::string& session_id);
+ void OnSessionMessage(uint32 reference_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,
+ media::MediaKeys::KeyError error_code,
+ int system_code);
private:
RendererMediaPlayerManager* manager_;
int media_keys_id_;
- media::KeyAddedCB key_added_cb_;
- media::KeyErrorCB key_error_cb_;
- media::KeyMessageCB key_message_cb_;
- media::SetSessionIdCB set_session_id_cb_;
+ media::SessionCreatedCB session_created_cb_;
+ media::SessionMessageCB session_message_cb_;
+ media::SessionReadyCB session_ready_cb_;
+ media::SessionClosedCB session_closed_cb_;
+ media::SessionErrorCB session_error_cb_;
DISALLOW_COPY_AND_ASSIGN(ProxyMediaKeys);
};
diff --git a/content/renderer/media/android/renderer_media_player_manager.cc b/content/renderer/media/android/renderer_media_player_manager.cc
index d3560ad..d75a7e3 100644
--- a/content/renderer/media/android/renderer_media_player_manager.cc
+++ b/content/renderer/media/android/renderer_media_player_manager.cc
@@ -57,10 +57,11 @@ bool RendererMediaPlayerManager::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(MediaPlayerMsg_DidExitFullscreen, OnDidExitFullscreen)
IPC_MESSAGE_HANDLER(MediaPlayerMsg_DidMediaPlayerPlay, OnPlayerPlay)
IPC_MESSAGE_HANDLER(MediaPlayerMsg_DidMediaPlayerPause, OnPlayerPause)
- IPC_MESSAGE_HANDLER(MediaKeysMsg_KeyAdded, OnKeyAdded)
- IPC_MESSAGE_HANDLER(MediaKeysMsg_KeyError, OnKeyError)
- IPC_MESSAGE_HANDLER(MediaKeysMsg_KeyMessage, OnKeyMessage)
- IPC_MESSAGE_HANDLER(MediaKeysMsg_SetSessionId, OnSetSessionId)
+ // TODO(jrummell): Update IPC names for EME WD and add Closed.
+ IPC_MESSAGE_HANDLER(MediaKeysMsg_KeyAdded, OnSessionReady)
+ IPC_MESSAGE_HANDLER(MediaKeysMsg_KeyError, OnSessionError)
+ IPC_MESSAGE_HANDLER(MediaKeysMsg_KeyMessage, OnSessionMessage)
+ IPC_MESSAGE_HANDLER(MediaKeysMsg_SetSessionId, OnSessionCreated)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -255,39 +256,47 @@ void RendererMediaPlayerManager::CancelKeyRequest(int media_keys_id,
routing_id(), media_keys_id, reference_id));
}
-void RendererMediaPlayerManager::OnKeyAdded(int media_keys_id,
- uint32 reference_id) {
- ProxyMediaKeys* media_keys = GetMediaKeys(media_keys_id);
- if (media_keys)
- media_keys->OnKeyAdded(reference_id);
-}
-
-void RendererMediaPlayerManager::OnKeyError(
+void RendererMediaPlayerManager::OnSessionCreated(
int media_keys_id,
uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code) {
+ const std::string& session_id) {
ProxyMediaKeys* media_keys = GetMediaKeys(media_keys_id);
if (media_keys)
- media_keys->OnKeyError(reference_id, error_code, system_code);
+ media_keys->OnSessionCreated(reference_id, session_id);
}
-void RendererMediaPlayerManager::OnKeyMessage(
+void RendererMediaPlayerManager::OnSessionMessage(
int media_keys_id,
uint32 reference_id,
const std::vector<uint8>& message,
const std::string& destination_url) {
ProxyMediaKeys* media_keys = GetMediaKeys(media_keys_id);
if (media_keys)
- media_keys->OnKeyMessage(reference_id, message, destination_url);
+ media_keys->OnSessionMessage(reference_id, message, destination_url);
+}
+
+void RendererMediaPlayerManager::OnSessionReady(int media_keys_id,
+ uint32 reference_id) {
+ ProxyMediaKeys* media_keys = GetMediaKeys(media_keys_id);
+ if (media_keys)
+ media_keys->OnSessionReady(reference_id);
+}
+
+void RendererMediaPlayerManager::OnSessionClosed(int media_keys_id,
+ uint32 reference_id) {
+ ProxyMediaKeys* media_keys = GetMediaKeys(media_keys_id);
+ if (media_keys)
+ media_keys->OnSessionClosed(reference_id);
}
-void RendererMediaPlayerManager::OnSetSessionId(int media_keys_id,
- uint32 reference_id,
- const std::string& session_id) {
+void RendererMediaPlayerManager::OnSessionError(
+ int media_keys_id,
+ uint32 reference_id,
+ media::MediaKeys::KeyError error_code,
+ int system_code) {
ProxyMediaKeys* media_keys = GetMediaKeys(media_keys_id);
if (media_keys)
- media_keys->OnSetSessionId(reference_id, session_id);
+ media_keys->OnSessionError(reference_id, error_code, system_code);
}
int RendererMediaPlayerManager::RegisterMediaPlayer(
diff --git a/content/renderer/media/android/renderer_media_player_manager.h b/content/renderer/media/android/renderer_media_player_manager.h
index 58344c7..6830a71 100644
--- a/content/renderer/media/android/renderer_media_player_manager.h
+++ b/content/renderer/media/android/renderer_media_player_manager.h
@@ -160,18 +160,19 @@ class RendererMediaPlayerManager : public RenderViewObserver {
void OnPlayerPlay(int player_id);
void OnPlayerPause(int player_id);
void OnRequestFullscreen(int player_id);
- void OnKeyAdded(int media_keys_id, uint32 reference_id);
- void OnKeyError(int media_keys_id,
- uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code);
- void OnKeyMessage(int media_keys_id,
- uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& destination_url);
- void OnSetSessionId(int media_keys_id,
+ void OnSessionCreated(int media_keys_id,
+ uint32 reference_id,
+ const std::string& session_id);
+ void OnSessionMessage(int media_keys_id,
+ uint32 reference_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url);
+ void OnSessionReady(int media_keys_id, uint32 reference_id);
+ void OnSessionClosed(int media_keys_id, uint32 reference_id);
+ void OnSessionError(int media_keys_id,
uint32 reference_id,
- const std::string& session_id);
+ media::MediaKeys::KeyError error_code,
+ int system_code);
// Info for all available WebMediaPlayerAndroid on a page; kept so that
// we can enumerate them to send updates about tab focus and visibility.
diff --git a/content/renderer/media/crypto/content_decryption_module_factory.cc b/content/renderer/media/crypto/content_decryption_module_factory.cc
index b715997..feafca7 100644
--- a/content/renderer/media/crypto/content_decryption_module_factory.cc
+++ b/content/renderer/media/crypto/content_decryption_module_factory.cc
@@ -47,10 +47,11 @@ static scoped_refptr<PepperPluginInstanceImpl> CreateHelperPlugin(
static scoped_ptr<media::MediaKeys> CreatePpapiDecryptor(
const std::string& key_system,
- const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb,
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb,
const base::Closure& destroy_plugin_cb,
blink::WebMediaPlayerClient* web_media_player_client,
blink::WebFrame* web_frame) {
@@ -69,10 +70,11 @@ static scoped_ptr<media::MediaKeys> CreatePpapiDecryptor(
scoped_ptr<PpapiDecryptor> decryptor =
PpapiDecryptor::Create(key_system,
plugin_instance,
- key_added_cb,
- key_error_cb,
- key_message_cb,
- set_session_id_cb,
+ session_created_cb,
+ session_message_cb,
+ session_ready_cb,
+ session_closed_cb,
+ session_error_cb,
destroy_plugin_cb);
if (!decryptor)
@@ -100,13 +102,18 @@ scoped_ptr<media::MediaKeys> ContentDecryptionModuleFactory::Create(
int media_keys_id,
const GURL& frame_url,
#endif // defined(ENABLE_PEPPER_CDMS)
- const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb) {
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb) {
if (CanUseAesDecryptor(key_system)) {
- return scoped_ptr<media::MediaKeys>(new media::AesDecryptor(
- key_added_cb, key_error_cb, key_message_cb, set_session_id_cb));
+ return scoped_ptr<media::MediaKeys>(
+ new media::AesDecryptor(session_created_cb,
+ session_message_cb,
+ session_ready_cb,
+ session_closed_cb,
+ session_error_cb));
}
#if defined(ENABLE_PEPPER_CDMS)
@@ -116,10 +123,11 @@ scoped_ptr<media::MediaKeys> ContentDecryptionModuleFactory::Create(
return scoped_ptr<media::MediaKeys>();
return CreatePpapiDecryptor(key_system,
- key_added_cb,
- key_error_cb,
- key_message_cb,
- set_session_id_cb,
+ session_created_cb,
+ session_message_cb,
+ session_ready_cb,
+ session_closed_cb,
+ session_error_cb,
destroy_plugin_cb,
web_media_player_client,
web_frame);
@@ -127,10 +135,11 @@ scoped_ptr<media::MediaKeys> ContentDecryptionModuleFactory::Create(
scoped_ptr<ProxyMediaKeys> proxy_media_keys(
new ProxyMediaKeys(manager,
media_keys_id,
- key_added_cb,
- key_error_cb,
- key_message_cb,
- set_session_id_cb));
+ session_created_cb,
+ session_message_cb,
+ session_ready_cb,
+ session_closed_cb,
+ session_error_cb));
proxy_media_keys->InitializeCDM(key_system, frame_url);
return proxy_media_keys.PassAs<media::MediaKeys>();
#else
diff --git a/content/renderer/media/crypto/content_decryption_module_factory.h b/content/renderer/media/crypto/content_decryption_module_factory.h
index 1b8fa7c..87623ca 100644
--- a/content/renderer/media/crypto/content_decryption_module_factory.h
+++ b/content/renderer/media/crypto/content_decryption_module_factory.h
@@ -37,10 +37,11 @@ class ContentDecryptionModuleFactory {
int media_keys_id,
const GURL& frame_url,
#endif // defined(ENABLE_PEPPER_CDMS)
- const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb);
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb);
#if defined(ENABLE_PEPPER_CDMS)
static void DestroyHelperPlugin(
diff --git a/content/renderer/media/crypto/ppapi_decryptor.cc b/content/renderer/media/crypto/ppapi_decryptor.cc
index b31b8d6..becaa18 100644
--- a/content/renderer/media/crypto/ppapi_decryptor.cc
+++ b/content/renderer/media/crypto/ppapi_decryptor.cc
@@ -25,10 +25,11 @@ namespace content {
scoped_ptr<PpapiDecryptor> PpapiDecryptor::Create(
const std::string& key_system,
const scoped_refptr<PepperPluginInstanceImpl>& plugin_instance,
- const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb,
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb,
const base::Closure& destroy_plugin_cb) {
ContentDecryptorDelegate* plugin_cdm_delegate =
plugin_instance->GetContentDecryptorDelegate();
@@ -41,44 +42,49 @@ scoped_ptr<PpapiDecryptor> PpapiDecryptor::Create(
return scoped_ptr<PpapiDecryptor>(new PpapiDecryptor(plugin_instance,
plugin_cdm_delegate,
- key_added_cb,
- key_error_cb,
- key_message_cb,
- set_session_id_cb,
+ session_created_cb,
+ session_message_cb,
+ session_ready_cb,
+ session_closed_cb,
+ session_error_cb,
destroy_plugin_cb));
}
PpapiDecryptor::PpapiDecryptor(
const scoped_refptr<PepperPluginInstanceImpl>& plugin_instance,
ContentDecryptorDelegate* plugin_cdm_delegate,
- const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb,
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb,
const base::Closure& destroy_plugin_cb)
: plugin_instance_(plugin_instance),
plugin_cdm_delegate_(plugin_cdm_delegate),
- key_added_cb_(key_added_cb),
- key_error_cb_(key_error_cb),
- key_message_cb_(key_message_cb),
- set_session_id_cb_(set_session_id_cb),
+ session_created_cb_(session_created_cb),
+ session_message_cb_(session_message_cb),
+ session_ready_cb_(session_ready_cb),
+ session_closed_cb_(session_closed_cb),
+ session_error_cb_(session_error_cb),
destroy_plugin_cb_(destroy_plugin_cb),
render_loop_proxy_(base::MessageLoopProxy::current()),
weak_ptr_factory_(this) {
DCHECK(plugin_instance_.get());
- DCHECK(!key_added_cb_.is_null());
- DCHECK(!key_error_cb_.is_null());
- DCHECK(!key_message_cb_.is_null());
- DCHECK(!set_session_id_cb_.is_null());
+ DCHECK(!session_created_cb_.is_null());
+ DCHECK(!session_message_cb_.is_null());
+ DCHECK(!session_ready_cb_.is_null());
+ DCHECK(!session_closed_cb_.is_null());
+ DCHECK(!session_error_cb_.is_null());
DCHECK(!destroy_plugin_cb_.is_null());
weak_this_ = weak_ptr_factory_.GetWeakPtr();
- plugin_cdm_delegate_->SetKeyEventCallbacks(
- base::Bind(&PpapiDecryptor::KeyAdded, weak_this_),
- base::Bind(&PpapiDecryptor::KeyError, weak_this_),
- base::Bind(&PpapiDecryptor::KeyMessage, weak_this_),
- base::Bind(&PpapiDecryptor::SetSessionId, weak_this_));
+ plugin_cdm_delegate_->SetSessionEventCallbacks(
+ base::Bind(&PpapiDecryptor::OnSessionCreated, weak_this_),
+ base::Bind(&PpapiDecryptor::OnSessionMessage, weak_this_),
+ base::Bind(&PpapiDecryptor::OnSessionReady, weak_this_),
+ base::Bind(&PpapiDecryptor::OnSessionClosed, weak_this_),
+ base::Bind(&PpapiDecryptor::OnSessionError, weak_this_));
}
PpapiDecryptor::~PpapiDecryptor() {
@@ -87,15 +93,15 @@ PpapiDecryptor::~PpapiDecryptor() {
destroy_plugin_cb_.Run();
}
-bool PpapiDecryptor::GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length) {
- DVLOG(2) << "GenerateKeyRequest()";
+bool PpapiDecryptor::CreateSession(uint32 reference_id,
+ const std::string& 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_->GenerateKeyRequest(
+ if (!plugin_cdm_delegate_->CreateSession(
reference_id, type, init_data, init_data_length)) {
ReportFailureToCallPlugin(reference_id);
return false;
@@ -104,18 +110,15 @@ bool PpapiDecryptor::GenerateKeyRequest(uint32 reference_id,
return true;
}
-void PpapiDecryptor::AddKey(uint32 reference_id,
- const uint8* key,
- int key_length,
- const uint8* init_data,
- int init_data_length) {
- DVLOG(2) << "AddKey()";
+void PpapiDecryptor::UpdateSession(uint32 reference_id,
+ const uint8* response,
+ int response_length) {
+ DVLOG(2) << __FUNCTION__;
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
- if (!plugin_cdm_delegate_->AddKey(
- reference_id, key, key_length, init_data, init_data_length)) {
+ if (!plugin_cdm_delegate_->UpdateSession(
+ reference_id, response, response_length))
ReportFailureToCallPlugin(reference_id);
- }
if (!new_audio_key_cb_.is_null())
new_audio_key_cb_.Run();
@@ -124,11 +127,11 @@ void PpapiDecryptor::AddKey(uint32 reference_id,
new_video_key_cb_.Run();
}
-void PpapiDecryptor::CancelKeyRequest(uint32 reference_id) {
- DVLOG(2) << "CancelKeyRequest()";
+void PpapiDecryptor::ReleaseSession(uint32 reference_id) {
+ DVLOG(2) << __FUNCTION__;
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
- if (!plugin_cdm_delegate_->CancelKeyRequest(reference_id))
+ if (!plugin_cdm_delegate_->ReleaseSession(reference_id))
ReportFailureToCallPlugin(reference_id);
}
@@ -293,7 +296,7 @@ void PpapiDecryptor::DeinitializeDecoder(StreamType stream_type) {
void PpapiDecryptor::ReportFailureToCallPlugin(uint32 reference_id) {
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
DVLOG(1) << "Failed to call plugin.";
- key_error_cb_.Run(reference_id, kUnknownError, 0);
+ session_error_cb_.Run(reference_id, kUnknownError, 0);
}
void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type,
@@ -313,29 +316,34 @@ void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type,
}
}
-void PpapiDecryptor::KeyAdded(uint32 reference_id) {
+void PpapiDecryptor::OnSessionCreated(uint32 reference_id,
+ const std::string& session_id) {
+ DCHECK(render_loop_proxy_->BelongsToCurrentThread());
+ session_created_cb_.Run(reference_id, session_id);
+}
+
+void PpapiDecryptor::OnSessionMessage(uint32 reference_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url) {
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
- key_added_cb_.Run(reference_id);
+ session_message_cb_.Run(reference_id, message, destination_url);
}
-void PpapiDecryptor::KeyError(uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code) {
+void PpapiDecryptor::OnSessionReady(uint32 reference_id) {
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
- key_error_cb_.Run(reference_id, error_code, system_code);
+ session_ready_cb_.Run(reference_id);
}
-void PpapiDecryptor::KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url) {
+void PpapiDecryptor::OnSessionClosed(uint32 reference_id) {
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
- key_message_cb_.Run(reference_id, message, default_url);
+ session_closed_cb_.Run(reference_id);
}
-void PpapiDecryptor::SetSessionId(uint32 reference_id,
- const std::string& session_id) {
+void PpapiDecryptor::OnSessionError(uint32 reference_id,
+ media::MediaKeys::KeyError error_code,
+ int system_code) {
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
- set_session_id_cb_.Run(reference_id, session_id);
+ session_error_cb_.Run(reference_id, error_code, system_code);
}
} // namespace content
diff --git a/content/renderer/media/crypto/ppapi_decryptor.h b/content/renderer/media/crypto/ppapi_decryptor.h
index 48bf436..875233c 100644
--- a/content/renderer/media/crypto/ppapi_decryptor.h
+++ b/content/renderer/media/crypto/ppapi_decryptor.h
@@ -23,8 +23,8 @@ namespace content {
class ContentDecryptorDelegate;
class PepperPluginInstanceImpl;
-// PpapiDecryptor implements media::Decryptor and forwards all calls to the
-// PluginInstance.
+// PpapiDecryptor implements media::MediaKeys and media::Decryptor and forwards
+// all calls to the PluginInstance.
// This class should always be created & destroyed on the main renderer thread.
class PpapiDecryptor : public media::MediaKeys, public media::Decryptor {
public:
@@ -32,25 +32,24 @@ class PpapiDecryptor : public media::MediaKeys, public media::Decryptor {
// TODO(ddorwin): Remove after updating the delegate.
const std::string& key_system,
const scoped_refptr<PepperPluginInstanceImpl>& plugin_instance,
- const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb,
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb,
const base::Closure& destroy_plugin_cb);
virtual ~PpapiDecryptor();
// media::MediaKeys implementation.
- virtual bool GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length) OVERRIDE;
- virtual void AddKey(uint32 reference_id,
- const uint8* key,
- int key_length,
- const uint8* init_data,
- int init_data_length) OVERRIDE;
- virtual void CancelKeyRequest(uint32 reference_id) OVERRIDE;
+ virtual bool CreateSession(uint32 reference_id,
+ const std::string& type,
+ const uint8* init_data,
+ int init_data_length) OVERRIDE;
+ virtual void UpdateSession(uint32 reference_id,
+ const uint8* response,
+ int response_length) OVERRIDE;
+ virtual void ReleaseSession(uint32 reference_id) OVERRIDE;
virtual Decryptor* GetDecryptor() OVERRIDE;
// media::Decryptor implementation.
@@ -76,25 +75,27 @@ class PpapiDecryptor : public media::MediaKeys, public media::Decryptor {
private:
PpapiDecryptor(const scoped_refptr<PepperPluginInstanceImpl>& plugin_instance,
ContentDecryptorDelegate* plugin_cdm_delegate,
- const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb,
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb,
const base::Closure& destroy_plugin_cb);
void ReportFailureToCallPlugin(uint32 reference_id);
void OnDecoderInitialized(StreamType stream_type, bool success);
- // Callbacks for |plugin_cdm_delegate_| to fire key events.
- void KeyAdded(uint32 reference_id);
- void KeyError(uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code);
- void KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url);
- void SetSessionId(uint32 reference_id, const std::string& session_id);
+ // Callbacks for |plugin_cdm_delegate_| to fire session events.
+ void OnSessionCreated(uint32 reference_id, const std::string& session_id);
+ void OnSessionMessage(uint32 reference_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,
+ media::MediaKeys::KeyError error_code,
+ int system_code);
base::WeakPtr<PpapiDecryptor> weak_this_;
@@ -105,11 +106,12 @@ class PpapiDecryptor : public media::MediaKeys, public media::Decryptor {
ContentDecryptorDelegate* plugin_cdm_delegate_;
- // Callbacks for firing key events.
- media::KeyAddedCB key_added_cb_;
- media::KeyErrorCB key_error_cb_;
- media::KeyMessageCB key_message_cb_;
- media::SetSessionIdCB set_session_id_cb_;
+ // Callbacks for firing session events.
+ media::SessionCreatedCB session_created_cb_;
+ media::SessionMessageCB session_message_cb_;
+ media::SessionReadyCB session_ready_cb_;
+ media::SessionClosedCB session_closed_cb_;
+ media::SessionErrorCB session_error_cb_;
// Called to destroy the helper plugin when this class no longer needs it.
base::Closure destroy_plugin_cb_;
diff --git a/content/renderer/media/crypto/proxy_decryptor.cc b/content/renderer/media/crypto/proxy_decryptor.cc
index 8105669..088decc 100644
--- a/content/renderer/media/crypto/proxy_decryptor.cc
+++ b/content/renderer/media/crypto/proxy_decryptor.cc
@@ -117,7 +117,7 @@ bool ProxyDecryptor::GenerateKeyRequest(const std::string& type,
int init_data_length) {
// Use a unique reference id for this request.
uint32 reference_id = next_reference_id_++;
- if (!media_keys_->GenerateKeyRequest(
+ if (!media_keys_->CreateSession(
reference_id, type, init_data, init_data_length)) {
media_keys_.reset();
return false;
@@ -161,13 +161,12 @@ void ProxyDecryptor::AddKey(const uint8* key,
std::string jwk =
media::GenerateJWKSet(key, key_length, init_data, init_data_length);
DCHECK(!jwk.empty());
- media_keys_->AddKey(reference_id,
- reinterpret_cast<const uint8*>(jwk.data()), jwk.size(),
- NULL, 0);
+ media_keys_->UpdateSession(
+ reference_id, reinterpret_cast<const uint8*>(jwk.data()), jwk.size());
return;
}
- media_keys_->AddKey(reference_id, key, key_length, NULL, 0);
+ media_keys_->UpdateSession(reference_id, key, key_length);
}
void ProxyDecryptor::CancelKeyRequest(const std::string& session_id) {
@@ -181,7 +180,7 @@ void ProxyDecryptor::CancelKeyRequest(const std::string& session_id) {
std::string(), media::MediaKeys::kUnknownError, 0);
}
else {
- media_keys_->CancelKeyRequest(reference_id);
+ media_keys_->ReleaseSession(reference_id);
}
}
@@ -200,39 +199,49 @@ scoped_ptr<media::MediaKeys> ProxyDecryptor::CreateMediaKeys(
media_keys_id_,
frame_url,
#endif // defined(ENABLE_PEPPER_CDMS)
- base::Bind(&ProxyDecryptor::KeyAdded, weak_ptr_factory_.GetWeakPtr()),
- base::Bind(&ProxyDecryptor::KeyError, weak_ptr_factory_.GetWeakPtr()),
- base::Bind(&ProxyDecryptor::KeyMessage, weak_ptr_factory_.GetWeakPtr()),
- base::Bind(&ProxyDecryptor::SetSessionId,
+ base::Bind(&ProxyDecryptor::OnSessionCreated,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&ProxyDecryptor::OnSessionMessage,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&ProxyDecryptor::OnSessionReady,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&ProxyDecryptor::OnSessionClosed,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::Bind(&ProxyDecryptor::OnSessionError,
weak_ptr_factory_.GetWeakPtr()));
}
-void ProxyDecryptor::KeyAdded(uint32 reference_id) {
- // Assumes that SetSessionId() has been called before this.
- key_added_cb_.Run(LookupSessionId(reference_id));
+void ProxyDecryptor::OnSessionCreated(uint32 reference_id,
+ const std::string& session_id) {
+ // Due to heartbeat messages, OnSessionCreated() can get called multiple
+ // times.
+ SessionIdMap::iterator it = sessions_.find(reference_id);
+ DCHECK(it == sessions_.end() || it->second == session_id);
+ if (it == sessions_.end())
+ sessions_[reference_id] = session_id;
}
-void ProxyDecryptor::KeyError(uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code) {
- // Assumes that SetSessionId() has been called before this.
- key_error_cb_.Run(LookupSessionId(reference_id), error_code, system_code);
+void ProxyDecryptor::OnSessionMessage(uint32 reference_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url) {
+ // Assumes that OnSessionCreated() has been called before this.
+ key_message_cb_.Run(LookupSessionId(reference_id), message, destination_url);
}
-void ProxyDecryptor::KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url) {
- // Assumes that SetSessionId() has been called before this.
- key_message_cb_.Run(LookupSessionId(reference_id), message, default_url);
+void ProxyDecryptor::OnSessionReady(uint32 reference_id) {
+ // Assumes that OnSessionCreated() has been called before this.
+ key_added_cb_.Run(LookupSessionId(reference_id));
}
-void ProxyDecryptor::SetSessionId(uint32 reference_id,
- const std::string& session_id) {
- // Due to heartbeat messages, SetSessionId() can get called multiple times.
- SessionIdMap::iterator it = sessions_.find(reference_id);
- DCHECK(it == sessions_.end() || it->second == session_id);
- if (it == sessions_.end())
- sessions_[reference_id] = session_id;
+void ProxyDecryptor::OnSessionClosed(uint32 reference_id) {
+ // No closed event in EME v0.1b.
+}
+
+void ProxyDecryptor::OnSessionError(uint32 reference_id,
+ media::MediaKeys::KeyError error_code,
+ int system_code) {
+ // Assumes that OnSessionCreated() has been called before this.
+ key_error_cb_.Run(LookupSessionId(reference_id), error_code, system_code);
}
uint32 ProxyDecryptor::LookupReferenceId(const std::string& session_id) {
diff --git a/content/renderer/media/crypto/proxy_decryptor.h b/content/renderer/media/crypto/proxy_decryptor.h
index 9062b4e..3ffec58 100644
--- a/content/renderer/media/crypto/proxy_decryptor.h
+++ b/content/renderer/media/crypto/proxy_decryptor.h
@@ -93,15 +93,16 @@ class ProxyDecryptor {
scoped_ptr<media::MediaKeys> CreateMediaKeys(const std::string& key_system,
const GURL& frame_url);
- // Callbacks for firing key events.
- void KeyAdded(uint32 reference_id);
- void KeyError(uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code);
- void KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url);
- void SetSessionId(uint32 reference_id, const std::string& session_id);
+ // Callbacks for firing session events.
+ void OnSessionCreated(uint32 reference_id, const std::string& session_id);
+ void OnSessionMessage(uint32 reference_id,
+ const std::vector<uint8>& message,
+ const std::string& default_url);
+ void OnSessionReady(uint32 reference_id);
+ void OnSessionClosed(uint32 reference_id);
+ void OnSessionError(uint32 reference_id,
+ media::MediaKeys::KeyError error_code,
+ int system_code);
// Helper function to determine reference_id for the provided |session_id|.
uint32 LookupReferenceId(const std::string& session_id);
diff --git a/content/renderer/media/webcontentdecryptionmodule_impl.cc b/content/renderer/media/webcontentdecryptionmodule_impl.cc
index 4878d96..2c363ce 100644
--- a/content/renderer/media/webcontentdecryptionmodule_impl.cc
+++ b/content/renderer/media/webcontentdecryptionmodule_impl.cc
@@ -41,15 +41,16 @@ class ReferenceIdAdapter {
private:
typedef std::map<uint32, WebContentDecryptionModuleSessionImpl*> SessionMap;
- // Callbacks for firing key events.
- void KeyAdded(uint32 reference_id);
- void KeyError(uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code);
- void KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& destination_url);
- void SetSessionId(uint32 reference_id, const std::string& session_id);
+ // Callbacks for firing session events.
+ void OnSessionCreated(uint32 reference_id, const std::string& session_id);
+ void OnSessionMessage(uint32 reference_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,
+ media::MediaKeys::KeyError error_code,
+ int system_code);
// Helper function of the callbacks.
WebContentDecryptionModuleSessionImpl* GetSession(uint32 reference_id);
@@ -90,10 +91,11 @@ bool ReferenceIdAdapter::Initialize(const std::string& key_system,
// TODO(ddorwin): Get the URL for the frame containing the MediaKeys.
GURL(),
#endif // defined(ENABLE_PEPPER_CDMS)
- base::Bind(&ReferenceIdAdapter::KeyAdded, weak_this),
- base::Bind(&ReferenceIdAdapter::KeyError, weak_this),
- base::Bind(&ReferenceIdAdapter::KeyMessage, weak_this),
- base::Bind(&ReferenceIdAdapter::SetSessionId, weak_this));
+ base::Bind(&ReferenceIdAdapter::OnSessionCreated, weak_this),
+ base::Bind(&ReferenceIdAdapter::OnSessionMessage, weak_this),
+ base::Bind(&ReferenceIdAdapter::OnSessionReady, weak_this),
+ base::Bind(&ReferenceIdAdapter::OnSessionClosed, weak_this),
+ base::Bind(&ReferenceIdAdapter::OnSessionError, weak_this));
if (!created_media_keys)
return false;
@@ -113,25 +115,29 @@ void ReferenceIdAdapter::RemoveSession(uint32 reference_id) {
sessions_.erase(reference_id);
}
-void ReferenceIdAdapter::KeyAdded(uint32 reference_id) {
- GetSession(reference_id)->KeyAdded();
+void ReferenceIdAdapter::OnSessionCreated(uint32 reference_id,
+ const std::string& session_id) {
+ GetSession(reference_id)->OnSessionCreated(session_id);
}
-void ReferenceIdAdapter::KeyError(uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code) {
- GetSession(reference_id)->KeyError(error_code, system_code);
+void ReferenceIdAdapter::OnSessionMessage(uint32 reference_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url) {
+ GetSession(reference_id)->OnSessionMessage(message, destination_url);
}
-void ReferenceIdAdapter::KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& destination_url) {
- GetSession(reference_id)->KeyMessage(message, destination_url);
+void ReferenceIdAdapter::OnSessionReady(uint32 reference_id) {
+ GetSession(reference_id)->OnSessionReady();
}
-void ReferenceIdAdapter::SetSessionId(uint32 reference_id,
- const std::string& session_id) {
- GetSession(reference_id)->SetSessionId(session_id);
+void ReferenceIdAdapter::OnSessionClosed(uint32 reference_id) {
+ GetSession(reference_id)->OnSessionClosed();
+}
+
+void ReferenceIdAdapter::OnSessionError(uint32 reference_id,
+ media::MediaKeys::KeyError error_code,
+ int system_code) {
+ GetSession(reference_id)->OnSessionError(error_code, system_code);
}
WebContentDecryptionModuleSessionImpl* ReferenceIdAdapter::GetSession(
diff --git a/content/renderer/media/webcontentdecryptionmodulesession_impl.cc b/content/renderer/media/webcontentdecryptionmodulesession_impl.cc
index fb71437..6b30469 100644
--- a/content/renderer/media/webcontentdecryptionmodulesession_impl.cc
+++ b/content/renderer/media/webcontentdecryptionmodulesession_impl.cc
@@ -43,40 +43,37 @@ void WebContentDecryptionModuleSessionImpl::generateKeyRequest(
// Chromium only supports ASCII MIME types.
if (!IsStringASCII(mime_type)) {
NOTREACHED();
- KeyError(media::MediaKeys::kUnknownError, 0);
+ OnSessionError(media::MediaKeys::kUnknownError, 0);
return;
}
- media_keys_->GenerateKeyRequest(
+ media_keys_->CreateSession(
reference_id_, UTF16ToASCII(mime_type), init_data, init_data_length);
}
-void WebContentDecryptionModuleSessionImpl::update(const uint8* key,
- size_t key_length) {
- DCHECK(key);
- media_keys_->AddKey(reference_id_, key, key_length, NULL, 0);
+void WebContentDecryptionModuleSessionImpl::update(const uint8* response,
+ size_t response_length) {
+ DCHECK(response);
+ media_keys_->UpdateSession(reference_id_, response, response_length);
}
void WebContentDecryptionModuleSessionImpl::close() {
- // Detach from the CDM.
- // TODO(jrummell): We shouldn't detach here because closed and other events
- // may be fired in the latest version of the spec. http://crbug.com/309235
- if (!session_closed_cb_.is_null())
- base::ResetAndReturn(&session_closed_cb_).Run(reference_id_);
-}
-
-void WebContentDecryptionModuleSessionImpl::KeyAdded() {
- client_->keyAdded();
+ media_keys_->ReleaseSession(reference_id_);
}
-void WebContentDecryptionModuleSessionImpl::KeyError(
- media::MediaKeys::KeyError error_code,
- int system_code) {
- client_->keyError(static_cast<Client::MediaKeyErrorCode>(error_code),
- system_code);
+void WebContentDecryptionModuleSessionImpl::OnSessionCreated(
+ const std::string& session_id) {
+ // Due to heartbeat messages, OnSessionCreated() can get called multiple
+ // times.
+ // TODO(jrummell): Once all CDMs are updated to support reference ids,
+ // OnSessionCreated() should only be called once, and the second check can be
+ // removed.
+ DCHECK(session_id_.empty() || session_id_ == session_id)
+ << "Session ID may not be changed once set.";
+ session_id_ = session_id;
}
-void WebContentDecryptionModuleSessionImpl::KeyMessage(
+void WebContentDecryptionModuleSessionImpl::OnSessionMessage(
const std::vector<uint8>& message,
const std::string& destination_url) {
client_->keyMessage(message.empty() ? NULL : &message[0],
@@ -84,15 +81,22 @@ void WebContentDecryptionModuleSessionImpl::KeyMessage(
GURL(destination_url));
}
-void WebContentDecryptionModuleSessionImpl::SetSessionId(
- const std::string& session_id) {
- // Due to heartbeat messages, SetSessionId() can get called multiple times.
- // TODO(jrummell): Once all CDMs are updated to support reference ids,
- // SetSessionId() should only be called once, and the second check can be
- // removed.
- DCHECK(session_id_.empty() || session_id_ == session_id)
- << "Session ID may not be changed once set.";
- session_id_ = session_id;
+void WebContentDecryptionModuleSessionImpl::OnSessionReady() {
+ // TODO(jrummell): Blink APIs need to be updated to the new EME API. For now,
+ // convert the response to the old v0.1b API.
+ client_->keyAdded();
+}
+
+void WebContentDecryptionModuleSessionImpl::OnSessionClosed() {
+ if (!session_closed_cb_.is_null())
+ base::ResetAndReturn(&session_closed_cb_).Run(reference_id_);
+}
+
+void WebContentDecryptionModuleSessionImpl::OnSessionError(
+ media::MediaKeys::KeyError error_code,
+ int system_code) {
+ client_->keyError(static_cast<Client::MediaKeyErrorCode>(error_code),
+ system_code);
}
} // namespace content
diff --git a/content/renderer/media/webcontentdecryptionmodulesession_impl.h b/content/renderer/media/webcontentdecryptionmodulesession_impl.h
index d920e2d..68527d0 100644
--- a/content/renderer/media/webcontentdecryptionmodulesession_impl.h
+++ b/content/renderer/media/webcontentdecryptionmodulesession_impl.h
@@ -36,7 +36,7 @@ class WebContentDecryptionModuleSessionImpl
virtual void generateKeyRequest(const blink::WebString& mime_type,
const uint8* init_data,
size_t init_data_length) OVERRIDE;
- virtual void update(const uint8* key, size_t key_length) OVERRIDE;
+ virtual void update(const uint8* response, size_t response_length) OVERRIDE;
virtual void close() OVERRIDE;
const std::string& session_id() const { return session_id_; }
@@ -44,11 +44,12 @@ class WebContentDecryptionModuleSessionImpl
uint32 reference_id() const { return reference_id_; }
// Callbacks.
- void KeyAdded();
- void KeyError(media::MediaKeys::KeyError error_code, int system_code);
- void KeyMessage(const std::vector<uint8>& message,
- const std::string& destination_url);
- void SetSessionId(const std::string& session_id);
+ void OnSessionCreated(const std::string& session_id);
+ void OnSessionMessage(const std::vector<uint8>& message,
+ const std::string& destination_url);
+ void OnSessionReady();
+ void OnSessionClosed();
+ void OnSessionError(media::MediaKeys::KeyError error_code, int system_code);
private:
// Non-owned pointers.
@@ -58,7 +59,7 @@ class WebContentDecryptionModuleSessionImpl
SessionClosedCB session_closed_cb_;
// Session ID is the user visible ID for this session generated by the CDM.
- // This value is not set until the CDM calls SetSessionId().
+ // This value is not set until the CDM calls OnSessionCreated().
std::string session_id_;
// Reference ID is used to uniquely track this object so that CDM callbacks
diff --git a/content/renderer/pepper/content_decryptor_delegate.cc b/content/renderer/pepper/content_decryptor_delegate.cc
index f1b4e96..6666f6e 100644
--- a/content/renderer/pepper/content_decryptor_delegate.cc
+++ b/content/renderer/pepper/content_decryptor_delegate.cc
@@ -272,26 +272,28 @@ void ContentDecryptorDelegate::Initialize(const std::string& key_system) {
StringVar::StringToPPVar(key_system_));
}
-void ContentDecryptorDelegate::SetKeyEventCallbacks(
- const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb) {
- key_added_cb_ = key_added_cb;
- key_error_cb_ = key_error_cb;
- key_message_cb_ = key_message_cb;
- set_session_id_cb_ = set_session_id_cb;
+void ContentDecryptorDelegate::SetSessionEventCallbacks(
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb) {
+ session_created_cb_ = session_created_cb;
+ session_message_cb_ = session_message_cb;
+ session_ready_cb_ = session_ready_cb;
+ session_closed_cb_ = session_closed_cb;
+ session_error_cb_ = session_error_cb;
}
-bool ContentDecryptorDelegate::GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length) {
+bool ContentDecryptorDelegate::CreateSession(uint32 reference_id,
+ const std::string& type,
+ const uint8* init_data,
+ int init_data_length) {
PP_Var init_data_array =
PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
init_data_length, init_data);
- plugin_decryption_interface_->GenerateKeyRequest(
+ plugin_decryption_interface_->CreateSession(
pp_instance_,
reference_id,
StringVar::StringToPPVar(type),
@@ -299,25 +301,19 @@ bool ContentDecryptorDelegate::GenerateKeyRequest(uint32 reference_id,
return true;
}
-bool ContentDecryptorDelegate::AddKey(uint32 reference_id,
- const uint8* key,
- int key_length,
- const uint8* init_data,
- int init_data_length) {
- PP_Var key_array =
- PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(key_length,
- key);
- PP_Var init_data_array =
+bool ContentDecryptorDelegate::UpdateSession(uint32 reference_id,
+ const uint8* response,
+ int response_length) {
+ PP_Var response_array =
PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
- init_data_length, init_data);
-
- plugin_decryption_interface_->AddKey(
- pp_instance_, reference_id, key_array, init_data_array);
+ response_length, response);
+ plugin_decryption_interface_->UpdateSession(
+ pp_instance_, reference_id, response_array);
return true;
}
-bool ContentDecryptorDelegate::CancelKeyRequest(uint32 reference_id) {
- plugin_decryption_interface_->CancelKeyRequest(pp_instance_, reference_id);
+bool ContentDecryptorDelegate::ReleaseSession(uint32 reference_id) {
+ plugin_decryption_interface_->ReleaseSession(pp_instance_, reference_id);
return true;
}
@@ -594,21 +590,28 @@ bool ContentDecryptorDelegate::DecryptAndDecodeVideo(
return true;
}
-void ContentDecryptorDelegate::KeyAdded(uint32 reference_id) {
- if (key_added_cb_.is_null())
+void ContentDecryptorDelegate::OnSessionCreated(uint32 reference_id,
+ PP_Var session_id_var) {
+ if (session_created_cb_.is_null())
return;
- key_added_cb_.Run(reference_id);
+ StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
+
+ if (!session_id_string) {
+ OnSessionError(reference_id, media::MediaKeys::kUnknownError, 0);
+ return;
+ }
+
+ session_created_cb_.Run(reference_id, session_id_string->value());
}
-void ContentDecryptorDelegate::KeyMessage(uint32 reference_id,
- PP_Var message_var,
- PP_Var default_url_var) {
- if (key_message_cb_.is_null())
+void ContentDecryptorDelegate::OnSessionMessage(uint32 reference_id,
+ PP_Var message_var,
+ PP_Var default_url_var) {
+ if (session_message_cb_.is_null())
return;
- ArrayBufferVar* message_array_buffer =
- ArrayBufferVar::FromPPVar(message_var);
+ ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var);
std::vector<uint8> message;
if (message_array_buffer) {
@@ -619,37 +622,36 @@ void ContentDecryptorDelegate::KeyMessage(uint32 reference_id,
StringVar* default_url_string = StringVar::FromPPVar(default_url_var);
if (!default_url_string) {
- key_error_cb_.Run(reference_id, media::MediaKeys::kUnknownError, 0);
+ OnSessionError(reference_id, media::MediaKeys::kUnknownError, 0);
return;
}
- key_message_cb_.Run(reference_id, message, default_url_string->value());
+ session_message_cb_.Run(reference_id, message, default_url_string->value());
}
-void ContentDecryptorDelegate::KeyError(uint32 reference_id,
- int32_t media_error,
- int32_t system_code) {
- if (key_error_cb_.is_null())
+void ContentDecryptorDelegate::OnSessionReady(uint32 reference_id) {
+ if (session_ready_cb_.is_null())
return;
- key_error_cb_.Run(reference_id,
- static_cast<media::MediaKeys::KeyError>(media_error),
- system_code);
+ session_ready_cb_.Run(reference_id);
}
-void ContentDecryptorDelegate::SetSessionId(uint32 reference_id,
- PP_Var session_id_var) {
- if (set_session_id_cb_.is_null())
+void ContentDecryptorDelegate::OnSessionClosed(uint32 reference_id) {
+ if (session_closed_cb_.is_null())
return;
- StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
+ session_closed_cb_.Run(reference_id);
+}
- if (!session_id_string) {
- key_error_cb_.Run(reference_id, media::MediaKeys::kUnknownError, 0);
+void ContentDecryptorDelegate::OnSessionError(uint32 reference_id,
+ int32_t media_error,
+ int32_t system_code) {
+ if (session_error_cb_.is_null())
return;
- }
- set_session_id_cb_.Run(reference_id, session_id_string->value());
+ session_error_cb_.Run(reference_id,
+ static_cast<media::MediaKeys::KeyError>(media_error),
+ system_code);
}
void ContentDecryptorDelegate::DecoderInitializeDone(
diff --git a/content/renderer/pepper/content_decryptor_delegate.h b/content/renderer/pepper/content_decryptor_delegate.h
index 6d0962d..7e43c2b 100644
--- a/content/renderer/pepper/content_decryptor_delegate.h
+++ b/content/renderer/pepper/content_decryptor_delegate.h
@@ -41,22 +41,22 @@ class ContentDecryptorDelegate {
void Initialize(const std::string& key_system);
- void SetKeyEventCallbacks(const media::KeyAddedCB& key_added_cb,
- const media::KeyErrorCB& key_error_cb,
- const media::KeyMessageCB& key_message_cb,
- const media::SetSessionIdCB& set_session_id_cb);
+ void SetSessionEventCallbacks(
+ const media::SessionCreatedCB& session_created_cb,
+ const media::SessionMessageCB& session_message_cb,
+ const media::SessionReadyCB& session_ready_cb,
+ const media::SessionClosedCB& session_closed_cb,
+ const media::SessionErrorCB& session_error_cb);
// Provides access to PPP_ContentDecryptor_Private.
- bool GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length);
- bool AddKey(uint32 reference_id,
- const uint8* key,
- int key_length,
- const uint8* init_data,
- int init_data_length);
- bool CancelKeyRequest(uint32 reference_id);
+ bool CreateSession(uint32 reference_id,
+ const std::string& type,
+ const uint8* init_data,
+ int init_data_length);
+ bool UpdateSession(uint32 reference_id,
+ const uint8* response,
+ int response_length);
+ bool ReleaseSession(uint32 reference_id);
bool Decrypt(media::Decryptor::StreamType stream_type,
const scoped_refptr<media::DecoderBuffer>& encrypted_buffer,
const media::Decryptor::DecryptCB& decrypt_cb);
@@ -80,14 +80,15 @@ class ContentDecryptorDelegate {
const media::Decryptor::VideoDecodeCB& video_decode_cb);
// PPB_ContentDecryptor_Private dispatching methods.
- void KeyAdded(uint32 reference_id);
- void KeyMessage(uint32 reference_id,
- PP_Var message,
- PP_Var default_url);
- void KeyError(uint32 reference_id,
- int32_t media_error,
- int32_t system_code);
- void SetSessionId(uint32 reference_id, PP_Var session_id_var);
+ void OnSessionCreated(uint32 reference_id, PP_Var session_id_var);
+ void OnSessionMessage(uint32 reference_id,
+ PP_Var message,
+ PP_Var destination_url);
+ void OnSessionReady(uint32 reference_id);
+ void OnSessionClosed(uint32 reference_id);
+ void OnSessionError(uint32 reference_id,
+ int32_t media_error,
+ int32_t system_code);
void DeliverBlock(PP_Resource decrypted_block,
const PP_DecryptedBlockInfo* block_info);
void DecoderInitializeDone(PP_DecryptorStreamType decoder_type,
@@ -138,11 +139,12 @@ class ContentDecryptorDelegate {
// TODO(ddorwin): Remove after updating the Pepper API to not use key system.
std::string key_system_;
- // Callbacks for firing key events.
- media::KeyAddedCB key_added_cb_;
- media::KeyErrorCB key_error_cb_;
- media::KeyMessageCB key_message_cb_;
- media::SetSessionIdCB set_session_id_cb_;
+ // Callbacks for firing session events.
+ media::SessionCreatedCB session_created_cb_;
+ media::SessionMessageCB session_message_cb_;
+ media::SessionReadyCB session_ready_cb_;
+ media::SessionClosedCB session_closed_cb_;
+ media::SessionErrorCB session_error_cb_;
gfx::Size natural_size_;
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
index 730361f..06b1dde 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -2262,30 +2262,36 @@ PP_Var PepperPluginInstanceImpl::GetDefaultCharSet(PP_Instance instance) {
// PPP_ContentDecryptor_Private calls made on |content_decryptor_delegate_|.
// Therefore, |content_decryptor_delegate_| must have been initialized when
// the following methods are called.
-void PepperPluginInstanceImpl::KeyAdded(PP_Instance instance,
- uint32_t reference_id) {
- content_decryptor_delegate_->KeyAdded(reference_id);
+void PepperPluginInstanceImpl::SessionCreated(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var session_id_var) {
+ content_decryptor_delegate_->OnSessionCreated(reference_id, session_id_var);
}
-void PepperPluginInstanceImpl::KeyMessage(PP_Instance instance,
- uint32_t reference_id,
- PP_Var message_var,
- PP_Var default_url_var) {
- content_decryptor_delegate_->KeyMessage(
- reference_id, message_var, default_url_var);
+void PepperPluginInstanceImpl::SessionMessage(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var message_var,
+ PP_Var destination_url) {
+ content_decryptor_delegate_->OnSessionMessage(
+ reference_id, message_var, destination_url);
}
-void PepperPluginInstanceImpl::KeyError(PP_Instance instance,
- uint32_t reference_id,
- int32_t media_error,
- int32_t system_code) {
- content_decryptor_delegate_->KeyError(reference_id, media_error, system_code);
+void PepperPluginInstanceImpl::SessionReady(PP_Instance instance,
+ uint32_t reference_id) {
+ content_decryptor_delegate_->OnSessionReady(reference_id);
}
-void PepperPluginInstanceImpl::SetSessionId(PP_Instance instance,
+void PepperPluginInstanceImpl::SessionClosed(PP_Instance instance,
+ uint32_t reference_id) {
+ content_decryptor_delegate_->OnSessionClosed(reference_id);
+}
+
+void PepperPluginInstanceImpl::SessionError(PP_Instance instance,
uint32_t reference_id,
- PP_Var session_id_var) {
- content_decryptor_delegate_->SetSessionId(reference_id, session_id_var);
+ int32_t media_error,
+ int32_t system_code) {
+ content_decryptor_delegate_->OnSessionError(
+ reference_id, media_error, system_code);
}
void PepperPluginInstanceImpl::DeliverBlock(
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h
index 58c5a72..3e3e24e 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.h
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.h
@@ -445,19 +445,21 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
PP_URLComponents_Dev* components) OVERRIDE;
// PPB_ContentDecryptor_Private implementation.
- virtual void KeyAdded(PP_Instance instance,
- uint32_t reference_id) OVERRIDE;
- virtual void KeyMessage(PP_Instance instance,
- uint32_t reference_id,
- PP_Var message,
- PP_Var default_url) OVERRIDE;
- virtual void KeyError(PP_Instance instance,
- uint32_t reference_id,
- int32_t media_error,
- int32_t system_code) OVERRIDE;
- virtual void SetSessionId(PP_Instance instance,
+ virtual void SessionCreated(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var session_id_var) OVERRIDE;
+ virtual void SessionMessage(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var message,
+ PP_Var destination_url) OVERRIDE;
+ virtual void SessionReady(PP_Instance instance,
+ uint32_t reference_id) OVERRIDE;
+ virtual void SessionClosed(PP_Instance instance,
+ uint32_t reference_id) OVERRIDE;
+ virtual void SessionError(PP_Instance instance,
uint32_t reference_id,
- PP_Var session_id_var) OVERRIDE;
+ int32_t media_error,
+ int32_t system_code) OVERRIDE;
virtual void DeliverBlock(PP_Instance instance,
PP_Resource decrypted_block,
const PP_DecryptedBlockInfo* block_info) OVERRIDE;
diff --git a/media/base/android/media_drm_bridge.cc b/media/base/android/media_drm_bridge.cc
index 8b5d59e..a098249 100644
--- a/media/base/android/media_drm_bridge.cc
+++ b/media/base/android/media_drm_bridge.cc
@@ -236,10 +236,10 @@ MediaDrmBridge::~MediaDrmBridge() {
Java_MediaDrmBridge_release(env, j_media_drm_.obj());
}
-bool MediaDrmBridge::GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length) {
+bool MediaDrmBridge::CreateSession(uint32 reference_id,
+ const std::string& type,
+ const uint8* init_data,
+ int init_data_length) {
std::vector<uint8> pssh_data;
if (!GetPsshData(init_data, init_data_length, scheme_uuid_, &pssh_data))
return false;
@@ -254,20 +254,21 @@ bool MediaDrmBridge::GenerateKeyRequest(uint32 reference_id,
return true;
}
-void MediaDrmBridge::AddKey(uint32 reference_id,
- const uint8* key, int key_length,
- const uint8* init_data, int init_data_length) {
+void MediaDrmBridge::UpdateSession(uint32 reference_id,
+ const uint8* response,
+ int response_length) {
DVLOG(1) << __FUNCTION__;
JNIEnv* env = AttachCurrentThread();
- ScopedJavaLocalRef<jbyteArray> j_key_data =
- base::android::ToJavaByteArray(env, key, key_length);
+ ScopedJavaLocalRef<jbyteArray> j_response =
+ base::android::ToJavaByteArray(env, response, response_length);
ScopedJavaLocalRef<jstring> j_session_id =
ConvertUTF8ToJavaString(env, LookupSessionId(reference_id));
+ // TODO(jrummell): Update Android names to match new functionality.
Java_MediaDrmBridge_addKey(
- env, j_media_drm_.obj(), j_session_id.obj(), j_key_data.obj());
+ env, j_media_drm_.obj(), j_session_id.obj(), j_response.obj());
}
-void MediaDrmBridge::CancelKeyRequest(uint32 reference_id) {
+void MediaDrmBridge::ReleaseSession(uint32 reference_id) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jstring> j_session_id =
ConvertUTF8ToJavaString(env, LookupSessionId(reference_id));
@@ -308,22 +309,22 @@ void MediaDrmBridge::OnKeyMessage(JNIEnv* env,
JavaByteArrayToByteVector(env, j_message, &message);
std::string destination_url = ConvertJavaStringToUTF8(env, j_destination_url);
- manager_->OnSetSessionId(media_keys_id_, reference_id, session_id);
- manager_->OnKeyMessage(
+ manager_->OnSessionCreated(media_keys_id_, reference_id, session_id);
+ manager_->OnSessionMessage(
media_keys_id_, reference_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_->OnKeyAdded(media_keys_id_, reference_id);
+ manager_->OnSessionReady(media_keys_id_, reference_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);
- manager_->OnKeyError(
+ manager_->OnSessionError(
media_keys_id_, reference_id, MediaKeys::kUnknownError, 0);
}
diff --git a/media/base/android/media_drm_bridge.h b/media/base/android/media_drm_bridge.h
index 2443f65..7581291 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 GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length) OVERRIDE;
- virtual void AddKey(uint32 reference_id,
- const uint8* key, int key_length,
- const uint8* init_data, int init_data_length) OVERRIDE;
- virtual void CancelKeyRequest(uint32 reference_id) OVERRIDE;
+ virtual bool CreateSession(uint32 reference_id,
+ const std::string& type,
+ const uint8* init_data,
+ int init_data_length) OVERRIDE;
+ virtual void UpdateSession(uint32 reference_id,
+ const uint8* response,
+ int response_length) OVERRIDE;
+ virtual void ReleaseSession(uint32 reference_id) OVERRIDE;
// Returns a MediaCrypto object if it's already created. Returns a null object
// otherwise.
diff --git a/media/base/android/media_player_manager.h b/media/base/android/media_player_manager.h
index ec15b35..ce4a196 100644
--- a/media/base/android/media_player_manager.h
+++ b/media/base/android/media_player_manager.h
@@ -87,30 +87,33 @@ class MEDIA_EXPORT MediaPlayerManager {
// Called by the player to get a hardware protected surface.
virtual void OnProtectedSurfaceRequested(int player_id) = 0;
- // TODO(xhwang): The following four methods needs to be decoupled from
- // MediaPlayerManager to support the W3C Working Draft version of the EME
- // spec. http://crbug.com/315312
-
- // Called when MediaDrmBridge wants to send a KeyAdded.
- virtual void OnKeyAdded(int media_keys_id,
- uint32 reference_id) = 0;
-
- // Called when MediaDrmBridge wants to send a KeyError.
- virtual void OnKeyError(int media_keys_id,
- uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code) = 0;
-
- // Called when MediaDrmBridge wants to send a KeyMessage.
- virtual void OnKeyMessage(int media_keys_id,
- uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& destination_url) = 0;
+ // The following five methods are related to EME.
+ // TODO(xhwang): These methods needs to be decoupled from MediaPlayerManager
+ // to support the W3C Working Draft version of the EME spec.
+ // http://crbug.com/315312
// Called when MediaDrmBridge determines a SessionId.
- virtual void OnSetSessionId(int media_keys_id,
+ virtual void OnSessionCreated(int media_keys_id,
+ uint32 reference_id,
+ const std::string& session_id) = 0;
+
+ // Called when MediaDrmBridge wants to send a Message event.
+ virtual void OnSessionMessage(int media_keys_id,
+ uint32 reference_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;
+
+ // Called when MediaDrmBridge wants to send a Closed event.
+ virtual void OnSessionClosed(int media_keys_id, uint32 reference_id) = 0;
+
+ // Called when MediaDrmBridge wants to send an Error event.
+ virtual void OnSessionError(int media_keys_id,
uint32 reference_id,
- const std::string& session_id) = 0;
+ media::MediaKeys::KeyError error_code,
+ int system_code) = 0;
};
} // namespace media
diff --git a/media/base/android/media_source_player_unittest.cc b/media/base/android/media_source_player_unittest.cc
index b7572f9..1da6641 100644
--- a/media/base/android/media_source_player_unittest.cc
+++ b/media/base/android/media_source_player_unittest.cc
@@ -73,19 +73,21 @@ class MockMediaPlayerManager : public MediaPlayerManager {
return NULL;
}
virtual void OnProtectedSurfaceRequested(int player_id) OVERRIDE {}
- virtual void OnKeyAdded(int key_id,
- uint32 reference_id) OVERRIDE {}
- virtual void OnKeyError(int key_id,
- uint32 reference_id,
- MediaKeys::KeyError error_code,
- int system_code) OVERRIDE {}
- virtual void OnKeyMessage(int key_id,
- uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& destination_url) OVERRIDE {}
- virtual void OnSetSessionId(int media_keys_id,
+ virtual void OnSessionCreated(int media_keys_id,
+ uint32 reference_id,
+ const std::string& session_id) OVERRIDE {}
+ virtual void OnSessionMessage(int media_keys_id,
+ uint32 reference_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 OnSessionError(int media_keys_id,
uint32 reference_id,
- const std::string& session_id) OVERRIDE {}
+ media::MediaKeys::KeyError error_code,
+ int system_code) OVERRIDE {}
bool playback_completed() const {
return playback_completed_;
diff --git a/media/base/media_keys.h b/media/base/media_keys.h
index 743d714..a17fc85 100644
--- a/media/base/media_keys.h
+++ b/media/base/media_keys.h
@@ -44,25 +44,21 @@ class MEDIA_EXPORT MediaKeys {
// Generates a key request with the |type| and |init_data| provided.
// Returns true if generating key request succeeded, false otherwise.
- // Note: AddKey() and CancelKeyRequest() should only be called after
- // GenerateKeyRequest() returns true.
- virtual bool GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length) = 0;
-
- // Adds a |key| to the session. The |key| is not limited to a decryption
- // key. It can be any data that the key system accepts, such as a license.
- // If multiple calls of this function set different keys for the same
- // key ID, the older key will be replaced by the newer key.
- virtual void AddKey(uint32 reference_id,
- const uint8* key,
- int key_length,
- const uint8* init_data,
- int init_data_length) = 0;
-
- // Cancels the key request specified by |reference_id|.
- virtual void CancelKeyRequest(uint32 reference_id) = 0;
+ // 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,
+ 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,
+ const uint8* response,
+ int response_length) = 0;
+
+ // Releases the session specified by |reference_id|.
+ virtual void ReleaseSession(uint32 reference_id) = 0;
// Gets the Decryptor object associated with the MediaKeys. Returns NULL if
// no Decryptor object is associated. The returned object is only guaranteed
@@ -74,22 +70,23 @@ class MEDIA_EXPORT MediaKeys {
};
// Key event callbacks. See the spec for details:
-// http://dvcs.w3.org/hg/html-media/raw-file/eme-v0.1b/encrypted-media/encrypted-media.html#event-summary
-typedef base::Callback<void(uint32 reference_id)> KeyAddedCB;
-
-typedef base::Callback<void(uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code)> KeyErrorCB;
+// 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)>
+ SessionCreatedCB;
typedef base::Callback<void(uint32 reference_id,
const std::vector<uint8>& message,
- const std::string& default_url)> KeyMessageCB;
+ const std::string& destination_url)>
+ SessionMessageCB;
+
+typedef base::Callback<void(uint32 reference_id)> SessionReadyCB;
+
+typedef base::Callback<void(uint32 reference_id)> SessionClosedCB;
-// Called by the CDM when it generates the |session_id| as a result of a
-// GenerateKeyRequest() call. Must be called before KeyMessageCB or KeyAddedCB
-// events are fired.
typedef base::Callback<void(uint32 reference_id,
- const std::string& session_id)> SetSessionIdCB;
+ media::MediaKeys::KeyError error_code,
+ int system_code)> SessionErrorCB;
+
} // namespace media
#endif // MEDIA_BASE_MEDIA_KEYS_H_
diff --git a/media/cdm/aes_decryptor.cc b/media/cdm/aes_decryptor.cc
index 10f0499..ee4b987 100644
--- a/media/cdm/aes_decryptor.cc
+++ b/media/cdm/aes_decryptor.cc
@@ -142,23 +142,25 @@ static scoped_refptr<DecoderBuffer> DecryptData(const DecoderBuffer& input,
return output;
}
-AesDecryptor::AesDecryptor(const KeyAddedCB& key_added_cb,
- const KeyErrorCB& key_error_cb,
- const KeyMessageCB& key_message_cb,
- const SetSessionIdCB& set_session_id_cb)
- : key_added_cb_(key_added_cb),
- key_error_cb_(key_error_cb),
- key_message_cb_(key_message_cb),
- set_session_id_cb_(set_session_id_cb) {}
+AesDecryptor::AesDecryptor(const SessionCreatedCB& session_created_cb,
+ const SessionMessageCB& session_message_cb,
+ const SessionReadyCB& session_ready_cb,
+ const SessionClosedCB& session_closed_cb,
+ const SessionErrorCB& session_error_cb)
+ : session_created_cb_(session_created_cb),
+ session_message_cb_(session_message_cb),
+ session_ready_cb_(session_ready_cb),
+ session_closed_cb_(session_closed_cb),
+ session_error_cb_(session_error_cb) {}
AesDecryptor::~AesDecryptor() {
STLDeleteValues(&key_map_);
}
-bool AesDecryptor::GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length) {
+bool AesDecryptor::CreateSession(uint32 reference_id,
+ const std::string& type,
+ const uint8* init_data,
+ int init_data_length) {
std::string session_id_string(base::UintToString(next_session_id_++));
// For now, the AesDecryptor does not care about |type|;
@@ -167,35 +169,28 @@ bool AesDecryptor::GenerateKeyRequest(uint32 reference_id,
if (init_data && init_data_length)
message.assign(init_data, init_data + init_data_length);
- set_session_id_cb_.Run(reference_id, session_id_string);
- key_message_cb_.Run(reference_id, message, std::string());
+ session_created_cb_.Run(reference_id, session_id_string);
+ session_message_cb_.Run(reference_id, message, std::string());
return true;
}
-void AesDecryptor::AddKey(uint32 reference_id,
- const uint8* key,
- int key_length,
- const uint8* init_data,
- int init_data_length) {
- CHECK(key);
- CHECK_GT(key_length, 0);
- DCHECK(!init_data);
- DCHECK_EQ(init_data_length, 0);
-
- // AddKey() is called from update(), where the key(s) are passed as a JSON
- // Web Key (JWK) set. Each JWK needs to be a symmetric key ('kty' = "oct"),
- // with 'kid' being the base64-encoded key id, and 'k' being the
- // base64-encoded key.
- std::string key_string(reinterpret_cast<const char*>(key), key_length);
+void AesDecryptor::UpdateSession(uint32 reference_id,
+ const uint8* response,
+ int response_length) {
+ CHECK(response);
+ CHECK_GT(response_length, 0);
+
+ std::string key_string(reinterpret_cast<const char*>(response),
+ response_length);
KeyIdAndKeyPairs keys;
if (!ExtractKeysFromJWKSet(key_string, &keys)) {
- key_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
+ session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
return;
}
// Make sure that at least one key was extracted.
if (keys.empty()) {
- key_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
+ session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
return;
}
@@ -203,11 +198,11 @@ void AesDecryptor::AddKey(uint32 reference_id,
if (it->second.length() !=
static_cast<size_t>(DecryptConfig::kDecryptionKeySize)) {
DVLOG(1) << "Invalid key length: " << key_string.length();
- key_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
+ session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
return;
}
if (!AddDecryptionKey(it->first, it->second)) {
- key_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
+ session_error_cb_.Run(reference_id, MediaKeys::kUnknownError, 0);
return;
}
}
@@ -218,10 +213,11 @@ void AesDecryptor::AddKey(uint32 reference_id,
if (!new_video_key_cb_.is_null())
new_video_key_cb_.Run();
- key_added_cb_.Run(reference_id);
+ session_ready_cb_.Run(reference_id);
}
-void AesDecryptor::CancelKeyRequest(uint32 reference_id) {
+void AesDecryptor::ReleaseSession(uint32 reference_id) {
+ // TODO: Implement: http://crbug.com/313412.
}
Decryptor* AesDecryptor::GetDecryptor() {
diff --git a/media/cdm/aes_decryptor.h b/media/cdm/aes_decryptor.h
index d1f9341..8e03106 100644
--- a/media/cdm/aes_decryptor.h
+++ b/media/cdm/aes_decryptor.h
@@ -27,23 +27,22 @@ namespace media {
// encryption must be CTR with a key size of 128bits.
class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor {
public:
- AesDecryptor(const KeyAddedCB& key_added_cb,
- const KeyErrorCB& key_error_cb,
- const KeyMessageCB& key_message_cb,
- const SetSessionIdCB& set_session_id_cb);
+ AesDecryptor(const SessionCreatedCB& session_created_cb,
+ const SessionMessageCB& session_message_cb,
+ const SessionReadyCB& session_ready_cb,
+ const SessionClosedCB& session_closed_cb,
+ const SessionErrorCB& session_error_cb);
virtual ~AesDecryptor();
// MediaKeys implementation.
- virtual bool GenerateKeyRequest(uint32 reference_id,
- const std::string& type,
- const uint8* init_data,
- int init_data_length) OVERRIDE;
- virtual void AddKey(uint32 reference_id,
- const uint8* key,
- int key_length,
- const uint8* init_data,
- int init_data_length) OVERRIDE;
- virtual void CancelKeyRequest(uint32 reference_id) OVERRIDE;
+ virtual bool CreateSession(uint32 reference_id,
+ const std::string& type,
+ const uint8* init_data,
+ int init_data_length) OVERRIDE;
+ virtual void UpdateSession(uint32 reference_id,
+ const uint8* response,
+ int response_length) OVERRIDE;
+ virtual void ReleaseSession(uint32 reference_id) OVERRIDE;
virtual Decryptor* GetDecryptor() OVERRIDE;
// Decryptor implementation.
@@ -99,11 +98,12 @@ class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor {
// the key. Returns NULL if no key is associated with |key_id|.
DecryptionKey* GetKey(const std::string& key_id) const;
- // Callbacks for firing key events.
- KeyAddedCB key_added_cb_;
- KeyErrorCB key_error_cb_;
- KeyMessageCB key_message_cb_;
- SetSessionIdCB set_session_id_cb_;
+ // Callbacks for firing session events.
+ SessionCreatedCB session_created_cb_;
+ SessionMessageCB session_message_cb_;
+ SessionReadyCB session_ready_cb_;
+ SessionClosedCB session_closed_cb_;
+ SessionErrorCB session_error_cb_;
// KeyMap owns the DecryptionKey* and must delete them when they are
// not needed any more.
diff --git a/media/cdm/aes_decryptor_unittest.cc b/media/cdm/aes_decryptor_unittest.cc
index d9730a2..cd0d460 100644
--- a/media/cdm/aes_decryptor_unittest.cc
+++ b/media/cdm/aes_decryptor_unittest.cc
@@ -185,11 +185,16 @@ static scoped_refptr<DecoderBuffer> CreateEncryptedBuffer(
class AesDecryptorTest : public testing::Test {
public:
AesDecryptorTest()
- : decryptor_(
- base::Bind(&AesDecryptorTest::KeyAdded, base::Unretained(this)),
- base::Bind(&AesDecryptorTest::KeyError, base::Unretained(this)),
- base::Bind(&AesDecryptorTest::KeyMessage, base::Unretained(this)),
- base::Bind(&AesDecryptorTest::SetSession, base::Unretained(this))),
+ : decryptor_(base::Bind(&AesDecryptorTest::OnSessionCreated,
+ base::Unretained(this)),
+ base::Bind(&AesDecryptorTest::OnSessionMessage,
+ base::Unretained(this)),
+ base::Bind(&AesDecryptorTest::OnSessionReady,
+ base::Unretained(this)),
+ base::Bind(&AesDecryptorTest::OnSessionClosed,
+ base::Unretained(this)),
+ base::Bind(&AesDecryptorTest::OnSessionError,
+ base::Unretained(this))),
reference_id_(MediaKeys::kInvalidReferenceId),
decrypt_cb_(base::Bind(&AesDecryptorTest::BufferDecrypted,
base::Unretained(this))),
@@ -207,12 +212,12 @@ class AesDecryptorTest : public testing::Test {
}
protected:
- void GenerateKeyRequest(const std::vector<uint8>& key_id) {
+ void CreateSession(const std::vector<uint8>& key_id) {
reference_id_ = 6;
DCHECK(!key_id.empty());
- EXPECT_CALL(*this, SetSession(reference_id_, StrNe(std::string())));
- EXPECT_CALL(*this, KeyMessage(reference_id_, key_id, ""));
- EXPECT_TRUE(decryptor_.GenerateKeyRequest(
+ EXPECT_CALL(*this, OnSessionCreated(reference_id_, StrNe(std::string())));
+ EXPECT_CALL(*this, OnSessionMessage(reference_id_, key_id, ""));
+ EXPECT_TRUE(decryptor_.CreateSession(
reference_id_, std::string(), &key_id[0], key_id.size()));
}
@@ -225,18 +230,17 @@ class AesDecryptorTest : public testing::Test {
DCHECK(!key.empty());
if (result == KEY_ADDED) {
- EXPECT_CALL(*this, KeyAdded(reference_id_));
+ EXPECT_CALL(*this, OnSessionReady(reference_id_));
} else if (result == KEY_ERROR) {
- EXPECT_CALL(*this, KeyError(reference_id_, MediaKeys::kUnknownError, 0));
+ EXPECT_CALL(*this,
+ OnSessionError(reference_id_, MediaKeys::kUnknownError, 0));
} else {
NOTREACHED();
}
- decryptor_.AddKey(reference_id_,
- reinterpret_cast<const uint8*>(key.c_str()),
- key.length(),
- NULL,
- 0);
+ decryptor_.UpdateSession(reference_id_,
+ reinterpret_cast<const uint8*>(key.c_str()),
+ key.length());
}
MOCK_METHOD2(BufferDecrypted, void(Decryptor::Status,
@@ -287,14 +291,16 @@ class AesDecryptorTest : public testing::Test {
}
}
- MOCK_METHOD1(KeyAdded, void(uint32 reference_id));
- MOCK_METHOD3(KeyError, void(uint32 reference_id, MediaKeys::KeyError, int));
- MOCK_METHOD3(KeyMessage,
+ MOCK_METHOD2(OnSessionCreated,
+ void(uint32 reference_id, const std::string& session_id));
+ MOCK_METHOD3(OnSessionMessage,
void(uint32 reference_id,
const std::vector<uint8>& message,
const std::string& default_url));
- MOCK_METHOD2(SetSession,
- void(uint32 reference_id, const std::string& session_id));
+ MOCK_METHOD1(OnSessionReady, void(uint32 reference_id));
+ MOCK_METHOD1(OnSessionClosed, void(uint32 reference_id));
+ MOCK_METHOD3(OnSessionError,
+ void(uint32 reference_id, MediaKeys::KeyError, int system_code));
AesDecryptor decryptor_;
uint32 reference_id_;
@@ -310,36 +316,32 @@ class AesDecryptorTest : public testing::Test {
const std::vector<SubsampleEntry> no_subsample_entries_;
};
-TEST_F(AesDecryptorTest, GenerateKeyRequestWithNullInitData) {
+TEST_F(AesDecryptorTest, CreateSessionWithNullInitData) {
reference_id_ = 8;
- EXPECT_CALL(*this, KeyMessage(reference_id_, IsEmpty(), ""));
- EXPECT_CALL(*this, SetSession(reference_id_, StrNe(std::string())));
- EXPECT_TRUE(
- decryptor_.GenerateKeyRequest(reference_id_, std::string(), NULL, 0));
+ 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));
}
-TEST_F(AesDecryptorTest, MultipleGenerateKeyRequest) {
+TEST_F(AesDecryptorTest, MultipleCreateSession) {
uint32 reference_id1 = 10;
- EXPECT_CALL(*this, KeyMessage(reference_id1, IsEmpty(), ""));
- EXPECT_CALL(*this, SetSession(reference_id1, StrNe(std::string())));
- EXPECT_TRUE(
- decryptor_.GenerateKeyRequest(reference_id1, std::string(), NULL, 0));
+ 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, KeyMessage(reference_id2, IsEmpty(), ""));
- EXPECT_CALL(*this, SetSession(reference_id2, StrNe(std::string())));
- EXPECT_TRUE(
- decryptor_.GenerateKeyRequest(reference_id2, std::string(), NULL, 0));
+ 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, KeyMessage(reference_id3, IsEmpty(), ""));
- EXPECT_CALL(*this, SetSession(reference_id3, StrNe(std::string())));
- EXPECT_TRUE(
- decryptor_.GenerateKeyRequest(reference_id3, std::string(), NULL, 0));
+ 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));
}
TEST_F(AesDecryptorTest, NormalDecryption) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
encrypted_data_, key_id_, iv_, 0, no_subsample_entries_);
@@ -347,7 +349,7 @@ TEST_F(AesDecryptorTest, NormalDecryption) {
}
TEST_F(AesDecryptorTest, DecryptionWithOffset) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
encrypted_data_, key_id_, iv_, 23, no_subsample_entries_);
@@ -362,7 +364,7 @@ TEST_F(AesDecryptorTest, UnencryptedFrame) {
}
TEST_F(AesDecryptorTest, WrongKey) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kWrongKeyAsJWK, KEY_ADDED);
scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
encrypted_data_, key_id_, iv_, 0, no_subsample_entries_);
@@ -377,7 +379,7 @@ TEST_F(AesDecryptorTest, NoKey) {
}
TEST_F(AesDecryptorTest, KeyReplacement) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
encrypted_data_, key_id_, iv_, 0, no_subsample_entries_);
@@ -391,12 +393,12 @@ TEST_F(AesDecryptorTest, KeyReplacement) {
}
TEST_F(AesDecryptorTest, WrongSizedKey) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kWrongSizedKeyAsJWK, KEY_ERROR);
}
TEST_F(AesDecryptorTest, MultipleKeysAndFrames) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
encrypted_data_, key_id_, iv_, 10, no_subsample_entries_);
@@ -425,7 +427,7 @@ TEST_F(AesDecryptorTest, MultipleKeysAndFrames) {
}
TEST_F(AesDecryptorTest, CorruptedIv) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
std::vector<uint8> bad_iv = iv_;
@@ -438,7 +440,7 @@ TEST_F(AesDecryptorTest, CorruptedIv) {
}
TEST_F(AesDecryptorTest, CorruptedData) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
std::vector<uint8> bad_data = encrypted_data_;
@@ -450,7 +452,7 @@ TEST_F(AesDecryptorTest, CorruptedData) {
}
TEST_F(AesDecryptorTest, EncryptedAsUnencryptedFailure) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
encrypted_data_, key_id_, std::vector<uint8>(), 0, no_subsample_entries_);
@@ -458,7 +460,7 @@ TEST_F(AesDecryptorTest, EncryptedAsUnencryptedFailure) {
}
TEST_F(AesDecryptorTest, SubsampleDecryption) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
subsample_encrypted_data_, key_id_, iv_, 0, normal_subsample_entries_);
@@ -469,7 +471,7 @@ TEST_F(AesDecryptorTest, SubsampleDecryption) {
// expect to encounter this in the wild, but since the DecryptConfig doesn't
// disallow such a configuration, it should be covered.
TEST_F(AesDecryptorTest, SubsampleDecryptionWithOffset) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
subsample_encrypted_data_, key_id_, iv_, 23, normal_subsample_entries_);
@@ -477,7 +479,7 @@ TEST_F(AesDecryptorTest, SubsampleDecryptionWithOffset) {
}
TEST_F(AesDecryptorTest, SubsampleWrongSize) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
std::vector<SubsampleEntry> subsample_entries_wrong_size(
@@ -490,7 +492,7 @@ TEST_F(AesDecryptorTest, SubsampleWrongSize) {
}
TEST_F(AesDecryptorTest, SubsampleInvalidTotalSize) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
std::vector<SubsampleEntry> subsample_entries_invalid_total_size(
@@ -506,7 +508,7 @@ TEST_F(AesDecryptorTest, SubsampleInvalidTotalSize) {
// No cypher bytes in any of the subsamples.
TEST_F(AesDecryptorTest, SubsampleClearBytesOnly) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
std::vector<SubsampleEntry> clear_only_subsample_entries(
@@ -520,7 +522,7 @@ TEST_F(AesDecryptorTest, SubsampleClearBytesOnly) {
// No clear bytes in any of the subsamples.
TEST_F(AesDecryptorTest, SubsampleCypherBytesOnly) {
- GenerateKeyRequest(key_id_);
+ CreateSession(key_id_);
AddKeyAndExpect(kKeyAsJWK, KEY_ADDED);
std::vector<SubsampleEntry> cypher_only_subsample_entries(
diff --git a/media/cdm/ppapi/cdm_adapter.cc b/media/cdm/ppapi/cdm_adapter.cc
index 1d9200a..489eb1d 100644
--- a/media/cdm/ppapi/cdm_adapter.cc
+++ b/media/cdm/ppapi/cdm_adapter.cc
@@ -235,7 +235,7 @@ bool CdmAdapter::CreateCdmInstance(const std::string& key_system) {
// No KeyErrors should be reported in this function because they cannot be
// bubbled up in the WD EME API. Those errors will be reported during session
-// creation (aka GenerateKeyRequest).
+// creation (CreateSession).
void CdmAdapter::Initialize(const std::string& key_system) {
PP_DCHECK(!key_system.empty());
PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_));
@@ -247,13 +247,13 @@ void CdmAdapter::Initialize(const std::string& key_system) {
key_system_ = key_system;
}
-void CdmAdapter::GenerateKeyRequest(uint32_t reference_id,
- const std::string& type,
- pp::VarArrayBuffer init_data) {
- // Initialize() doesn't report an error, so GenerateKeyRequest() can be called
+void CdmAdapter::CreateSession(uint32_t reference_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_) {
- SendUnknownKeyError(reference_id);
+ OnSessionError(reference_id, cdm::kUnknownError, 0);
return;
}
@@ -261,7 +261,7 @@ void CdmAdapter::GenerateKeyRequest(uint32_t reference_id,
PP_URLComponents_Dev url_components = {};
const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get();
if (!url_util) {
- SendUnknownKeyError(reference_id);
+ OnSessionError(reference_id, cdm::kUnknownError, 0);
return;
}
pp::Var href = url_util->GetDocumentURL(
@@ -272,56 +272,52 @@ void CdmAdapter::GenerateKeyRequest(uint32_t reference_id,
PP_DCHECK(0 < url_components.host.len);
#endif // defined(CHECK_DOCUMENT_URL)
- cdm_->GenerateKeyRequest(reference_id,
- type.data(),
- type.size(),
- static_cast<const uint8_t*>(init_data.Map()),
- init_data.ByteLength());
+ cdm_->CreateSession(reference_id,
+ type.data(),
+ type.size(),
+ static_cast<const uint8_t*>(init_data.Map()),
+ init_data.ByteLength());
}
-void CdmAdapter::AddKey(uint32_t reference_id,
- pp::VarArrayBuffer key,
- pp::VarArrayBuffer init_data) {
+void CdmAdapter::UpdateSession(uint32_t reference_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_) {
- SendUnknownKeyError(reference_id);
+ OnSessionError(reference_id, cdm::kUnknownError, 0);
return;
}
- const uint8_t* key_ptr = static_cast<const uint8_t*>(key.Map());
- const uint32_t key_size = key.ByteLength();
- const uint8_t* init_data_ptr = static_cast<const uint8_t*>(init_data.Map());
- const uint32_t init_data_size = init_data.ByteLength();
- PP_DCHECK(!init_data_ptr == !init_data_size);
+ const uint8_t* response_ptr = static_cast<const uint8_t*>(response.Map());
+ const uint32_t response_size = response.ByteLength();
- if (!key_ptr || key_size <= 0) {
- SendUnknownKeyError(reference_id);
+ if (!response_ptr || response_size <= 0) {
+ OnSessionError(reference_id, cdm::kUnknownError, 0);
return;
}
- CdmWrapper::Result result = cdm_->AddKey(
- reference_id, key_ptr, key_size, init_data_ptr, init_data_size);
+ CdmWrapper::Result result =
+ cdm_->UpdateSession(reference_id, response_ptr, response_size);
switch (result) {
case CdmWrapper::NO_ACTION:
break;
case CdmWrapper::CALL_KEY_ADDED:
- SendKeyAdded(reference_id);
+ OnSessionReady(reference_id);
break;
case CdmWrapper::CALL_KEY_ERROR:
- SendUnknownKeyError(reference_id);
+ OnSessionError(reference_id, cdm::kUnknownError, 0);
break;
}
}
-void CdmAdapter::CancelKeyRequest(uint32_t reference_id) {
+void CdmAdapter::ReleaseSession(uint32_t reference_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_) {
- SendUnknownKeyError(reference_id);
+ OnSessionError(reference_id, cdm::kUnknownError, 0);
return;
}
- CdmWrapper::Result result = cdm_->CancelKeyRequest(reference_id);
+ CdmWrapper::Result result = cdm_->ReleaseSession(reference_id);
switch (result) {
case CdmWrapper::NO_ACTION:
break;
@@ -329,7 +325,7 @@ void CdmAdapter::CancelKeyRequest(uint32_t reference_id) {
PP_NOTREACHED();
break;
case CdmWrapper::CALL_KEY_ERROR:
- SendUnknownKeyError(reference_id);
+ OnSessionError(reference_id, cdm::kUnknownError, 0);
break;
}
}
@@ -542,14 +538,9 @@ void CdmAdapter::SendKeyMessage(
PP_DCHECK(!session_id_str.empty());
uint32_t reference_id = cdm_->DetermineReferenceId(session_id_str);
- PostOnMain(callback_factory_.NewCallback(
- &CdmAdapter::SetSessionId, reference_id, session_id_str));
-
- PostOnMain(callback_factory_.NewCallback(
- &CdmAdapter::KeyMessage,
- reference_id,
- std::vector<uint8>(message, message + message_length),
- std::string(default_url, default_url_length)));
+ OnSessionCreated(reference_id, session_id, session_id_length);
+ OnSessionMessage(
+ reference_id, message, message_length, default_url, default_url_length);
}
void CdmAdapter::SendKeyError(const char* session_id,
@@ -558,8 +549,7 @@ void CdmAdapter::SendKeyError(const char* session_id,
uint32_t system_code) {
std::string session_id_str(session_id, session_id_length);
uint32_t reference_id = cdm_->DetermineReferenceId(session_id_str);
-
- SendKeyErrorInternal(reference_id, error_code, system_code);
+ OnSessionError(reference_id, error_code, system_code);
}
void CdmAdapter::GetPrivateData(int32_t* instance,
@@ -568,31 +558,58 @@ void CdmAdapter::GetPrivateData(int32_t* instance,
*get_interface = pp::Module::Get()->get_browser_interface();
}
-void CdmAdapter::SendUnknownKeyError(uint32_t reference_id) {
- SendKeyErrorInternal(reference_id, cdm::kUnknownError, 0);
+void CdmAdapter::OnSessionCreated(uint32_t reference_id,
+ const char* session_id,
+ uint32_t session_id_length) {
+ PostOnMain(callback_factory_.NewCallback(
+ &CdmAdapter::SendSessionCreatedInternal,
+ reference_id,
+ std::string(session_id, session_id_length)));
+}
+
+void CdmAdapter::OnSessionMessage(uint32_t reference_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,
+ std::vector<uint8>(message, message + message_length),
+ std::string(destination_url, destination_url_length)));
+}
+
+void CdmAdapter::OnSessionReady(uint32_t reference_id) {
+ PostOnMain(callback_factory_.NewCallback(
+ &CdmAdapter::SendSessionReadyInternal, reference_id));
}
-void CdmAdapter::SendKeyAdded(uint32_t reference_id) {
- PostOnMain(
- callback_factory_.NewCallback(&CdmAdapter::KeyAdded, reference_id));
+void CdmAdapter::OnSessionClosed(uint32_t reference_id) {
+ PostOnMain(callback_factory_.NewCallback(
+ &CdmAdapter::SendSessionClosedInternal, reference_id));
}
-void CdmAdapter::SendKeyErrorInternal(uint32_t reference_id,
- cdm::MediaKeyError error_code,
- uint32_t system_code) {
+void CdmAdapter::OnSessionError(uint32_t reference_id,
+ cdm::MediaKeyError error_code,
+ uint32_t system_code) {
PostOnMain(callback_factory_.NewCallback(
- &CdmAdapter::KeyError, reference_id, error_code, system_code));
+ &CdmAdapter::SendSessionErrorInternal,
+ reference_id,
+ error_code,
+ system_code));
}
-void CdmAdapter::KeyAdded(int32_t result, uint32_t reference_id) {
+void CdmAdapter::SendSessionCreatedInternal(int32_t result,
+ uint32_t reference_id,
+ const std::string& session_id) {
PP_DCHECK(result == PP_OK);
- pp::ContentDecryptor_Private::KeyAdded(reference_id);
+ pp::ContentDecryptor_Private::SessionCreated(reference_id, session_id);
}
-void CdmAdapter::KeyMessage(int32_t result,
- uint32_t reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url) {
+void CdmAdapter::SendSessionMessageInternal(int32_t result,
+ uint32_t reference_id,
+ const std::vector<uint8>& message,
+ const std::string& default_url) {
PP_DCHECK(result == PP_OK);
pp::VarArrayBuffer message_array_buffer(message.size());
@@ -600,25 +617,29 @@ void CdmAdapter::KeyMessage(int32_t result,
memcpy(message_array_buffer.Map(), message.data(), message.size());
}
- pp::ContentDecryptor_Private::KeyMessage(
- reference_id,
- message_array_buffer,
- default_url);
+ pp::ContentDecryptor_Private::SessionMessage(
+ reference_id, message_array_buffer, default_url);
+}
+
+void CdmAdapter::SendSessionReadyInternal(int32_t result,
+ uint32_t reference_id) {
+ PP_DCHECK(result == PP_OK);
+ pp::ContentDecryptor_Private::SessionReady(reference_id);
}
-void CdmAdapter::KeyError(int32_t result,
- uint32_t reference_id,
- cdm::MediaKeyError error_code,
- uint32_t system_code) {
+void CdmAdapter::SendSessionClosedInternal(int32_t result,
+ uint32_t reference_id) {
PP_DCHECK(result == PP_OK);
- pp::ContentDecryptor_Private::KeyError(reference_id, error_code, system_code);
+ pp::ContentDecryptor_Private::SessionClosed(reference_id);
}
-void CdmAdapter::SetSessionId(int32_t result,
- uint32_t reference_id,
- const std::string& session_id) {
+void CdmAdapter::SendSessionErrorInternal(int32_t result,
+ uint32_t reference_id,
+ cdm::MediaKeyError error_code,
+ uint32_t system_code) {
PP_DCHECK(result == PP_OK);
- pp::ContentDecryptor_Private::SetSessionId(reference_id, session_id);
+ pp::ContentDecryptor_Private::SessionError(
+ reference_id, error_code, system_code);
}
void CdmAdapter::DeliverBlock(int32_t result,
@@ -928,7 +949,7 @@ void* GetCdmHost(int host_interface_version, void* user_data) {
return NULL;
COMPILE_ASSERT(cdm::ContentDecryptionModule::Host::kVersion ==
- cdm::ContentDecryptionModule_2::Host::kVersion,
+ cdm::ContentDecryptionModule_3::Host::kVersion,
update_code_below);
// Ensure IsSupportedCdmHostVersion matches implementation of this function.
@@ -949,10 +970,10 @@ void* GetCdmHost(int host_interface_version, void* user_data) {
CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data);
switch (host_interface_version) {
- // The latest CDM host version.
- case cdm::ContentDecryptionModule::Host::kVersion:
- return static_cast<cdm::ContentDecryptionModule::Host*>(cdm_adapter);
- // Older supported version(s) of the CDM host.
+ case cdm::Host_3::kVersion:
+ return static_cast<cdm::Host_3*>(cdm_adapter);
+ case cdm::Host_2::kVersion:
+ return static_cast<cdm::Host_2*>(cdm_adapter);
case cdm::Host_1::kVersion:
return static_cast<cdm::Host_1*>(cdm_adapter);
default:
diff --git a/media/cdm/ppapi/cdm_adapter.h b/media/cdm/ppapi/cdm_adapter.h
index 0542c5d..57e7524 100644
--- a/media/cdm/ppapi/cdm_adapter.h
+++ b/media/cdm/ppapi/cdm_adapter.h
@@ -38,7 +38,8 @@ void* GetCdmHost(int host_interface_version, void* user_data);
class CdmAdapter : public pp::Instance,
public pp::ContentDecryptor_Private,
public cdm::Host_1,
- public cdm::Host_2 {
+ public cdm::Host_2,
+ public cdm::Host_3 {
public:
CdmAdapter(PP_Instance instance, pp::Module* module);
virtual ~CdmAdapter();
@@ -52,13 +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 GenerateKeyRequest(uint32_t reference_id,
- const std::string& type,
- pp::VarArrayBuffer init_data) OVERRIDE;
- virtual void AddKey(uint32_t reference_id,
- pp::VarArrayBuffer key,
- pp::VarArrayBuffer init_data) OVERRIDE;
- virtual void CancelKeyRequest(uint32_t reference_id) OVERRIDE;
+ virtual void CreateSession(uint32_t reference_id,
+ const std::string& type,
+ pp::VarArrayBuffer init_data) OVERRIDE;
+ virtual void UpdateSession(uint32_t reference_id,
+ pp::VarArrayBuffer response) OVERRIDE;
+ virtual void ReleaseSession(uint32_t reference_id) OVERRIDE;
virtual void Decrypt(
pp::Buffer_Dev encrypted_buffer,
const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
@@ -103,6 +103,21 @@ class CdmAdapter : public pp::Instance,
cdm::StreamType stream_type,
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,
+ 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,
+ cdm::MediaKeyError error_code,
+ uint32_t system_code) OVERRIDE;
+
private:
typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock;
typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame;
@@ -110,27 +125,23 @@ class CdmAdapter : public pp::Instance,
bool CreateCdmInstance(const std::string& key_system);
- void SendUnknownKeyError(uint32_t reference_id);
- void SendKeyAdded(uint32_t reference_id);
- void SendKeyErrorInternal(uint32_t reference_id,
- cdm::MediaKeyError error_code,
- uint32_t system_code);
-
// <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to
// <code>callback_factory_</code> to ensure that calls into
// <code>PPP_ContentDecryptor_Private</code> are asynchronous.
- void KeyAdded(int32_t result, uint32_t reference_id);
- void KeyMessage(int32_t result,
- uint32_t reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url);
- void KeyError(int32_t result,
- uint32_t reference_id,
- cdm::MediaKeyError error_code,
- uint32_t system_code);
- void SetSessionId(int32_t result,
- uint32_t reference_id,
- const std::string& session_id);
+ void SendSessionCreatedInternal(int32_t result,
+ uint32_t reference_id,
+ const std::string& session_id);
+ void SendSessionMessageInternal(int32_t result,
+ uint32_t reference_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 SendSessionErrorInternal(int32_t result,
+ uint32_t reference_id,
+ cdm::MediaKeyError error_code,
+ uint32_t system_code);
+
void DeliverBlock(int32_t result,
const cdm::Status& status,
const LinkedDecryptedBlock& decrypted_block,
diff --git a/media/cdm/ppapi/cdm_wrapper.h b/media/cdm/ppapi/cdm_wrapper.h
index 8d3003a..63d8bbf 100644
--- a/media/cdm/ppapi/cdm_wrapper.h
+++ b/media/cdm/ppapi/cdm_wrapper.h
@@ -52,17 +52,15 @@ class CdmWrapper {
virtual ~CdmWrapper() {};
- virtual void GenerateKeyRequest(uint32_t reference_id,
- const char* type,
- uint32_t type_size,
- const uint8_t* init_data,
- uint32_t init_data_size) = 0;
- virtual Result AddKey(uint32_t reference_id,
- const uint8_t* key,
- uint32_t key_size,
- const uint8_t* key_id,
- uint32_t key_id_size) = 0;
- virtual Result CancelKeyRequest(uint32_t reference_id) = 0;
+ virtual void CreateSession(uint32_t reference_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,
+ const uint8_t* response,
+ uint32_t response_size) = 0;
+ virtual Result ReleaseSession(uint32_t reference_id) = 0;
virtual void TimerExpired(void* context) = 0;
virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
cdm::DecryptedBlock* decrypted_buffer) = 0;
@@ -85,10 +83,11 @@ class CdmWrapper {
uint32_t output_protection_mask) = 0;
// ContentDecryptionModule_1 and ContentDecryptionModule_2 interface methods
- // AddKey() and CancelKeyRequest() (older versions of Update() and Close(),
- // 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.
+ // 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.
//
// The following functions maintain the reference_id <-> session_id mapping.
// These can be removed once _1 and _2 interfaces are no longer supported.
@@ -99,16 +98,15 @@ class CdmWrapper {
// Determine the corresponding session_id for |reference_id|.
virtual const std::string LookupSessionId(uint32_t reference_id) = 0;
- protected:
+ // 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;
- CdmWrapper() : current_key_request_reference_id_(kInvalidReferenceId) {}
-
// Map between session_id and reference_id.
SessionMap session_map_;
- // As the response from GenerateKeyRequest() may be synchronous or
+ // 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
@@ -118,6 +116,9 @@ class CdmWrapper {
uint32_t current_key_request_reference_id_;
std::queue<uint32_t> pending_key_request_reference_ids_;
+ protected:
+ CdmWrapper() : current_key_request_reference_id_(kInvalidReferenceId) {}
+
private:
DISALLOW_COPY_AND_ASSIGN(CdmWrapper);
};
@@ -146,91 +147,24 @@ class CdmWrapperImpl : public CdmWrapper {
cdm_->Destroy();
}
- // TODO(jrummell): In CDM_3 all key callbacks will use reference_id, so there
- // is no need to keep track of the current/pending request IDs. As well, the
- // definition for AddKey() and CancelKeyRequest() require the CDM to always
- // send a response (success or error), so the callbacks are not required.
- // Simplify the following 3 routines when CDM_3 is supported.
-
- virtual void GenerateKeyRequest(uint32_t reference_id,
- const char* type,
- uint32_t type_size,
- const uint8_t* init_data,
- uint32_t init_data_size) OVERRIDE {
- // As it is possible for CDMs to reply synchronously during the call to
- // GenerateKeyRequest(), keep track of |reference_id|.
- current_key_request_reference_id_ = reference_id;
-
- cdm::Status status =
- cdm_->GenerateKeyRequest(type, type_size, init_data, init_data_size);
- PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError);
- if (status != cdm::kSuccess) {
- // If GenerateKeyRequest() failed, no subsequent asynchronous replies
- // will be sent. Verify that a response was sent synchronously.
- PP_DCHECK(current_key_request_reference_id_ == kInvalidReferenceId);
- current_key_request_reference_id_ = kInvalidReferenceId;
- return;
- }
-
- if (current_key_request_reference_id_) {
- // If this request is still pending (SendKeyMessage() or SendKeyError()
- // not called synchronously), add |reference_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
- // we can by keeping track of this in a queue, and assuming the responses
- // come back in order.
- pending_key_request_reference_ids_.push(reference_id);
- current_key_request_reference_id_ = kInvalidReferenceId;
- }
+ virtual void CreateSession(uint32_t reference_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);
}
- virtual Result AddKey(uint32_t reference_id,
- const uint8_t* key,
- uint32_t key_size,
- const uint8_t* key_id,
- uint32_t key_id_size) OVERRIDE {
- const std::string session_id = LookupSessionId(reference_id);
- if (session_id.empty()) {
- // Possible if AddKey() called before GenerateKeyRequest().
- return CALL_KEY_ERROR;
- }
-
- cdm::Status status = cdm_->AddKey(session_id.data(),
- session_id.size(),
- key,
- key_size,
- key_id,
- key_id_size);
- PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError);
- if (status != cdm::kSuccess) {
- // http://crbug.com/310345: CDMs should send a KeyError message if they
- // return a failure, so no need to do it twice. Remove this once all CDMs
- // have been updated.
- return CALL_KEY_ERROR;
- }
-
- return CALL_KEY_ADDED;
+ virtual Result UpdateSession(uint32_t reference_id,
+ const uint8_t* response,
+ uint32_t response_size) OVERRIDE {
+ cdm_->UpdateSession(reference_id, response, response_size);
+ return NO_ACTION;
}
- virtual Result CancelKeyRequest(uint32_t reference_id) OVERRIDE {
- const std::string session_id = LookupSessionId(reference_id);
- if (session_id.empty()) {
- // Possible if CancelKeyRequest() called before GenerateKeyRequest().
- return CALL_KEY_ERROR;
- }
-
- session_map_.erase(reference_id);
- cdm::Status status =
- cdm_->CancelKeyRequest(session_id.data(), session_id.size());
-
- PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError);
- if (status != cdm::kSuccess) {
- // http://crbug.com/310345: CDMs should send a KeyError message if they
- // return a failure, so no need to do it twice. Remove this once all CDMs
- // have been updated.
- return CALL_KEY_ERROR;
- }
-
+ virtual Result ReleaseSession(uint32_t reference_id) OVERRIDE {
+ cdm_->ReleaseSession(reference_id);
return NO_ACTION;
}
@@ -293,11 +227,12 @@ class CdmWrapperImpl : public CdmWrapper {
}
// There is no entry in the map; assume it came from the current
- // GenerateKeyRequest() call (if possible). If no current request,
- // assume it came from the oldest GenerateKeyRequest() call.
+ // 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_) {
- // Only 1 response is allowed for the current GenerateKeyRequest().
+ // Only 1 response is allowed for the current
+ // PrefixedGenerateKeyRequest().
current_key_request_reference_id_ = kInvalidReferenceId;
} else {
PP_DCHECK(!pending_key_request_reference_ids_.empty());
@@ -318,7 +253,7 @@ class CdmWrapperImpl : public CdmWrapper {
}
const std::string LookupSessionId(uint32_t reference_id) {
- // Session may not exist if error happens during GenerateKeyRequest().
+ // Session may not exist if error happens during CreateSession().
SessionMap::iterator it = session_map_.find(reference_id);
return (it != session_map_.end()) ? it->second : std::string();
}
@@ -333,8 +268,124 @@ class CdmWrapperImpl : public CdmWrapper {
DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl);
};
+// For ContentDecryptionModule_1 and ContentDecryptionModule_2,
+// CreateSession(), UpdateSession(), and ReleaseSession() call methods
+// are incompatible with ContentDecryptionModule_3. Use the following
+// templated functions to handle this.
+
+template <class CdmInterface>
+void PrefixedGenerateKeyRequest(CdmWrapper* wrapper,
+ CdmInterface* cdm,
+ uint32_t reference_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;
+
+ cdm::Status status =
+ cdm->GenerateKeyRequest(type, type_size, init_data, init_data_size);
+ PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError);
+ 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;
+ return;
+ }
+
+ if (wrapper->current_key_request_reference_id_) {
+ // If this request is still pending (SendKeyMessage() or SendKeyError()
+ // not called synchronously), add |reference_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
+ // 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;
+ }
+}
+
+template <class CdmInterface>
+CdmWrapper::Result PrefixedAddKey(CdmWrapper* wrapper,
+ CdmInterface* cdm,
+ uint32_t reference_id,
+ const uint8_t* response,
+ uint32_t response_size) {
+ const std::string session_id = wrapper->LookupSessionId(reference_id);
+ if (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);
+ 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.
+ return CdmWrapper::CALL_KEY_ERROR;
+ }
+
+ return CdmWrapper::CALL_KEY_ADDED;
+}
+
+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()) {
+ // Possible if ReleaseSession() called before CreateSession().
+ return CdmWrapper::CALL_KEY_ERROR;
+ }
+
+ wrapper->session_map_.erase(reference_id);
+ cdm::Status status =
+ cdm->CancelKeyRequest(session_id.data(), session_id.size());
+
+ 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.
+ return CdmWrapper::CALL_KEY_ERROR;
+ }
+
+ return CdmWrapper::NO_ACTION;
+}
+
// Specializations for ContentDecryptionModule_1.
+template <>
+void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::CreateSession(
+ uint32_t reference_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);
+}
+
+template <>
+CdmWrapper::Result CdmWrapperImpl<
+ cdm::ContentDecryptionModule_1>::UpdateSession(uint32_t reference_id,
+ const uint8_t* response,
+ uint32_t response_size) {
+ return PrefixedAddKey(this, cdm_, reference_id, response, response_size);
+}
+
+template <>
+CdmWrapper::Result CdmWrapperImpl<
+ cdm::ContentDecryptionModule_1>::ReleaseSession(uint32_t reference_id) {
+ return PrefixedCancelKeyRequest(this, cdm_, reference_id);
+}
+
template <> void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::
OnPlatformChallengeResponse(
const cdm::PlatformChallengeResponse& response) {
@@ -361,12 +412,39 @@ template <> cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_1>::
return cdm::kSuccess;
}
+// Specializations for ContentDecryptionModule_2.
+
+template <>
+void CdmWrapperImpl<cdm::ContentDecryptionModule_2>::CreateSession(
+ uint32_t reference_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);
+}
+
+template <>
+CdmWrapper::Result CdmWrapperImpl<
+ cdm::ContentDecryptionModule_2>::UpdateSession(uint32_t reference_id,
+ const uint8_t* response,
+ uint32_t response_size) {
+ return PrefixedAddKey(this, cdm_, reference_id, response, response_size);
+}
+
+template <>
+CdmWrapper::Result CdmWrapperImpl<
+ cdm::ContentDecryptionModule_2>::ReleaseSession(uint32_t reference_id) {
+ return PrefixedCancelKeyRequest(this, cdm_, reference_id);
+}
+
CdmWrapper* CdmWrapper::Create(const char* key_system,
uint32_t key_system_size,
GetCdmHostFunc get_cdm_host_func,
void* user_data) {
COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
- cdm::ContentDecryptionModule_2::kVersion,
+ cdm::ContentDecryptionModule_3::kVersion,
update_code_below);
// Ensure IsSupportedCdmInterfaceVersion matches this implementation.
@@ -378,6 +456,8 @@ CdmWrapper* CdmWrapper::Create(const char* key_system,
cdm::ContentDecryptionModule::kVersion + 1) &&
IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion) &&
IsSupportedCdmInterfaceVersion(
+ cdm::ContentDecryptionModule_2::kVersion) &&
+ IsSupportedCdmInterfaceVersion(
cdm::ContentDecryptionModule_1::kVersion) &&
!IsSupportedCdmInterfaceVersion(
cdm::ContentDecryptionModule_1::kVersion - 1));
@@ -390,6 +470,11 @@ CdmWrapper* CdmWrapper::Create(const char* key_system,
return cdm_wrapper;
// Try to see if the CDM supports older version(s) of the CDM interface.
+ cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_2>::Create(
+ key_system, key_system_size, get_cdm_host_func, user_data);
+ if (cdm_wrapper)
+ return cdm_wrapper;
+
cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_1>::Create(
key_system, key_system_size, get_cdm_host_func, user_data);
return cdm_wrapper;
@@ -400,7 +485,7 @@ CdmWrapper* CdmWrapper::Create(const char* key_system,
// does not have.
// Also update supported_cdm_versions.h.
COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
- cdm::ContentDecryptionModule_2::kVersion,
+ cdm::ContentDecryptionModule_3::kVersion,
ensure_cdm_wrapper_templates_have_old_version_support);
} // namespace media
diff --git a/media/cdm/ppapi/clear_key_cdm.cc b/media/cdm/ppapi/clear_key_cdm.cc
index 044cbb2..3fc10e1 100644
--- a/media/cdm/ppapi/clear_key_cdm.cc
+++ b/media/cdm/ppapi/clear_key_cdm.cc
@@ -171,43 +171,49 @@ ClearKeyCdm::Client::~Client() {}
void ClearKeyCdm::Client::Reset() {
status_ = kNone;
session_id_.clear();
- key_message_.clear();
- default_url_.clear();
+ message_.clear();
+ destination_url_.clear();
error_code_ = MediaKeys::kUnknownError;
system_code_ = 0;
}
-void ClearKeyCdm::Client::KeyAdded(uint32 reference_id) {
- status_ = static_cast<Status>(status_ | kKeyAdded);
+void ClearKeyCdm::Client::OnSessionCreated(uint32 reference_id,
+ const std::string& session_id) {
+ status_ = static_cast<Status>(status_ | kCreated);
+ session_id_ = session_id;
}
-void ClearKeyCdm::Client::KeyError(uint32 reference_id,
- media::MediaKeys::KeyError error_code,
- int system_code) {
- status_ = static_cast<Status>(status_ | kKeyError);
- error_code_ = error_code;
- system_code_ = system_code;
+void ClearKeyCdm::Client::OnSessionMessage(uint32 reference_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url) {
+ status_ = static_cast<Status>(status_ | kMessage);
+ message_ = message;
+ destination_url_ = destination_url;
}
-void ClearKeyCdm::Client::KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url) {
- status_ = static_cast<Status>(status_ | kKeyMessage);
- key_message_ = message;
- default_url_ = default_url;
+void ClearKeyCdm::Client::OnSessionReady(uint32 reference_id) {
+ status_ = static_cast<Status>(status_ | kReady);
}
-void ClearKeyCdm::Client::SetSessionId(uint32 reference_id,
- const std::string& session_id) {
- status_ = static_cast<Status>(status_ | kSetSessionId);
- session_id_ = session_id;
+void ClearKeyCdm::Client::OnSessionClosed(uint32 reference_id) {
+ status_ = static_cast<Status>(status_ | kClosed);
+}
+
+void ClearKeyCdm::Client::OnSessionError(uint32 reference_id,
+ media::MediaKeys::KeyError error_code,
+ int system_code) {
+ status_ = static_cast<Status>(status_ | kError);
+ error_code_ = error_code;
+ system_code_ = system_code;
}
ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, bool is_decrypt_only)
- : decryptor_(base::Bind(&Client::KeyAdded, base::Unretained(&client_)),
- base::Bind(&Client::KeyError, base::Unretained(&client_)),
- base::Bind(&Client::KeyMessage, base::Unretained(&client_)),
- base::Bind(&Client::SetSessionId, base::Unretained(&client_))),
+ : decryptor_(
+ base::Bind(&Client::OnSessionCreated, base::Unretained(&client_)),
+ base::Bind(&Client::OnSessionMessage, base::Unretained(&client_)),
+ base::Bind(&Client::OnSessionReady, base::Unretained(&client_)),
+ base::Bind(&Client::OnSessionClosed, base::Unretained(&client_)),
+ base::Bind(&Client::OnSessionError, base::Unretained(&client_))),
host_(host),
is_decrypt_only_(is_decrypt_only),
timer_delay_ms_(kInitialTimerDelayMs),
@@ -230,11 +236,11 @@ cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* type,
DVLOG(1) << "GenerateKeyRequest()";
base::AutoLock auto_lock(client_lock_);
ScopedResetter<Client> auto_resetter(&client_);
- decryptor_.GenerateKeyRequest(MediaKeys::kInvalidReferenceId,
- std::string(type, type_size),
- init_data, init_data_size);
+ decryptor_.CreateSession(MediaKeys::kInvalidReferenceId,
+ std::string(type, type_size),
+ init_data, init_data_size);
- if (client_.status() != (Client::kKeyMessage | Client::kSetSessionId)) {
+ if (client_.status() != (Client::kMessage | Client::kCreated)) {
// Use values returned to client if possible.
host_->SendKeyError(client_.session_id().data(),
client_.session_id().size(),
@@ -245,9 +251,9 @@ cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* type,
host_->SendKeyMessage(
client_.session_id().data(), client_.session_id().size(),
- reinterpret_cast<const char*>(&client_.key_message()[0]),
- client_.key_message().size(),
- client_.default_url().data(), client_.default_url().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();
@@ -262,13 +268,12 @@ cdm::Status ClearKeyCdm::AddKey(const char* session_id,
const uint8_t* key_id,
uint32_t key_id_size) {
DVLOG(1) << "AddKey()";
+ DCHECK(!key_id && !key_id_size);
base::AutoLock auto_lock(client_lock_);
ScopedResetter<Client> auto_resetter(&client_);
- decryptor_.AddKey(MediaKeys::kInvalidReferenceId,
- key, key_size,
- key_id, key_id_size);
+ decryptor_.UpdateSession(MediaKeys::kInvalidReferenceId, key, key_size);
- if (client_.status() != Client::kKeyAdded) {
+ if (client_.status() != Client::kReady) {
host_->SendKeyError(session_id, session_id_size,
static_cast<cdm::MediaKeyError>(client_.error_code()),
client_.system_code());
@@ -288,11 +293,11 @@ cdm::Status ClearKeyCdm::CancelKeyRequest(const char* session_id,
DVLOG(1) << "CancelKeyRequest()";
base::AutoLock auto_lock(client_lock_);
ScopedResetter<Client> auto_resetter(&client_);
- decryptor_.CancelKeyRequest(MediaKeys::kInvalidReferenceId);
+ decryptor_.ReleaseSession(MediaKeys::kInvalidReferenceId);
- // No message normally sent by CancelKeyRequest(), but if an error occurred,
+ // No message normally sent by Release(), but if an error occurred,
// report it as a failure.
- if (client_.status() == Client::kKeyError) {
+ if (client_.status() == Client::kError) {
host_->SendKeyError(session_id, session_id_size,
static_cast<cdm::MediaKeyError>(client_.error_code()),
client_.system_code());
diff --git a/media/cdm/ppapi/clear_key_cdm.h b/media/cdm/ppapi/clear_key_cdm.h
index 6ef4e04..4c5cb34 100644
--- a/media/cdm/ppapi/clear_key_cdm.h
+++ b/media/cdm/ppapi/clear_key_cdm.h
@@ -75,10 +75,11 @@ class ClearKeyCdm : public ClearKeyCdmInterface {
// interface supports reference_id passing completely.
enum Status {
kNone = 0,
- kKeyAdded = 1 << 0,
- kKeyError = 1 << 1,
- kKeyMessage = 1 << 2,
- kSetSessionId = 1 << 3
+ kCreated = 1 << 0,
+ kMessage = 1 << 1,
+ kReady = 1 << 2,
+ kClosed = 1 << 3,
+ kError = 1 << 4
};
Client();
@@ -86,28 +87,29 @@ class ClearKeyCdm : public ClearKeyCdmInterface {
Status status() { return status_; }
const std::string& session_id() { return session_id_; }
- const std::vector<uint8>& key_message() { return key_message_; }
- const std::string& default_url() { return default_url_; }
+ const std::vector<uint8>& message() { return message_; }
+ const std::string& destination_url() { return destination_url_; }
MediaKeys::KeyError error_code() { return error_code_; }
int system_code() { return system_code_; }
// Resets the Client to a clean state.
void Reset();
- void KeyAdded(uint32 reference_id);
- void KeyError(uint32 reference_id,
- MediaKeys::KeyError error_code,
- int system_code);
- void KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url);
- void SetSessionId(uint32 reference_id, const std::string& session_id);
+ void OnSessionCreated(uint32 reference_id, const std::string& session_id);
+ void OnSessionMessage(uint32 reference_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,
+ MediaKeys::KeyError error_code,
+ int system_code);
private:
Status status_;
std::string session_id_;
- std::vector<uint8> key_message_;
- std::string default_url_;
+ std::vector<uint8> message_;
+ std::string destination_url_;
MediaKeys::KeyError error_code_;
int system_code_;
};
diff --git a/media/cdm/ppapi/clear_key_cdm_common.h b/media/cdm/ppapi/clear_key_cdm_common.h
index d6ed59b..8f84397 100644
--- a/media/cdm/ppapi/clear_key_cdm_common.h
+++ b/media/cdm/ppapi/clear_key_cdm_common.h
@@ -10,7 +10,7 @@
namespace media {
// Aliases for the version of the interfaces that this CDM implements.
-typedef cdm::ContentDecryptionModule ClearKeyCdmInterface;
+typedef cdm::ContentDecryptionModule_2 ClearKeyCdmInterface;
typedef ClearKeyCdmInterface::Host ClearKeyCdmHost;
} // namespace media
diff --git a/media/cdm/ppapi/supported_cdm_versions.h b/media/cdm/ppapi/supported_cdm_versions.h
index 085eaf44..04723d8 100644
--- a/media/cdm/ppapi/supported_cdm_versions.h
+++ b/media/cdm/ppapi/supported_cdm_versions.h
@@ -21,12 +21,12 @@ bool IsSupportedCdmModuleVersion(int version) {
bool IsSupportedCdmInterfaceVersion(int version) {
COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
- cdm::ContentDecryptionModule_2::kVersion,
+ cdm::ContentDecryptionModule_3::kVersion,
update_code_below);
switch(version) {
- // Latest.
- case cdm::ContentDecryptionModule::kVersion:
- // Older supported versions.
+ // Supported versions in decreasing order.
+ case cdm::ContentDecryptionModule_3::kVersion:
+ case cdm::ContentDecryptionModule_2::kVersion:
case cdm::ContentDecryptionModule_1::kVersion:
return true;
default:
@@ -36,12 +36,13 @@ bool IsSupportedCdmInterfaceVersion(int version) {
bool IsSupportedCdmHostVersion(int version) {
COMPILE_ASSERT(cdm::ContentDecryptionModule::Host::kVersion ==
- cdm::ContentDecryptionModule_2::Host::kVersion,
+ cdm::ContentDecryptionModule_3::Host::kVersion,
update_code_below);
switch(version) {
- // Supported versions in increasing order (there is no default).
- case cdm::Host_1::kVersion:
+ // Supported versions in decreasing order.
+ case cdm::Host_3::kVersion:
case cdm::Host_2::kVersion:
+ case cdm::Host_1::kVersion:
return true;
default:
return false;
diff --git a/media/filters/pipeline_integration_test.cc b/media/filters/pipeline_integration_test.cc
index 1b96bdb..afff6a9 100644
--- a/media/filters/pipeline_integration_test.cc
+++ b/media/filters/pipeline_integration_test.cc
@@ -80,22 +80,24 @@ class FakeEncryptedMedia {
public:
virtual ~AppBase() {}
- virtual void KeyAdded(uint32 reference_id) = 0;
+ virtual void SetSession(uint32 reference_id,
+ const std::string& session_id) = 0;
+
+ virtual void Message(uint32 reference_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url) = 0;
+
+ virtual void Ready(uint32 reference_id) = 0;
+
+ virtual void Closed(uint32 reference_id) = 0;
// Errors are not expected unless overridden.
- virtual void KeyError(uint32 reference_id,
- MediaKeys::KeyError error_code,
- int system_code) {
+ virtual void Error(uint32 reference_id,
+ MediaKeys::KeyError error_code,
+ int system_code) {
FAIL() << "Unexpected Key Error";
}
- virtual void KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url) = 0;
-
- virtual void SetSession(uint32 reference_id,
- const std::string& session_id) = 0;
-
virtual void NeedKey(const std::string& type,
const std::vector<uint8>& init_data,
AesDecryptor* decryptor) = 0;
@@ -103,11 +105,11 @@ class FakeEncryptedMedia {
FakeEncryptedMedia(AppBase* app)
: decryptor_(
- base::Bind(&FakeEncryptedMedia::KeyAdded, base::Unretained(this)),
- base::Bind(&FakeEncryptedMedia::KeyError, base::Unretained(this)),
- base::Bind(&FakeEncryptedMedia::KeyMessage, base::Unretained(this)),
- base::Bind(&FakeEncryptedMedia::SetSession,
- base::Unretained(this))),
+ 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) {
}
@@ -115,25 +117,29 @@ class FakeEncryptedMedia {
return &decryptor_;
}
- // Callbacks for firing key events. Delegate to |app_|.
- void KeyAdded(uint32 reference_id) {
- app_->KeyAdded(reference_id);
+ // 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 KeyError(uint32 reference_id,
- MediaKeys::KeyError error_code,
- int system_code) {
- app_->KeyError(reference_id, error_code, system_code);
+ void Message(uint32 reference_id,
+ const std::vector<uint8>& message,
+ const std::string& destination_url) {
+ app_->Message(reference_id, message, destination_url);
}
- void KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url) {
- app_->KeyMessage(reference_id, message, default_url);
+ void Ready(uint32 reference_id) {
+ app_->Ready(reference_id);
}
- void SetSession(uint32 reference_id, const std::string& session_id) {
- app_->SetSession(reference_id, session_id);
+ void Closed(uint32 reference_id) {
+ app_->Closed(reference_id);
+ }
+
+ void Error(uint32 reference_id,
+ MediaKeys::KeyError error_code,
+ int system_code) {
+ app_->Error(reference_id, error_code, system_code);
}
void NeedKey(const std::string& type,
@@ -151,31 +157,35 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
public:
KeyProvidingApp() : current_reference_id_(0) {}
- virtual void KeyAdded(uint32 reference_id) OVERRIDE {
+ virtual void SetSession(uint32 reference_id,
+ const std::string& session_id) OVERRIDE {
EXPECT_GT(reference_id, 0u);
+ EXPECT_FALSE(session_id.empty());
}
- virtual void KeyMessage(uint32 reference_id,
- const std::vector<uint8>& message,
- const std::string& default_url) OVERRIDE {
+ 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());
current_reference_id_ = reference_id;
}
- virtual void SetSession(uint32 reference_id,
- const std::string& session_id) OVERRIDE {
+ virtual void Ready(uint32 reference_id) OVERRIDE {
+ EXPECT_GT(reference_id, 0u);
+ }
+
+ virtual void Closed(uint32 reference_id) OVERRIDE {
EXPECT_GT(reference_id, 0u);
- EXPECT_FALSE(session_id.empty());
}
virtual void NeedKey(const std::string& type,
const std::vector<uint8>& init_data,
AesDecryptor* decryptor) OVERRIDE {
if (current_reference_id_ == 0u) {
- EXPECT_TRUE(decryptor->GenerateKeyRequest(
- 12, type, kInitData, arraysize(kInitData)));
+ EXPECT_TRUE(
+ decryptor->CreateSession(12, type, kInitData, arraysize(kInitData)));
}
EXPECT_EQ(current_reference_id_, 12u);
@@ -193,9 +203,9 @@ 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->AddKey(current_reference_id_,
- reinterpret_cast<const uint8*>(jwk.data()), jwk.size(),
- NULL, 0);
+ decryptor->UpdateSession(current_reference_id_,
+ reinterpret_cast<const uint8*>(jwk.data()),
+ jwk.size());
}
uint32 current_reference_id_;
@@ -204,24 +214,29 @@ class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
// Ignores needkey and does not perform a license request
class NoResponseApp : public FakeEncryptedMedia::AppBase {
public:
- virtual void KeyAdded(uint32 reference_id) OVERRIDE {
- EXPECT_GT(reference_id, 0u);
- FAIL() << "Unexpected KeyAdded";
- }
-
- virtual void KeyMessage(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 SetSession(uint32 reference_id,
- const std::string& session_id) OVERRIDE {
- EXPECT_GT(reference_id, 0u);
- EXPECT_FALSE(session_id.empty());
- }
+ virtual void SetSession(uint32 reference_id,
+ const std::string& session_id) OVERRIDE {
+ EXPECT_GT(reference_id, 0u);
+ EXPECT_FALSE(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 NeedKey(const std::string& type,
const std::vector<uint8>& init_data,
diff --git a/ppapi/api/private/ppb_content_decryptor_private.idl b/ppapi/api/private/ppb_content_decryptor_private.idl
index 8577de2..0d990eb 100644
--- a/ppapi/api/private/ppb_content_decryptor_private.idl
+++ b/ppapi/api/private/ppb_content_decryptor_private.idl
@@ -12,50 +12,46 @@
[generate_thunk]
label Chrome {
- M32 = 0.8
+ M33 = 0.9
};
/**
* <code>PPB_ContentDecryptor_Private</code> structure contains the function
* pointers the browser must implement to support plugins implementing the
* <code>PPP_ContentDecryptor_Private</code> interface. This interface provides
- * browser side support for the Content Decryption Module (CDM) for v0.1 of the
- * proposed Encrypted Media Extensions: http://goo.gl/rbdnR
+ * browser side support for the Content Decryption Module (CDM) for Encrypted
+ * Media Extensions: http://www.w3.org/TR/encrypted-media/
*/
interface PPB_ContentDecryptor_Private {
/**
- * A key has been added as the result of a call to the <code>AddKey()</code>
- * method on the <code>PPP_ContentDecryptor_Private</code> interface.
+ * A session has been created by the CDM.
*
- * Note: The above describes the most simple case. Depending on the key
- * system, a series of <code>KeyMessage()</code> calls from the CDM will be
- * sent to the browser, and then on to the web application. The web
- * application must then provide more data to the CDM by directing the browser
- * to pass the data to the CDM via calls to <code>AddKey()</code> on the
- * <code>PPP_ContentDecryptor_Private</code> interface.
- * The CDM must call <code>KeyAdded()</code> when the sequence is completed,
- * and, in response, the browser must notify the web application.
+ * @param[in] reference_id A reference for the session for which the CDM
+ * created a session.
+ *
+ * @param[in] web_session_id A <code>PP_Var</code> of type
+ * <code>PP_VARTYPE_STRING</code> containing the string for the
+ * MediaKeySession's sessionId attribute.
*
- * @param[in] reference_id A reference for the session for which a key
- * was added.
*/
- void KeyAdded(
+ void SessionCreated(
[in] PP_Instance instance,
- [in] uint32_t reference_id);
+ [in] uint32_t reference_id,
+ [in] PP_Var web_session_id);
/**
* A message or request has been generated for key_system in the CDM, and
* must be sent to the web application.
*
- * For example, when the browser invokes <code>GenerateKeyRequest()</code>
+ * For example, when the browser invokes <code>CreateSession()</code>
* on the <code>PPP_ContentDecryptor_Private</code> interface, the plugin
- * must send a key message containing the key request.
+ * must send a message containing the license request.
*
- * Note that <code>KeyMessage()</code> can be used for purposes other than
- * responses to <code>GenerateKeyRequest()</code> calls. See also the text
- * in the comment for <code>KeyAdded()</code>, which describes a sequence of
- * <code>AddKey()</code> and <code>KeyMessage()</code> calls required to
- * prepare for decryption.
+ * Note that <code>SessionMessage()</code> can be used for purposes other than
+ * responses to <code>CreateSession()</code> calls. See also the text
+ * in the comment for <code>SessionReady()</code>, which describes a sequence
+ * of <code>UpdateSession()</code> and <code>SessionMessage()</code> calls
+ * required to prepare for decryption.
*
* @param[in] reference_id A reference for the session for which the message
* is intended.
@@ -63,14 +59,45 @@ interface PPB_ContentDecryptor_Private {
* @param[in] message A <code>PP_Var</code> of type
* <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the message.
*
- * @param[in] default_url A <code>PP_Var</code> of type
- * <code>PP_VARTYPE_STRING</code> containing the default URL for the message.
+ * @param[in] destination_url A <code>PP_Var</code> of type
+ * <code>PP_VARTYPE_STRING</code> containing the destination URL for the
+ * message.
*/
- void KeyMessage(
+ void SessionMessage(
[in] PP_Instance instance,
[in] uint32_t reference_id,
[in] PP_Var message,
- [in] PP_Var default_url);
+ [in] PP_Var destination_url);
+
+ /**
+ * The session is now ready to decrypt the media stream.
+ *
+ * Note: The above describes the most simple case. Depending on the key
+ * system, a series of <code>SessionMessage()</code> calls from the CDM will
+ * be sent to the browser, and then on to the web application. The web
+ * application must then provide more data to the CDM by directing the browser
+ * to pass the data to the CDM via calls to <code>UpdateSession()</code> on
+ * the <code>PPP_ContentDecryptor_Private</code> interface.
+ * The CDM must call <code>SessionReady()</code> when the sequence is
+ * completed, and, in response, the browser must notify the web application.
+ *
+ * @param[in] reference_id A reference for the session that is ready.
+ */
+ void SessionReady(
+ [in] PP_Instance instance,
+ [in] uint32_t reference_id);
+
+ /**
+ * The session has been closed as the result of a call to the
+ * <code>ReleaseSession()</code> method on the
+ * <code>PPP_ContentDecryptor_Private</code> interface, or due to other
+ * factors as determined by the CDM.
+ *
+ * @param[in] reference_id A reference for the session that is closed.
+ */
+ void SessionClosed(
+ [in] PP_Instance instance,
+ [in] uint32_t reference_id);
/**
* An error occurred in a <code>PPP_ContentDecryptor_Private</code> method,
@@ -83,28 +110,13 @@ interface PPB_ContentDecryptor_Private {
*
* @param[in] system_error A system error code.
*/
- void KeyError(
+ void SessionError(
[in] PP_Instance instance,
[in] uint32_t reference_id,
[in] int32_t media_error,
[in] int32_t system_code);
/**
- * A session ID has been generated by the CDM for a session.
- *
- * @param[in] reference_id A reference for the session for which the session
- * id is intended.
- *
- * @param[in] session_id A <code>PP_Var</code> of type
- * <code>PP_VARTYPE_STRING</code> containing the session ID.
- *
- */
- void SetSessionId(
- [in] PP_Instance instance,
- [in] uint32_t reference_id,
- [in] PP_Var session_id);
-
- /**
* Called after the <code>Decrypt()</code> method on the
* <code>PPP_ContentDecryptor_Private</code> interface completes to
* deliver decrypted_block to the browser for decoding and rendering.
diff --git a/ppapi/api/private/ppp_content_decryptor_private.idl b/ppapi/api/private/ppp_content_decryptor_private.idl
index 0136ff0..11cffe0 100644
--- a/ppapi/api/private/ppp_content_decryptor_private.idl
+++ b/ppapi/api/private/ppp_content_decryptor_private.idl
@@ -9,15 +9,15 @@
* Decryption Modules, not normal plugins.
*/
label Chrome {
- M32 = 0.8
+ M33 = 0.9
};
/**
* <code>PPP_ContentDecryptor_Private</code> structure contains the function
* pointers the decryption plugin must implement to provide services needed by
* the browser. This interface provides the plugin side support for the Content
- * Decryption Module (CDM) for v0.1 of the proposed Encrypted Media Extensions:
- * http://goo.gl/rbdnR
+ * Decryption Module (CDM) for Encrypted Media Extensions:
+ * http://www.w3.org/TR/encrypted-media/
*/
interface PPP_ContentDecryptor_Private {
/**
@@ -31,16 +31,16 @@ interface PPP_ContentDecryptor_Private {
[in] PP_Var key_system);
/**
- * Generates a key request. key_system specifies the key or licensing system
- * to use. type contains the MIME type of init_data. init_data is a data
- * buffer containing data for use in generating the request.
+ * Creates a session. <code>type</code> contains the MIME type of
+ * <code>init_data</code>. <code>init_data</code> is a data buffer
+ * containing data for use in generating the request.
*
- * Note: <code>GenerateKeyRequest()</code> must create the session ID used in
+ * Note: <code>CreateSession()</code> must create the session ID used in
* other methods on this interface. The session ID must be provided to the
- * browser by the CDM via <code>KeyMessage()</code> on the
+ * browser by the CDM via <code>SessionCreated()</code> on the
* <code>PPB_ContentDecryptor_Private</code> interface.
*
- * @param[in] reference_id A reference for the session for which the key
+ * @param[in] reference_id A reference for the session for which a session
* should be generated.
*
* @param[in] type A <code>PP_Var</code> of type
@@ -50,47 +50,42 @@ interface PPP_ContentDecryptor_Private {
* <code>PP_VARTYPE_ARRAYBUFFER</code> containing container specific
* initialization data.
*/
- void GenerateKeyRequest(
+ void CreateSession(
[in] PP_Instance instance,
[in] uint32_t reference_id,
[in] PP_Var type,
[in] PP_Var init_data);
/**
- * Provides a key or license to the decryptor for decrypting media data.
+ * Provides a license or other message to the decryptor.
*
- * When the CDM needs more information to complete addition of the key it
- * will call <code>KeyMessage()</code> on the
- * <code>PPB_ContentDecryptor_Private</code> interface, which the browser
- * passes to the application. When the key is ready to use, the CDM
- * must call call <code>KeyAdded()</code> on the
+ * When the CDM needs more information, it must call
+ * <code>SessionMessage()</code> on the
+ * <code>PPB_ContentDecryptor_Private</code> interface, and the browser
+ * must notify the web application. When the CDM has finished processing
+ * <code>response</code> and needs no more information, it must call
+ * <code>SessionReady()</code> on the
* <code>PPB_ContentDecryptor_Private</code> interface, and the browser
* must notify the web application.
*
- * @param[in] reference_id A reference for the session for which the key
- * should be added.
- *
- * @param[in] key A <code>PP_Var</code> of type
- * <code>PP_VARTYPE_ARRAYBUFFER</code> containing the decryption key, license,
- * or other message for the given session ID.
+ * @param[in] reference_id A reference for the session to update.
*
- * @param[in] init_data A <code>PP_Var</code> of type
- * <code>PP_VARTYPE_ARRAYBUFFER</code> containing container specific
- * initialization data.
+ * @param[in] response A <code>PP_Var</code> of type
+ * <code>PP_VARTYPE_ARRAYBUFFER</code> containing the license or other
+ * message for the given session ID.
*/
- void AddKey(
+ void UpdateSession(
[in] PP_Instance instance,
[in] uint32_t reference_id,
- [in] PP_Var key,
- [in] PP_Var init_data);
+ [in] PP_Var response);
/**
- * Cancels a pending key request for the specified session ID.
+ * Release the specified session and related resources.
*
- * @param[in] reference_id A reference for the session for which the key
- * request should be cancelled.
+ * @param[in] reference_id A reference for the session that should be
+ * released.
*/
- void CancelKeyRequest(
+ void ReleaseSession(
[in] PP_Instance instance,
[in] uint32_t reference_id);
diff --git a/ppapi/c/private/ppb_content_decryptor_private.h b/ppapi/c/private/ppb_content_decryptor_private.h
index 72bd457..18fa715 100644
--- a/ppapi/c/private/ppb_content_decryptor_private.h
+++ b/ppapi/c/private/ppb_content_decryptor_private.h
@@ -4,7 +4,7 @@
*/
/* From private/ppb_content_decryptor_private.idl,
- * modified Mon Oct 21 17:11:33 2013.
+ * modified Wed Nov 27 14:10:24 2013.
*/
#ifndef PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_
@@ -18,10 +18,10 @@
#include "ppapi/c/pp_var.h"
#include "ppapi/c/private/pp_content_decryptor.h"
-#define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_8 \
- "PPB_ContentDecryptor_Private;0.8"
+#define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_9 \
+ "PPB_ContentDecryptor_Private;0.9"
#define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE \
- PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_8
+ PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_9
/**
* @file
@@ -39,40 +39,37 @@
* <code>PPB_ContentDecryptor_Private</code> structure contains the function
* pointers the browser must implement to support plugins implementing the
* <code>PPP_ContentDecryptor_Private</code> interface. This interface provides
- * browser side support for the Content Decryption Module (CDM) for v0.1 of the
- * proposed Encrypted Media Extensions: http://goo.gl/rbdnR
+ * browser side support for the Content Decryption Module (CDM) for Encrypted
+ * Media Extensions: http://www.w3.org/TR/encrypted-media/
*/
-struct PPB_ContentDecryptor_Private_0_8 {
+struct PPB_ContentDecryptor_Private_0_9 {
/**
- * A key has been added as the result of a call to the <code>AddKey()</code>
- * method on the <code>PPP_ContentDecryptor_Private</code> interface.
+ * A session has been created by the CDM.
*
- * Note: The above describes the most simple case. Depending on the key
- * system, a series of <code>KeyMessage()</code> calls from the CDM will be
- * sent to the browser, and then on to the web application. The web
- * application must then provide more data to the CDM by directing the browser
- * to pass the data to the CDM via calls to <code>AddKey()</code> on the
- * <code>PPP_ContentDecryptor_Private</code> interface.
- * The CDM must call <code>KeyAdded()</code> when the sequence is completed,
- * and, in response, the browser must notify the web application.
+ * @param[in] reference_id A reference for the session for which the CDM
+ * created a session.
+ *
+ * @param[in] web_session_id A <code>PP_Var</code> of type
+ * <code>PP_VARTYPE_STRING</code> containing the string for the
+ * MediaKeySession's sessionId attribute.
*
- * @param[in] reference_id A reference for the session for which a key
- * was added.
*/
- void (*KeyAdded)(PP_Instance instance, uint32_t reference_id);
+ void (*SessionCreated)(PP_Instance instance,
+ uint32_t reference_id,
+ struct PP_Var web_session_id);
/**
* A message or request has been generated for key_system in the CDM, and
* must be sent to the web application.
*
- * For example, when the browser invokes <code>GenerateKeyRequest()</code>
+ * For example, when the browser invokes <code>CreateSession()</code>
* on the <code>PPP_ContentDecryptor_Private</code> interface, the plugin
- * must send a key message containing the key request.
+ * must send a message containing the license request.
*
- * Note that <code>KeyMessage()</code> can be used for purposes other than
- * responses to <code>GenerateKeyRequest()</code> calls. See also the text
- * in the comment for <code>KeyAdded()</code>, which describes a sequence of
- * <code>AddKey()</code> and <code>KeyMessage()</code> calls required to
- * prepare for decryption.
+ * Note that <code>SessionMessage()</code> can be used for purposes other than
+ * responses to <code>CreateSession()</code> calls. See also the text
+ * in the comment for <code>SessionReady()</code>, which describes a sequence
+ * of <code>UpdateSession()</code> and <code>SessionMessage()</code> calls
+ * required to prepare for decryption.
*
* @param[in] reference_id A reference for the session for which the message
* is intended.
@@ -80,13 +77,38 @@ struct PPB_ContentDecryptor_Private_0_8 {
* @param[in] message A <code>PP_Var</code> of type
* <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the message.
*
- * @param[in] default_url A <code>PP_Var</code> of type
- * <code>PP_VARTYPE_STRING</code> containing the default URL for the message.
+ * @param[in] destination_url A <code>PP_Var</code> of type
+ * <code>PP_VARTYPE_STRING</code> containing the destination URL for the
+ * message.
+ */
+ void (*SessionMessage)(PP_Instance instance,
+ uint32_t reference_id,
+ struct PP_Var message,
+ struct PP_Var destination_url);
+ /**
+ * The session is now ready to decrypt the media stream.
+ *
+ * Note: The above describes the most simple case. Depending on the key
+ * system, a series of <code>SessionMessage()</code> calls from the CDM will
+ * be sent to the browser, and then on to the web application. The web
+ * application must then provide more data to the CDM by directing the browser
+ * to pass the data to the CDM via calls to <code>UpdateSession()</code> on
+ * the <code>PPP_ContentDecryptor_Private</code> interface.
+ * The CDM must call <code>SessionReady()</code> when the sequence is
+ * completed, and, in response, the browser must notify the web application.
+ *
+ * @param[in] reference_id A reference for the session that is ready.
*/
- void (*KeyMessage)(PP_Instance instance,
- uint32_t reference_id,
- struct PP_Var message,
- struct PP_Var default_url);
+ void (*SessionReady)(PP_Instance instance, uint32_t reference_id);
+ /**
+ * The session has been closed as the result of a call to the
+ * <code>ReleaseSession()</code> method on the
+ * <code>PPP_ContentDecryptor_Private</code> interface, or due to other
+ * factors as determined by the CDM.
+ *
+ * @param[in] reference_id A reference for the session that is closed.
+ */
+ void (*SessionClosed)(PP_Instance instance, uint32_t reference_id);
/**
* An error occurred in a <code>PPP_ContentDecryptor_Private</code> method,
* or within the plugin implementing the interface.
@@ -98,23 +120,10 @@ struct PPB_ContentDecryptor_Private_0_8 {
*
* @param[in] system_error A system error code.
*/
- void (*KeyError)(PP_Instance instance,
- uint32_t reference_id,
- int32_t media_error,
- int32_t system_code);
- /**
- * A session ID has been generated by the CDM for a session.
- *
- * @param[in] reference_id A reference for the session for which the session
- * id is intended.
- *
- * @param[in] session_id A <code>PP_Var</code> of type
- * <code>PP_VARTYPE_STRING</code> containing the session ID.
- *
- */
- void (*SetSessionId)(PP_Instance instance,
+ void (*SessionError)(PP_Instance instance,
uint32_t reference_id,
- struct PP_Var session_id);
+ int32_t media_error,
+ int32_t system_code);
/**
* Called after the <code>Decrypt()</code> method on the
* <code>PPP_ContentDecryptor_Private</code> interface completes to
@@ -244,7 +253,7 @@ struct PPB_ContentDecryptor_Private_0_8 {
const struct PP_DecryptedSampleInfo* decrypted_sample_info);
};
-typedef struct PPB_ContentDecryptor_Private_0_8 PPB_ContentDecryptor_Private;
+typedef struct PPB_ContentDecryptor_Private_0_9 PPB_ContentDecryptor_Private;
/**
* @}
*/
diff --git a/ppapi/c/private/ppp_content_decryptor_private.h b/ppapi/c/private/ppp_content_decryptor_private.h
index 97ecf0d..1873abc 100644
--- a/ppapi/c/private/ppp_content_decryptor_private.h
+++ b/ppapi/c/private/ppp_content_decryptor_private.h
@@ -4,7 +4,7 @@
*/
/* From private/ppp_content_decryptor_private.idl,
- * modified Fri Oct 18 18:11:09 2013.
+ * modified Wed Nov 27 15:42:55 2013.
*/
#ifndef PPAPI_C_PRIVATE_PPP_CONTENT_DECRYPTOR_PRIVATE_H_
@@ -18,10 +18,10 @@
#include "ppapi/c/pp_var.h"
#include "ppapi/c/private/pp_content_decryptor.h"
-#define PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_8 \
- "PPP_ContentDecryptor_Private;0.8"
+#define PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_9 \
+ "PPP_ContentDecryptor_Private;0.9"
#define PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE \
- PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_8
+ PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_9
/**
* @file
@@ -39,10 +39,10 @@
* <code>PPP_ContentDecryptor_Private</code> structure contains the function
* pointers the decryption plugin must implement to provide services needed by
* the browser. This interface provides the plugin side support for the Content
- * Decryption Module (CDM) for v0.1 of the proposed Encrypted Media Extensions:
- * http://goo.gl/rbdnR
+ * Decryption Module (CDM) for Encrypted Media Extensions:
+ * http://www.w3.org/TR/encrypted-media/
*/
-struct PPP_ContentDecryptor_Private_0_8 {
+struct PPP_ContentDecryptor_Private_0_9 {
/**
* Initialize for the specified key system.
*
@@ -51,16 +51,16 @@ struct PPP_ContentDecryptor_Private_0_8 {
*/
void (*Initialize)(PP_Instance instance, struct PP_Var key_system);
/**
- * Generates a key request. key_system specifies the key or licensing system
- * to use. type contains the MIME type of init_data. init_data is a data
- * buffer containing data for use in generating the request.
+ * Creates a session. <code>type</code> contains the MIME type of
+ * <code>init_data</code>. <code>init_data</code> is a data buffer
+ * containing data for use in generating the request.
*
- * Note: <code>GenerateKeyRequest()</code> must create the session ID used in
+ * Note: <code>CreateSession()</code> must create the session ID used in
* other methods on this interface. The session ID must be provided to the
- * browser by the CDM via <code>KeyMessage()</code> on the
+ * browser by the CDM via <code>SessionCreated()</code> on the
* <code>PPB_ContentDecryptor_Private</code> interface.
*
- * @param[in] reference_id A reference for the session for which the key
+ * @param[in] reference_id A reference for the session for which a session
* should be generated.
*
* @param[in] type A <code>PP_Var</code> of type
@@ -70,43 +70,38 @@ struct PPP_ContentDecryptor_Private_0_8 {
* <code>PP_VARTYPE_ARRAYBUFFER</code> containing container specific
* initialization data.
*/
- void (*GenerateKeyRequest)(PP_Instance instance,
- uint32_t reference_id,
- struct PP_Var type,
- struct PP_Var init_data);
+ void (*CreateSession)(PP_Instance instance,
+ uint32_t reference_id,
+ struct PP_Var type,
+ struct PP_Var init_data);
/**
- * Provides a key or license to the decryptor for decrypting media data.
+ * Provides a license or other message to the decryptor.
*
- * When the CDM needs more information to complete addition of the key it
- * will call <code>KeyMessage()</code> on the
- * <code>PPB_ContentDecryptor_Private</code> interface, which the browser
- * passes to the application. When the key is ready to use, the CDM
- * must call call <code>KeyAdded()</code> on the
+ * When the CDM needs more information, it must call
+ * <code>SessionMessage()</code> on the
+ * <code>PPB_ContentDecryptor_Private</code> interface, and the browser
+ * must notify the web application. When the CDM has finished processing
+ * <code>response</code> and needs no more information, it must call
+ * <code>SessionReady()</code> on the
* <code>PPB_ContentDecryptor_Private</code> interface, and the browser
* must notify the web application.
*
- * @param[in] reference_id A reference for the session for which the key
- * should be added.
- *
- * @param[in] key A <code>PP_Var</code> of type
- * <code>PP_VARTYPE_ARRAYBUFFER</code> containing the decryption key, license,
- * or other message for the given session ID.
+ * @param[in] reference_id A reference for the session to update.
*
- * @param[in] init_data A <code>PP_Var</code> of type
- * <code>PP_VARTYPE_ARRAYBUFFER</code> containing container specific
- * initialization data.
+ * @param[in] response A <code>PP_Var</code> of type
+ * <code>PP_VARTYPE_ARRAYBUFFER</code> containing the license or other
+ * message for the given session ID.
*/
- void (*AddKey)(PP_Instance instance,
- uint32_t reference_id,
- struct PP_Var key,
- struct PP_Var init_data);
+ void (*UpdateSession)(PP_Instance instance,
+ uint32_t reference_id,
+ struct PP_Var response);
/**
- * Cancels a pending key request for the specified session ID.
+ * Release the specified session and related resources.
*
- * @param[in] reference_id A reference for the session for which the key
- * request should be cancelled.
+ * @param[in] reference_id A reference for the session that should be
+ * released.
*/
- void (*CancelKeyRequest)(PP_Instance instance, uint32_t reference_id);
+ void (*ReleaseSession)(PP_Instance instance, uint32_t reference_id);
/**
* Decrypts the block and returns the unencrypted block via
* <code>DeliverBlock()</code> on the
@@ -233,7 +228,7 @@ struct PPP_ContentDecryptor_Private_0_8 {
const struct PP_EncryptedBlockInfo* encrypted_block_info);
};
-typedef struct PPP_ContentDecryptor_Private_0_8 PPP_ContentDecryptor_Private;
+typedef struct PPP_ContentDecryptor_Private_0_9 PPP_ContentDecryptor_Private;
/**
* @}
*/
diff --git a/ppapi/cpp/private/content_decryptor_private.cc b/ppapi/cpp/private/content_decryptor_private.cc
index 905b115..973144c 100644
--- a/ppapi/cpp/private/content_decryptor_private.cc
+++ b/ppapi/cpp/private/content_decryptor_private.cc
@@ -38,10 +38,10 @@ void Initialize(PP_Instance instance,
key_system_var.AsString());
}
-void GenerateKeyRequest(PP_Instance instance,
- uint32_t reference_id,
- PP_Var type_arg,
- PP_Var init_data_arg) {
+void CreateSession(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var type_arg,
+ PP_Var init_data_arg) {
void* object =
Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
if (!object)
@@ -56,45 +56,34 @@ void GenerateKeyRequest(PP_Instance instance,
return;
pp::VarArrayBuffer init_data_array_buffer(init_data_var);
- static_cast<ContentDecryptor_Private*>(object)->GenerateKeyRequest(
- reference_id,
- type_var.AsString(),
- init_data_array_buffer);
+ static_cast<ContentDecryptor_Private*>(object)->CreateSession(
+ reference_id, type_var.AsString(), init_data_array_buffer);
}
-void AddKey(PP_Instance instance,
- uint32_t reference_id,
- PP_Var key_arg,
- PP_Var init_data_arg) {
+void UpdateSession(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var response_arg) {
void* object =
Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
if (!object)
return;
- pp::Var key_var(pp::PASS_REF, key_arg);
- if (!key_var.is_array_buffer())
+ pp::Var response_var(pp::PASS_REF, response_arg);
+ if (!response_var.is_array_buffer())
return;
- pp::VarArrayBuffer key(key_var);
+ pp::VarArrayBuffer response(response_var);
- pp::Var init_data_var(pp::PASS_REF, init_data_arg);
- if (!init_data_var.is_array_buffer())
- return;
- pp::VarArrayBuffer init_data(init_data_var);
-
- static_cast<ContentDecryptor_Private*>(object)->AddKey(
- reference_id,
- key,
- init_data);
+ static_cast<ContentDecryptor_Private*>(object)
+ ->UpdateSession(reference_id, response);
}
-void CancelKeyRequest(PP_Instance instance, uint32_t reference_id) {
+void ReleaseSession(PP_Instance instance, uint32_t reference_id) {
void* object =
Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface);
if (!object)
return;
- static_cast<ContentDecryptor_Private*>(object)->CancelKeyRequest(
- reference_id);
+ static_cast<ContentDecryptor_Private*>(object)->ReleaseSession(reference_id);
}
@@ -187,9 +176,9 @@ void DecryptAndDecode(PP_Instance instance,
const PPP_ContentDecryptor_Private ppp_content_decryptor = {
&Initialize,
- &GenerateKeyRequest,
- &AddKey,
- &CancelKeyRequest,
+ &CreateSession,
+ &UpdateSession,
+ &ReleaseSession,
&Decrypt,
&InitializeAudioDecoder,
&InitializeVideoDecoder,
@@ -217,20 +206,23 @@ ContentDecryptor_Private::~ContentDecryptor_Private() {
this);
}
-void ContentDecryptor_Private::KeyAdded(uint32_t reference_id) {
+void ContentDecryptor_Private::SessionCreated(uint32_t reference_id,
+ const std::string& session_id) {
if (has_interface<PPB_ContentDecryptor_Private>()) {
- get_interface<PPB_ContentDecryptor_Private>()->KeyAdded(
+ pp::Var session_id_var(session_id);
+ get_interface<PPB_ContentDecryptor_Private>()->SessionCreated(
associated_instance_.pp_instance(),
- reference_id);
+ reference_id,
+ session_id_var.pp_var());
}
}
-void ContentDecryptor_Private::KeyMessage(uint32_t reference_id,
- pp::VarArrayBuffer message,
- const std::string& default_url) {
+void ContentDecryptor_Private::SessionMessage(uint32_t reference_id,
+ pp::VarArrayBuffer message,
+ const std::string& default_url) {
if (has_interface<PPB_ContentDecryptor_Private>()) {
pp::Var default_url_var(default_url);
- get_interface<PPB_ContentDecryptor_Private>()->KeyMessage(
+ get_interface<PPB_ContentDecryptor_Private>()->SessionMessage(
associated_instance_.pp_instance(),
reference_id,
message.pp_var(),
@@ -238,26 +230,29 @@ void ContentDecryptor_Private::KeyMessage(uint32_t reference_id,
}
}
-void ContentDecryptor_Private::KeyError(uint32_t reference_id,
- int32_t media_error,
- int32_t system_code) {
+void ContentDecryptor_Private::SessionReady(uint32_t reference_id) {
if (has_interface<PPB_ContentDecryptor_Private>()) {
- get_interface<PPB_ContentDecryptor_Private>()->KeyError(
- associated_instance_.pp_instance(),
- reference_id,
- media_error,
- system_code);
+ get_interface<PPB_ContentDecryptor_Private>()->SessionReady(
+ associated_instance_.pp_instance(), reference_id);
}
}
-void ContentDecryptor_Private::SetSessionId(uint32_t reference_id,
- const std::string& session_id) {
+void ContentDecryptor_Private::SessionClosed(uint32_t reference_id) {
if (has_interface<PPB_ContentDecryptor_Private>()) {
- pp::Var session_id_var(session_id);
- get_interface<PPB_ContentDecryptor_Private>()->SetSessionId(
+ get_interface<PPB_ContentDecryptor_Private>()->SessionClosed(
+ associated_instance_.pp_instance(), reference_id);
+ }
+}
+
+void ContentDecryptor_Private::SessionError(uint32_t reference_id,
+ int32_t media_error,
+ int32_t system_code) {
+ if (has_interface<PPB_ContentDecryptor_Private>()) {
+ get_interface<PPB_ContentDecryptor_Private>()->SessionError(
associated_instance_.pp_instance(),
reference_id,
- session_id_var.pp_var());
+ media_error,
+ system_code);
}
}
diff --git a/ppapi/cpp/private/content_decryptor_private.h b/ppapi/cpp/private/content_decryptor_private.h
index e8a93dc..c2a2ef0 100644
--- a/ppapi/cpp/private/content_decryptor_private.h
+++ b/ppapi/cpp/private/content_decryptor_private.h
@@ -32,13 +32,12 @@ class ContentDecryptor_Private {
// strings. The change would allow the CDM wrapper to reuse vars when
// replying to the browser.
virtual void Initialize(const std::string& key_system) = 0;
- virtual void GenerateKeyRequest(uint32_t reference_id,
- const std::string& type,
- pp::VarArrayBuffer init_data) = 0;
- virtual void AddKey(uint32_t reference_id,
- pp::VarArrayBuffer key,
- pp::VarArrayBuffer init_data) = 0;
- virtual void CancelKeyRequest(uint32_t reference_id) = 0;
+ virtual void CreateSession(uint32_t reference_id,
+ const std::string& type,
+ pp::VarArrayBuffer init_data) = 0;
+ virtual void UpdateSession(uint32_t reference_id,
+ pp::VarArrayBuffer response) = 0;
+ virtual void ReleaseSession(uint32_t reference_id) = 0;
virtual void Decrypt(pp::Buffer_Dev encrypted_buffer,
const PP_EncryptedBlockInfo& encrypted_block_info) = 0;
virtual void InitializeAudioDecoder(
@@ -59,14 +58,15 @@ class ContentDecryptor_Private {
// PPB_ContentDecryptor_Private methods for passing data from the decryptor
// to the browser.
- void KeyAdded(uint32_t reference_id);
- void KeyMessage(uint32_t reference_id,
- pp::VarArrayBuffer message,
- const std::string& default_url);
- void KeyError(uint32_t reference_id,
- int32_t media_error,
- int32_t system_code);
- void SetSessionId(uint32_t reference_id, const std::string& session_id);
+ void SessionCreated(uint32_t reference_id, const std::string& session_id);
+ void SessionMessage(uint32_t reference_id,
+ pp::VarArrayBuffer message,
+ const std::string& default_url);
+ void SessionReady(uint32_t reference_id);
+ void SessionClosed(uint32_t reference_id);
+ void SessionError(uint32_t reference_id,
+ int32_t media_error,
+ int32_t system_code);
// The plugin must not hold a reference to the encrypted buffer resource
// provided to Decrypt() when it calls this method. The browser will reuse
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index 5edbe5c..1c00a38 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -195,7 +195,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Selection_Dev_0_3;
-static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8;
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_CrxFileSystem_Private_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_Private_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRefPrivate_0_1;
@@ -233,7 +233,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UMA_Private_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDestination_Private_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoSource_Private_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_X509Certificate_Private_0_1;
-static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8;
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Instance_Private_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1;
@@ -2348,59 +2348,64 @@ static struct PP_Var Pnacl_M13_PPP_Selection_Dev_GetSelectedText(PP_Instance ins
/* Not generating wrapper methods for PPP_Zoom_Dev_0_3 */
-/* Begin wrapper methods for PPB_ContentDecryptor_Private_0_8 */
+/* Begin wrapper methods for PPB_ContentDecryptor_Private_0_9 */
-static void Pnacl_M32_PPB_ContentDecryptor_Private_KeyAdded(PP_Instance instance, uint32_t reference_id) {
- const struct PPB_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8.real_iface;
- iface->KeyAdded(instance, reference_id);
+static void Pnacl_M33_PPB_ContentDecryptor_Private_SessionCreated(PP_Instance instance, uint32_t reference_id, struct PP_Var* web_session_id) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
+ iface->SessionCreated(instance, reference_id, *web_session_id);
}
-static void Pnacl_M32_PPB_ContentDecryptor_Private_KeyMessage(PP_Instance instance, uint32_t reference_id, struct PP_Var* message, struct PP_Var* default_url) {
- const struct PPB_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8.real_iface;
- iface->KeyMessage(instance, reference_id, *message, *default_url);
+static void Pnacl_M33_PPB_ContentDecryptor_Private_SessionMessage(PP_Instance instance, uint32_t reference_id, struct PP_Var* message, struct PP_Var* destination_url) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
+ iface->SessionMessage(instance, reference_id, *message, *destination_url);
}
-static void Pnacl_M32_PPB_ContentDecryptor_Private_KeyError(PP_Instance instance, uint32_t reference_id, int32_t media_error, int32_t system_code) {
- const struct PPB_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8.real_iface;
- iface->KeyError(instance, reference_id, media_error, system_code);
+static void Pnacl_M33_PPB_ContentDecryptor_Private_SessionReady(PP_Instance instance, uint32_t reference_id) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
+ iface->SessionReady(instance, reference_id);
}
-static void Pnacl_M32_PPB_ContentDecryptor_Private_SetSessionId(PP_Instance instance, uint32_t reference_id, struct PP_Var* session_id) {
- const struct PPB_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8.real_iface;
- iface->SetSessionId(instance, reference_id, *session_id);
+static void Pnacl_M33_PPB_ContentDecryptor_Private_SessionClosed(PP_Instance instance, uint32_t reference_id) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
+ iface->SessionClosed(instance, reference_id);
}
-static void Pnacl_M32_PPB_ContentDecryptor_Private_DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info) {
- const struct PPB_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPB_ContentDecryptor_Private_SessionError(PP_Instance instance, uint32_t reference_id, int32_t media_error, int32_t system_code) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
+ iface->SessionError(instance, reference_id, media_error, system_code);
+}
+
+static void Pnacl_M33_PPB_ContentDecryptor_Private_DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
iface->DeliverBlock(instance, decrypted_block, decrypted_block_info);
}
-static void Pnacl_M32_PPB_ContentDecryptor_Private_DecoderInitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success) {
- const struct PPB_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPB_ContentDecryptor_Private_DecoderInitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
iface->DecoderInitializeDone(instance, decoder_type, request_id, success);
}
-static void Pnacl_M32_PPB_ContentDecryptor_Private_DecoderDeinitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) {
- const struct PPB_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPB_ContentDecryptor_Private_DecoderDeinitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
iface->DecoderDeinitializeDone(instance, decoder_type, request_id);
}
-static void Pnacl_M32_PPB_ContentDecryptor_Private_DecoderResetDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) {
- const struct PPB_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPB_ContentDecryptor_Private_DecoderResetDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
iface->DecoderResetDone(instance, decoder_type, request_id);
}
-static void Pnacl_M32_PPB_ContentDecryptor_Private_DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info) {
- const struct PPB_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPB_ContentDecryptor_Private_DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
iface->DeliverFrame(instance, decrypted_frame, decrypted_frame_info);
}
-static void Pnacl_M32_PPB_ContentDecryptor_Private_DeliverSamples(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedSampleInfo* decrypted_sample_info) {
- const struct PPB_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPB_ContentDecryptor_Private_DeliverSamples(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedSampleInfo* decrypted_sample_info) {
+ const struct PPB_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9.real_iface;
iface->DeliverSamples(instance, audio_frames, decrypted_sample_info);
}
-/* End wrapper methods for PPB_ContentDecryptor_Private_0_8 */
+/* End wrapper methods for PPB_ContentDecryptor_Private_0_9 */
/* Begin wrapper methods for PPB_Ext_CrxFileSystem_Private_0_1 */
@@ -3765,79 +3770,79 @@ static void Pnacl_M19_PPB_X509Certificate_Private_GetField(struct PP_Var* _struc
/* End wrapper methods for PPB_X509Certificate_Private_0_1 */
-/* Begin wrapper methods for PPP_ContentDecryptor_Private_0_8 */
+/* Begin wrapper methods for PPP_ContentDecryptor_Private_0_9 */
-static void Pnacl_M32_PPP_ContentDecryptor_Private_Initialize(PP_Instance instance, struct PP_Var key_system) {
- const struct PPP_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPP_ContentDecryptor_Private_Initialize(PP_Instance instance, struct PP_Var key_system) {
+ const struct PPP_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9.real_iface;
void (*temp_fp)(PP_Instance instance, struct PP_Var* key_system) =
((void (*)(PP_Instance instance, struct PP_Var* key_system))iface->Initialize);
temp_fp(instance, &key_system);
}
-static void Pnacl_M32_PPP_ContentDecryptor_Private_GenerateKeyRequest(PP_Instance instance, uint32_t reference_id, struct PP_Var type, struct PP_Var init_data) {
- const struct PPP_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPP_ContentDecryptor_Private_CreateSession(PP_Instance instance, uint32_t reference_id, struct PP_Var type, struct PP_Var init_data) {
+ const struct PPP_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9.real_iface;
void (*temp_fp)(PP_Instance instance, uint32_t reference_id, struct PP_Var* type, struct PP_Var* init_data) =
- ((void (*)(PP_Instance instance, uint32_t reference_id, struct PP_Var* type, struct PP_Var* init_data))iface->GenerateKeyRequest);
+ ((void (*)(PP_Instance instance, uint32_t reference_id, struct PP_Var* type, struct PP_Var* init_data))iface->CreateSession);
temp_fp(instance, reference_id, &type, &init_data);
}
-static void Pnacl_M32_PPP_ContentDecryptor_Private_AddKey(PP_Instance instance, uint32_t reference_id, struct PP_Var key, struct PP_Var init_data) {
- const struct PPP_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8.real_iface;
- void (*temp_fp)(PP_Instance instance, uint32_t reference_id, struct PP_Var* key, struct PP_Var* init_data) =
- ((void (*)(PP_Instance instance, uint32_t reference_id, struct PP_Var* key, struct PP_Var* init_data))iface->AddKey);
- temp_fp(instance, reference_id, &key, &init_data);
+static void Pnacl_M33_PPP_ContentDecryptor_Private_UpdateSession(PP_Instance instance, uint32_t reference_id, struct PP_Var response) {
+ const struct PPP_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9.real_iface;
+ void (*temp_fp)(PP_Instance instance, uint32_t reference_id, struct PP_Var* response) =
+ ((void (*)(PP_Instance instance, uint32_t reference_id, struct PP_Var* response))iface->UpdateSession);
+ temp_fp(instance, reference_id, &response);
}
-static void Pnacl_M32_PPP_ContentDecryptor_Private_CancelKeyRequest(PP_Instance instance, uint32_t reference_id) {
- const struct PPP_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPP_ContentDecryptor_Private_ReleaseSession(PP_Instance instance, uint32_t reference_id) {
+ const struct PPP_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9.real_iface;
void (*temp_fp)(PP_Instance instance, uint32_t reference_id) =
- ((void (*)(PP_Instance instance, uint32_t reference_id))iface->CancelKeyRequest);
+ ((void (*)(PP_Instance instance, uint32_t reference_id))iface->ReleaseSession);
temp_fp(instance, reference_id);
}
-static void Pnacl_M32_PPP_ContentDecryptor_Private_Decrypt(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info) {
- const struct PPP_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPP_ContentDecryptor_Private_Decrypt(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info) {
+ const struct PPP_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9.real_iface;
void (*temp_fp)(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info) =
((void (*)(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info))iface->Decrypt);
temp_fp(instance, encrypted_block, encrypted_block_info);
}
-static void Pnacl_M32_PPP_ContentDecryptor_Private_InitializeAudioDecoder(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data) {
- const struct PPP_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPP_ContentDecryptor_Private_InitializeAudioDecoder(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data) {
+ const struct PPP_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9.real_iface;
void (*temp_fp)(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data) =
((void (*)(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data))iface->InitializeAudioDecoder);
temp_fp(instance, decoder_config, codec_extra_data);
}
-static void Pnacl_M32_PPP_ContentDecryptor_Private_InitializeVideoDecoder(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data) {
- const struct PPP_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPP_ContentDecryptor_Private_InitializeVideoDecoder(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data) {
+ const struct PPP_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9.real_iface;
void (*temp_fp)(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data) =
((void (*)(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data))iface->InitializeVideoDecoder);
temp_fp(instance, decoder_config, codec_extra_data);
}
-static void Pnacl_M32_PPP_ContentDecryptor_Private_DeinitializeDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) {
- const struct PPP_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPP_ContentDecryptor_Private_DeinitializeDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) {
+ const struct PPP_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9.real_iface;
void (*temp_fp)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) =
((void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))iface->DeinitializeDecoder);
temp_fp(instance, decoder_type, request_id);
}
-static void Pnacl_M32_PPP_ContentDecryptor_Private_ResetDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) {
- const struct PPP_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPP_ContentDecryptor_Private_ResetDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) {
+ const struct PPP_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9.real_iface;
void (*temp_fp)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) =
((void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))iface->ResetDecoder);
temp_fp(instance, decoder_type, request_id);
}
-static void Pnacl_M32_PPP_ContentDecryptor_Private_DecryptAndDecode(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) {
- const struct PPP_ContentDecryptor_Private_0_8 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8.real_iface;
+static void Pnacl_M33_PPP_ContentDecryptor_Private_DecryptAndDecode(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) {
+ const struct PPP_ContentDecryptor_Private_0_9 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9.real_iface;
void (*temp_fp)(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) =
((void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info))iface->DecryptAndDecode);
temp_fp(instance, decoder_type, encrypted_buffer, encrypted_block_info);
}
-/* End wrapper methods for PPP_ContentDecryptor_Private_0_8 */
+/* End wrapper methods for PPP_ContentDecryptor_Private_0_9 */
/* Not generating wrapper methods for PPP_Flash_BrowserOperations_1_0 */
@@ -4715,17 +4720,18 @@ struct PPP_Selection_Dev_0_3 Pnacl_Wrappers_PPP_Selection_Dev_0_3 = {
/* Not generating wrapper interface for PPP_Zoom_Dev_0_3 */
-struct PPB_ContentDecryptor_Private_0_8 Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_8 = {
- .KeyAdded = (void (*)(PP_Instance instance, uint32_t reference_id))&Pnacl_M32_PPB_ContentDecryptor_Private_KeyAdded,
- .KeyMessage = (void (*)(PP_Instance instance, uint32_t reference_id, struct PP_Var message, struct PP_Var default_url))&Pnacl_M32_PPB_ContentDecryptor_Private_KeyMessage,
- .KeyError = (void (*)(PP_Instance instance, uint32_t reference_id, int32_t media_error, int32_t system_code))&Pnacl_M32_PPB_ContentDecryptor_Private_KeyError,
- .SetSessionId = (void (*)(PP_Instance instance, uint32_t reference_id, struct PP_Var session_id))&Pnacl_M32_PPB_ContentDecryptor_Private_SetSessionId,
- .DeliverBlock = (void (*)(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info))&Pnacl_M32_PPB_ContentDecryptor_Private_DeliverBlock,
- .DecoderInitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success))&Pnacl_M32_PPB_ContentDecryptor_Private_DecoderInitializeDone,
- .DecoderDeinitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M32_PPB_ContentDecryptor_Private_DecoderDeinitializeDone,
- .DecoderResetDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M32_PPB_ContentDecryptor_Private_DecoderResetDone,
- .DeliverFrame = (void (*)(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info))&Pnacl_M32_PPB_ContentDecryptor_Private_DeliverFrame,
- .DeliverSamples = (void (*)(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedSampleInfo* decrypted_sample_info))&Pnacl_M32_PPB_ContentDecryptor_Private_DeliverSamples
+struct PPB_ContentDecryptor_Private_0_9 Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_9 = {
+ .SessionCreated = (void (*)(PP_Instance instance, uint32_t reference_id, struct PP_Var web_session_id))&Pnacl_M33_PPB_ContentDecryptor_Private_SessionCreated,
+ .SessionMessage = (void (*)(PP_Instance instance, uint32_t reference_id, struct PP_Var message, struct PP_Var destination_url))&Pnacl_M33_PPB_ContentDecryptor_Private_SessionMessage,
+ .SessionReady = (void (*)(PP_Instance instance, uint32_t reference_id))&Pnacl_M33_PPB_ContentDecryptor_Private_SessionReady,
+ .SessionClosed = (void (*)(PP_Instance instance, uint32_t reference_id))&Pnacl_M33_PPB_ContentDecryptor_Private_SessionClosed,
+ .SessionError = (void (*)(PP_Instance instance, uint32_t reference_id, int32_t media_error, int32_t system_code))&Pnacl_M33_PPB_ContentDecryptor_Private_SessionError,
+ .DeliverBlock = (void (*)(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info))&Pnacl_M33_PPB_ContentDecryptor_Private_DeliverBlock,
+ .DecoderInitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success))&Pnacl_M33_PPB_ContentDecryptor_Private_DecoderInitializeDone,
+ .DecoderDeinitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M33_PPB_ContentDecryptor_Private_DecoderDeinitializeDone,
+ .DecoderResetDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M33_PPB_ContentDecryptor_Private_DecoderResetDone,
+ .DeliverFrame = (void (*)(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info))&Pnacl_M33_PPB_ContentDecryptor_Private_DeliverFrame,
+ .DeliverSamples = (void (*)(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedSampleInfo* decrypted_sample_info))&Pnacl_M33_PPB_ContentDecryptor_Private_DeliverSamples
};
struct PPB_Ext_CrxFileSystem_Private_0_1 Pnacl_Wrappers_PPB_Ext_CrxFileSystem_Private_0_1 = {
@@ -5090,17 +5096,17 @@ struct PPB_X509Certificate_Private_0_1 Pnacl_Wrappers_PPB_X509Certificate_Privat
.GetField = (struct PP_Var (*)(PP_Resource resource, PP_X509Certificate_Private_Field field))&Pnacl_M19_PPB_X509Certificate_Private_GetField
};
-struct PPP_ContentDecryptor_Private_0_8 Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_8 = {
- .Initialize = &Pnacl_M32_PPP_ContentDecryptor_Private_Initialize,
- .GenerateKeyRequest = &Pnacl_M32_PPP_ContentDecryptor_Private_GenerateKeyRequest,
- .AddKey = &Pnacl_M32_PPP_ContentDecryptor_Private_AddKey,
- .CancelKeyRequest = &Pnacl_M32_PPP_ContentDecryptor_Private_CancelKeyRequest,
- .Decrypt = &Pnacl_M32_PPP_ContentDecryptor_Private_Decrypt,
- .InitializeAudioDecoder = &Pnacl_M32_PPP_ContentDecryptor_Private_InitializeAudioDecoder,
- .InitializeVideoDecoder = &Pnacl_M32_PPP_ContentDecryptor_Private_InitializeVideoDecoder,
- .DeinitializeDecoder = &Pnacl_M32_PPP_ContentDecryptor_Private_DeinitializeDecoder,
- .ResetDecoder = &Pnacl_M32_PPP_ContentDecryptor_Private_ResetDecoder,
- .DecryptAndDecode = &Pnacl_M32_PPP_ContentDecryptor_Private_DecryptAndDecode
+struct PPP_ContentDecryptor_Private_0_9 Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_9 = {
+ .Initialize = &Pnacl_M33_PPP_ContentDecryptor_Private_Initialize,
+ .CreateSession = &Pnacl_M33_PPP_ContentDecryptor_Private_CreateSession,
+ .UpdateSession = &Pnacl_M33_PPP_ContentDecryptor_Private_UpdateSession,
+ .ReleaseSession = &Pnacl_M33_PPP_ContentDecryptor_Private_ReleaseSession,
+ .Decrypt = &Pnacl_M33_PPP_ContentDecryptor_Private_Decrypt,
+ .InitializeAudioDecoder = &Pnacl_M33_PPP_ContentDecryptor_Private_InitializeAudioDecoder,
+ .InitializeVideoDecoder = &Pnacl_M33_PPP_ContentDecryptor_Private_InitializeVideoDecoder,
+ .DeinitializeDecoder = &Pnacl_M33_PPP_ContentDecryptor_Private_DeinitializeDecoder,
+ .ResetDecoder = &Pnacl_M33_PPP_ContentDecryptor_Private_ResetDecoder,
+ .DecryptAndDecode = &Pnacl_M33_PPP_ContentDecryptor_Private_DecryptAndDecode
};
/* Not generating wrapper interface for PPP_Flash_BrowserOperations_1_0 */
@@ -5515,9 +5521,9 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Selection_Dev_0_3 = {
.real_iface = NULL
};
-static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8 = {
- .iface_macro = PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_8,
- .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_8,
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9 = {
+ .iface_macro = PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_9,
+ .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_9,
.real_iface = NULL
};
@@ -5743,9 +5749,9 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_X509Certificate_Private_0
.real_iface = NULL
};
-static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8 = {
- .iface_macro = PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_8,
- .wrapped_iface = (void *) &Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_8,
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9 = {
+ .iface_macro = PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_9,
+ .wrapped_iface = (void *) &Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_9,
.real_iface = NULL
};
@@ -5836,7 +5842,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2,
&Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3,
&Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16,
- &Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_8,
+ &Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_9,
&Pnacl_WrapperInfo_PPB_Ext_CrxFileSystem_Private_0_1,
&Pnacl_WrapperInfo_PPB_FileIO_Private_0_1,
&Pnacl_WrapperInfo_PPB_FileRefPrivate_0_1,
@@ -5884,7 +5890,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
static struct __PnaclWrapperInfo *s_ppp_wrappers[] = {
&Pnacl_WrapperInfo_PPP_Messaging_1_0,
&Pnacl_WrapperInfo_PPP_Selection_Dev_0_3,
- &Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_8,
+ &Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_9,
&Pnacl_WrapperInfo_PPP_Instance_Private_0_1,
NULL
};
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 8118bdd..ef6ae4e 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -648,17 +648,16 @@ IPC_MESSAGE_ROUTED3(
IPC_MESSAGE_ROUTED2(PpapiMsg_PPPContentDecryptor_Initialize,
PP_Instance /* instance */,
ppapi::proxy::SerializedVar /* key_system, String */)
-IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest,
+IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_CreateSession,
PP_Instance /* instance */,
uint32_t /* reference_id */,
ppapi::proxy::SerializedVar /* type, String */,
ppapi::proxy::SerializedVar /* init_data, ArrayBuffer */)
-IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_AddKey,
+IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_UpdateSession,
PP_Instance /* instance */,
uint32_t /* reference_id */,
- ppapi::proxy::SerializedVar /* key, ArrayBuffer */,
- ppapi::proxy::SerializedVar /* init_data, ArrayBuffer */)
-IPC_MESSAGE_ROUTED2(PpapiMsg_PPPContentDecryptor_CancelKeyRequest,
+ ppapi::proxy::SerializedVar /* response, ArrayBuffer */)
+IPC_MESSAGE_ROUTED2(PpapiMsg_PPPContentDecryptor_ReleaseSession,
PP_Instance /* instance */,
uint32_t /* reference_id */)
IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_Decrypt,
@@ -983,23 +982,26 @@ IPC_SYNC_MESSAGE_ROUTED2_2(
ppapi::proxy::SerializedHandle /* result_shm_handle */)
// PPB_ContentDecryptor_Dev messages handled in PPB_Instance_Proxy.
-IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBInstance_KeyAdded,
+IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_SessionCreated,
PP_Instance /* instance */,
- uint32_t /* reference_id */)
-IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_KeyMessage,
+ uint32_t /* reference_id */,
+ ppapi::proxy::SerializedVar /* session_id, String */)
+IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SessionMessage,
PP_Instance /* instance */,
uint32_t /* reference_id */,
ppapi::proxy::SerializedVar /* message, ArrayBuffer */,
- ppapi::proxy::SerializedVar /* default_url, String */)
-IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_KeyError,
+ ppapi::proxy::SerializedVar /* destination_url, String */)
+IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBInstance_SessionReady,
+ PP_Instance /* instance */,
+ uint32_t /* reference_id */)
+IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBInstance_SessionClosed,
+ PP_Instance /* instance */,
+ uint32_t /* reference_id */)
+IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SessionError,
PP_Instance /* instance */,
uint32_t /* reference_id */,
int32_t /* media_error */,
int32_t /* system_code */)
-IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_SetSessionId,
- PP_Instance /* instance */,
- uint32_t /* reference_id */,
- ppapi::proxy::SerializedVar /* session_id, String */)
IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_DeliverBlock,
PP_Instance /* instance */,
PP_Resource /* decrypted_block, PPB_Buffer_Dev */,
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index 40cd470..d6232ae 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -175,14 +175,16 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgGetPluginInstanceURL)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginReferrerURL,
OnHostMsgGetPluginReferrerURL)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_KeyAdded,
- OnHostMsgKeyAdded)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_KeyMessage,
- OnHostMsgKeyMessage)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_KeyError,
- OnHostMsgKeyError)
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetSessionId,
- OnHostMsgSetSessionId)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionCreated,
+ OnHostMsgSessionCreated)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionMessage,
+ OnHostMsgSessionMessage)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionReady,
+ OnHostMsgSessionReady)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionClosed,
+ OnHostMsgSessionClosed)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionError,
+ OnHostMsgSessionError)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverBlock,
OnHostMsgDeliverBlock)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DecoderInitializeDone,
@@ -540,49 +542,46 @@ PP_Var PPB_Instance_Proxy::GetPluginReferrerURL(
components);
}
-void PPB_Instance_Proxy::KeyAdded(PP_Instance instance, uint32_t reference_id) {
- dispatcher()->Send(
- new PpapiHostMsg_PPBInstance_KeyAdded(
- API_ID_PPB_INSTANCE,
- instance,
- reference_id));
+void PPB_Instance_Proxy::SessionCreated(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var session_id) {
+ dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionCreated(
+ API_ID_PPB_INSTANCE,
+ instance,
+ reference_id,
+ SerializedVarSendInput(dispatcher(), session_id)));
}
-void PPB_Instance_Proxy::KeyMessage(PP_Instance instance,
- uint32_t reference_id,
- PP_Var message,
- PP_Var default_url) {
- dispatcher()->Send(
- new PpapiHostMsg_PPBInstance_KeyMessage(
- API_ID_PPB_INSTANCE,
- instance,
- reference_id,
- SerializedVarSendInput(dispatcher(), message),
- SerializedVarSendInput(dispatcher(), default_url)));
+void PPB_Instance_Proxy::SessionMessage(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var message,
+ PP_Var destination_url) {
+ dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionMessage(
+ API_ID_PPB_INSTANCE,
+ instance,
+ reference_id,
+ SerializedVarSendInput(dispatcher(), message),
+ SerializedVarSendInput(dispatcher(), destination_url)));
}
-void PPB_Instance_Proxy::KeyError(PP_Instance instance,
- uint32_t reference_id,
- int32_t media_error,
- int32_t system_code) {
- dispatcher()->Send(
- new PpapiHostMsg_PPBInstance_KeyError(
- API_ID_PPB_INSTANCE,
- instance,
- reference_id,
- media_error,
- system_code));
+void PPB_Instance_Proxy::SessionReady(PP_Instance instance,
+ uint32_t reference_id) {
+ dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionReady(
+ API_ID_PPB_INSTANCE, instance, reference_id));
+}
+
+void PPB_Instance_Proxy::SessionClosed(PP_Instance instance,
+ uint32_t reference_id) {
+ dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionClosed(
+ API_ID_PPB_INSTANCE, instance, reference_id));
}
-void PPB_Instance_Proxy::SetSessionId(PP_Instance instance,
+void PPB_Instance_Proxy::SessionError(PP_Instance instance,
uint32_t reference_id,
- PP_Var session_id) {
- dispatcher()->Send(
- new PpapiHostMsg_PPBInstance_SetSessionId(
- API_ID_PPB_INSTANCE,
- instance,
- reference_id,
- SerializedVarSendInput(dispatcher(), session_id)));
+ int32_t media_error,
+ int32_t system_code) {
+ dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionError(
+ API_ID_PPB_INSTANCE, instance, reference_id, media_error, system_code));
}
void PPB_Instance_Proxy::DeliverBlock(PP_Instance instance,
@@ -1049,60 +1048,65 @@ void PPB_Instance_Proxy::OnHostMsgGetPluginReferrerURL(
}
}
-void PPB_Instance_Proxy::OnHostMsgKeyAdded(
+void PPB_Instance_Proxy::OnHostMsgSessionCreated(
PP_Instance instance,
- uint32_t reference_id) {
+ uint32_t reference_id,
+ SerializedVarReceiveInput session_id) {
if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE))
return;
EnterInstanceNoLock enter(instance);
if (enter.succeeded()) {
- enter.functions()->KeyAdded(instance, reference_id);
+ enter.functions()->SessionCreated(
+ instance, reference_id, session_id.Get(dispatcher()));
}
}
-void PPB_Instance_Proxy::OnHostMsgKeyMessage(
+void PPB_Instance_Proxy::OnHostMsgSessionMessage(
PP_Instance instance,
uint32_t reference_id,
SerializedVarReceiveInput message,
- SerializedVarReceiveInput default_url) {
+ SerializedVarReceiveInput destination_url) {
if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE))
return;
EnterInstanceNoLock enter(instance);
if (enter.succeeded()) {
- enter.functions()->KeyMessage(instance,
- reference_id,
- message.Get(dispatcher()),
- default_url.Get(dispatcher()));
+ enter.functions()->SessionMessage(instance,
+ reference_id,
+ message.Get(dispatcher()),
+ destination_url.Get(dispatcher()));
}
}
-void PPB_Instance_Proxy::OnHostMsgKeyError(
- PP_Instance instance,
- uint32_t reference_id,
- int32_t media_error,
- int32_t system_error) {
+void PPB_Instance_Proxy::OnHostMsgSessionReady(PP_Instance instance,
+ uint32_t reference_id) {
if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE))
return;
EnterInstanceNoLock enter(instance);
if (enter.succeeded()) {
- enter.functions()->KeyError(instance,
- reference_id,
- media_error,
- system_error);
+ enter.functions()->SessionReady(instance, reference_id);
}
}
-void PPB_Instance_Proxy::OnHostMsgSetSessionId(
- PP_Instance instance,
- uint32_t reference_id,
- SerializedVarReceiveInput session_id) {
+void PPB_Instance_Proxy::OnHostMsgSessionClosed(PP_Instance instance,
+ uint32_t reference_id) {
+ if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE))
+ return;
+ EnterInstanceNoLock enter(instance);
+ if (enter.succeeded()) {
+ enter.functions()->SessionClosed(instance, reference_id);
+ }
+}
+
+void PPB_Instance_Proxy::OnHostMsgSessionError(PP_Instance instance,
+ uint32_t reference_id,
+ int32_t media_error,
+ int32_t system_error) {
if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE))
return;
EnterInstanceNoLock enter(instance);
if (enter.succeeded()) {
- enter.functions()->SetSessionId(instance,
- reference_id,
- session_id.Get(dispatcher()));
+ enter.functions()->SessionError(
+ instance, reference_id, media_error, system_error);
}
}
diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h
index 4a892e5..2b02051 100644
--- a/ppapi/proxy/ppb_instance_proxy.h
+++ b/ppapi/proxy/ppb_instance_proxy.h
@@ -117,19 +117,21 @@ class PPB_Instance_Proxy : public InterfaceProxy,
virtual PP_Var GetPluginReferrerURL(
PP_Instance instance,
PP_URLComponents_Dev* components) OVERRIDE;
- virtual void KeyAdded(PP_Instance instance,
- uint32_t reference_id) OVERRIDE;
- virtual void KeyMessage(PP_Instance instance,
- uint32_t reference_id,
- PP_Var message,
- PP_Var default_url) OVERRIDE;
- virtual void KeyError(PP_Instance instance,
- uint32_t reference_id,
- int32_t media_error,
- int32_t system_code) OVERRIDE;
- virtual void SetSessionId(PP_Instance instance,
+ virtual void SessionCreated(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var session_id) OVERRIDE;
+ virtual void SessionMessage(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var message,
+ PP_Var destination_url) OVERRIDE;
+ virtual void SessionReady(PP_Instance instance,
+ uint32_t reference_id) OVERRIDE;
+ virtual void SessionClosed(PP_Instance instance,
+ uint32_t reference_id) OVERRIDE;
+ virtual void SessionError(PP_Instance instance,
uint32_t reference_id,
- PP_Var session_id) OVERRIDE;
+ int32_t media_error,
+ int32_t system_code) OVERRIDE;
virtual void DeliverBlock(PP_Instance instance,
PP_Resource decrypted_block,
const PP_DecryptedBlockInfo* block_info) OVERRIDE;
@@ -220,19 +222,22 @@ class PPB_Instance_Proxy : public InterfaceProxy,
SerializedVarReturnValue result);
void OnHostMsgGetPluginReferrerURL(PP_Instance instance,
SerializedVarReturnValue result);
- virtual void OnHostMsgKeyAdded(PP_Instance instance,
- uint32_t reference_id);
- virtual void OnHostMsgKeyMessage(PP_Instance instance,
- uint32_t reference_id,
- SerializedVarReceiveInput message,
- SerializedVarReceiveInput default_url);
- virtual void OnHostMsgKeyError(PP_Instance instance,
- uint32_t reference_id,
- int32_t media_error,
- int32_t system_code);
- virtual void OnHostMsgSetSessionId(PP_Instance instance,
+ virtual void OnHostMsgSessionCreated(PP_Instance instance,
+ uint32_t reference_id,
+ SerializedVarReceiveInput session_id);
+ virtual void OnHostMsgSessionMessage(
+ PP_Instance instance,
+ uint32_t reference_id,
+ SerializedVarReceiveInput message,
+ SerializedVarReceiveInput destination_url);
+ virtual void OnHostMsgSessionReady(PP_Instance instance,
+ uint32_t reference_id);
+ virtual void OnHostMsgSessionClosed(PP_Instance instance,
+ uint32_t reference_id);
+ virtual void OnHostMsgSessionError(PP_Instance instance,
uint32_t reference_id,
- SerializedVarReceiveInput session_id);
+ int32_t media_error,
+ int32_t system_code);
virtual void OnHostMsgDecoderInitializeDone(
PP_Instance instance,
PP_DecryptorStreamType decoder_type,
diff --git a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc
index 12ee04e..f0fa47a 100644
--- a/ppapi/proxy/ppp_content_decryptor_private_proxy.cc
+++ b/ppapi/proxy/ppp_content_decryptor_private_proxy.cc
@@ -124,56 +124,49 @@ void Initialize(PP_Instance instance,
SerializedVarSendInput(dispatcher, key_system)));
}
-void GenerateKeyRequest(PP_Instance instance,
- uint32_t reference_id,
- PP_Var type,
- PP_Var init_data) {
+void CreateSession(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var type,
+ PP_Var init_data) {
HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
if (!dispatcher) {
NOTREACHED();
return;
}
- dispatcher->Send(
- new PpapiMsg_PPPContentDecryptor_GenerateKeyRequest(
- API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
- instance,
- reference_id,
- SerializedVarSendInput(dispatcher, type),
- SerializedVarSendInput(dispatcher, init_data)));
+ dispatcher->Send(new PpapiMsg_PPPContentDecryptor_CreateSession(
+ API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
+ instance,
+ reference_id,
+ SerializedVarSendInput(dispatcher, type),
+ SerializedVarSendInput(dispatcher, init_data)));
}
-void AddKey(PP_Instance instance,
- uint32_t reference_id,
- PP_Var key,
- PP_Var init_data) {
+void UpdateSession(PP_Instance instance,
+ uint32_t reference_id,
+ PP_Var response) {
HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
if (!dispatcher) {
NOTREACHED();
return;
}
- dispatcher->Send(
- new PpapiMsg_PPPContentDecryptor_AddKey(
- API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
- instance,
- reference_id,
- SerializedVarSendInput(dispatcher, key),
- SerializedVarSendInput(dispatcher, init_data)));
+ dispatcher->Send(new PpapiMsg_PPPContentDecryptor_UpdateSession(
+ API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
+ instance,
+ reference_id,
+ SerializedVarSendInput(dispatcher, response)));
}
-void CancelKeyRequest(PP_Instance instance, uint32_t reference_id) {
+void ReleaseSession(PP_Instance instance, uint32_t reference_id) {
HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
if (!dispatcher) {
NOTREACHED();
return;
}
- dispatcher->Send(
- new PpapiMsg_PPPContentDecryptor_CancelKeyRequest(
- API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
- instance,
- reference_id));
+ dispatcher->Send(new PpapiMsg_PPPContentDecryptor_ReleaseSession(
+ API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, reference_id));
}
void Decrypt(PP_Instance instance,
@@ -365,9 +358,9 @@ void DecryptAndDecode(PP_Instance instance,
static const PPP_ContentDecryptor_Private content_decryptor_interface = {
&Initialize,
- &GenerateKeyRequest,
- &AddKey,
- &CancelKeyRequest,
+ &CreateSession,
+ &UpdateSession,
+ &ReleaseSession,
&Decrypt,
&InitializeAudioDecoder,
&InitializeVideoDecoder,
@@ -408,12 +401,12 @@ bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived(
IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Initialize,
OnMsgInitialize)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest,
- OnMsgGenerateKeyRequest)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey,
- OnMsgAddKey)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest,
- OnMsgCancelKeyRequest)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CreateSession,
+ OnMsgCreateSession)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_UpdateSession,
+ OnMsgUpdateSession)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ReleaseSession,
+ OnMsgReleaseSession)
IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt,
OnMsgDecrypt)
IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_InitializeAudioDecoder,
@@ -443,13 +436,13 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgInitialize(
}
}
-void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest(
+void PPP_ContentDecryptor_Private_Proxy::OnMsgCreateSession(
PP_Instance instance,
uint32_t reference_id,
SerializedVarReceiveInput type,
SerializedVarReceiveInput init_data) {
if (ppp_decryptor_impl_) {
- CallWhileUnlocked(ppp_decryptor_impl_->GenerateKeyRequest,
+ CallWhileUnlocked(ppp_decryptor_impl_->CreateSession,
instance,
reference_id,
ExtractReceivedVarAndAddRef(dispatcher(), &type),
@@ -457,25 +450,23 @@ void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest(
}
}
-void PPP_ContentDecryptor_Private_Proxy::OnMsgAddKey(
+void PPP_ContentDecryptor_Private_Proxy::OnMsgUpdateSession(
PP_Instance instance,
uint32_t reference_id,
- SerializedVarReceiveInput key,
- SerializedVarReceiveInput init_data) {
+ SerializedVarReceiveInput response) {
if (ppp_decryptor_impl_) {
- CallWhileUnlocked(ppp_decryptor_impl_->AddKey,
+ CallWhileUnlocked(ppp_decryptor_impl_->UpdateSession,
instance,
reference_id,
- ExtractReceivedVarAndAddRef(dispatcher(), &key),
- ExtractReceivedVarAndAddRef(dispatcher(), &init_data));
+ ExtractReceivedVarAndAddRef(dispatcher(), &response));
}
}
-void PPP_ContentDecryptor_Private_Proxy::OnMsgCancelKeyRequest(
+void PPP_ContentDecryptor_Private_Proxy::OnMsgReleaseSession(
PP_Instance instance,
uint32_t reference_id) {
if (ppp_decryptor_impl_) {
- CallWhileUnlocked(ppp_decryptor_impl_->CancelKeyRequest,
+ CallWhileUnlocked(ppp_decryptor_impl_->ReleaseSession,
instance,
reference_id);
}
diff --git a/ppapi/proxy/ppp_content_decryptor_private_proxy.h b/ppapi/proxy/ppp_content_decryptor_private_proxy.h
index b4472f5..192ab5f 100644
--- a/ppapi/proxy/ppp_content_decryptor_private_proxy.h
+++ b/ppapi/proxy/ppp_content_decryptor_private_proxy.h
@@ -32,16 +32,14 @@ class PPP_ContentDecryptor_Private_Proxy : public InterfaceProxy {
// Message handlers.
void OnMsgInitialize(PP_Instance instance,
SerializedVarReceiveInput key_system);
- void OnMsgGenerateKeyRequest(PP_Instance instance,
- uint32_t reference_id,
- SerializedVarReceiveInput type,
- SerializedVarReceiveInput init_data);
- void OnMsgAddKey(PP_Instance instance,
- uint32_t reference_id,
- SerializedVarReceiveInput key,
- SerializedVarReceiveInput init_data);
- void OnMsgCancelKeyRequest(PP_Instance instance,
- uint32_t reference_id);
+ void OnMsgCreateSession(PP_Instance instance,
+ uint32_t reference_id,
+ SerializedVarReceiveInput type,
+ SerializedVarReceiveInput init_data);
+ void OnMsgUpdateSession(PP_Instance instance,
+ uint32_t reference_id,
+ SerializedVarReceiveInput response);
+ void OnMsgReleaseSession(PP_Instance instance, uint32_t reference_id);
void OnMsgDecrypt(PP_Instance instance,
const PPPDecryptor_Buffer& encrypted_buffer,
const std::string& serialized_encrypted_block_info);
diff --git a/ppapi/thunk/interfaces_ppb_private.h b/ppapi/thunk/interfaces_ppb_private.h
index 9002545..11d5e52 100644
--- a/ppapi/thunk/interfaces_ppb_private.h
+++ b/ppapi/thunk/interfaces_ppb_private.h
@@ -25,8 +25,8 @@ PROXIED_IFACE(PPB_Broker, PPB_BROKER_TRUSTED_INTERFACE_0_3,
PROXIED_IFACE(PPB_Instance, PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0,
PPB_BrowserFont_Trusted_1_0)
PROXIED_IFACE(PPB_Instance,
- PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_8,
- PPB_ContentDecryptor_Private_0_8)
+ PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_9,
+ PPB_ContentDecryptor_Private_0_9)
PROXIED_IFACE(PPB_Instance, PPB_CHARSET_TRUSTED_INTERFACE_1_0,
PPB_CharSet_Trusted_1_0)
PROXIED_IFACE(NoAPIName, PPB_FILECHOOSER_TRUSTED_INTERFACE_0_5,
diff --git a/ppapi/thunk/ppb_content_decryptor_private_thunk.cc b/ppapi/thunk/ppb_content_decryptor_private_thunk.cc
index 201d526..ad9ece9 100644
--- a/ppapi/thunk/ppb_content_decryptor_private_thunk.cc
+++ b/ppapi/thunk/ppb_content_decryptor_private_thunk.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
// From private/ppb_content_decryptor_private.idl,
-// modified Thu Oct 17 15:03:48 2013.
+// modified Wed Nov 27 11:47:56 2013.
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/private/ppb_content_decryptor_private.h"
@@ -18,44 +18,58 @@ namespace thunk {
namespace {
-void KeyAdded(PP_Instance instance, uint32_t reference_id) {
- VLOG(4) << "PPB_ContentDecryptor_Private::KeyAdded()";
+void SessionCreated(PP_Instance instance,
+ uint32_t reference_id,
+ struct PP_Var web_session_id) {
+ VLOG(4) << "PPB_ContentDecryptor_Private::SessionCreated()";
EnterInstance enter(instance);
if (enter.failed())
return;
- enter.functions()->KeyAdded(instance, reference_id);
+ enter.functions()->SessionCreated(instance, reference_id, web_session_id);
}
-void KeyMessage(PP_Instance instance,
- uint32_t reference_id,
- struct PP_Var message,
- struct PP_Var default_url) {
- VLOG(4) << "PPB_ContentDecryptor_Private::KeyMessage()";
+void SessionMessage(PP_Instance instance,
+ uint32_t reference_id,
+ struct PP_Var message,
+ struct PP_Var destination_url) {
+ VLOG(4) << "PPB_ContentDecryptor_Private::SessionMessage()";
EnterInstance enter(instance);
if (enter.failed())
return;
- enter.functions()->KeyMessage(instance, reference_id, message, default_url);
+ enter.functions()->SessionMessage(instance,
+ reference_id,
+ message,
+ destination_url);
}
-void KeyError(PP_Instance instance,
- uint32_t reference_id,
- int32_t media_error,
- int32_t system_code) {
- VLOG(4) << "PPB_ContentDecryptor_Private::KeyError()";
+void SessionReady(PP_Instance instance, uint32_t reference_id) {
+ VLOG(4) << "PPB_ContentDecryptor_Private::SessionReady()";
EnterInstance enter(instance);
if (enter.failed())
return;
- enter.functions()->KeyError(instance, reference_id, media_error, system_code);
+ enter.functions()->SessionReady(instance, reference_id);
}
-void SetSessionId(PP_Instance instance,
+void SessionClosed(PP_Instance instance, uint32_t reference_id) {
+ VLOG(4) << "PPB_ContentDecryptor_Private::SessionClosed()";
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return;
+ enter.functions()->SessionClosed(instance, reference_id);
+}
+
+void SessionError(PP_Instance instance,
uint32_t reference_id,
- struct PP_Var session_id) {
- VLOG(4) << "PPB_ContentDecryptor_Private::SetSessionId()";
+ int32_t media_error,
+ int32_t system_code) {
+ VLOG(4) << "PPB_ContentDecryptor_Private::SessionError()";
EnterInstance enter(instance);
if (enter.failed())
return;
- enter.functions()->SetSessionId(instance, reference_id, session_id);
+ enter.functions()->SessionError(instance,
+ reference_id,
+ media_error,
+ system_code);
}
void DeliverBlock(PP_Instance instance,
@@ -131,12 +145,13 @@ void DeliverSamples(
decrypted_sample_info);
}
-const PPB_ContentDecryptor_Private_0_8
- g_ppb_contentdecryptor_private_thunk_0_8 = {
- &KeyAdded,
- &KeyMessage,
- &KeyError,
- &SetSessionId,
+const PPB_ContentDecryptor_Private_0_9
+ g_ppb_contentdecryptor_private_thunk_0_9 = {
+ &SessionCreated,
+ &SessionMessage,
+ &SessionReady,
+ &SessionClosed,
+ &SessionError,
&DeliverBlock,
&DecoderInitializeDone,
&DecoderDeinitializeDone,
@@ -147,9 +162,9 @@ const PPB_ContentDecryptor_Private_0_8
} // namespace
-const PPB_ContentDecryptor_Private_0_8*
- GetPPB_ContentDecryptor_Private_0_8_Thunk() {
- return &g_ppb_contentdecryptor_private_thunk_0_8;
+const PPB_ContentDecryptor_Private_0_9*
+ GetPPB_ContentDecryptor_Private_0_9_Thunk() {
+ return &g_ppb_contentdecryptor_private_thunk_0_9;
}
} // namespace thunk
diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h
index 60e4f07..54636a3 100644
--- a/ppapi/thunk/ppb_instance_api.h
+++ b/ppapi/thunk/ppb_instance_api.h
@@ -142,19 +142,19 @@ class PPB_Instance_API {
PP_URLComponents_Dev* components) = 0;
#if !defined(OS_NACL)
// Content Decryptor.
- virtual void KeyAdded(PP_Instance instance,
- uint32 reference_id) = 0;
- virtual void KeyMessage(PP_Instance instance,
- uint32 reference_id,
- PP_Var message,
- PP_Var default_url) = 0;
- virtual void KeyError(PP_Instance instance,
- uint32 reference_id,
- int32_t media_error,
- int32_t system_error) = 0;
- virtual void SetSessionId(PP_Instance instance,
+ virtual void SessionCreated(PP_Instance instance,
+ uint32 reference_id,
+ PP_Var session_id) = 0;
+ virtual void SessionMessage(PP_Instance instance,
+ uint32 reference_id,
+ PP_Var message,
+ PP_Var destination_url) = 0;
+ virtual void SessionReady(PP_Instance instance, uint32 reference_id) = 0;
+ virtual void SessionClosed(PP_Instance instance, uint32 reference_id) = 0;
+ virtual void SessionError(PP_Instance instance,
uint32 reference_id,
- PP_Var session_id) = 0;
+ int32_t media_error,
+ int32_t system_error) = 0;
virtual void DeliverBlock(PP_Instance instance,
PP_Resource decrypted_block,
const PP_DecryptedBlockInfo* block_info) = 0;