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_CONTENT_DECRYPTION_MODULE_H_ |
6 #define MEDIA_BASE_MEDIA_KEYS_H_ | 6 #define MEDIA_BASE_CONTENT_DECRYPTION_MODULE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
18 #include "media/base/eme_constants.h" | 18 #include "media/base/eme_constants.h" |
19 #include "media/base/media_export.h" | 19 #include "media/base/media_export.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class Time; | 23 class Time; |
24 } | 24 } |
25 | 25 |
26 namespace media { | 26 namespace media { |
27 | 27 |
28 class CdmContext; | 28 class CdmContext; |
29 struct CdmKeyInformation; | 29 struct CdmKeyInformation; |
30 struct MediaKeysTraits; | 30 struct ContentDecryptionModuleTraits; |
31 | 31 |
32 template <typename... T> | 32 template <typename... T> |
33 class CdmPromiseTemplate; | 33 class CdmPromiseTemplate; |
34 | 34 |
35 typedef CdmPromiseTemplate<std::string> NewSessionCdmPromise; | 35 typedef CdmPromiseTemplate<std::string> NewSessionCdmPromise; |
36 typedef CdmPromiseTemplate<> SimpleCdmPromise; | 36 typedef CdmPromiseTemplate<> SimpleCdmPromise; |
37 typedef ScopedVector<CdmKeyInformation> CdmKeysInfo; | 37 typedef ScopedVector<CdmKeyInformation> CdmKeysInfo; |
38 | 38 |
39 // An interface that represents the Content Decryption Module (CDM) in the | 39 // An interface that represents the Content Decryption Module (CDM) in the |
40 // Encrypted Media Extensions (EME) spec in Chromium. | 40 // Encrypted Media Extensions (EME) spec in Chromium. |
(...skipping 12 matching lines...) Expand all Loading... | |
53 // directly to avoid having a ref-count held by the callback. | 53 // directly to avoid having a ref-count held by the callback. |
54 // | 54 // |
55 // * Thread Safety | 55 // * Thread Safety |
56 // | 56 // |
57 // Most CDM operations happen on one thread. However, it is not uncommon that | 57 // Most CDM operations happen on one thread. However, it is not uncommon that |
58 // the media player lives on a different thread and may call into the CDM from | 58 // the media player lives on a different thread and may call into the CDM from |
59 // that thread. For example, if the CDM supports a Decryptor interface, the | 59 // that thread. For example, if the CDM supports a Decryptor interface, the |
60 // Decryptor methods could be called on a different thread. The CDM | 60 // Decryptor methods could be called on a different thread. The CDM |
61 // implementation should make sure it's thread safe for these situations. | 61 // implementation should make sure it's thread safe for these situations. |
62 // | 62 // |
63 // TODO(xhwang): Rename MediaKeys to ContentDecryptionModule. See | 63 // TODO(xhwang): Rename ContentDecryptionModule to ContentDecryptionModule. See |
64 // http://crbug.com/309237 | 64 // http://crbug.com/309237 |
jrummell
2016/12/12 22:08:40
nit: You can remove this comment now :)
xhwang
2016/12/12 22:32:50
Done.
| |
65 | 65 |
66 class MEDIA_EXPORT MediaKeys | 66 class MEDIA_EXPORT ContentDecryptionModule |
67 : public base::RefCountedThreadSafe<MediaKeys, MediaKeysTraits> { | 67 : public base::RefCountedThreadSafe<ContentDecryptionModule, |
68 ContentDecryptionModuleTraits> { | |
68 public: | 69 public: |
69 // Type of license required when creating/loading a session. | 70 // Type of license required when creating/loading a session. |
70 // Must be consistent with the values specified in the spec: | 71 // Must be consistent with the values specified in the spec: |
71 // https://w3c.github.io/encrypted-media/#idl-def-MediaKeySessionType | 72 // https://w3c.github.io/encrypted-media/#idl-def-MediaKeySessionType |
72 enum SessionType { | 73 enum SessionType { |
73 TEMPORARY_SESSION, | 74 TEMPORARY_SESSION, |
74 PERSISTENT_LICENSE_SESSION, | 75 PERSISTENT_LICENSE_SESSION, |
75 PERSISTENT_RELEASE_MESSAGE_SESSION, | 76 PERSISTENT_RELEASE_MESSAGE_SESSION, |
76 SESSION_TYPE_MAX = PERSISTENT_RELEASE_MESSAGE_SESSION | 77 SESSION_TYPE_MAX = PERSISTENT_RELEASE_MESSAGE_SESSION |
77 }; | 78 }; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 // TODO(xhwang): Convert all SetCdm() implementations to use CdmContext so | 145 // TODO(xhwang): Convert all SetCdm() implementations to use CdmContext so |
145 // that this function should never return nullptr. | 146 // that this function should never return nullptr. |
146 virtual CdmContext* GetCdmContext(); | 147 virtual CdmContext* GetCdmContext(); |
147 | 148 |
148 // Deletes |this| on the correct thread. By default |this| is deleted | 149 // Deletes |this| on the correct thread. By default |this| is deleted |
149 // immediately. Override this method if |this| needs to be deleted on a | 150 // immediately. Override this method if |this| needs to be deleted on a |
150 // specific thread. | 151 // specific thread. |
151 virtual void DeleteOnCorrectThread() const; | 152 virtual void DeleteOnCorrectThread() const; |
152 | 153 |
153 protected: | 154 protected: |
154 friend class base::RefCountedThreadSafe<MediaKeys, MediaKeysTraits>; | 155 friend class base::RefCountedThreadSafe<ContentDecryptionModule, |
156 ContentDecryptionModuleTraits>; | |
155 | 157 |
156 MediaKeys(); | 158 ContentDecryptionModule(); |
157 virtual ~MediaKeys(); | 159 virtual ~ContentDecryptionModule(); |
158 | 160 |
159 private: | 161 private: |
160 DISALLOW_COPY_AND_ASSIGN(MediaKeys); | 162 DISALLOW_COPY_AND_ASSIGN(ContentDecryptionModule); |
161 }; | 163 }; |
162 | 164 |
163 struct MEDIA_EXPORT MediaKeysTraits { | 165 struct MEDIA_EXPORT ContentDecryptionModuleTraits { |
164 // Destroys |media_keys| on the correct thread. | 166 // Destroys |cdm| on the correct thread. |
165 static void Destruct(const MediaKeys* media_keys); | 167 static void Destruct(const ContentDecryptionModule* cdm); |
166 }; | 168 }; |
167 | 169 |
168 // CDM session event callbacks. | 170 // CDM session event callbacks. |
169 | 171 |
170 // Called when the CDM needs to queue a message event to the session object. | 172 // Called when the CDM needs to queue a message event to the session object. |
171 // See http://w3c.github.io/encrypted-media/#dom-evt-message | 173 // See http://w3c.github.io/encrypted-media/#dom-evt-message |
172 typedef base::Callback<void(const std::string& session_id, | 174 typedef base::Callback<void(const std::string& session_id, |
173 MediaKeys::MessageType message_type, | 175 ContentDecryptionModule::MessageType message_type, |
174 const std::vector<uint8_t>& message)> | 176 const std::vector<uint8_t>& message)> |
175 SessionMessageCB; | 177 SessionMessageCB; |
176 | 178 |
177 // Called when the session specified by |session_id| is closed. Note that the | 179 // Called when the session specified by |session_id| is closed. Note that the |
178 // CDM may close a session at any point, such as in response to a CloseSession() | 180 // CDM may close a session at any point, such as in response to a CloseSession() |
179 // call, when the session is no longer needed, or when system resources are | 181 // call, when the session is no longer needed, or when system resources are |
180 // lost. See http://w3c.github.io/encrypted-media/#session-close | 182 // lost. See http://w3c.github.io/encrypted-media/#session-close |
181 typedef base::Callback<void(const std::string& session_id)> SessionClosedCB; | 183 typedef base::Callback<void(const std::string& session_id)> SessionClosedCB; |
182 | 184 |
183 // Called when there has been a change in the keys in the session or their | 185 // Called when there has been a change in the keys in the session or their |
184 // status. See http://w3c.github.io/encrypted-media/#dom-evt-keystatuseschange | 186 // status. See http://w3c.github.io/encrypted-media/#dom-evt-keystatuseschange |
185 typedef base::Callback<void(const std::string& session_id, | 187 typedef base::Callback<void(const std::string& session_id, |
186 bool has_additional_usable_key, | 188 bool has_additional_usable_key, |
187 CdmKeysInfo keys_info)> SessionKeysChangeCB; | 189 CdmKeysInfo keys_info)> |
190 SessionKeysChangeCB; | |
188 | 191 |
189 // Called when the CDM changes the expiration time of a session. | 192 // Called when the CDM changes the expiration time of a session. |
190 // See http://w3c.github.io/encrypted-media/#update-expiration | 193 // See http://w3c.github.io/encrypted-media/#update-expiration |
191 typedef base::Callback<void(const std::string& session_id, | 194 typedef base::Callback<void(const std::string& session_id, |
192 base::Time new_expiry_time)> | 195 base::Time new_expiry_time)> |
193 SessionExpirationUpdateCB; | 196 SessionExpirationUpdateCB; |
194 | 197 |
195 } // namespace media | 198 } // namespace media |
196 | 199 |
197 #endif // MEDIA_BASE_MEDIA_KEYS_H_ | 200 #endif // MEDIA_BASE_CONTENT_DECRYPTION_MODULE_H_ |
OLD | NEW |