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

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

Issue 23546014: Plumb PPAPI PlatformVerification into CDM.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « DEPS ('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 #include <cstring> 5 #include <cstring>
6 #include <map> 6 #include <map>
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "build/build_config.h"
13 #include "media/cdm/ppapi/api/content_decryption_module.h" 14 #include "media/cdm/ppapi/api/content_decryption_module.h"
14 #include "media/cdm/ppapi/linked_ptr.h" 15 #include "media/cdm/ppapi/linked_ptr.h"
16 #include "ppapi/c/pp_completion_callback.h"
15 #include "ppapi/c/pp_errors.h" 17 #include "ppapi/c/pp_errors.h"
16 #include "ppapi/c/pp_stdint.h" 18 #include "ppapi/c/pp_stdint.h"
17 #include "ppapi/c/private/pp_content_decryptor.h" 19 #include "ppapi/c/private/pp_content_decryptor.h"
18 #include "ppapi/cpp/completion_callback.h" 20 #include "ppapi/cpp/completion_callback.h"
19 #include "ppapi/cpp/core.h" 21 #include "ppapi/cpp/core.h"
20 #include "ppapi/cpp/dev/buffer_dev.h" 22 #include "ppapi/cpp/dev/buffer_dev.h"
21 #include "ppapi/cpp/instance.h" 23 #include "ppapi/cpp/instance.h"
22 #include "ppapi/cpp/logging.h" 24 #include "ppapi/cpp/logging.h"
23 #include "ppapi/cpp/module.h" 25 #include "ppapi/cpp/module.h"
24 #include "ppapi/cpp/pass_ref.h" 26 #include "ppapi/cpp/pass_ref.h"
25 #include "ppapi/cpp/private/content_decryptor_private.h" 27 #include "ppapi/cpp/private/content_decryptor_private.h"
26 #include "ppapi/cpp/resource.h" 28 #include "ppapi/cpp/resource.h"
27 #include "ppapi/cpp/var.h" 29 #include "ppapi/cpp/var.h"
28 #include "ppapi/cpp/var_array_buffer.h" 30 #include "ppapi/cpp/var_array_buffer.h"
29 #include "ppapi/utility/completion_callback_factory.h" 31 #include "ppapi/utility/completion_callback_factory.h"
30 32
31 #if defined(CHECK_DOCUMENT_URL) 33 #if defined(CHECK_DOCUMENT_URL)
32 #include "ppapi/cpp/dev/url_util_dev.h" 34 #include "ppapi/cpp/dev/url_util_dev.h"
33 #include "ppapi/cpp/instance_handle.h" 35 #include "ppapi/cpp/instance_handle.h"
34 #endif // defined(CHECK_DOCUMENT_URL) 36 #endif // defined(CHECK_DOCUMENT_URL)
35 37
38 #if defined(OS_CHROMEOS)
39 #include "ppapi/cpp/private/output_protection_private.h"
40 #include "ppapi/cpp/private/platform_verification.h"
41 #endif
42
36 namespace { 43 namespace {
37 44
38 bool IsMainThread() { 45 bool IsMainThread() {
39 return pp::Module::Get()->core()->IsMainThread(); 46 return pp::Module::Get()->core()->IsMainThread();
40 } 47 }
41 48
42 // Posts a task to run |cb| on the main thread. The task is posted even if the 49 // Posts a task to run |cb| on the main thread. The task is posted even if the
43 // current thread is the main thread. 50 // current thread is the main thread.
44 void PostOnMain(pp::CompletionCallback cb) { 51 void PostOnMain(pp::CompletionCallback cb) {
45 pp::Module::Get()->core()->CallOnMainThread(0, cb, PP_OK); 52 pp::Module::Get()->core()->CallOnMainThread(0, cb, PP_OK);
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 plane_offsets_[i] = 0; 456 plane_offsets_[i] = 0;
450 strides_[i] = 0; 457 strides_[i] = 0;
451 } 458 }
452 } 459 }
453 460
454 VideoFrameImpl::~VideoFrameImpl() { 461 VideoFrameImpl::~VideoFrameImpl() {
455 if (frame_buffer_) 462 if (frame_buffer_)
456 frame_buffer_->Destroy(); 463 frame_buffer_->Destroy();
457 } 464 }
458 465
459 class AudioFramesImpl : public cdm::AudioFrames { 466 class AudioFramesImpl : public cdm::AudioFrames_1,
467 public cdm::AudioFrames_2 {
460 public: 468 public:
461 AudioFramesImpl() : buffer_(NULL) {} 469 AudioFramesImpl() : buffer_(NULL), format_(cdm::kAudioFormatS16) {}
462 virtual ~AudioFramesImpl() { 470 virtual ~AudioFramesImpl() {
463 if (buffer_) 471 if (buffer_)
464 buffer_->Destroy(); 472 buffer_->Destroy();
465 } 473 }
466 474
467 // AudioFrames implementation. 475 // AudioFrames implementation.
468 virtual void SetFrameBuffer(cdm::Buffer* buffer) OVERRIDE { 476 virtual void SetFrameBuffer(cdm::Buffer* buffer) OVERRIDE {
469 buffer_ = static_cast<PpbBuffer*>(buffer); 477 buffer_ = static_cast<PpbBuffer*>(buffer);
470 } 478 }
471 virtual cdm::Buffer* FrameBuffer() OVERRIDE { 479 virtual cdm::Buffer* FrameBuffer() OVERRIDE {
472 return buffer_; 480 return buffer_;
473 } 481 }
482 virtual void SetFormat(cdm::AudioFormat format) OVERRIDE {
483 format_ = format;
484 }
485 virtual cdm::AudioFormat Format() const OVERRIDE {
486 return format_;
487 }
474 488
475 private: 489 private:
476 PpbBuffer* buffer_; 490 PpbBuffer* buffer_;
491 cdm::AudioFormat format_;
477 492
478 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); 493 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl);
479 }; 494 };
480 495
481 // GetCdmHostFunc implementation. 496 // GetCdmHostFunc implementation.
482 void* GetCdmHost(int host_interface_version, void* user_data); 497 void* GetCdmHost(int host_interface_version, void* user_data);
483 498
484 // A wrapper class for abstracting away PPAPI interaction and threading for a 499 // A wrapper class for abstracting away PPAPI interaction and threading for a
485 // Content Decryption Module (CDM). 500 // Content Decryption Module (CDM).
486 class CdmWrapper : public pp::Instance, 501 class CdmWrapper : public pp::Instance,
487 public pp::ContentDecryptor_Private, 502 public pp::ContentDecryptor_Private,
488 public cdm::Host { 503 public cdm::Host_1,
504 public cdm::Host_2 {
489 public: 505 public:
490 CdmWrapper(PP_Instance instance, pp::Module* module); 506 CdmWrapper(PP_Instance instance, pp::Module* module);
491 virtual ~CdmWrapper(); 507 virtual ~CdmWrapper();
492 508
493 // pp::Instance implementation. 509 // pp::Instance implementation.
494 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { 510 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
495 return true; 511 return true;
496 } 512 }
497 513
498 // PPP_ContentDecryptor_Private implementation. 514 // PPP_ContentDecryptor_Private implementation.
(...skipping 18 matching lines...) Expand all
517 pp::Buffer_Dev extra_data_buffer) OVERRIDE; 533 pp::Buffer_Dev extra_data_buffer) OVERRIDE;
518 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, 534 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type,
519 uint32_t request_id) OVERRIDE; 535 uint32_t request_id) OVERRIDE;
520 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, 536 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type,
521 uint32_t request_id) OVERRIDE; 537 uint32_t request_id) OVERRIDE;
522 virtual void DecryptAndDecode( 538 virtual void DecryptAndDecode(
523 PP_DecryptorStreamType decoder_type, 539 PP_DecryptorStreamType decoder_type,
524 pp::Buffer_Dev encrypted_buffer, 540 pp::Buffer_Dev encrypted_buffer,
525 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; 541 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
526 542
527 // cdm::Host implementation. 543 // cdm::Host_1 implementation.
528 virtual cdm::Buffer* Allocate(int32_t capacity) OVERRIDE; 544 virtual cdm::Buffer* Allocate(int32_t capacity) OVERRIDE;
529 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; 545 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE;
530 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; 546 virtual double GetCurrentWallTimeInSeconds() OVERRIDE;
531 virtual void SendKeyMessage( 547 virtual void SendKeyMessage(
532 const char* session_id, int32_t session_id_length, 548 const char* session_id, int32_t session_id_length,
533 const char* message, int32_t message_length, 549 const char* message, int32_t message_length,
534 const char* default_url, int32_t default_url_length) OVERRIDE; 550 const char* default_url, int32_t default_url_length) OVERRIDE;
535 virtual void SendKeyError(const char* session_id, 551 virtual void SendKeyError(const char* session_id,
536 int32_t session_id_length, 552 int32_t session_id_length,
537 cdm::MediaKeyError error_code, 553 cdm::MediaKeyError error_code,
538 uint32_t system_code) OVERRIDE; 554 uint32_t system_code) OVERRIDE;
539 virtual void GetPrivateData(int32_t* instance, 555 virtual void GetPrivateData(int32_t* instance,
540 GetPrivateInterface* get_interface) OVERRIDE; 556 GetPrivateInterface* get_interface) OVERRIDE;
541 557
558 // cdm::Host_2 implementation.
559 virtual bool CanChallengePlatform() OVERRIDE;
560 virtual void SendPlatformChallenge(
561 const char* service_id, int32_t service_id_length,
562 const char* challenge, int32_t challenge_length) OVERRIDE;
563 virtual void EnableOutputProtection(
564 uint32_t desired_protection_mask) OVERRIDE;
565 virtual void QueryOutputProtectionStatus() OVERRIDE;
566
542 private: 567 private:
543 struct SessionInfo { 568 struct SessionInfo {
544 SessionInfo(const std::string& key_system_in, 569 SessionInfo(const std::string& key_system_in,
545 const std::string& session_id_in) 570 const std::string& session_id_in)
546 : key_system(key_system_in), 571 : key_system(key_system_in),
547 session_id(session_id_in) {} 572 session_id(session_id_in) {}
548 const std::string key_system; 573 const std::string key_system;
549 const std::string session_id; 574 const std::string session_id;
550 }; 575 };
551 576
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 void DeliverSamples(int32_t result, 624 void DeliverSamples(int32_t result,
600 const cdm::Status& status, 625 const cdm::Status& status,
601 const LinkedAudioFrames& audio_frames, 626 const LinkedAudioFrames& audio_frames,
602 const PP_DecryptTrackingInfo& tracking_info); 627 const PP_DecryptTrackingInfo& tracking_info);
603 628
604 // Helper for SetTimer(). 629 // Helper for SetTimer().
605 void TimerExpired(int32_t result, void* context); 630 void TimerExpired(int32_t result, void* context);
606 631
607 bool IsValidVideoFrame(const LinkedVideoFrame& video_frame); 632 bool IsValidVideoFrame(const LinkedVideoFrame& video_frame);
608 633
634 #if defined(OS_CHROMEOS)
635 void CanChallengePlatformDone(int32_t result, bool can_challenge_platform);
636 void SendPlatformChallengeDone(int32_t result);
637 void EnableProtectionDone(int32_t result);
638 void QueryOutputProtectionStatusDone(int32_t result);
639
640 pp::OutputProtection_Private output_protection_;
641 pp::PlatformVerification platform_verification_;
642
643 // |can_challenge_platform_| is currently set asynchronously, return the value
644 // if we have it, otherwise guess "true" for the most common case...
645 // TODO(jrummell): This stinks. The value should be delivered via the
646 // Initialize() method once plumbed.
647 bool can_challenge_platform_;
648
649 // Since PPAPI doesn't provide handlers for CompletionCallbacks w/ more than
650 // one output we need to manage our own. These values are only read by
651 // SendPlatformChallengeDone().
652 pp::Var signed_data_output_;
653 pp::Var signed_data_signature_output_;
654 pp::Var platform_key_certificate_output_;
655 bool challenge_in_progress_;
656
657 // Same as above, these are only read by QueryOutputProtectionStatusDone().
658 uint32_t output_link_mask_;
659 uint32_t output_protection_mask_;
660 bool query_output_protection_in_progress_;
661 #endif
662
609 PpbBufferAllocator allocator_; 663 PpbBufferAllocator allocator_;
610 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; 664 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_;
611 cdm::ContentDecryptionModule* cdm_; 665 cdm::ContentDecryptionModule* cdm_;
612 std::string key_system_; 666 std::string key_system_;
613 667
614 DISALLOW_COPY_AND_ASSIGN(CdmWrapper); 668 DISALLOW_COPY_AND_ASSIGN(CdmWrapper);
615 }; 669 };
616 670
617 CdmWrapper::CdmWrapper(PP_Instance instance, pp::Module* module) 671 CdmWrapper::CdmWrapper(PP_Instance instance, pp::Module* module)
618 : pp::Instance(instance), 672 : pp::Instance(instance),
619 pp::ContentDecryptor_Private(this), 673 pp::ContentDecryptor_Private(this),
674 #if defined(OS_CHROMEOS)
675 output_protection_(this),
676 platform_verification_(this),
677 // Err on the side of the most common case...
678 can_challenge_platform_(true),
679 challenge_in_progress_(false),
680 output_link_mask_(0),
681 output_protection_mask_(0),
682 query_output_protection_in_progress_(false),
683 #endif
620 allocator_(this), 684 allocator_(this),
621 cdm_(NULL) { 685 cdm_(NULL) {
622 callback_factory_.Initialize(this); 686 callback_factory_.Initialize(this);
687 #if defined(OS_CHROMEOS)
688 // Preemptively retrieve the platform challenge status. It will not change.
689 platform_verification_.CanChallengePlatform(
690 callback_factory_.NewCallbackWithOutput(
691 &CdmWrapper::CanChallengePlatformDone));
692 #endif
623 } 693 }
624 694
625 CdmWrapper::~CdmWrapper() { 695 CdmWrapper::~CdmWrapper() {
626 if (cdm_) 696 if (cdm_)
627 cdm_->Destroy(); 697 cdm_->Destroy();
628 } 698 }
629 699
630 bool CdmWrapper::CreateCdmInstance(const std::string& key_system) { 700 bool CdmWrapper::CreateCdmInstance(const std::string& key_system) {
631 PP_DCHECK(!cdm_); 701 PP_DCHECK(!cdm_);
632 cdm_ = static_cast<cdm::ContentDecryptionModule*>( 702 cdm_ = static_cast<cdm::ContentDecryptionModule*>(
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 int32_t session_id_length, 999 int32_t session_id_length,
930 cdm::MediaKeyError error_code, 1000 cdm::MediaKeyError error_code,
931 uint32_t system_code) { 1001 uint32_t system_code) {
932 SendKeyErrorInternal(key_system_, 1002 SendKeyErrorInternal(key_system_,
933 std::string(session_id, session_id_length), 1003 std::string(session_id, session_id_length),
934 error_code, 1004 error_code,
935 system_code); 1005 system_code);
936 } 1006 }
937 1007
938 void CdmWrapper::GetPrivateData(int32_t* instance, 1008 void CdmWrapper::GetPrivateData(int32_t* instance,
939 cdm::Host::GetPrivateInterface* get_interface) { 1009 GetPrivateInterface* get_interface) {
940 *instance = pp_instance(); 1010 *instance = pp_instance();
941 *get_interface = pp::Module::Get()->get_browser_interface(); 1011 *get_interface = pp::Module::Get()->get_browser_interface();
942 } 1012 }
943 1013
944 void CdmWrapper::SendUnknownKeyError(const std::string& key_system, 1014 void CdmWrapper::SendUnknownKeyError(const std::string& key_system,
945 const std::string& session_id) { 1015 const std::string& session_id) {
946 SendKeyErrorInternal(key_system, session_id, cdm::kUnknownError, 0); 1016 SendKeyErrorInternal(key_system, session_id, cdm::kUnknownError, 0);
947 } 1017 }
948 1018
949 void CdmWrapper::SendKeyAdded(const std::string& key_system, 1019 void CdmWrapper::SendKeyAdded(const std::string& key_system,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 static_cast<cdm::VideoFrame::VideoPlane>(i); 1218 static_cast<cdm::VideoFrame::VideoPlane>(i);
1149 if (ppb_buffer->Size() < video_frame->PlaneOffset(plane) + 1219 if (ppb_buffer->Size() < video_frame->PlaneOffset(plane) +
1150 plane_height * video_frame->Stride(plane)) { 1220 plane_height * video_frame->Stride(plane)) {
1151 return false; 1221 return false;
1152 } 1222 }
1153 } 1223 }
1154 1224
1155 return true; 1225 return true;
1156 } 1226 }
1157 1227
1228 bool CdmWrapper::CanChallengePlatform() {
1229 #if defined(OS_CHROMEOS)
1230 return can_challenge_platform_;
1231 #else
1232 return false;
1233 #endif
1234 }
1235
1236 void CdmWrapper::SendPlatformChallenge(
1237 const char* service_id, int32_t service_id_length,
1238 const char* challenge, int32_t challenge_length) {
1239 #if defined(OS_CHROMEOS)
1240 PP_DCHECK(!challenge_in_progress_);
1241
1242 // Ensure member variables set by the callback are in a clean state.
1243 signed_data_output_ = pp::Var();
1244 signed_data_signature_output_ = pp::Var();
1245 platform_key_certificate_output_ = pp::Var();
1246
1247 pp::VarArrayBuffer challenge_var(challenge_length);
1248 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map());
1249 memcpy(var_data, challenge, challenge_length);
1250
1251 std::string service_id_str(service_id, service_id_length);
1252 int32_t result = platform_verification_.ChallengePlatform(
1253 pp::Var(service_id_str), challenge_var, &signed_data_output_,
1254 &signed_data_signature_output_, &platform_key_certificate_output_,
1255 callback_factory_.NewCallback(&CdmWrapper::SendPlatformChallengeDone));
1256 challenge_var.Unmap();
1257 if (result == PP_OK_COMPLETIONPENDING) {
1258 challenge_in_progress_ = true;
1259 return;
1260 }
1261
1262 // Fall through on error and issue an empty OnPlatformChallengeResponse().
1263 PP_DCHECK(result != PP_OK);
1264 #endif
1265
1266 cdm::PlatformChallengeResponse response = {};
1267 cdm_->OnPlatformChallengeResponse(response);
1268 }
1269
1270 void CdmWrapper::EnableOutputProtection(uint32_t desired_protection_mask) {
1271 #if defined(OS_CHROMEOS)
1272 output_protection_.EnableProtection(
1273 desired_protection_mask, callback_factory_.NewCallback(
1274 &CdmWrapper::EnableProtectionDone));
1275
1276 // Errors are ignored since clients must call QueryOutputProtectionStatus() to
1277 // inspect the protection status on a regular basis.
1278 // TODO(dalecurtis): It'd be nice to log a message or non-fatal error here...
1279 #endif
1280 }
1281
1282 void CdmWrapper::QueryOutputProtectionStatus() {
1283 #if defined(OS_CHROMEOS)
1284 PP_DCHECK(!query_output_protection_in_progress_);
1285
1286 output_link_mask_ = output_protection_mask_ = 0;
1287 const int32_t result = output_protection_.QueryStatus(
1288 &output_link_mask_,
1289 &output_protection_mask_,
1290 callback_factory_.NewCallback(
1291 &CdmWrapper::QueryOutputProtectionStatusDone));
1292 if (result == PP_OK_COMPLETIONPENDING) {
1293 query_output_protection_in_progress_ = true;
1294 return;
1295 }
1296
1297 // Fall through on error and issue an empty OnQueryOutputProtectionStatus().
1298 PP_DCHECK(result != PP_OK);
1299 #endif
1300
1301 cdm_->OnQueryOutputProtectionStatus(0, 0);
1302 }
1303
1304 #if defined(OS_CHROMEOS)
1305 void CdmWrapper::CanChallengePlatformDone(int32_t result,
1306 bool can_challenge_platform) {
1307 can_challenge_platform_ = (result == PP_OK) ? can_challenge_platform : false;
1308 }
1309
1310 void CdmWrapper::SendPlatformChallengeDone(int32_t result) {
1311 challenge_in_progress_ = false;
1312
1313 if (result != PP_OK) {
1314 cdm::PlatformChallengeResponse response = {};
1315 cdm_->OnPlatformChallengeResponse(response);
1316 return;
1317 }
1318
1319 pp::VarArrayBuffer signed_data_var(signed_data_output_);
1320 pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_);
1321 std::string platform_key_certificate_string =
1322 platform_key_certificate_output_.AsString();
1323
1324 cdm::PlatformChallengeResponse response = {
1325 static_cast<uint8_t*>(signed_data_var.Map()),
1326 static_cast<int32_t>(signed_data_var.ByteLength()),
1327
1328 static_cast<uint8_t*>(signed_data_signature_var.Map()),
1329 static_cast<int32_t>(signed_data_signature_var.ByteLength()),
1330
1331 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.c_str()),
1332 static_cast<int32_t>(platform_key_certificate_string.length())
1333 };
1334 cdm_->OnPlatformChallengeResponse(response);
1335
1336 signed_data_var.Unmap();
1337 signed_data_signature_var.Unmap();
1338 }
1339
1340 void CdmWrapper::EnableProtectionDone(int32_t result) {
1341 // Does nothing since clients must call QueryOutputProtectionStatus() to
1342 // inspect the protection status on a regular basis.
1343 // TODO(dalecurtis): It'd be nice to log a message or non-fatal error here...
1344 }
1345
1346 void CdmWrapper::QueryOutputProtectionStatusDone(int32_t result) {
1347 PP_DCHECK(query_output_protection_in_progress_);
1348 query_output_protection_in_progress_ = false;
1349
1350 // Return a protection status of none on error.
1351 if (result != PP_OK)
1352 output_link_mask_ = output_protection_mask_ = 0;
1353
1354 cdm_->OnQueryOutputProtectionStatus(output_link_mask_,
1355 output_protection_mask_);
1356 }
1357 #endif
1358
1158 void* GetCdmHost(int host_interface_version, void* user_data) { 1359 void* GetCdmHost(int host_interface_version, void* user_data) {
1159 if (!host_interface_version || !user_data) 1360 if (!host_interface_version || !user_data)
1160 return NULL; 1361 return NULL;
1161 1362
1162 if (host_interface_version != cdm::kHostInterfaceVersion)
1163 return NULL;
1164
1165 CdmWrapper* cdm_wrapper = static_cast<CdmWrapper*>(user_data); 1363 CdmWrapper* cdm_wrapper = static_cast<CdmWrapper*>(user_data);
1166 return static_cast<cdm::Host*>(cdm_wrapper); 1364 switch (host_interface_version) {
1365 case cdm::kHostInterfaceVersion_1:
1366 return static_cast<cdm::Host_1*>(cdm_wrapper);
1367 case cdm::kHostInterfaceVersion_2:
1368 return static_cast<cdm::Host_2*>(cdm_wrapper);
1369 default:
1370 PP_NOTREACHED();
1371 return NULL;
1372 }
1167 } 1373 }
1168 1374
1169 // This object is the global object representing this plugin library as long 1375 // This object is the global object representing this plugin library as long
1170 // as it is loaded. 1376 // as it is loaded.
1171 class CdmWrapperModule : public pp::Module { 1377 class CdmWrapperModule : public pp::Module {
1172 public: 1378 public:
1173 CdmWrapperModule() : pp::Module() { 1379 CdmWrapperModule() : pp::Module() {
1174 // This function blocks the renderer thread (PluginInstance::Initialize()). 1380 // This function blocks the renderer thread (PluginInstance::Initialize()).
1175 // Move this call to other places if this may be a concern in the future. 1381 // Move this call to other places if this may be a concern in the future.
1176 INITIALIZE_CDM_MODULE(); 1382 INITIALIZE_CDM_MODULE();
(...skipping 10 matching lines...) Expand all
1187 } // namespace media 1393 } // namespace media
1188 1394
1189 namespace pp { 1395 namespace pp {
1190 1396
1191 // Factory function for your specialization of the Module object. 1397 // Factory function for your specialization of the Module object.
1192 Module* CreateModule() { 1398 Module* CreateModule() {
1193 return new media::CdmWrapperModule(); 1399 return new media::CdmWrapperModule();
1194 } 1400 }
1195 1401
1196 } // namespace pp 1402 } // namespace pp
OLDNEW
« no previous file with comments | « DEPS ('k') | media/cdm/ppapi/clear_key_cdm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698