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

Side by Side Diff: media/cdm/proxy_decryptor.h

Issue 1712903002: Remove prefixed EME. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix isRenewalMessage() in browser tests. Created 4 years, 10 months 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
« no previous file with comments | « media/blink/webmediaplayer_util.cc ('k') | media/cdm/proxy_decryptor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_CDM_PROXY_DECRYPTOR_H_
6 #define MEDIA_CDM_PROXY_DECRYPTOR_H_
7
8 #include <stdint.h>
9
10 #include <string>
11 #include <vector>
12
13 #include "base/containers/hash_tables.h"
14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/scoped_vector.h"
18 #include "base/memory/weak_ptr.h"
19 #include "build/build_config.h"
20 #include "media/base/cdm_context.h"
21 #include "media/base/decryptor.h"
22 #include "media/base/eme_constants.h"
23 #include "media/base/media_export.h"
24 #include "media/base/media_keys.h"
25 #include "url/gurl.h"
26
27 namespace media {
28
29 class CdmFactory;
30 class MediaPermission;
31
32 // ProxyDecryptor is for EME v0.1b only. It should not be used for the WD API.
33 // A decryptor proxy that creates a real decryptor object on demand and
34 // forwards decryptor calls to it.
35 //
36 // TODO(xhwang): Currently we don't support run-time switching among decryptor
37 // objects. Fix this when needed.
38 // TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name!
39 class MEDIA_EXPORT ProxyDecryptor {
40 public:
41 // Callback to provide a CdmContext when the CDM creation is finished.
42 // If CDM creation failed, |cdm_context| will be null.
43 typedef base::Callback<void(CdmContext* cdm_context)> CdmContextReadyCB;
44
45 // These are similar to the callbacks in media_keys.h, but pass back the
46 // session ID rather than the internal session ID.
47 typedef base::Callback<void(const std::string& session_id)> KeyAddedCB;
48 typedef base::Callback<void(const std::string& session_id,
49 MediaKeys::KeyError error_code,
50 uint32_t system_code)> KeyErrorCB;
51 typedef base::Callback<void(const std::string& session_id,
52 const std::vector<uint8_t>& message,
53 const GURL& destination_url)> KeyMessageCB;
54
55 ProxyDecryptor(MediaPermission* media_permission,
56 bool use_hw_secure_codecs,
57 const KeyAddedCB& key_added_cb,
58 const KeyErrorCB& key_error_cb,
59 const KeyMessageCB& key_message_cb);
60 virtual ~ProxyDecryptor();
61
62 // Creates the CDM and fires |cdm_created_cb|. This method should only be
63 // called once. If CDM creation failed, all following GenerateKeyRequest,
64 // AddKey and CancelKeyRequest calls will result in a KeyError.
65 void CreateCdm(CdmFactory* cdm_factory,
66 const std::string& key_system,
67 const GURL& security_origin,
68 const CdmContextReadyCB& cdm_context_ready_cb);
69
70 // May only be called after CreateCDM().
71 void GenerateKeyRequest(EmeInitDataType init_data_type,
72 const uint8_t* init_data,
73 int init_data_length);
74 void AddKey(const uint8_t* key,
75 int key_length,
76 const uint8_t* init_data,
77 int init_data_length,
78 const std::string& session_id);
79 void CancelKeyRequest(const std::string& session_id);
80
81 private:
82 // Callback for CreateCdm().
83 void OnCdmCreated(const std::string& key_system,
84 const GURL& security_origin,
85 const CdmContextReadyCB& cdm_context_ready_cb,
86 const scoped_refptr<MediaKeys>& cdm,
87 const std::string& error_message);
88
89 void GenerateKeyRequestInternal(EmeInitDataType init_data_type,
90 const std::vector<uint8_t>& init_data);
91
92 // Callbacks for firing session events.
93 void OnSessionMessage(const std::string& session_id,
94 MediaKeys::MessageType message_type,
95 const std::vector<uint8_t>& message,
96 const GURL& legacy_destination_url);
97 void OnSessionKeysChange(const std::string& session_id,
98 bool has_additional_usable_key,
99 CdmKeysInfo keys_info);
100 void OnSessionExpirationUpdate(const std::string& session_id,
101 const base::Time& new_expiry_time);
102 void GenerateKeyAdded(const std::string& session_id);
103 void OnSessionClosed(const std::string& session_id);
104 void OnLegacySessionError(const std::string& session_id,
105 MediaKeys::Exception exception_code,
106 uint32_t system_code,
107 const std::string& error_message);
108
109 // Callback for permission request.
110 void OnPermissionStatus(MediaKeys::SessionType session_type,
111 EmeInitDataType init_data_type,
112 const std::vector<uint8_t>& init_data,
113 scoped_ptr<NewSessionCdmPromise> promise,
114 bool granted);
115
116 enum SessionCreationType {
117 TemporarySession,
118 PersistentSession,
119 LoadSession
120 };
121
122 // Called when a session is actually created or loaded.
123 void SetSessionId(SessionCreationType session_type,
124 const std::string& session_id);
125
126 struct PendingGenerateKeyRequestData {
127 PendingGenerateKeyRequestData(EmeInitDataType init_data_type,
128 const std::vector<uint8_t>& init_data);
129 ~PendingGenerateKeyRequestData();
130
131 const EmeInitDataType init_data_type;
132 const std::vector<uint8_t> init_data;
133 };
134
135 bool is_creating_cdm_;
136
137 // The real MediaKeys that manages key operations for the ProxyDecryptor.
138 scoped_refptr<MediaKeys> media_keys_;
139
140 #if defined(OS_CHROMEOS) || defined(OS_ANDROID)
141 MediaPermission* media_permission_;
142 #endif
143
144 bool use_hw_secure_codecs_;
145
146 // Callbacks for firing key events.
147 KeyAddedCB key_added_cb_;
148 KeyErrorCB key_error_cb_;
149 KeyMessageCB key_message_cb_;
150
151 std::string key_system_;
152 GURL security_origin_;
153
154 // Keep track of both persistent and non-persistent sessions.
155 base::hash_map<std::string, bool> active_sessions_;
156
157 bool is_clear_key_;
158
159 ScopedVector<PendingGenerateKeyRequestData> pending_requests_;
160
161 // NOTE: Weak pointers must be invalidated before all other member variables.
162 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_;
163
164 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor);
165 };
166
167 } // namespace media
168
169 #endif // MEDIA_CDM_PROXY_DECRYPTOR_H_
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_util.cc ('k') | media/cdm/proxy_decryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698