| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CDM_CONTENT_DECRYPTION_MODULE_H_ | 5 #ifndef CDM_CONTENT_DECRYPTION_MODULE_H_ |
| 6 #define CDM_CONTENT_DECRYPTION_MODULE_H_ | 6 #define CDM_CONTENT_DECRYPTION_MODULE_H_ |
| 7 | 7 |
| 8 #if defined(_MSC_VER) | 8 #if defined(_MSC_VER) |
| 9 typedef unsigned char uint8_t; | 9 typedef unsigned char uint8_t; |
| 10 typedef unsigned int uint32_t; | 10 typedef unsigned int uint32_t; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 CDM_EXPORT void* CreateCdmInstance( | 68 CDM_EXPORT void* CreateCdmInstance( |
| 69 int cdm_interface_version, | 69 int cdm_interface_version, |
| 70 const char* key_system, uint32_t key_system_size, | 70 const char* key_system, uint32_t key_system_size, |
| 71 GetCdmHostFunc get_cdm_host_func, void* user_data); | 71 GetCdmHostFunc get_cdm_host_func, void* user_data); |
| 72 | 72 |
| 73 CDM_EXPORT const char* GetCdmVersion(); | 73 CDM_EXPORT const char* GetCdmVersion(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 namespace cdm { | 76 namespace cdm { |
| 77 | 77 |
| 78 class AudioFrames_1; | |
| 79 class AudioFrames_2; | 78 class AudioFrames_2; |
| 80 typedef AudioFrames_2 AudioFrames; | 79 typedef AudioFrames_2 AudioFrames; |
| 81 | 80 |
| 82 class Host_1; | |
| 83 class Host_2; | |
| 84 class Host_4; | 81 class Host_4; |
| 85 | 82 |
| 86 class DecryptedBlock; | 83 class DecryptedBlock; |
| 87 class VideoFrame; | 84 class VideoFrame; |
| 88 | 85 |
| 89 enum Status { | 86 enum Status { |
| 90 kSuccess = 0, | 87 kSuccess = 0, |
| 91 kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample. | 88 kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample. |
| 92 kNoKey, // The required decryption key is not available. | 89 kNoKey, // The required decryption key is not available. |
| 93 kSessionError, // Session management error. | 90 kSessionError, // Session management error. |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // - kError indicates write failure, e.g. the storage isn't open or cannot be | 369 // - kError indicates write failure, e.g. the storage isn't open or cannot be |
| 373 // fully written. Upon write failure, the contents of the file should be | 370 // fully written. Upon write failure, the contents of the file should be |
| 374 // regarded as corrupt and should not used. | 371 // regarded as corrupt and should not used. |
| 375 virtual void OnWriteComplete(Status status) = 0; | 372 virtual void OnWriteComplete(Status status) = 0; |
| 376 | 373 |
| 377 protected: | 374 protected: |
| 378 FileIOClient() {} | 375 FileIOClient() {} |
| 379 virtual ~FileIOClient() {} | 376 virtual ~FileIOClient() {} |
| 380 }; | 377 }; |
| 381 | 378 |
| 382 // WARNING: Deprecated. Will be removed in the near future. CDMs should | |
| 383 // implement ContentDecryptionModule_2 instead. | |
| 384 | |
| 385 // ContentDecryptionModule interface that all CDMs need to implement. | |
| 386 // The interface is versioned for backward compatibility. | |
| 387 // Note: ContentDecryptionModule implementations must use the allocator | |
| 388 // provided in CreateCdmInstance() to allocate any Buffer that needs to | |
| 389 // be passed back to the caller. Implementations must call Buffer::Destroy() | |
| 390 // when a Buffer is created that will never be returned to the caller. | |
| 391 class ContentDecryptionModule_1 { | |
| 392 public: | |
| 393 static const int kVersion = 1; | |
| 394 typedef Host_1 Host; | |
| 395 | |
| 396 // Generates a |key_request| given |type| and |init_data|. | |
| 397 // | |
| 398 // Returns kSuccess if the key request was successfully generated, in which | |
| 399 // case the CDM must send the key message by calling Host::SendKeyMessage(). | |
| 400 // Returns kSessionError if any error happened, in which case the CDM must | |
| 401 // send a key error by calling Host::SendKeyError(). | |
| 402 virtual Status GenerateKeyRequest( | |
| 403 const char* type, uint32_t type_size, | |
| 404 const uint8_t* init_data, uint32_t init_data_size) = 0; | |
| 405 | |
| 406 // Adds the |key| to the CDM to be associated with |key_id|. | |
| 407 // | |
| 408 // Returns kSuccess if the key was successfully added, kSessionError | |
| 409 // otherwise. | |
| 410 virtual Status AddKey(const char* session_id, uint32_t session_id_size, | |
| 411 const uint8_t* key, uint32_t key_size, | |
| 412 const uint8_t* key_id, uint32_t key_id_size) = 0; | |
| 413 | |
| 414 // Cancels any pending key request made to the CDM for |session_id|. | |
| 415 // | |
| 416 // Returns kSuccess if all pending key requests for |session_id| were | |
| 417 // successfully canceled or there was no key request to be canceled, | |
| 418 // kSessionError otherwise. | |
| 419 virtual Status CancelKeyRequest( | |
| 420 const char* session_id, uint32_t session_id_size) = 0; | |
| 421 | |
| 422 // Performs scheduled operation with |context| when the timer fires. | |
| 423 virtual void TimerExpired(void* context) = 0; | |
| 424 | |
| 425 // Decrypts the |encrypted_buffer|. | |
| 426 // | |
| 427 // Returns kSuccess if decryption succeeded, in which case the callee | |
| 428 // should have filled the |decrypted_buffer| and passed the ownership of | |
| 429 // |data| in |decrypted_buffer| to the caller. | |
| 430 // Returns kNoKey if the CDM did not have the necessary decryption key | |
| 431 // to decrypt. | |
| 432 // Returns kDecryptError if any other error happened. | |
| 433 // If the return value is not kSuccess, |decrypted_buffer| should be ignored | |
| 434 // by the caller. | |
| 435 virtual Status Decrypt(const InputBuffer& encrypted_buffer, | |
| 436 DecryptedBlock* decrypted_buffer) = 0; | |
| 437 | |
| 438 // Initializes the CDM audio decoder with |audio_decoder_config|. This | |
| 439 // function must be called before DecryptAndDecodeSamples() is called. | |
| 440 // | |
| 441 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM | |
| 442 // audio decoder is successfully initialized. | |
| 443 // Returns kSessionError if |audio_decoder_config| is not supported. The CDM | |
| 444 // may still be able to do Decrypt(). | |
| 445 virtual Status InitializeAudioDecoder( | |
| 446 const AudioDecoderConfig& audio_decoder_config) = 0; | |
| 447 | |
| 448 // Initializes the CDM video decoder with |video_decoder_config|. This | |
| 449 // function must be called before DecryptAndDecodeFrame() is called. | |
| 450 // | |
| 451 // Returns kSuccess if the |video_decoder_config| is supported and the CDM | |
| 452 // video decoder is successfully initialized. | |
| 453 // Returns kSessionError if |video_decoder_config| is not supported. The CDM | |
| 454 // may still be able to do Decrypt(). | |
| 455 virtual Status InitializeVideoDecoder( | |
| 456 const VideoDecoderConfig& video_decoder_config) = 0; | |
| 457 | |
| 458 // De-initializes the CDM decoder and sets it to an uninitialized state. The | |
| 459 // caller can initialize the decoder again after this call to re-initialize | |
| 460 // it. This can be used to reconfigure the decoder if the configuration | |
| 461 // changes. | |
| 462 virtual void DeinitializeDecoder(StreamType decoder_type) = 0; | |
| 463 | |
| 464 // Resets the CDM decoder to an initialized clean state. All internal buffers | |
| 465 // MUST be flushed. | |
| 466 virtual void ResetDecoder(StreamType decoder_type) = 0; | |
| 467 | |
| 468 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a | |
| 469 // |video_frame|. Upon end-of-stream, the caller should call this function | |
| 470 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty | |
| 471 // |video_frame| (|format| == kEmptyVideoFrame) is produced. | |
| 472 // | |
| 473 // Returns kSuccess if decryption and decoding both succeeded, in which case | |
| 474 // the callee will have filled the |video_frame| and passed the ownership of | |
| 475 // |frame_buffer| in |video_frame| to the caller. | |
| 476 // Returns kNoKey if the CDM did not have the necessary decryption key | |
| 477 // to decrypt. | |
| 478 // Returns kNeedMoreData if more data was needed by the decoder to generate | |
| 479 // a decoded frame (e.g. during initialization and end-of-stream). | |
| 480 // Returns kDecryptError if any decryption error happened. | |
| 481 // Returns kDecodeError if any decoding error happened. | |
| 482 // If the return value is not kSuccess, |video_frame| should be ignored by | |
| 483 // the caller. | |
| 484 virtual Status DecryptAndDecodeFrame(const InputBuffer& encrypted_buffer, | |
| 485 VideoFrame* video_frame) = 0; | |
| 486 | |
| 487 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into | |
| 488 // |audio_frames|. Upon end-of-stream, the caller should call this function | |
| 489 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty | |
| 490 // |audio_frames| is produced. | |
| 491 // | |
| 492 // Returns kSuccess if decryption and decoding both succeeded, in which case | |
| 493 // the callee will have filled |audio_frames| and passed the ownership of | |
| 494 // |data| in |audio_frames| to the caller. | |
| 495 // Returns kNoKey if the CDM did not have the necessary decryption key | |
| 496 // to decrypt. | |
| 497 // Returns kNeedMoreData if more data was needed by the decoder to generate | |
| 498 // audio samples (e.g. during initialization and end-of-stream). | |
| 499 // Returns kDecryptError if any decryption error happened. | |
| 500 // Returns kDecodeError if any decoding error happened. | |
| 501 // If the return value is not kSuccess, |audio_frames| should be ignored by | |
| 502 // the caller. | |
| 503 virtual Status DecryptAndDecodeSamples(const InputBuffer& encrypted_buffer, | |
| 504 AudioFrames_1* audio_frames) = 0; | |
| 505 | |
| 506 // Destroys the object in the same context as it was created. | |
| 507 virtual void Destroy() = 0; | |
| 508 | |
| 509 protected: | |
| 510 ContentDecryptionModule_1() {} | |
| 511 virtual ~ContentDecryptionModule_1() {} | |
| 512 }; | |
| 513 | |
| 514 // ContentDecryptionModule interface that all CDMs need to implement. | 379 // ContentDecryptionModule interface that all CDMs need to implement. |
| 515 // The interface is versioned for backward compatibility. | 380 // The interface is versioned for backward compatibility. |
| 516 // Note: ContentDecryptionModule implementations must use the allocator | 381 // Note: ContentDecryptionModule implementations must use the allocator |
| 517 // provided in CreateCdmInstance() to allocate any Buffer that needs to | |
| 518 // be passed back to the caller. Implementations must call Buffer::Destroy() | |
| 519 // when a Buffer is created that will never be returned to the caller. | |
| 520 class ContentDecryptionModule_2 { | |
| 521 public: | |
| 522 static const int kVersion = 2; | |
| 523 typedef Host_2 Host; | |
| 524 | |
| 525 // Generates a |key_request| given |type| and |init_data|. | |
| 526 // | |
| 527 // Returns kSuccess if the key request was successfully generated, in which | |
| 528 // case the CDM must send the key message by calling Host::SendKeyMessage(). | |
| 529 // Returns kSessionError if any error happened, in which case the CDM must | |
| 530 // send a key error by calling Host::SendKeyError(). | |
| 531 virtual Status GenerateKeyRequest( | |
| 532 const char* type, uint32_t type_size, | |
| 533 const uint8_t* init_data, uint32_t init_data_size) = 0; | |
| 534 | |
| 535 // Adds the |key| to the CDM to be associated with |key_id|. | |
| 536 // | |
| 537 // Returns kSuccess if the key was successfully added, kSessionError | |
| 538 // otherwise. | |
| 539 virtual Status AddKey(const char* session_id, uint32_t session_id_size, | |
| 540 const uint8_t* key, uint32_t key_size, | |
| 541 const uint8_t* key_id, uint32_t key_id_size) = 0; | |
| 542 | |
| 543 // Cancels any pending key request made to the CDM for |session_id|. | |
| 544 // | |
| 545 // Returns kSuccess if all pending key requests for |session_id| were | |
| 546 // successfully canceled or there was no key request to be canceled, | |
| 547 // kSessionError otherwise. | |
| 548 virtual Status CancelKeyRequest( | |
| 549 const char* session_id, uint32_t session_id_size) = 0; | |
| 550 | |
| 551 // Performs scheduled operation with |context| when the timer fires. | |
| 552 virtual void TimerExpired(void* context) = 0; | |
| 553 | |
| 554 // Decrypts the |encrypted_buffer|. | |
| 555 // | |
| 556 // Returns kSuccess if decryption succeeded, in which case the callee | |
| 557 // should have filled the |decrypted_buffer| and passed the ownership of | |
| 558 // |data| in |decrypted_buffer| to the caller. | |
| 559 // Returns kNoKey if the CDM did not have the necessary decryption key | |
| 560 // to decrypt. | |
| 561 // Returns kDecryptError if any other error happened. | |
| 562 // If the return value is not kSuccess, |decrypted_buffer| should be ignored | |
| 563 // by the caller. | |
| 564 virtual Status Decrypt(const InputBuffer& encrypted_buffer, | |
| 565 DecryptedBlock* decrypted_buffer) = 0; | |
| 566 | |
| 567 // Initializes the CDM audio decoder with |audio_decoder_config|. This | |
| 568 // function must be called before DecryptAndDecodeSamples() is called. | |
| 569 // | |
| 570 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM | |
| 571 // audio decoder is successfully initialized. | |
| 572 // Returns kSessionError if |audio_decoder_config| is not supported. The CDM | |
| 573 // may still be able to do Decrypt(). | |
| 574 // Returns kDeferredInitialization if the CDM is not ready to initialize the | |
| 575 // decoder at this time. Must call Host::OnDeferredInitializationDone() once | |
| 576 // initialization is complete. | |
| 577 virtual Status InitializeAudioDecoder( | |
| 578 const AudioDecoderConfig& audio_decoder_config) = 0; | |
| 579 | |
| 580 // Initializes the CDM video decoder with |video_decoder_config|. This | |
| 581 // function must be called before DecryptAndDecodeFrame() is called. | |
| 582 // | |
| 583 // Returns kSuccess if the |video_decoder_config| is supported and the CDM | |
| 584 // video decoder is successfully initialized. | |
| 585 // Returns kSessionError if |video_decoder_config| is not supported. The CDM | |
| 586 // may still be able to do Decrypt(). | |
| 587 // Returns kDeferredInitialization if the CDM is not ready to initialize the | |
| 588 // decoder at this time. Must call Host::OnDeferredInitializationDone() once | |
| 589 // initialization is complete. | |
| 590 virtual Status InitializeVideoDecoder( | |
| 591 const VideoDecoderConfig& video_decoder_config) = 0; | |
| 592 | |
| 593 // De-initializes the CDM decoder and sets it to an uninitialized state. The | |
| 594 // caller can initialize the decoder again after this call to re-initialize | |
| 595 // it. This can be used to reconfigure the decoder if the configuration | |
| 596 // changes. | |
| 597 virtual void DeinitializeDecoder(StreamType decoder_type) = 0; | |
| 598 | |
| 599 // Resets the CDM decoder to an initialized clean state. All internal buffers | |
| 600 // MUST be flushed. | |
| 601 virtual void ResetDecoder(StreamType decoder_type) = 0; | |
| 602 | |
| 603 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a | |
| 604 // |video_frame|. Upon end-of-stream, the caller should call this function | |
| 605 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty | |
| 606 // |video_frame| (|format| == kEmptyVideoFrame) is produced. | |
| 607 // | |
| 608 // Returns kSuccess if decryption and decoding both succeeded, in which case | |
| 609 // the callee will have filled the |video_frame| and passed the ownership of | |
| 610 // |frame_buffer| in |video_frame| to the caller. | |
| 611 // Returns kNoKey if the CDM did not have the necessary decryption key | |
| 612 // to decrypt. | |
| 613 // Returns kNeedMoreData if more data was needed by the decoder to generate | |
| 614 // a decoded frame (e.g. during initialization and end-of-stream). | |
| 615 // Returns kDecryptError if any decryption error happened. | |
| 616 // Returns kDecodeError if any decoding error happened. | |
| 617 // If the return value is not kSuccess, |video_frame| should be ignored by | |
| 618 // the caller. | |
| 619 virtual Status DecryptAndDecodeFrame(const InputBuffer& encrypted_buffer, | |
| 620 VideoFrame* video_frame) = 0; | |
| 621 | |
| 622 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into | |
| 623 // |audio_frames|. Upon end-of-stream, the caller should call this function | |
| 624 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty | |
| 625 // |audio_frames| is produced. | |
| 626 // | |
| 627 // Returns kSuccess if decryption and decoding both succeeded, in which case | |
| 628 // the callee will have filled |audio_frames| and passed the ownership of | |
| 629 // |data| in |audio_frames| to the caller. | |
| 630 // Returns kNoKey if the CDM did not have the necessary decryption key | |
| 631 // to decrypt. | |
| 632 // Returns kNeedMoreData if more data was needed by the decoder to generate | |
| 633 // audio samples (e.g. during initialization and end-of-stream). | |
| 634 // Returns kDecryptError if any decryption error happened. | |
| 635 // Returns kDecodeError if any decoding error happened. | |
| 636 // If the return value is not kSuccess, |audio_frames| should be ignored by | |
| 637 // the caller. | |
| 638 virtual Status DecryptAndDecodeSamples(const InputBuffer& encrypted_buffer, | |
| 639 AudioFrames* audio_frames) = 0; | |
| 640 | |
| 641 // Called by the host after a platform challenge was initiated via | |
| 642 // Host::SendPlatformChallenge(). | |
| 643 virtual void OnPlatformChallengeResponse( | |
| 644 const PlatformChallengeResponse& response) = 0; | |
| 645 | |
| 646 // Called by the host after a call to Host::QueryOutputProtectionStatus(). The | |
| 647 // |link_mask| is a bit mask of OutputLinkTypes and |output_protection_mask| | |
| 648 // is a bit mask of OutputProtectionMethods. | |
| 649 virtual void OnQueryOutputProtectionStatus( | |
| 650 uint32_t link_mask, uint32_t output_protection_mask) = 0; | |
| 651 | |
| 652 // Destroys the object in the same context as it was created. | |
| 653 virtual void Destroy() = 0; | |
| 654 | |
| 655 protected: | |
| 656 ContentDecryptionModule_2() {} | |
| 657 virtual ~ContentDecryptionModule_2() {} | |
| 658 }; | |
| 659 | |
| 660 // ContentDecryptionModule interface that all CDMs need to implement. | |
| 661 // The interface is versioned for backward compatibility. | |
| 662 // Note: ContentDecryptionModule implementations must use the allocator | |
| 663 // provided in CreateCdmInstance() to allocate any Buffer that needs to | 382 // provided in CreateCdmInstance() to allocate any Buffer that needs to |
| 664 // be passed back to the caller. Implementations must call Buffer::Destroy() | 383 // be passed back to the caller. Implementations must call Buffer::Destroy() |
| 665 // when a Buffer is created that will never be returned to the caller. | 384 // when a Buffer is created that will never be returned to the caller. |
| 666 class ContentDecryptionModule_4 { | 385 class ContentDecryptionModule_4 { |
| 667 public: | 386 public: |
| 668 static const int kVersion = 4; | 387 static const int kVersion = 4; |
| 669 typedef Host_4 Host; | 388 typedef Host_4 Host; |
| 670 | 389 |
| 671 // CreateSession(), UpdateSession(), and ReleaseSession() get passed a | 390 // CreateSession(), UpdateSession(), and ReleaseSession() get passed a |
| 672 // |session_id| for a MediaKeySession object. It must be used in the reply via | 391 // |session_id| for a MediaKeySession object. It must be used in the reply via |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 | 536 |
| 818 protected: | 537 protected: |
| 819 Buffer() {} | 538 Buffer() {} |
| 820 virtual ~Buffer() {} | 539 virtual ~Buffer() {} |
| 821 | 540 |
| 822 private: | 541 private: |
| 823 Buffer(const Buffer&); | 542 Buffer(const Buffer&); |
| 824 void operator=(const Buffer&); | 543 void operator=(const Buffer&); |
| 825 }; | 544 }; |
| 826 | 545 |
| 827 // Host interface that the CDM can call into to access browser side services. | |
| 828 // Host interfaces are versioned for backward compatibility. CDM should use | |
| 829 // HostFactory object to request a Host interface of a particular version. | |
| 830 class Host_1 { | |
| 831 public: | |
| 832 static const int kVersion = 1; | |
| 833 | |
| 834 // Returns a Buffer* containing non-zero members upon success, or NULL on | |
| 835 // failure. The caller owns the Buffer* after this call. The buffer is not | |
| 836 // guaranteed to be zero initialized. The capacity of the allocated Buffer | |
| 837 // is guaranteed to be not less than |capacity|. | |
| 838 virtual Buffer* Allocate(uint32_t capacity) = 0; | |
| 839 | |
| 840 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms| | |
| 841 // from now with |context|. | |
| 842 virtual void SetTimer(int64_t delay_ms, void* context) = 0; | |
| 843 | |
| 844 // Returns the current epoch wall time in seconds. | |
| 845 virtual double GetCurrentWallTimeInSeconds() = 0; | |
| 846 | |
| 847 // Sends a keymessage event to the application. | |
| 848 // Length parameters should not include null termination. | |
| 849 virtual void SendKeyMessage( | |
| 850 const char* session_id, uint32_t session_id_length, | |
| 851 const char* message, uint32_t message_length, | |
| 852 const char* default_url, uint32_t default_url_length) = 0; | |
| 853 | |
| 854 // Sends a keyerror event to the application. | |
| 855 // |session_id_length| should not include null termination. | |
| 856 virtual void SendKeyError(const char* session_id, | |
| 857 uint32_t session_id_length, | |
| 858 MediaKeyError error_code, | |
| 859 uint32_t system_code) = 0; | |
| 860 | |
| 861 // Get private data from the host. This function is limited to internal use. | |
| 862 typedef const void* (*GetPrivateInterface)(const char* interface_name); | |
| 863 virtual void GetPrivateData(int32_t* instance, | |
| 864 GetPrivateInterface* get_interface) = 0; | |
| 865 | |
| 866 protected: | |
| 867 Host_1() {} | |
| 868 virtual ~Host_1() {} | |
| 869 }; | |
| 870 | |
| 871 class Host_2 { | |
| 872 public: | |
| 873 static const int kVersion = 2; | |
| 874 | |
| 875 // Returns a Buffer* containing non-zero members upon success, or NULL on | |
| 876 // failure. The caller owns the Buffer* after this call. The buffer is not | |
| 877 // guaranteed to be zero initialized. The capacity of the allocated Buffer | |
| 878 // is guaranteed to be not less than |capacity|. | |
| 879 virtual Buffer* Allocate(uint32_t capacity) = 0; | |
| 880 | |
| 881 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms| | |
| 882 // from now with |context|. | |
| 883 virtual void SetTimer(int64_t delay_ms, void* context) = 0; | |
| 884 | |
| 885 // Returns the current epoch wall time in seconds. | |
| 886 virtual double GetCurrentWallTimeInSeconds() = 0; | |
| 887 | |
| 888 // Sends a keymessage event to the application. | |
| 889 // Length parameters should not include null termination. | |
| 890 virtual void SendKeyMessage( | |
| 891 const char* session_id, uint32_t session_id_length, | |
| 892 const char* message, uint32_t message_length, | |
| 893 const char* default_url, uint32_t default_url_length) = 0; | |
| 894 | |
| 895 // Sends a keyerror event to the application. | |
| 896 // |session_id_length| should not include null termination. | |
| 897 virtual void SendKeyError(const char* session_id, | |
| 898 uint32_t session_id_length, | |
| 899 MediaKeyError error_code, | |
| 900 uint32_t system_code) = 0; | |
| 901 | |
| 902 // Get private data from the host. This function is limited to internal use. | |
| 903 virtual void GetPrivateData(int32_t* instance, | |
| 904 Host_1::GetPrivateInterface* get_interface) = 0; | |
| 905 | |
| 906 // Sends a platform challenge for the given |service_id|. |challenge| is at | |
| 907 // most 256 bits of data to be signed. Once the challenge has been completed, | |
| 908 // the host will call ContentDecryptionModule::OnPlatformChallengeResponse() | |
| 909 // with the signed challenge response and platform certificate. Length | |
| 910 // parameters should not include null termination. | |
| 911 virtual void SendPlatformChallenge( | |
| 912 const char* service_id, uint32_t service_id_length, | |
| 913 const char* challenge, uint32_t challenge_length) = 0; | |
| 914 | |
| 915 // Attempts to enable output protection (e.g. HDCP) on the display link. The | |
| 916 // |desired_protection_mask| is a bit mask of OutputProtectionMethods. No | |
| 917 // status callback is issued, the CDM must call QueryOutputProtectionStatus() | |
| 918 // periodically to ensure the desired protections are applied. | |
| 919 virtual void EnableOutputProtection(uint32_t desired_protection_mask) = 0; | |
| 920 | |
| 921 // Requests the current output protection status. Once the host has the status | |
| 922 // it will call ContentDecryptionModule::OnQueryOutputProtectionStatus(). | |
| 923 virtual void QueryOutputProtectionStatus() = 0; | |
| 924 | |
| 925 // Must be called by the CDM if it returned kDeferredInitialization during | |
| 926 // InitializeAudioDecoder() or InitializeVideoDecoder(). | |
| 927 virtual void OnDeferredInitializationDone(StreamType stream_type, | |
| 928 Status decoder_status) = 0; | |
| 929 | |
| 930 protected: | |
| 931 Host_2() {} | |
| 932 virtual ~Host_2() {} | |
| 933 }; | |
| 934 | |
| 935 class Host_4 { | 546 class Host_4 { |
| 936 public: | 547 public: |
| 937 static const int kVersion = 4; | 548 static const int kVersion = 4; |
| 938 | 549 |
| 939 // Returns a Buffer* containing non-zero members upon success, or NULL on | 550 // Returns a Buffer* containing non-zero members upon success, or NULL on |
| 940 // failure. The caller owns the Buffer* after this call. The buffer is not | 551 // failure. The caller owns the Buffer* after this call. The buffer is not |
| 941 // guaranteed to be zero initialized. The capacity of the allocated Buffer | 552 // guaranteed to be zero initialized. The capacity of the allocated Buffer |
| 942 // is guaranteed to be not less than |capacity|. | 553 // is guaranteed to be not less than |capacity|. |
| 943 virtual Buffer* Allocate(uint32_t capacity) = 0; | 554 virtual Buffer* Allocate(uint32_t capacity) = 0; |
| 944 | 555 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 virtual uint32_t Stride(VideoPlane plane) = 0; | 670 virtual uint32_t Stride(VideoPlane plane) = 0; |
| 1060 | 671 |
| 1061 virtual void SetTimestamp(int64_t timestamp) = 0; | 672 virtual void SetTimestamp(int64_t timestamp) = 0; |
| 1062 virtual int64_t Timestamp() const = 0; | 673 virtual int64_t Timestamp() const = 0; |
| 1063 | 674 |
| 1064 protected: | 675 protected: |
| 1065 VideoFrame() {} | 676 VideoFrame() {} |
| 1066 virtual ~VideoFrame() {} | 677 virtual ~VideoFrame() {} |
| 1067 }; | 678 }; |
| 1068 | 679 |
| 1069 // | |
| 1070 // WARNING: Deprecated. Will be removed in the near future. CDMs should be | |
| 1071 // implementing ContentDecryptionModule_2 instead which uses AudioFrames_2. | |
| 1072 // | |
| 1073 // Represents decrypted and decoded audio frames. AudioFrames can contain | 680 // Represents decrypted and decoded audio frames. AudioFrames can contain |
| 1074 // multiple audio output buffers, which are serialized into this format: | 681 // multiple audio output buffers, which are serialized into this format: |
| 1075 // | 682 // |
| 1076 // |<------------------- serialized audio buffer ------------------->| | 683 // |<------------------- serialized audio buffer ------------------->| |
| 1077 // | int64_t timestamp | int64_t length | length bytes of audio data | | 684 // | int64_t timestamp | int64_t length | length bytes of audio data | |
| 1078 // | 685 // |
| 1079 // For example, with three audio output buffers, the AudioFrames will look | 686 // For example, with three audio output buffers, the AudioFrames will look |
| 1080 // like this: | 687 // like this: |
| 1081 // | 688 // |
| 1082 // |<----------------- AudioFrames ------------------>| | 689 // |<----------------- AudioFrames ------------------>| |
| 1083 // | audio buffer 0 | audio buffer 1 | audio buffer 2 | | 690 // | audio buffer 0 | audio buffer 1 | audio buffer 2 | |
| 1084 class AudioFrames_1 { | |
| 1085 public: | |
| 1086 virtual void SetFrameBuffer(Buffer* buffer) = 0; | |
| 1087 virtual Buffer* FrameBuffer() = 0; | |
| 1088 | |
| 1089 protected: | |
| 1090 AudioFrames_1() {} | |
| 1091 virtual ~AudioFrames_1() {} | |
| 1092 }; | |
| 1093 | |
| 1094 // Same as AudioFrames except the format of the data may be specified to avoid | |
| 1095 // unnecessary conversion steps. Planar data should be stored end to end; e.g., | |
| 1096 // |ch1 sample1||ch1 sample2|....|ch1 sample_last||ch2 sample1|... | |
| 1097 class AudioFrames_2 { | 691 class AudioFrames_2 { |
| 1098 public: | 692 public: |
| 1099 virtual void SetFrameBuffer(Buffer* buffer) = 0; | 693 virtual void SetFrameBuffer(Buffer* buffer) = 0; |
| 1100 virtual Buffer* FrameBuffer() = 0; | 694 virtual Buffer* FrameBuffer() = 0; |
| 1101 | 695 |
| 1102 // The CDM must call this method, providing a valid format, when providing | 696 // The CDM must call this method, providing a valid format, when providing |
| 1103 // frame buffers. | 697 // frame buffers. Planar data should be stored end to end; e.g., |
| 698 // |ch1 sample1||ch1 sample2|....|ch1 sample_last||ch2 sample1|... |
| 1104 virtual void SetFormat(AudioFormat format) = 0; | 699 virtual void SetFormat(AudioFormat format) = 0; |
| 1105 virtual AudioFormat Format() const = 0; | 700 virtual AudioFormat Format() const = 0; |
| 1106 | 701 |
| 1107 protected: | 702 protected: |
| 1108 AudioFrames_2() {} | 703 AudioFrames_2() {} |
| 1109 virtual ~AudioFrames_2() {} | 704 virtual ~AudioFrames_2() {} |
| 1110 }; | 705 }; |
| 1111 | 706 |
| 1112 } // namespace cdm | 707 } // namespace cdm |
| 1113 | 708 |
| 1114 #endif // CDM_CONTENT_DECRYPTION_MODULE_H_ | 709 #endif // CDM_CONTENT_DECRYPTION_MODULE_H_ |
| OLD | NEW |