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

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

Issue 446693004: Add support for CDM_6. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments Created 6 years, 4 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/cdm/ppapi/cdm_adapter.cc ('k') | media/cdm/ppapi/external_clear_key/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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 uint32_t init_data_size, 49 uint32_t init_data_size,
50 cdm::SessionType session_type) = 0; 50 cdm::SessionType session_type) = 0;
51 virtual void LoadSession(uint32_t promise_id, 51 virtual void LoadSession(uint32_t promise_id,
52 const char* web_session_id, 52 const char* web_session_id,
53 uint32_t web_session_id_size) = 0; 53 uint32_t web_session_id_size) = 0;
54 virtual void UpdateSession(uint32_t promise_id, 54 virtual void UpdateSession(uint32_t promise_id,
55 const char* web_session_id, 55 const char* web_session_id,
56 uint32_t web_session_id_size, 56 uint32_t web_session_id_size,
57 const uint8_t* response, 57 const uint8_t* response,
58 uint32_t response_size) = 0; 58 uint32_t response_size) = 0;
59 virtual void ReleaseSession(uint32_t promise_id, 59 virtual void CloseSession(uint32_t promise_id,
60 const char* web_session_id, 60 const char* web_session_id,
61 uint32_t web_session_id_size) = 0; 61 uint32_t web_session_id_size) = 0;
62 virtual bool RemoveSession(uint32_t promise_id,
63 const char* web_session_id,
64 uint32_t web_session_id_size) = 0;
65 virtual bool GetUsableKeyIds(uint32_t promise_id,
66 const char* web_session_id,
67 uint32_t web_session_id_size) = 0;
62 virtual void TimerExpired(void* context) = 0; 68 virtual void TimerExpired(void* context) = 0;
63 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, 69 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
64 cdm::DecryptedBlock* decrypted_buffer) = 0; 70 cdm::DecryptedBlock* decrypted_buffer) = 0;
65 virtual cdm::Status InitializeAudioDecoder( 71 virtual cdm::Status InitializeAudioDecoder(
66 const cdm::AudioDecoderConfig& audio_decoder_config) = 0; 72 const cdm::AudioDecoderConfig& audio_decoder_config) = 0;
67 virtual cdm::Status InitializeVideoDecoder( 73 virtual cdm::Status InitializeVideoDecoder(
68 const cdm::VideoDecoderConfig& video_decoder_config) = 0; 74 const cdm::VideoDecoderConfig& video_decoder_config) = 0;
69 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) = 0; 75 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) = 0;
70 virtual void ResetDecoder(cdm::StreamType decoder_type) = 0; 76 virtual void ResetDecoder(cdm::StreamType decoder_type) = 0;
71 virtual cdm::Status DecryptAndDecodeFrame( 77 virtual cdm::Status DecryptAndDecodeFrame(
(...skipping 16 matching lines...) Expand all
88 // Since the callbacks don't come through this interface, cdm_adapter needs to 94 // Since the callbacks don't come through this interface, cdm_adapter needs to
89 // create the mapping (and delete it on release). 95 // create the mapping (and delete it on release).
90 // TODO(jrummell): Remove these once Host_4 interface is removed. 96 // TODO(jrummell): Remove these once Host_4 interface is removed.
91 virtual uint32_t LookupPromiseId(uint32_t session_id) = 0; 97 virtual uint32_t LookupPromiseId(uint32_t session_id) = 0;
92 virtual void AssignWebSessionId(uint32_t session_id, 98 virtual void AssignWebSessionId(uint32_t session_id,
93 const char* web_session_id, 99 const char* web_session_id,
94 uint32_t web_session_id_size) = 0; 100 uint32_t web_session_id_size) = 0;
95 virtual std::string LookupWebSessionId(uint32_t session_id) = 0; 101 virtual std::string LookupWebSessionId(uint32_t session_id) = 0;
96 virtual void DropWebSessionId(std::string web_session_id) = 0; 102 virtual void DropWebSessionId(std::string web_session_id) = 0;
97 103
104 // Helper functions for the cdm::Host_4 and cdm::Host_5 methods.
105 // CDMs using cdm::Host_6 will call OnSessionUsableKeys() as necessary when
106 // resolving LoadSession() and UpdateSession(). This needs to be simulated
107 // for the older CDMs. These must not be called for cdm::Host_6 and later.
108 // TODO(jrummell): Remove these once Host_4 and Host_5 interfaces are removed.
109
110 // Query whether a SessionUsableKeys event is necessary for the specified
111 // |promise_id|. Returns true if needed and |web_session_id| is updated,
112 // otherwise returns false.
113 virtual bool SessionUsableKeysEventNeeded(uint32_t promise_id,
ddorwin 2014/08/08 01:16:31 nit: Is...
114 std::string* web_session_id) = 0;
115
116 // Used to indicate that a SessionUsableKeys event is required for the
117 // specified |promise_id| and associated |web_session_id|.
118 virtual void SetSessionUsableKeysEventNeeded(
119 uint32_t promise_id,
120 const char* web_session_id,
121 uint32_t web_session_id_size) = 0;
122
123 // cdm::Host_6 introduces InputBuffer_2 (aka InputBuffer). cdm::Host_4 and
124 // cdm::Host_5 methods still use InputBuffer_1, so this helper function
125 // converts InputBuffer_2 to InputBuffer_1.
126 // TODO(jrummell): Remove these once Host_4 and Host_5 interfaces are removed.
127 virtual void ConvertInputBuffer(const cdm::InputBuffer& v2,
128 cdm::InputBuffer_1* v1) = 0;
129
98 protected: 130 protected:
99 CdmWrapper() {} 131 CdmWrapper() {}
100 132
101 private: 133 private:
102 DISALLOW_COPY_AND_ASSIGN(CdmWrapper); 134 DISALLOW_COPY_AND_ASSIGN(CdmWrapper);
103 }; 135 };
104 136
105 // Template class that does the CdmWrapper -> CdmInterface conversion. Default 137 // Template class that does the CdmWrapper -> CdmInterface conversion. Default
106 // implementations are provided. Any methods that need special treatment should 138 // implementations are provided. Any methods that need special treatment should
107 // be specialized. 139 // be specialized.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 uint32_t web_session_id_size, 183 uint32_t web_session_id_size,
152 const uint8_t* response, 184 const uint8_t* response,
153 uint32_t response_size) OVERRIDE { 185 uint32_t response_size) OVERRIDE {
154 cdm_->UpdateSession(promise_id, 186 cdm_->UpdateSession(promise_id,
155 web_session_id, 187 web_session_id,
156 web_session_id_size, 188 web_session_id_size,
157 response, 189 response,
158 response_size); 190 response_size);
159 } 191 }
160 192
161 virtual void ReleaseSession(uint32_t promise_id, 193 virtual bool GetUsableKeyIds(uint32_t promise_id,
162 const char* web_session_id, 194 const char* web_session_id,
163 uint32_t web_session_id_size) OVERRIDE { 195 uint32_t web_session_id_size) OVERRIDE {
164 cdm_->ReleaseSession(promise_id, web_session_id, web_session_id_size); 196 cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size);
197 return true;
198 }
199
200 virtual void CloseSession(uint32_t promise_id,
201 const char* web_session_id,
202 uint32_t web_session_id_size) OVERRIDE {
203 cdm_->CloseSession(promise_id, web_session_id, web_session_id_size);
204 }
205
206 virtual bool RemoveSession(uint32_t promise_id,
207 const char* web_session_id,
208 uint32_t web_session_id_size) OVERRIDE {
209 cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size);
210 return true;
165 } 211 }
166 212
167 virtual void TimerExpired(void* context) OVERRIDE { 213 virtual void TimerExpired(void* context) OVERRIDE {
168 cdm_->TimerExpired(context); 214 cdm_->TimerExpired(context);
169 } 215 }
170 216
171 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, 217 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
172 cdm::DecryptedBlock* decrypted_buffer) OVERRIDE { 218 cdm::DecryptedBlock* decrypted_buffer) OVERRIDE {
173 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer); 219 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer);
174 } 220 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 return it->first; 300 return it->first;
255 } 301 }
256 PP_NOTREACHED(); 302 PP_NOTREACHED();
257 return std::string(); 303 return std::string();
258 } 304 }
259 305
260 virtual void DropWebSessionId(std::string web_session_id) { 306 virtual void DropWebSessionId(std::string web_session_id) {
261 web_session_to_session_id_map_.erase(web_session_id); 307 web_session_to_session_id_map_.erase(web_session_id);
262 } 308 }
263 309
310 virtual bool SessionUsableKeysEventNeeded(uint32_t promise_id,
311 std::string* web_session_id) {
312 std::map<uint32_t, std::string>::iterator it =
313 promises_needing_usable_keys_event_.find(promise_id);
314 if (it == promises_needing_usable_keys_event_.end())
315 return false;
316 web_session_id->swap(it->second);
317 promises_needing_usable_keys_event_.erase(it);
318 return true;
319 }
320
321 virtual void SetSessionUsableKeysEventNeeded(uint32_t promise_id,
322 const char* web_session_id,
323 uint32_t web_session_id_size) {
324 promises_needing_usable_keys_event_.insert(std::make_pair(
325 promise_id, std::string(web_session_id, web_session_id_size)));
326 }
327
328 virtual void ConvertInputBuffer(const cdm::InputBuffer& v2,
329 cdm::InputBuffer_1* v1) {
330 v1->data = v2.data;
331 v1->data_size = v2.data_size;
332 v1->data_offset = 0;
333 v1->key_id = v2.key_id;
334 v1->key_id_size = v2.key_id_size;
335 v1->iv = v2.iv;
336 v1->iv_size = v2.iv_size;
337 v1->subsamples = v2.subsamples;
338 v1->num_subsamples = v2.num_subsamples;
339 v1->timestamp = v2.timestamp;
340 }
341
264 private: 342 private:
265 CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm), next_session_id_(100) { 343 CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm), next_session_id_(100) {
266 PP_DCHECK(cdm_); 344 PP_DCHECK(cdm_);
267 } 345 }
268 346
269 CdmInterface* cdm_; 347 CdmInterface* cdm_;
270 348
271 std::map<uint32_t, uint32_t> promise_to_session_id_map_; 349 std::map<uint32_t, uint32_t> promise_to_session_id_map_;
272 uint32_t next_session_id_; 350 uint32_t next_session_id_;
273 std::map<std::string, uint32_t> web_session_to_session_id_map_; 351 std::map<std::string, uint32_t> web_session_to_session_id_map_;
274 352
353 std::map<uint32_t, std::string> promises_needing_usable_keys_event_;
354
275 DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl); 355 DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl);
276 }; 356 };
277 357
278 // Overrides for the cdm::Host_4 methods. Calls to CreateSession(), 358 // Overrides for the cdm::Host_4 methods. Calls to CreateSession(),
279 // LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids, 359 // LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids,
280 // but the CDM interface needs session ids. For create and load, we need to 360 // but the CDM interface needs session ids. For create and load, we need to
281 // create a new session_id to pass to the CDM. For update and release, we need 361 // create a new session_id to pass to the CDM. For update and release, we need
282 // to look up |web_session_id| and convert it into the existing |session_id|. 362 // to look up |web_session_id| and convert it into the existing |session_id|.
283 // Since the callbacks don't come through this interface, cdm_adapter needs to 363 // Since the callbacks don't come through this interface, cdm_adapter needs to
284 // create the mapping (and delete it on release). 364 // create the mapping (and delete it on release).
(...skipping 16 matching lines...) Expand all
301 init_data_size); 381 init_data_size);
302 } 382 }
303 383
304 template <> 384 template <>
305 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::LoadSession( 385 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::LoadSession(
306 uint32_t promise_id, 386 uint32_t promise_id,
307 const char* web_session_id, 387 const char* web_session_id,
308 uint32_t web_session_id_size) { 388 uint32_t web_session_id_size) {
309 uint32_t session_id = CreateSessionId(); 389 uint32_t session_id = CreateSessionId();
310 RegisterPromise(session_id, promise_id); 390 RegisterPromise(session_id, promise_id);
391 // As CDM_4 doesn't support OnSessionUsableKeysChange(), make sure to generate
392 // one when the promise is resolved. This may be overly aggressive.
393 SetSessionUsableKeysEventNeeded(
394 promise_id, web_session_id, web_session_id_size);
311 cdm_->LoadSession(session_id, web_session_id, web_session_id_size); 395 cdm_->LoadSession(session_id, web_session_id, web_session_id_size);
312 } 396 }
313 397
314 template <> 398 template <>
315 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::UpdateSession( 399 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::UpdateSession(
316 uint32_t promise_id, 400 uint32_t promise_id,
317 const char* web_session_id, 401 const char* web_session_id,
318 uint32_t web_session_id_size, 402 uint32_t web_session_id_size,
319 const uint8_t* response, 403 const uint8_t* response,
320 uint32_t response_size) { 404 uint32_t response_size) {
321 std::string web_session_str(web_session_id, web_session_id_size); 405 std::string web_session_str(web_session_id, web_session_id_size);
322 uint32_t session_id = LookupSessionId(web_session_str); 406 uint32_t session_id = LookupSessionId(web_session_str);
323 RegisterPromise(session_id, promise_id); 407 RegisterPromise(session_id, promise_id);
408 // As CDM_4 doesn't support OnSessionUsableKeysChange(), make sure to generate
409 // one when the promise is resolved. This may be overly aggressive.
410 SetSessionUsableKeysEventNeeded(
411 promise_id, web_session_id, web_session_id_size);
324 cdm_->UpdateSession(session_id, response, response_size); 412 cdm_->UpdateSession(session_id, response, response_size);
325 } 413 }
326 414
327 template <> 415 template <>
328 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::ReleaseSession( 416 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CloseSession(
329 uint32_t promise_id, 417 uint32_t promise_id,
330 const char* web_session_id, 418 const char* web_session_id,
331 uint32_t web_session_id_size) { 419 uint32_t web_session_id_size) {
332 std::string web_session_str(web_session_id, web_session_id_size); 420 std::string web_session_str(web_session_id, web_session_id_size);
333 uint32_t session_id = LookupSessionId(web_session_str); 421 uint32_t session_id = LookupSessionId(web_session_str);
334 RegisterPromise(session_id, promise_id); 422 RegisterPromise(session_id, promise_id);
335 cdm_->ReleaseSession(session_id); 423 cdm_->ReleaseSession(session_id);
336 } 424 }
337 425
426 template <>
427 bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::RemoveSession(
428 uint32_t promise_id,
429 const char* web_session_id,
430 uint32_t web_session_id_size) {
431 return false;
432 }
433
434 template <>
435 bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::GetUsableKeyIds(
436 uint32_t promise_id,
437 const char* web_session_id,
438 uint32_t web_session_id_size) {
439 return false;
440 }
441
442 template <>
443 cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Decrypt(
444 const cdm::InputBuffer& encrypted_buffer,
445 cdm::DecryptedBlock* decrypted_buffer) {
446 cdm::InputBuffer_1 buffer;
447 ConvertInputBuffer(encrypted_buffer, &buffer);
448 return cdm_->Decrypt(buffer, decrypted_buffer);
449 }
450
451 template <>
452 cdm::Status
453 CdmWrapperImpl<cdm::ContentDecryptionModule_4>::DecryptAndDecodeFrame(
454 const cdm::InputBuffer& encrypted_buffer,
455 cdm::VideoFrame* video_frame) {
456 cdm::InputBuffer_1 buffer;
457 ConvertInputBuffer(encrypted_buffer, &buffer);
458 return cdm_->DecryptAndDecodeFrame(buffer, video_frame);
459 }
460
461 template <>
462 cdm::Status
463 CdmWrapperImpl<cdm::ContentDecryptionModule_4>::DecryptAndDecodeSamples(
464 const cdm::InputBuffer& encrypted_buffer,
465 cdm::AudioFrames* audio_frames) {
466 cdm::InputBuffer_1 buffer;
467 ConvertInputBuffer(encrypted_buffer, &buffer);
468 return cdm_->DecryptAndDecodeSamples(buffer, audio_frames);
469 }
470
471 // Overrides for the cdm::Host_5 methods.
472 // TODO(jrummell): Remove these once Host_5 interface is removed.
473
474 template <>
475 void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::LoadSession(
476 uint32_t promise_id,
477 const char* web_session_id,
478 uint32_t web_session_id_size) {
479 // As CDM_5 doesn't support OnSessionUsableKeysChange(), make sure to generate
480 // one when the promise is resolved. This may be overly aggressive.
481 SetSessionUsableKeysEventNeeded(
482 promise_id, web_session_id, web_session_id_size);
483 cdm_->LoadSession(promise_id, web_session_id, web_session_id_size);
484 }
485
486 template <>
487 void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::UpdateSession(
488 uint32_t promise_id,
489 const char* web_session_id,
490 uint32_t web_session_id_size,
491 const uint8_t* response,
492 uint32_t response_size) {
493 // As CDM_5 doesn't support OnSessionUsableKeysChange(), make sure to generate
494 // one when the promise is resolved. This may be overly aggressive.
495 SetSessionUsableKeysEventNeeded(
496 promise_id, web_session_id, web_session_id_size);
497 cdm_->UpdateSession(
498 promise_id, web_session_id, web_session_id_size, response, response_size);
499 }
500
501 template <>
502 void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CloseSession(
503 uint32_t promise_id,
504 const char* web_session_id,
505 uint32_t web_session_id_size) {
506 cdm_->ReleaseSession(promise_id, web_session_id, web_session_id_size);
507 }
508
509 template <>
510 bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::RemoveSession(
511 uint32_t promise_id,
512 const char* web_session_id,
513 uint32_t web_session_id_size) {
514 return false;
515 }
516
517 template <>
518 bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::GetUsableKeyIds(
519 uint32_t promise_id,
520 const char* web_session_id,
521 uint32_t web_session_id_size) {
522 return false;
523 }
524
525 template <>
526 cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Decrypt(
527 const cdm::InputBuffer& encrypted_buffer,
528 cdm::DecryptedBlock* decrypted_buffer) {
529 cdm::InputBuffer_1 buffer;
530 ConvertInputBuffer(encrypted_buffer, &buffer);
531 return cdm_->Decrypt(buffer, decrypted_buffer);
532 }
533
534 template <>
535 cdm::Status
536 CdmWrapperImpl<cdm::ContentDecryptionModule_5>::DecryptAndDecodeFrame(
537 const cdm::InputBuffer& encrypted_buffer,
538 cdm::VideoFrame* video_frame) {
539 cdm::InputBuffer_1 buffer;
540 ConvertInputBuffer(encrypted_buffer, &buffer);
541 return cdm_->DecryptAndDecodeFrame(buffer, video_frame);
542 }
543
544 template <>
545 cdm::Status
546 CdmWrapperImpl<cdm::ContentDecryptionModule_5>::DecryptAndDecodeSamples(
547 const cdm::InputBuffer& encrypted_buffer,
548 cdm::AudioFrames* audio_frames) {
549 cdm::InputBuffer_1 buffer;
550 ConvertInputBuffer(encrypted_buffer, &buffer);
551 return cdm_->DecryptAndDecodeSamples(buffer, audio_frames);
552 }
553
338 CdmWrapper* CdmWrapper::Create(const char* key_system, 554 CdmWrapper* CdmWrapper::Create(const char* key_system,
339 uint32_t key_system_size, 555 uint32_t key_system_size,
340 GetCdmHostFunc get_cdm_host_func, 556 GetCdmHostFunc get_cdm_host_func,
341 void* user_data) { 557 void* user_data) {
342 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == 558 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
343 cdm::ContentDecryptionModule_5::kVersion, 559 cdm::ContentDecryptionModule_6::kVersion,
344 update_code_below); 560 update_code_below);
345 561
346 // Ensure IsSupportedCdmInterfaceVersion() matches this implementation. 562 // Ensure IsSupportedCdmInterfaceVersion() matches this implementation.
347 // Always update this DCHECK when updating this function. 563 // Always update this DCHECK when updating this function.
348 // If this check fails, update this function and DCHECK or update 564 // If this check fails, update this function and DCHECK or update
349 // IsSupportedCdmInterfaceVersion(). 565 // IsSupportedCdmInterfaceVersion().
350 PP_DCHECK( 566 PP_DCHECK(
351 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion + 567 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion +
352 1) && 568 1) &&
353 IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion) && 569 IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion) &&
354 IsSupportedCdmInterfaceVersion( 570 IsSupportedCdmInterfaceVersion(
355 cdm::ContentDecryptionModule_4::kVersion) && 571 cdm::ContentDecryptionModule_4::kVersion) &&
356 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule_4::kVersion - 572 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule_4::kVersion -
357 1)); 573 1));
358 574
359 // Try to create the CDM using the latest CDM interface version. 575 // Try to create the CDM using the latest CDM interface version.
360 CdmWrapper* cdm_wrapper = 576 CdmWrapper* cdm_wrapper =
361 CdmWrapperImpl<cdm::ContentDecryptionModule>::Create( 577 CdmWrapperImpl<cdm::ContentDecryptionModule>::Create(
362 key_system, key_system_size, get_cdm_host_func, user_data); 578 key_system, key_system_size, get_cdm_host_func, user_data);
363 if (cdm_wrapper) 579 if (cdm_wrapper)
364 return cdm_wrapper; 580 return cdm_wrapper;
365 581
366 // If |cdm_wrapper| is NULL, try to create the CDM using older supported 582 // If |cdm_wrapper| is NULL, try to create the CDM using older supported
367 // versions of the CDM interface. 583 // versions of the CDM interface.
584 cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Create(
585 key_system, key_system_size, get_cdm_host_func, user_data);
586 if (cdm_wrapper)
587 return cdm_wrapper;
588
368 cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Create( 589 cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Create(
369 key_system, key_system_size, get_cdm_host_func, user_data); 590 key_system, key_system_size, get_cdm_host_func, user_data);
370 return cdm_wrapper; 591 return cdm_wrapper;
371 } 592 }
372 593
373 // When updating the CdmAdapter, ensure you've updated the CdmWrapper to contain 594 // When updating the CdmAdapter, ensure you've updated the CdmWrapper to contain
374 // stub implementations for new or modified methods that the older CDM interface 595 // stub implementations for new or modified methods that the older CDM interface
375 // does not have. 596 // does not have.
376 // Also update supported_cdm_versions.h. 597 // Also update supported_cdm_versions.h.
377 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == 598 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion ==
378 cdm::ContentDecryptionModule_5::kVersion, 599 cdm::ContentDecryptionModule_6::kVersion,
379 ensure_cdm_wrapper_templates_have_old_version_support); 600 ensure_cdm_wrapper_templates_have_old_version_support);
380 601
381 } // namespace media 602 } // namespace media
382 603
383 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ 604 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_
OLDNEW
« no previous file with comments | « media/cdm/ppapi/cdm_adapter.cc ('k') | media/cdm/ppapi/external_clear_key/clear_key_cdm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698