Index: media/cdm/proxy_decryptor.h |
diff --git a/media/cdm/proxy_decryptor.h b/media/cdm/proxy_decryptor.h |
index ff611ad3197a60da3268b51bfdbfbea698b1164c..ee20f3518adc96941f04c8103a5ac6f0981330a4 100644 |
--- a/media/cdm/proxy_decryptor.h |
+++ b/media/cdm/proxy_decryptor.h |
@@ -12,6 +12,7 @@ |
#include "base/containers/hash_tables.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/memory/weak_ptr.h" |
+#include "media/base/cdm_context.h" |
#include "media/base/decryptor.h" |
#include "media/base/eme_constants.h" |
#include "media/base/media_export.h" |
@@ -32,6 +33,9 @@ class MediaPermission; |
// TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name! |
class MEDIA_EXPORT ProxyDecryptor { |
public: |
+ typedef base::Callback<void(CdmContext*, const CdmAttachedCB&)> |
+ SetCdmContextCB; |
+ |
// These are similar to the callbacks in media_keys.h, but pass back the |
// session ID rather than the internal session ID. |
typedef base::Callback<void(const std::string& session_id)> KeyAddedCB; |
@@ -48,16 +52,16 @@ class MEDIA_EXPORT ProxyDecryptor { |
const KeyMessageCB& key_message_cb); |
virtual ~ProxyDecryptor(); |
- // Returns the CdmContext associated with this object. |
- CdmContext* GetCdmContext(); |
- |
- // Only call this once. |
- bool InitializeCDM(CdmFactory* cdm_factory, |
- const std::string& key_system, |
- const GURL& security_origin); |
+ // Creates the CDM and fires |cdm_created_cb|. This method should only be |
+ // called once. If CDM creation failed, all following GenerateKeyRequest, |
+ // AddKey and CancelKeyRequest calls will result in a KeyError. |
+ void CreateCdm(CdmFactory* cdm_factory, |
+ const std::string& key_system, |
+ const GURL& security_origin, |
+ const SetCdmContextCB& set_cdm_context_cb); |
- // May only be called after InitializeCDM() succeeds. |
- bool GenerateKeyRequest(EmeInitDataType init_data_type, |
+ // May only be called after CreateCDM(). |
+ void GenerateKeyRequest(EmeInitDataType init_data_type, |
const uint8* init_data, |
int init_data_length); |
void AddKey(const uint8* key, int key_length, |
@@ -66,11 +70,14 @@ class MEDIA_EXPORT ProxyDecryptor { |
void CancelKeyRequest(const std::string& session_id); |
private: |
- // Helper function to create MediaKeys to handle the given |key_system|. |
- scoped_ptr<MediaKeys> CreateMediaKeys( |
- CdmFactory* cdm_factory, |
- const std::string& key_system, |
- const GURL& security_origin); |
+ // Callback for CreateCdm(). |
+ void OnCdmCreated(const std::string& key_system, |
+ const GURL& security_origin, |
+ const SetCdmContextCB& set_cdm_context_cb, |
+ scoped_ptr<MediaKeys> cdm); |
+ |
+ void GenerateKeyRequestInternal(EmeInitDataType init_data_type, |
+ const std::vector<uint8>& init_data); |
// Callbacks for firing session events. |
void OnSessionMessage(const std::string& session_id, |
@@ -106,6 +113,17 @@ class MEDIA_EXPORT ProxyDecryptor { |
void SetSessionId(SessionCreationType session_type, |
const std::string& session_id); |
+ struct PendingGenerateKeyRequestData { |
+ PendingGenerateKeyRequestData(EmeInitDataType init_data_type, |
+ const std::vector<uint8>& init_data); |
+ ~PendingGenerateKeyRequestData(); |
+ |
+ EmeInitDataType init_data_type; |
+ std::vector<uint8> init_data; |
+ }; |
+ |
+ bool is_creating_cdm_; |
+ |
// The real MediaKeys that manages key operations for the ProxyDecryptor. |
scoped_ptr<MediaKeys> media_keys_; |
@@ -124,6 +142,8 @@ class MEDIA_EXPORT ProxyDecryptor { |
bool is_clear_key_; |
+ std::vector<PendingGenerateKeyRequestData> pending_requests_; |
+ |
// NOTE: Weak pointers must be invalidated before all other member variables. |
base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; |