Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BASE_MEDIA_KEYS_H_ | 5 #ifndef MEDIA_BASE_MEDIA_KEYS_H_ |
| 6 #define MEDIA_BASE_MEDIA_KEYS_H_ | 6 #define MEDIA_BASE_MEDIA_KEYS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "media/base/cdm_context.h" | |
| 14 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class Time; | 19 class Time; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace media { | 22 namespace media { |
| 22 | 23 |
| 23 class Decryptor; | 24 class Decryptor; |
| 24 | 25 |
| 25 template <typename... T> | 26 template <typename... T> |
| 26 class CdmPromiseTemplate; | 27 class CdmPromiseTemplate; |
| 27 | 28 |
| 28 typedef CdmPromiseTemplate<std::string> NewSessionCdmPromise; | 29 typedef CdmPromiseTemplate<std::string> NewSessionCdmPromise; |
| 29 typedef CdmPromiseTemplate<> SimpleCdmPromise; | 30 typedef CdmPromiseTemplate<> SimpleCdmPromise; |
| 30 typedef std::vector<std::vector<uint8> > KeyIdsVector; | 31 typedef std::vector<std::vector<uint8> > KeyIdsVector; |
| 31 typedef CdmPromiseTemplate<KeyIdsVector> KeyIdsPromise; | 32 typedef CdmPromiseTemplate<KeyIdsVector> KeyIdsPromise; |
| 32 | 33 |
| 33 // Performs media key operations. | 34 // Performs media key operations. |
| 34 // | 35 // |
| 35 // All key operations are called on the renderer thread. Therefore, these calls | 36 // All key operations are called on the renderer thread. Therefore, these calls |
| 36 // should be fast and nonblocking; key events should be fired asynchronously. | 37 // should be fast and nonblocking; key events should be fired asynchronously. |
| 37 class MEDIA_EXPORT MediaKeys { | 38 class MEDIA_EXPORT MediaKeys : public CdmContext{ |
|
ddorwin
2014/11/20 21:31:46
Should the CDM be a Context or provide a context?
xhwang
2014/11/21 01:34:26
Yes, I also debated on that one. I think it makes
| |
| 38 public: | 39 public: |
| 39 // Reported to UMA, so never reuse a value! | 40 // Reported to UMA, so never reuse a value! |
| 40 // Must be kept in sync with blink::WebMediaPlayerClient::MediaKeyErrorCode | 41 // Must be kept in sync with blink::WebMediaPlayerClient::MediaKeyErrorCode |
| 41 // (enforced in webmediaplayer_impl.cc). | 42 // (enforced in webmediaplayer_impl.cc). |
| 42 // TODO(jrummell): Can this be moved to proxy_decryptor as it should only be | 43 // TODO(jrummell): Can this be moved to proxy_decryptor as it should only be |
| 43 // used by the prefixed EME code? | 44 // used by the prefixed EME code? |
| 44 enum KeyError { | 45 enum KeyError { |
| 45 kUnknownError = 1, | 46 kUnknownError = 1, |
| 46 kClientError, | 47 kClientError, |
| 47 // The commented v0.1b values below have never been used. | 48 // The commented v0.1b values below have never been used. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 65 | 66 |
| 66 // Type of license required when creating/loading a session. | 67 // Type of license required when creating/loading a session. |
| 67 // Must be consistent with the values specified in the spec: | 68 // Must be consistent with the values specified in the spec: |
| 68 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypte d-media.html#extensions | 69 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypte d-media.html#extensions |
| 69 enum SessionType { | 70 enum SessionType { |
| 70 TEMPORARY_SESSION, | 71 TEMPORARY_SESSION, |
| 71 PERSISTENT_SESSION | 72 PERSISTENT_SESSION |
| 72 }; | 73 }; |
| 73 | 74 |
| 74 static const uint32 kInvalidSessionId = 0; | 75 static const uint32 kInvalidSessionId = 0; |
| 75 #if defined(ENABLE_BROWSER_CDMS) | |
| 76 static const int kInvalidCdmId = 0; | |
| 77 #endif | |
| 78 | 76 |
| 79 MediaKeys(); | 77 MediaKeys(); |
|
ddorwin
2014/11/20 21:31:46
ditto
xhwang
2014/11/21 01:34:26
Done.
| |
| 80 virtual ~MediaKeys(); | 78 ~MediaKeys() override; |
| 81 | 79 |
| 82 // Provides a server certificate to be used to encrypt messages to the | 80 // Provides a server certificate to be used to encrypt messages to the |
| 83 // license server. | 81 // license server. |
| 84 virtual void SetServerCertificate(const uint8* certificate_data, | 82 virtual void SetServerCertificate(const uint8* certificate_data, |
| 85 int certificate_data_length, | 83 int certificate_data_length, |
| 86 scoped_ptr<SimpleCdmPromise> promise) = 0; | 84 scoped_ptr<SimpleCdmPromise> promise) = 0; |
| 87 | 85 |
| 88 // Creates a session with the |init_data_type|, |init_data| and |session_type| | 86 // Creates a session with the |init_data_type|, |init_data| and |session_type| |
| 89 // provided. | 87 // provided. |
| 90 // Note: UpdateSession() and ReleaseSession() should only be called after | 88 // Note: UpdateSession() and ReleaseSession() should only be called after |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 114 // Removes stored session data associated with the session specified by | 112 // Removes stored session data associated with the session specified by |
| 115 // |web_session_id|. | 113 // |web_session_id|. |
| 116 virtual void RemoveSession(const std::string& web_session_id, | 114 virtual void RemoveSession(const std::string& web_session_id, |
| 117 scoped_ptr<SimpleCdmPromise> promise) = 0; | 115 scoped_ptr<SimpleCdmPromise> promise) = 0; |
| 118 | 116 |
| 119 // Retrieves the key IDs for keys in the session that the CDM knows are | 117 // Retrieves the key IDs for keys in the session that the CDM knows are |
| 120 // currently usable to decrypt media data. | 118 // currently usable to decrypt media data. |
| 121 virtual void GetUsableKeyIds(const std::string& web_session_id, | 119 virtual void GetUsableKeyIds(const std::string& web_session_id, |
| 122 scoped_ptr<KeyIdsPromise> promise) = 0; | 120 scoped_ptr<KeyIdsPromise> promise) = 0; |
| 123 | 121 |
| 124 // Gets the Decryptor object associated with the MediaKeys. Returns NULL if | 122 // CdmContext implementation |
|
ddorwin
2014/11/20 21:31:47
nit: period.
xhwang
2014/11/21 01:34:26
Done.
| |
| 125 // no Decryptor object is associated. The returned object is only guaranteed | 123 Decryptor* GetDecryptor() override; |
|
ddorwin
2014/11/20 21:31:46
I may have asked this before, but why isn't this j
xhwang
2014/11/21 01:34:26
Done, so that we won't discuss this again in the f
| |
| 126 // to be valid during the MediaKeys' lifetime. | |
| 127 virtual Decryptor* GetDecryptor(); | |
| 128 | |
| 129 #if defined(ENABLE_BROWSER_CDMS) | |
| 130 // Returns the CDM ID associated with |this|. May be kInvalidCdmId if no CDM | |
| 131 // ID is associated. | |
| 132 virtual int GetCdmId() const = 0; | |
| 133 #endif | |
| 134 | 124 |
| 135 private: | 125 private: |
| 136 DISALLOW_COPY_AND_ASSIGN(MediaKeys); | 126 DISALLOW_COPY_AND_ASSIGN(MediaKeys); |
| 137 }; | 127 }; |
| 138 | 128 |
| 139 // Key event callbacks. See the spec for details: | 129 // Key event callbacks. See the spec for details: |
| 140 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted- media.html#event-summary | 130 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted- media.html#event-summary |
| 141 typedef base::Callback<void(const std::string& web_session_id, | 131 typedef base::Callback<void(const std::string& web_session_id, |
| 142 const std::vector<uint8>& message, | 132 const std::vector<uint8>& message, |
| 143 const GURL& destination_url)> SessionMessageCB; | 133 const GURL& destination_url)> SessionMessageCB; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 155 bool has_additional_usable_key)> | 145 bool has_additional_usable_key)> |
| 156 SessionKeysChangeCB; | 146 SessionKeysChangeCB; |
| 157 | 147 |
| 158 typedef base::Callback<void(const std::string& web_session_id, | 148 typedef base::Callback<void(const std::string& web_session_id, |
| 159 const base::Time& new_expiry_time)> | 149 const base::Time& new_expiry_time)> |
| 160 SessionExpirationUpdateCB; | 150 SessionExpirationUpdateCB; |
| 161 | 151 |
| 162 } // namespace media | 152 } // namespace media |
| 163 | 153 |
| 164 #endif // MEDIA_BASE_MEDIA_KEYS_H_ | 154 #endif // MEDIA_BASE_MEDIA_KEYS_H_ |
| OLD | NEW |