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

Side by Side Diff: media/cdm/ppapi/cdm_wrapper.h

Issue 105383002: Rename EME WD call parameters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nit Created 7 years 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/cdm/ppapi/cdm_adapter.cc ('k') | media/cdm/ppapi/clear_key_cdm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_CDM_PPAPI_CDM_WRAPPER_H_ 5 #ifndef MEDIA_CDM_PPAPI_CDM_WRAPPER_H_
6 #define MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ 6 #define MEDIA_CDM_PPAPI_CDM_WRAPPER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 CALL_KEY_ERROR 45 CALL_KEY_ERROR
46 }; 46 };
47 47
48 static CdmWrapper* Create(const char* key_system, 48 static CdmWrapper* Create(const char* key_system,
49 uint32_t key_system_size, 49 uint32_t key_system_size,
50 GetCdmHostFunc get_cdm_host_func, 50 GetCdmHostFunc get_cdm_host_func,
51 void* user_data); 51 void* user_data);
52 52
53 virtual ~CdmWrapper() {}; 53 virtual ~CdmWrapper() {};
54 54
55 virtual void CreateSession(uint32_t reference_id, 55 virtual void CreateSession(uint32_t session_id,
56 const char* type, 56 const char* type,
57 uint32_t type_size, 57 uint32_t type_size,
58 const uint8_t* init_data, 58 const uint8_t* init_data,
59 uint32_t init_data_size) = 0; 59 uint32_t init_data_size) = 0;
60 virtual Result UpdateSession(uint32_t reference_id, 60 virtual Result UpdateSession(uint32_t session_id,
61 const uint8_t* response, 61 const uint8_t* response,
62 uint32_t response_size) = 0; 62 uint32_t response_size) = 0;
63 virtual Result ReleaseSession(uint32_t reference_id) = 0; 63 virtual Result ReleaseSession(uint32_t session_id) = 0;
64 virtual void TimerExpired(void* context) = 0; 64 virtual void TimerExpired(void* context) = 0;
65 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, 65 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
66 cdm::DecryptedBlock* decrypted_buffer) = 0; 66 cdm::DecryptedBlock* decrypted_buffer) = 0;
67 virtual cdm::Status InitializeAudioDecoder( 67 virtual cdm::Status InitializeAudioDecoder(
68 const cdm::AudioDecoderConfig& audio_decoder_config) = 0; 68 const cdm::AudioDecoderConfig& audio_decoder_config) = 0;
69 virtual cdm::Status InitializeVideoDecoder( 69 virtual cdm::Status InitializeVideoDecoder(
70 const cdm::VideoDecoderConfig& video_decoder_config) = 0; 70 const cdm::VideoDecoderConfig& video_decoder_config) = 0;
71 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) = 0; 71 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) = 0;
72 virtual void ResetDecoder(cdm::StreamType decoder_type) = 0; 72 virtual void ResetDecoder(cdm::StreamType decoder_type) = 0;
73 virtual cdm::Status DecryptAndDecodeFrame( 73 virtual cdm::Status DecryptAndDecodeFrame(
74 const cdm::InputBuffer& encrypted_buffer, 74 const cdm::InputBuffer& encrypted_buffer,
75 cdm::VideoFrame* video_frame) = 0; 75 cdm::VideoFrame* video_frame) = 0;
76 virtual cdm::Status DecryptAndDecodeSamples( 76 virtual cdm::Status DecryptAndDecodeSamples(
77 const cdm::InputBuffer& encrypted_buffer, 77 const cdm::InputBuffer& encrypted_buffer,
78 cdm::AudioFrames* audio_frames) = 0; 78 cdm::AudioFrames* audio_frames) = 0;
79 virtual void OnPlatformChallengeResponse( 79 virtual void OnPlatformChallengeResponse(
80 const cdm::PlatformChallengeResponse& response) = 0; 80 const cdm::PlatformChallengeResponse& response) = 0;
81 virtual void OnQueryOutputProtectionStatus( 81 virtual void OnQueryOutputProtectionStatus(
82 uint32_t link_mask, 82 uint32_t link_mask,
83 uint32_t output_protection_mask) = 0; 83 uint32_t output_protection_mask) = 0;
84 84
85 // ContentDecryptionModule_1 and ContentDecryptionModule_2 interface methods 85 // ContentDecryptionModule_1 and ContentDecryptionModule_2 interface methods
86 // AddKey() and CancelKeyRequest() (older versions of UpdateSession() and 86 // AddKey() and CancelKeyRequest() (older versions of UpdateSession() and
87 // ReleaseSession(), respectively) pass in the session_id rather than the 87 // ReleaseSession(), respectively) pass in the web_session_id rather than the
88 // reference_id. As well, Host_1 and Host_2 callbacks SendKeyMessage() and 88 // session_id. As well, Host_1 and Host_2 callbacks SendKeyMessage() and
89 // SendKeyError() include the session ID, but the actual callbacks need the 89 // SendKeyError() include the web_session_id, but the actual callbacks need
90 // reference ID. 90 // session_id.
91 // 91 //
92 // The following functions maintain the reference_id <-> session_id mapping. 92 // The following functions maintain the session_id <-> web_session_id mapping.
93 // These can be removed once _1 and _2 interfaces are no longer supported. 93 // These can be removed once _1 and _2 interfaces are no longer supported.
94 94
95 // Determine the corresponding reference_id for |session_id|. 95 // Determine the corresponding session_id for |web_session_id|.
96 virtual uint32_t DetermineReferenceId(const std::string& session_id) = 0; 96 virtual uint32_t LookupSessionId(const std::string& web_session_id) = 0;
97 97
98 // Determine the corresponding session_id for |reference_id|. 98 // Determine the corresponding session_id for |session_id|.
99 virtual const std::string LookupSessionId(uint32_t reference_id) = 0; 99 virtual const std::string LookupWebSessionId(uint32_t session_id) = 0;
100 100
101 // Map between session_id and web_session_id.
101 // TODO(jrummell): The following can be removed once CDM_1 and CDM_2 are 102 // TODO(jrummell): The following can be removed once CDM_1 and CDM_2 are
102 // no longer supported. 103 // no longer supported.
103 typedef std::map<uint32_t, std::string> SessionMap; 104 typedef std::map<uint32_t, std::string> SessionMap;
104 static const uint32_t kInvalidReferenceId = 0; 105 SessionMap session_map_;
105 106
106 // Map between session_id and reference_id. 107 static const uint32_t kInvalidSessionId = 0;
107 SessionMap session_map_;
108 108
109 // As the response from PrefixedGenerateKeyRequest() may be synchronous or 109 // As the response from PrefixedGenerateKeyRequest() may be synchronous or
110 // asynchronous, keep track of the current request during the call to handle 110 // asynchronous, keep track of the current request during the call to handle
111 // synchronous responses or errors. If no response received, add this request 111 // synchronous responses or errors. If no response received, add this request
112 // to a queue and assume that the subsequent responses come back in the order 112 // to a queue and assume that the subsequent responses come back in the order
113 // issued. 113 // issued.
114 // TODO(jrummell): Remove once all supported CDM host interfaces support 114 // TODO(jrummell): Remove once all supported CDM host interfaces support
115 // reference_id. 115 // session_id.
116 uint32_t current_key_request_reference_id_; 116 uint32_t current_key_request_session_id_;
117 std::queue<uint32_t> pending_key_request_reference_ids_; 117 std::queue<uint32_t> pending_key_request_session_ids_;
118 118
119 protected: 119 protected:
120 CdmWrapper() : current_key_request_reference_id_(kInvalidReferenceId) {} 120 CdmWrapper() : current_key_request_session_id_(kInvalidSessionId) {}
121 121
122 private: 122 private:
123 DISALLOW_COPY_AND_ASSIGN(CdmWrapper); 123 DISALLOW_COPY_AND_ASSIGN(CdmWrapper);
124 }; 124 };
125 125
126 // Template class that does the CdmWrapper -> CdmInterface conversion. Default 126 // Template class that does the CdmWrapper -> CdmInterface conversion. Default
127 // implementations are provided. Any methods that need special treatment should 127 // implementations are provided. Any methods that need special treatment should
128 // be specialized. 128 // be specialized.
129 template <class CdmInterface> 129 template <class CdmInterface>
130 class CdmWrapperImpl : public CdmWrapper { 130 class CdmWrapperImpl : public CdmWrapper {
131 public: 131 public:
132 static CdmWrapper* Create(const char* key_system, 132 static CdmWrapper* Create(const char* key_system,
133 uint32_t key_system_size, 133 uint32_t key_system_size,
134 GetCdmHostFunc get_cdm_host_func, 134 GetCdmHostFunc get_cdm_host_func,
135 void* user_data) { 135 void* user_data) {
136 void* cdm_instance = ::CreateCdmInstance( 136 void* cdm_instance = ::CreateCdmInstance(
137 CdmInterface::kVersion, key_system, key_system_size, get_cdm_host_func, 137 CdmInterface::kVersion, key_system, key_system_size, get_cdm_host_func,
138 user_data); 138 user_data);
139 if (!cdm_instance) 139 if (!cdm_instance)
140 return NULL; 140 return NULL;
141 141
142 return new CdmWrapperImpl<CdmInterface>( 142 return new CdmWrapperImpl<CdmInterface>(
143 static_cast<CdmInterface*>(cdm_instance)); 143 static_cast<CdmInterface*>(cdm_instance));
144 } 144 }
145 145
146 virtual ~CdmWrapperImpl() { 146 virtual ~CdmWrapperImpl() {
147 cdm_->Destroy(); 147 cdm_->Destroy();
148 } 148 }
149 149
150 virtual void CreateSession(uint32_t reference_id, 150 virtual void CreateSession(uint32_t session_id,
151 const char* type, 151 const char* type,
152 uint32_t type_size, 152 uint32_t type_size,
153 const uint8_t* init_data, 153 const uint8_t* init_data,
154 uint32_t init_data_size) OVERRIDE { 154 uint32_t init_data_size) OVERRIDE {
155 cdm_->CreateSession( 155 cdm_->CreateSession(session_id, type, type_size, init_data, init_data_size);
156 reference_id, type, type_size, init_data, init_data_size);
157 } 156 }
158 157
159 virtual Result UpdateSession(uint32_t reference_id, 158 virtual Result UpdateSession(uint32_t session_id,
160 const uint8_t* response, 159 const uint8_t* response,
161 uint32_t response_size) OVERRIDE { 160 uint32_t response_size) OVERRIDE {
162 cdm_->UpdateSession(reference_id, response, response_size); 161 cdm_->UpdateSession(session_id, response, response_size);
163 return NO_ACTION; 162 return NO_ACTION;
164 } 163 }
165 164
166 virtual Result ReleaseSession(uint32_t reference_id) OVERRIDE { 165 virtual Result ReleaseSession(uint32_t session_id) OVERRIDE {
167 cdm_->ReleaseSession(reference_id); 166 cdm_->ReleaseSession(session_id);
168 return NO_ACTION; 167 return NO_ACTION;
169 } 168 }
170 169
171 virtual void TimerExpired(void* context) OVERRIDE { 170 virtual void TimerExpired(void* context) OVERRIDE {
172 cdm_->TimerExpired(context); 171 cdm_->TimerExpired(context);
173 } 172 }
174 173
175 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, 174 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
176 cdm::DecryptedBlock* decrypted_buffer) OVERRIDE { 175 cdm::DecryptedBlock* decrypted_buffer) OVERRIDE {
177 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer); 176 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 const cdm::PlatformChallengeResponse& response) OVERRIDE { 210 const cdm::PlatformChallengeResponse& response) OVERRIDE {
212 cdm_->OnPlatformChallengeResponse(response); 211 cdm_->OnPlatformChallengeResponse(response);
213 } 212 }
214 213
215 virtual void OnQueryOutputProtectionStatus( 214 virtual void OnQueryOutputProtectionStatus(
216 uint32_t link_mask, 215 uint32_t link_mask,
217 uint32_t output_protection_mask) OVERRIDE { 216 uint32_t output_protection_mask) OVERRIDE {
218 cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask); 217 cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask);
219 } 218 }
220 219
221 uint32_t DetermineReferenceId(const std::string& session_id) { 220 uint32_t LookupSessionId(const std::string& web_session_id) {
222 for (SessionMap::iterator it = session_map_.begin(); 221 for (SessionMap::iterator it = session_map_.begin();
223 it != session_map_.end(); 222 it != session_map_.end();
224 ++it) { 223 ++it) {
225 if (it->second == session_id) 224 if (it->second == web_session_id)
226 return it->first; 225 return it->first;
227 } 226 }
228 227
229 // There is no entry in the map; assume it came from the current 228 // There is no entry in the map; assume it came from the current
230 // PrefixedGenerateKeyRequest() call (if possible). If no current request, 229 // PrefixedGenerateKeyRequest() call (if possible). If no current request,
231 // assume it came from the oldest PrefixedGenerateKeyRequest() call. 230 // assume it came from the oldest PrefixedGenerateKeyRequest() call.
232 uint32_t reference_id = current_key_request_reference_id_; 231 uint32_t session_id = current_key_request_session_id_;
233 if (current_key_request_reference_id_) { 232 if (current_key_request_session_id_) {
234 // Only 1 response is allowed for the current 233 // Only 1 response is allowed for the current
235 // PrefixedGenerateKeyRequest(). 234 // PrefixedGenerateKeyRequest().
236 current_key_request_reference_id_ = kInvalidReferenceId; 235 current_key_request_session_id_ = kInvalidSessionId;
237 } else { 236 } else {
238 PP_DCHECK(!pending_key_request_reference_ids_.empty()); 237 PP_DCHECK(!pending_key_request_session_ids_.empty());
239 reference_id = pending_key_request_reference_ids_.front(); 238 session_id = pending_key_request_session_ids_.front();
240 pending_key_request_reference_ids_.pop(); 239 pending_key_request_session_ids_.pop();
241 } 240 }
242 241
243 // If this is a valid |session_id|, add it to the list. Otherwise, avoid 242 // If this is a valid |session_id|, add it to the list. Otherwise, avoid
244 // adding empty string as a mapping to prevent future calls with an empty 243 // adding empty string as a mapping to prevent future calls with an empty
245 // string from using the wrong reference_id. 244 // string from using the wrong session_id.
246 if (!session_id.empty()) { 245 if (!web_session_id.empty()) {
247 PP_DCHECK(session_map_.find(reference_id) == session_map_.end()); 246 PP_DCHECK(session_map_.find(session_id) == session_map_.end());
248 PP_DCHECK(!session_id.empty()); 247 session_map_[session_id] = web_session_id;
249 session_map_[reference_id] = session_id;
250 } 248 }
251 249
252 return reference_id; 250 return session_id;
253 } 251 }
254 252
255 const std::string LookupSessionId(uint32_t reference_id) { 253 const std::string LookupWebSessionId(uint32_t session_id) {
256 // Session may not exist if error happens during CreateSession(). 254 // Session may not exist if error happens during CreateSession().
257 SessionMap::iterator it = session_map_.find(reference_id); 255 SessionMap::iterator it = session_map_.find(session_id);
258 return (it != session_map_.end()) ? it->second : std::string(); 256 return (it != session_map_.end()) ? it->second : std::string();
259 } 257 }
260 258
261 private: 259 private:
262 CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm) { 260 CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm) {
263 PP_DCHECK(cdm_); 261 PP_DCHECK(cdm_);
264 } 262 }
265 263
266 CdmInterface* cdm_; 264 CdmInterface* cdm_;
267 265
268 DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl); 266 DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl);
269 }; 267 };
270 268
271 // For ContentDecryptionModule_1 and ContentDecryptionModule_2, 269 // For ContentDecryptionModule_1 and ContentDecryptionModule_2,
272 // CreateSession(), UpdateSession(), and ReleaseSession() call methods 270 // CreateSession(), UpdateSession(), and ReleaseSession() call methods
273 // are incompatible with ContentDecryptionModule_3. Use the following 271 // are incompatible with ContentDecryptionModule_3. Use the following
274 // templated functions to handle this. 272 // templated functions to handle this.
275 273
276 template <class CdmInterface> 274 template <class CdmInterface>
277 void PrefixedGenerateKeyRequest(CdmWrapper* wrapper, 275 void PrefixedGenerateKeyRequest(CdmWrapper* wrapper,
278 CdmInterface* cdm, 276 CdmInterface* cdm,
279 uint32_t reference_id, 277 uint32_t session_id,
280 const char* type, 278 const char* type,
281 uint32_t type_size, 279 uint32_t type_size,
282 const uint8_t* init_data, 280 const uint8_t* init_data,
283 uint32_t init_data_size) { 281 uint32_t init_data_size) {
284 // As it is possible for CDMs to reply synchronously during the call to 282 // As it is possible for CDMs to reply synchronously during the call to
285 // GenerateKeyRequest(), keep track of |reference_id|. 283 // GenerateKeyRequest(), keep track of |session_id|.
286 wrapper->current_key_request_reference_id_ = reference_id; 284 wrapper->current_key_request_session_id_ = session_id;
287 285
288 cdm::Status status = 286 cdm::Status status =
289 cdm->GenerateKeyRequest(type, type_size, init_data, init_data_size); 287 cdm->GenerateKeyRequest(type, type_size, init_data, init_data_size);
290 PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); 288 PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError);
291 if (status != cdm::kSuccess) { 289 if (status != cdm::kSuccess) {
292 // If GenerateKeyRequest() failed, no subsequent asynchronous replies 290 // If GenerateKeyRequest() failed, no subsequent asynchronous replies
293 // will be sent. Verify that a response was sent synchronously. 291 // will be sent. Verify that a response was sent synchronously.
294 PP_DCHECK(wrapper->current_key_request_reference_id_ == 292 PP_DCHECK(wrapper->current_key_request_session_id_ ==
295 CdmWrapper::kInvalidReferenceId); 293 CdmWrapper::kInvalidSessionId);
296 wrapper->current_key_request_reference_id_ = 294 wrapper->current_key_request_session_id_ = CdmWrapper::kInvalidSessionId;
297 CdmWrapper::kInvalidReferenceId;
298 return; 295 return;
299 } 296 }
300 297
301 if (wrapper->current_key_request_reference_id_) { 298 if (wrapper->current_key_request_session_id_) {
302 // If this request is still pending (SendKeyMessage() or SendKeyError() 299 // If this request is still pending (SendKeyMessage() or SendKeyError()
303 // not called synchronously), add |reference_id| to the end of the queue. 300 // not called synchronously), add |session_id| to the end of the queue.
304 // Without CDM support, it is impossible to match SendKeyMessage() 301 // Without CDM support, it is impossible to match SendKeyMessage()
305 // (or SendKeyError()) responses to the |reference_id|. Doing the best 302 // (or SendKeyError()) responses to the |session_id|. Doing the best
306 // we can by keeping track of this in a queue, and assuming the responses 303 // we can by keeping track of this in a queue, and assuming the responses
307 // come back in order. 304 // come back in order.
308 wrapper->pending_key_request_reference_ids_.push(reference_id); 305 wrapper->pending_key_request_session_ids_.push(session_id);
309 wrapper->current_key_request_reference_id_ = 306 wrapper->current_key_request_session_id_ = CdmWrapper::kInvalidSessionId;
310 CdmWrapper::kInvalidReferenceId;
311 } 307 }
312 } 308 }
313 309
314 template <class CdmInterface> 310 template <class CdmInterface>
315 CdmWrapper::Result PrefixedAddKey(CdmWrapper* wrapper, 311 CdmWrapper::Result PrefixedAddKey(CdmWrapper* wrapper,
316 CdmInterface* cdm, 312 CdmInterface* cdm,
317 uint32_t reference_id, 313 uint32_t session_id,
318 const uint8_t* response, 314 const uint8_t* response,
319 uint32_t response_size) { 315 uint32_t response_size) {
320 const std::string session_id = wrapper->LookupSessionId(reference_id); 316 const std::string web_session_id = wrapper->LookupWebSessionId(session_id);
321 if (session_id.empty()) { 317 if (web_session_id.empty()) {
322 // Possible if UpdateSession() called before CreateSession(). 318 // Possible if UpdateSession() called before CreateSession().
323 return CdmWrapper::CALL_KEY_ERROR; 319 return CdmWrapper::CALL_KEY_ERROR;
324 } 320 }
325 321
326 // CDM_1 and CDM_2 accept initdata, which is no longer needed. 322 // CDM_1 and CDM_2 accept initdata, which is no longer needed.
327 // In it's place pass in NULL. 323 // In it's place pass in NULL.
328 cdm::Status status = cdm->AddKey( 324 cdm::Status status = cdm->AddKey(web_session_id.data(), web_session_id.size(),
329 session_id.data(), session_id.size(), response, response_size, NULL, 0); 325 response, response_size,
326 NULL, 0);
330 PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); 327 PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError);
331 if (status != cdm::kSuccess) { 328 if (status != cdm::kSuccess) {
332 // Some CDMs using Host_1/2 don't call keyerror, so send one. 329 // Some CDMs using Host_1/2 don't call keyerror, so send one.
333 return CdmWrapper::CALL_KEY_ERROR; 330 return CdmWrapper::CALL_KEY_ERROR;
334 } 331 }
335 332
336 return CdmWrapper::CALL_KEY_ADDED; 333 return CdmWrapper::CALL_KEY_ADDED;
337 } 334 }
338 335
339 template <class CdmInterface> 336 template <class CdmInterface>
340 CdmWrapper::Result PrefixedCancelKeyRequest(CdmWrapper* wrapper, 337 CdmWrapper::Result PrefixedCancelKeyRequest(CdmWrapper* wrapper,
341 CdmInterface* cdm, 338 CdmInterface* cdm,
342 uint32_t reference_id) { 339 uint32_t session_id) {
343 const std::string session_id = wrapper->LookupSessionId(reference_id); 340 const std::string web_session_id = wrapper->LookupWebSessionId(session_id);
344 if (session_id.empty()) { 341 if (web_session_id.empty()) {
345 // Possible if ReleaseSession() called before CreateSession(). 342 // Possible if ReleaseSession() called before CreateSession().
346 return CdmWrapper::CALL_KEY_ERROR; 343 return CdmWrapper::CALL_KEY_ERROR;
347 } 344 }
348 345
349 wrapper->session_map_.erase(reference_id); 346 wrapper->session_map_.erase(session_id);
350 cdm::Status status = 347 cdm::Status status =
351 cdm->CancelKeyRequest(session_id.data(), session_id.size()); 348 cdm->CancelKeyRequest(web_session_id.data(), web_session_id.size());
352 349
353 PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); 350 PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError);
354 if (status != cdm::kSuccess) { 351 if (status != cdm::kSuccess) {
355 // Some CDMs using Host_1/2 don't call keyerror, so send one. 352 // Some CDMs using Host_1/2 don't call keyerror, so send one.
356 return CdmWrapper::CALL_KEY_ERROR; 353 return CdmWrapper::CALL_KEY_ERROR;
357 } 354 }
358 355
359 return CdmWrapper::NO_ACTION; 356 return CdmWrapper::NO_ACTION;
360 } 357 }
361 358
362 // Specializations for ContentDecryptionModule_1. 359 // Specializations for ContentDecryptionModule_1.
363 360
364 template <> 361 template <>
365 void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::CreateSession( 362 void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::CreateSession(
366 uint32_t reference_id, 363 uint32_t session_id,
367 const char* type, 364 const char* type,
368 uint32_t type_size, 365 uint32_t type_size,
369 const uint8_t* init_data, 366 const uint8_t* init_data,
370 uint32_t init_data_size) { 367 uint32_t init_data_size) {
371 PrefixedGenerateKeyRequest( 368 PrefixedGenerateKeyRequest(
372 this, cdm_, reference_id, type, type_size, init_data, init_data_size); 369 this, cdm_, session_id, type, type_size, init_data, init_data_size);
373 } 370 }
374 371
375 template <> 372 template <>
376 CdmWrapper::Result CdmWrapperImpl< 373 CdmWrapper::Result CdmWrapperImpl<
377 cdm::ContentDecryptionModule_1>::UpdateSession(uint32_t reference_id, 374 cdm::ContentDecryptionModule_1>::UpdateSession(uint32_t session_id,
378 const uint8_t* response, 375 const uint8_t* response,
379 uint32_t response_size) { 376 uint32_t response_size) {
380 return PrefixedAddKey(this, cdm_, reference_id, response, response_size); 377 return PrefixedAddKey(this, cdm_, session_id, response, response_size);
381 } 378 }
382 379
383 template <> 380 template <>
384 CdmWrapper::Result CdmWrapperImpl< 381 CdmWrapper::Result CdmWrapperImpl<
385 cdm::ContentDecryptionModule_1>::ReleaseSession(uint32_t reference_id) { 382 cdm::ContentDecryptionModule_1>::ReleaseSession(uint32_t session_id) {
386 return PrefixedCancelKeyRequest(this, cdm_, reference_id); 383 return PrefixedCancelKeyRequest(this, cdm_, session_id);
387 } 384 }
388 385
389 template <> void CdmWrapperImpl<cdm::ContentDecryptionModule_1>:: 386 template <> void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::
390 OnPlatformChallengeResponse( 387 OnPlatformChallengeResponse(
391 const cdm::PlatformChallengeResponse& response) { 388 const cdm::PlatformChallengeResponse& response) {
392 PP_NOTREACHED(); 389 PP_NOTREACHED();
393 } 390 }
394 391
395 template <> void CdmWrapperImpl<cdm::ContentDecryptionModule_1>:: 392 template <> void CdmWrapperImpl<cdm::ContentDecryptionModule_1>::
396 OnQueryOutputProtectionStatus(uint32_t link_mask, 393 OnQueryOutputProtectionStatus(uint32_t link_mask,
(...skipping 12 matching lines...) Expand all
409 406
410 audio_frames->SetFrameBuffer(audio_frames_1.PassFrameBuffer()); 407 audio_frames->SetFrameBuffer(audio_frames_1.PassFrameBuffer());
411 audio_frames->SetFormat(cdm::kAudioFormatS16); 408 audio_frames->SetFormat(cdm::kAudioFormatS16);
412 return cdm::kSuccess; 409 return cdm::kSuccess;
413 } 410 }
414 411
415 // Specializations for ContentDecryptionModule_2. 412 // Specializations for ContentDecryptionModule_2.
416 413
417 template <> 414 template <>
418 void CdmWrapperImpl<cdm::ContentDecryptionModule_2>::CreateSession( 415 void CdmWrapperImpl<cdm::ContentDecryptionModule_2>::CreateSession(
419 uint32_t reference_id, 416 uint32_t session_id,
420 const char* type, 417 const char* type,
421 uint32_t type_size, 418 uint32_t type_size,
422 const uint8_t* init_data, 419 const uint8_t* init_data,
423 uint32_t init_data_size) { 420 uint32_t init_data_size) {
424 PrefixedGenerateKeyRequest( 421 PrefixedGenerateKeyRequest(
425 this, cdm_, reference_id, type, type_size, init_data, init_data_size); 422 this, cdm_, session_id, type, type_size, init_data, init_data_size);
426 } 423 }
427 424
428 template <> 425 template <>
429 CdmWrapper::Result CdmWrapperImpl< 426 CdmWrapper::Result CdmWrapperImpl<
430 cdm::ContentDecryptionModule_2>::UpdateSession(uint32_t reference_id, 427 cdm::ContentDecryptionModule_2>::UpdateSession(uint32_t session_id,
431 const uint8_t* response, 428 const uint8_t* response,
432 uint32_t response_size) { 429 uint32_t response_size) {
433 return PrefixedAddKey(this, cdm_, reference_id, response, response_size); 430 return PrefixedAddKey(this, cdm_, session_id, response, response_size);
434 } 431 }
435 432
436 template <> 433 template <>
437 CdmWrapper::Result CdmWrapperImpl< 434 CdmWrapper::Result CdmWrapperImpl<
438 cdm::ContentDecryptionModule_2>::ReleaseSession(uint32_t reference_id) { 435 cdm::ContentDecryptionModule_2>::ReleaseSession(uint32_t session_id) {
439 return PrefixedCancelKeyRequest(this, cdm_, reference_id); 436 return PrefixedCancelKeyRequest(this, cdm_, session_id);
440 } 437 }
441 438
442 CdmWrapper* CdmWrapper::Create(const char* key_system, 439 CdmWrapper* CdmWrapper::Create(const char* key_system,
443 uint32_t key_system_size, 440 uint32_t key_system_size,
444 GetCdmHostFunc get_cdm_host_func, 441 GetCdmHostFunc get_cdm_host_func,
445 void* user_data) { 442 void* user_data) {
446 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == 443 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
447 cdm::ContentDecryptionModule_3::kVersion, 444 cdm::ContentDecryptionModule_3::kVersion,
448 update_code_below); 445 update_code_below);
449 446
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // stub implementations for new or modified methods that the older CDM interface 481 // stub implementations for new or modified methods that the older CDM interface
485 // does not have. 482 // does not have.
486 // Also update supported_cdm_versions.h. 483 // Also update supported_cdm_versions.h.
487 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == 484 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
488 cdm::ContentDecryptionModule_3::kVersion, 485 cdm::ContentDecryptionModule_3::kVersion,
489 ensure_cdm_wrapper_templates_have_old_version_support); 486 ensure_cdm_wrapper_templates_have_old_version_support);
490 487
491 } // namespace media 488 } // namespace media
492 489
493 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ 490 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_
OLDNEW
« no previous file with comments | « media/cdm/ppapi/cdm_adapter.cc ('k') | media/cdm/ppapi/clear_key_cdm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698