Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: media/base/media_keys.h

Issue 748473002: Introduce CdmContext interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@set_cdm
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/media_export.h" 14 #include "media/base/media_export.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 namespace base { 17 namespace base {
18 class Time; 18 class Time;
19 } 19 }
20 20
21 namespace media { 21 namespace media {
22 22
23 class Decryptor; 23 class CdmContext;
24 24
25 template <typename... T> 25 template <typename... T>
26 class CdmPromiseTemplate; 26 class CdmPromiseTemplate;
27 27
28 typedef CdmPromiseTemplate<std::string> NewSessionCdmPromise; 28 typedef CdmPromiseTemplate<std::string> NewSessionCdmPromise;
29 typedef CdmPromiseTemplate<> SimpleCdmPromise; 29 typedef CdmPromiseTemplate<> SimpleCdmPromise;
30 typedef std::vector<std::vector<uint8> > KeyIdsVector; 30 typedef std::vector<std::vector<uint8> > KeyIdsVector;
31 typedef CdmPromiseTemplate<KeyIdsVector> KeyIdsPromise; 31 typedef CdmPromiseTemplate<KeyIdsVector> KeyIdsPromise;
32 32
33 // Performs media key operations. 33 // Performs media key operations.
34 // 34 //
35 // All key operations are called on the renderer thread. Therefore, these calls 35 // All key operations are called on the renderer thread. Therefore, these calls
36 // should be fast and nonblocking; key events should be fired asynchronously. 36 // should be fast and nonblocking; key events should be fired asynchronously.
37 class MEDIA_EXPORT MediaKeys { 37 class MEDIA_EXPORT MediaKeys{
38 public: 38 public:
39 // Reported to UMA, so never reuse a value! 39 // Reported to UMA, so never reuse a value!
40 // Must be kept in sync with blink::WebMediaPlayerClient::MediaKeyErrorCode 40 // Must be kept in sync with blink::WebMediaPlayerClient::MediaKeyErrorCode
41 // (enforced in webmediaplayer_impl.cc). 41 // (enforced in webmediaplayer_impl.cc).
42 // TODO(jrummell): Can this be moved to proxy_decryptor as it should only be 42 // TODO(jrummell): Can this be moved to proxy_decryptor as it should only be
43 // used by the prefixed EME code? 43 // used by the prefixed EME code?
44 enum KeyError { 44 enum KeyError {
45 kUnknownError = 1, 45 kUnknownError = 1,
46 kClientError, 46 kClientError,
47 // The commented v0.1b values below have never been used. 47 // The commented v0.1b values below have never been used.
(...skipping 17 matching lines...) Expand all
65 65
66 // Type of license required when creating/loading a session. 66 // Type of license required when creating/loading a session.
67 // Must be consistent with the values specified in the spec: 67 // 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 68 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypte d-media.html#extensions
69 enum SessionType { 69 enum SessionType {
70 TEMPORARY_SESSION, 70 TEMPORARY_SESSION,
71 PERSISTENT_SESSION 71 PERSISTENT_SESSION
72 }; 72 };
73 73
74 static const uint32 kInvalidSessionId = 0; 74 static const uint32 kInvalidSessionId = 0;
75 #if defined(ENABLE_BROWSER_CDMS)
76 static const int kInvalidCdmId = 0;
77 #endif
78 75
79 MediaKeys();
80 virtual ~MediaKeys(); 76 virtual ~MediaKeys();
81 77
82 // Provides a server certificate to be used to encrypt messages to the 78 // Provides a server certificate to be used to encrypt messages to the
83 // license server. 79 // license server.
84 virtual void SetServerCertificate(const uint8* certificate_data, 80 virtual void SetServerCertificate(const uint8* certificate_data,
85 int certificate_data_length, 81 int certificate_data_length,
86 scoped_ptr<SimpleCdmPromise> promise) = 0; 82 scoped_ptr<SimpleCdmPromise> promise) = 0;
87 83
88 // Creates a session with the |init_data_type|, |init_data| and |session_type| 84 // Creates a session with the |init_data_type|, |init_data| and |session_type|
89 // provided. 85 // provided.
(...skipping 24 matching lines...) Expand all
114 // Removes stored session data associated with the session specified by 110 // Removes stored session data associated with the session specified by
115 // |web_session_id|. 111 // |web_session_id|.
116 virtual void RemoveSession(const std::string& web_session_id, 112 virtual void RemoveSession(const std::string& web_session_id,
117 scoped_ptr<SimpleCdmPromise> promise) = 0; 113 scoped_ptr<SimpleCdmPromise> promise) = 0;
118 114
119 // Retrieves the key IDs for keys in the session that the CDM knows are 115 // Retrieves the key IDs for keys in the session that the CDM knows are
120 // currently usable to decrypt media data. 116 // currently usable to decrypt media data.
121 virtual void GetUsableKeyIds(const std::string& web_session_id, 117 virtual void GetUsableKeyIds(const std::string& web_session_id,
122 scoped_ptr<KeyIdsPromise> promise) = 0; 118 scoped_ptr<KeyIdsPromise> promise) = 0;
123 119
124 // Gets the Decryptor object associated with the MediaKeys. Returns NULL if 120 // Returns the CdmContext associated with |this|, which must NOT be null.
125 // no Decryptor object is associated. The returned object is only guaranteed 121 // Usually the CdmContext is owned by |this|. Caller needs to make sure it is
126 // to be valid during the MediaKeys' lifetime. 122 // not used after |this| is destructed.
127 virtual Decryptor* GetDecryptor(); 123 virtual CdmContext* GetCdmContext() = 0;
128 124
129 #if defined(ENABLE_BROWSER_CDMS) 125 protected:
130 // Returns the CDM ID associated with |this|. May be kInvalidCdmId if no CDM 126 MediaKeys();
131 // ID is associated.
132 virtual int GetCdmId() const = 0;
133 #endif
134 127
135 private: 128 private:
136 DISALLOW_COPY_AND_ASSIGN(MediaKeys); 129 DISALLOW_COPY_AND_ASSIGN(MediaKeys);
137 }; 130 };
138 131
139 // Key event callbacks. See the spec for details: 132 // 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 133 // 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, 134 typedef base::Callback<void(const std::string& web_session_id,
142 const std::vector<uint8>& message, 135 const std::vector<uint8>& message,
143 const GURL& destination_url)> SessionMessageCB; 136 const GURL& destination_url)> SessionMessageCB;
(...skipping 11 matching lines...) Expand all
155 bool has_additional_usable_key)> 148 bool has_additional_usable_key)>
156 SessionKeysChangeCB; 149 SessionKeysChangeCB;
157 150
158 typedef base::Callback<void(const std::string& web_session_id, 151 typedef base::Callback<void(const std::string& web_session_id,
159 const base::Time& new_expiry_time)> 152 const base::Time& new_expiry_time)>
160 SessionExpirationUpdateCB; 153 SessionExpirationUpdateCB;
161 154
162 } // namespace media 155 } // namespace media
163 156
164 #endif // MEDIA_BASE_MEDIA_KEYS_H_ 157 #endif // MEDIA_BASE_MEDIA_KEYS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698