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

Side by Side Diff: content_decryption_module.h

Issue 2446413003: Add cdm::ContentDecryptionModule_9 (Closed)
Patch Set: RejectionReason Created 4 years, 1 month 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 | « no previous file | content_decryption_module_broker.h » ('j') | content_decryption_module_broker.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 #define CDM_CLASS_API [[clang::lto_visibility_public]] 30 #define CDM_CLASS_API [[clang::lto_visibility_public]]
31 #else 31 #else
32 #define CDM_CLASS_API 32 #define CDM_CLASS_API
33 #endif 33 #endif
34 34
35 #if defined(CDM_IMPLEMENTATION) 35 #if defined(CDM_IMPLEMENTATION)
36 #define CDM_API __declspec(dllexport) 36 #define CDM_API __declspec(dllexport)
37 #else 37 #else
38 #define CDM_API __declspec(dllimport) 38 #define CDM_API __declspec(dllimport)
39 #endif // defined(CDM_IMPLEMENTATION) 39 #endif // defined(CDM_IMPLEMENTATION)
40 40
xhwang 2016/10/31 22:43:47 +ddorwin: Continuing on the comment on #include
jrummell 2016/11/02 20:10:03 export.h is back.
41 #else // defined(WIN32) 41 #else // defined(WIN32)
42 #define CDM_API __attribute__((visibility("default"))) 42 #define CDM_API __attribute__((visibility("default")))
43 #define CDM_CLASS_API __attribute__((visibility("default"))) 43 #define CDM_CLASS_API __attribute__((visibility("default")))
44 #endif // defined(WIN32) 44 #endif // defined(WIN32)
45 45
46 // The version number must be rolled when the exported functions are updated! 46 // The version number must be rolled when the exported functions are updated!
47 // If the CDM and the adapter use different versions of these functions, the 47 // If the CDM and the adapter use different versions of these functions, the
48 // adapter will fail to load or crash! 48 // adapter will fail to load or crash!
49 #define CDM_MODULE_VERSION 4 49 #define CDM_MODULE_VERSION 4
50 50
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 CDM_API const char* GetCdmVersion(); 82 CDM_API const char* GetCdmVersion();
83 } 83 }
84 84
85 namespace cdm { 85 namespace cdm {
86 86
87 class AudioFrames; 87 class AudioFrames;
88 class DecryptedBlock; 88 class DecryptedBlock;
89 class VideoFrame; 89 class VideoFrame;
90 90
91 class Host_8; 91 class Host_8;
92 class Host_9;
92 93
93 enum Status { 94 enum Status {
94 kSuccess = 0, 95 kSuccess = 0,
95 kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample. 96 kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample.
96 kNoKey, // The required decryption key is not available. 97 kNoKey, // The required decryption key is not available.
97 kSessionError, // Session management error. 98 kInitializationError, // Initialization failed.
98 kDecryptError, // Decryption failed. 99 kDecryptError, // Decryption failed.
99 kDecodeError, // Error decoding audio or video. 100 kDecodeError, // Error decoding audio or video.
100 kDeferredInitialization // Decoder is not ready for initialization. 101 kDeferredInitialization // Decoder is not ready for initialization.
101 }; 102 };
102 103
103 // This must at least contain the exceptions defined in the spec: 104 // This must at least contain the exceptions defined in the spec:
104 // https://w3c.github.io/encrypted-media/#exceptions 105 // https://w3c.github.io/encrypted-media/#exceptions
105 // The following starts with the list of DOM4 exceptions from: 106 enum RejectionReason {
106 // http://www.w3.org/TR/dom/#domexception 107 // The values used are the legacy code values from
107 // Some DOM4 exceptions are not included as they are not expected to be used. 108 // https://heycam.github.io/webidl/#idl-DOMException-error-names
108 enum Error {
109 kNotSupportedError = 9, 109 kNotSupportedError = 9,
110 kInvalidStateError = 11, 110 kInvalidStateError = 11,
111 kInvalidAccessError = 15,
112 kQuotaExceededError = 22, 111 kQuotaExceededError = 22,
113 112
114 // Additional exceptions that do not have assigned codes. 113 // Additional exceptions that do not have assigned legacy codes.
115 // There are other non-EME-specific values, not included in this list. 114 kTypeError = 50,
xhwang 2016/10/31 22:43:47 OOC, where is 50 coming from? Is it just another a
jrummell 2016/11/02 20:10:03 A long time ago new specs would simply add their o
116 kUnknownError = 30,
117 115
118 // Additional values from previous EME versions. They currently have no 116 // Additional values from previous EME versions. They are deprecated and
119 // matching DOMException. 117 // should not be used.
120 kClientError = 100, 118 kDeprecatedInvalidAccessErrorWillBeTreatedAsTypeError = 15,
121 kOutputError = 101 119 kDeprecatedUnknownError = 30,
120 kDeprecatedClientErrorWillBeTreatedAsUnknownError = 100,
121 kDeprecatedOutputErrorWillBeTreatedAsUnknownError = 101
122 }; 122 };
123 123
124 // Time is defined as the number of seconds since the 124 // Time is defined as the number of seconds since the
125 // Epoch (00:00:00 UTC, January 1, 1970). 125 // Epoch (00:00:00 UTC, January 1, 1970).
126 typedef double Time; 126 typedef double Time;
127 127
128 // An input buffer can be split into several continuous subsamples. 128 // An input buffer can be split into several continuous subsamples.
129 // A SubsampleEntry specifies the number of clear and cipher bytes in each 129 // A SubsampleEntry specifies the number of clear and cipher bytes in each
130 // subsample. For example, the following buffer has three subsamples: 130 // subsample. For example, the following buffer has three subsamples:
131 // 131 //
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 kAudioFormatS16, // Interleaved signed 16-bit. 217 kAudioFormatS16, // Interleaved signed 16-bit.
218 kAudioFormatS32, // Interleaved signed 32-bit. 218 kAudioFormatS32, // Interleaved signed 32-bit.
219 kAudioFormatF32, // Interleaved float 32-bit. 219 kAudioFormatF32, // Interleaved float 32-bit.
220 kAudioFormatPlanarS16, // Signed 16-bit planar. 220 kAudioFormatPlanarS16, // Signed 16-bit planar.
221 kAudioFormatPlanarF32, // Float 32-bit planar. 221 kAudioFormatPlanarF32, // Float 32-bit planar.
222 }; 222 };
223 223
224 // Surface formats based on FOURCC labels, see: http://www.fourcc.org/yuv.php 224 // Surface formats based on FOURCC labels, see: http://www.fourcc.org/yuv.php
225 enum VideoFormat { 225 enum VideoFormat {
226 kUnknownVideoFormat = 0, // Unknown format value. Used for error reporting. 226 kUnknownVideoFormat = 0, // Unknown format value. Used for error reporting.
227 kYv12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples. 227 kYv12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples.
228 kI420 // 12bpp YVU planar 1x1 Y, 2x2 UV samples. 228 kI420 // 12bpp YUV planar 1x1 Y, 2x2 UV samples.
229 }; 229 };
230 230
231 struct Size { 231 struct Size {
232 Size() : width(0), height(0) {} 232 Size() : width(0), height(0) {}
233 Size(int32_t width, int32_t height) : width(width), height(height) {} 233 Size(int32_t width, int32_t height) : width(width), height(height) {}
234 234
235 int32_t width; 235 int32_t width;
236 int32_t height; 236 int32_t height;
237 }; 237 };
238 238
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 // If the return value is not kSuccess, |decrypted_buffer| should be ignored 556 // If the return value is not kSuccess, |decrypted_buffer| should be ignored
557 // by the caller. 557 // by the caller.
558 virtual Status Decrypt(const InputBuffer& encrypted_buffer, 558 virtual Status Decrypt(const InputBuffer& encrypted_buffer,
559 DecryptedBlock* decrypted_buffer) = 0; 559 DecryptedBlock* decrypted_buffer) = 0;
560 560
561 // Initializes the CDM audio decoder with |audio_decoder_config|. This 561 // Initializes the CDM audio decoder with |audio_decoder_config|. This
562 // function must be called before DecryptAndDecodeSamples() is called. 562 // function must be called before DecryptAndDecodeSamples() is called.
563 // 563 //
564 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM 564 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM
565 // audio decoder is successfully initialized. 565 // audio decoder is successfully initialized.
566 // Returns kSessionError if |audio_decoder_config| is not supported. The CDM 566 // Returns kInitializationError if |audio_decoder_config| is not supported.
567 // may still be able to do Decrypt(). 567 // The CDM may still be able to do Decrypt().
568 // Returns kDeferredInitialization if the CDM is not ready to initialize the 568 // Returns kDeferredInitialization if the CDM is not ready to initialize the
569 // decoder at this time. Must call Host::OnDeferredInitializationDone() once 569 // decoder at this time. Must call Host::OnDeferredInitializationDone() once
570 // initialization is complete. 570 // initialization is complete.
571 virtual Status InitializeAudioDecoder( 571 virtual Status InitializeAudioDecoder(
572 const AudioDecoderConfig& audio_decoder_config) = 0; 572 const AudioDecoderConfig& audio_decoder_config) = 0;
573 573
574 // Initializes the CDM video decoder with |video_decoder_config|. This 574 // Initializes the CDM video decoder with |video_decoder_config|. This
575 // function must be called before DecryptAndDecodeFrame() is called. 575 // function must be called before DecryptAndDecodeFrame() is called.
576 // 576 //
577 // Returns kSuccess if the |video_decoder_config| is supported and the CDM 577 // Returns kSuccess if the |video_decoder_config| is supported and the CDM
578 // video decoder is successfully initialized. 578 // video decoder is successfully initialized.
579 // Returns kSessionError if |video_decoder_config| is not supported. The CDM 579 // Returns kInitializationError if |video_decoder_config| is not supported.
580 // may still be able to do Decrypt(). 580 // The CDM may still be able to do Decrypt().
581 // Returns kDeferredInitialization if the CDM is not ready to initialize the 581 // Returns kDeferredInitialization if the CDM is not ready to initialize the
582 // decoder at this time. Must call Host::OnDeferredInitializationDone() once 582 // decoder at this time. Must call Host::OnDeferredInitializationDone() once
583 // initialization is complete. 583 // initialization is complete.
584 virtual Status InitializeVideoDecoder( 584 virtual Status InitializeVideoDecoder(
585 const VideoDecoderConfig& video_decoder_config) = 0; 585 const VideoDecoderConfig& video_decoder_config) = 0;
586 586
587 // De-initializes the CDM decoder and sets it to an uninitialized state. The 587 // De-initializes the CDM decoder and sets it to an uninitialized state. The
588 // caller can initialize the decoder again after this call to re-initialize 588 // caller can initialize the decoder again after this call to re-initialize
589 // it. This can be used to reconfigure the decoder if the configuration 589 // it. This can be used to reconfigure the decoder if the configuration
590 // changes. 590 // changes.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 uint32_t output_protection_mask) = 0; 648 uint32_t output_protection_mask) = 0;
649 649
650 // Destroys the object in the same context as it was created. 650 // Destroys the object in the same context as it was created.
651 virtual void Destroy() = 0; 651 virtual void Destroy() = 0;
652 652
653 protected: 653 protected:
654 ContentDecryptionModule_8() {} 654 ContentDecryptionModule_8() {}
655 virtual ~ContentDecryptionModule_8() {} 655 virtual ~ContentDecryptionModule_8() {}
656 }; 656 };
657 657
658 typedef ContentDecryptionModule_8 ContentDecryptionModule; 658 // ContentDecryptionModule interface that all CDMs need to implement.
659 // The interface is versioned for backward compatibility.
660 // Note: ContentDecryptionModule implementations must use the allocator
661 // provided in CreateCdmInstance() to allocate any Buffer that needs to
662 // be passed back to the caller. Implementations must call Buffer::Destroy()
663 // when a Buffer is created that will never be returned to the caller.
664 class CDM_CLASS_API ContentDecryptionModule_9 {
665 public:
666 static const int kVersion = 9;
667 typedef Host_9 Host;
668
669 // Initializes the CDM instance, providing information about permitted
670 // functionalities.
671 // If |allow_distinctive_identifier| is false, messages from the CDM,
672 // such as message events, must not contain a Distinctive Identifier,
673 // even in an encrypted form.
674 // If |allow_persistent_state| is false, the CDM must not attempt to
675 // persist state. Calls to CreateFileIO() will fail.
676 virtual void Initialize(bool allow_distinctive_identifier,
677 bool allow_persistent_state) = 0;
678
679 // SetServerCertificate(), CreateSessionAndGenerateRequest(), LoadSession(),
680 // UpdateSession(), CloseSession(), and RemoveSession() all accept a
681 // |promise_id|, which must be passed to the completion Host method
682 // (e.g. Host::OnResolveNewSessionPromise()).
683
684 // Provides a server certificate to be used to encrypt messages to the
685 // license server. The CDM must respond by calling either
686 // Host::OnResolvePromise() or Host::OnRejectPromise().
687 virtual void SetServerCertificate(uint32_t promise_id,
688 const uint8_t* server_certificate_data,
689 uint32_t server_certificate_data_size) = 0;
690
691 // Creates a session given |session_type|, |init_data_type|, and |init_data|.
692 // The CDM must respond by calling either Host::OnResolveNewSessionPromise()
693 // or Host::OnRejectPromise().
694 virtual void CreateSessionAndGenerateRequest(uint32_t promise_id,
695 SessionType session_type,
696 InitDataType init_data_type,
697 const uint8_t* init_data,
698 uint32_t init_data_size) = 0;
699
700 // Loads the session of type |session_type| specified by |session_id|.
701 // The CDM must respond by calling either Host::OnResolveNewSessionPromise()
702 // or Host::OnRejectPromise(). If the session is not found, call
703 // Host::OnResolveNewSessionPromise() with session_id = NULL.
704 virtual void LoadSession(uint32_t promise_id,
705 SessionType session_type,
706 const char* session_id,
707 uint32_t session_id_size) = 0;
708
709 // Updates the session with |response|. The CDM must respond by calling
710 // either Host::OnResolvePromise() or Host::OnRejectPromise().
711 virtual void UpdateSession(uint32_t promise_id,
712 const char* session_id,
713 uint32_t session_id_size,
714 const uint8_t* response,
715 uint32_t response_size) = 0;
716
717 // Requests that the CDM close the session. The CDM must respond by calling
718 // either Host::OnResolvePromise() or Host::OnRejectPromise() when the request
719 // has been processed. This may be before the session is closed. Once the
720 // session is closed, Host::OnSessionClosed() must also be called.
721 virtual void CloseSession(uint32_t promise_id,
722 const char* session_id,
723 uint32_t session_id_size) = 0;
724
725 // Removes any stored session data associated with this session. Will only be
726 // called for persistent sessions. The CDM must respond by calling either
727 // Host::OnResolvePromise() or Host::OnRejectPromise() when the request has
728 // been processed.
729 virtual void RemoveSession(uint32_t promise_id,
730 const char* session_id,
731 uint32_t session_id_size) = 0;
732
733 // Performs scheduled operation with |context| when the timer fires.
734 virtual void TimerExpired(void* context) = 0;
735
736 // Decrypts the |encrypted_buffer|.
737 //
738 // Returns kSuccess if decryption succeeded, in which case the callee
739 // should have filled the |decrypted_buffer| and passed the ownership of
740 // |data| in |decrypted_buffer| to the caller.
741 // Returns kNoKey if the CDM did not have the necessary decryption key
742 // to decrypt.
743 // Returns kDecryptError if any other error happened.
744 // If the return value is not kSuccess, |decrypted_buffer| should be ignored
745 // by the caller.
746 virtual Status Decrypt(const InputBuffer& encrypted_buffer,
747 DecryptedBlock* decrypted_buffer) = 0;
748
749 // Initializes the CDM audio decoder with |audio_decoder_config|. This
750 // function must be called before DecryptAndDecodeSamples() is called.
751 //
752 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM
753 // audio decoder is successfully initialized.
754 // Returns kInitializationError if |audio_decoder_config| is not supported.
755 // The CDM may still be able to do Decrypt().
756 // Returns kDeferredInitialization if the CDM is not ready to initialize the
757 // decoder at this time. Must call Host::OnDeferredInitializationDone() once
758 // initialization is complete.
759 virtual Status InitializeAudioDecoder(
760 const AudioDecoderConfig& audio_decoder_config) = 0;
761
762 // Initializes the CDM video decoder with |video_decoder_config|. This
763 // function must be called before DecryptAndDecodeVideo() is called.
764 //
765 // Returns kSuccess if the |video_decoder_config| is supported and the CDM
766 // video decoder is successfully initialized.
767 // Returns kInitializationError if |video_decoder_config| is not supported.
768 // The CDM may still be able to do Decrypt().
769 // Returns kDeferredInitialization if the CDM is not ready to initialize the
770 // decoder at this time. Must call Host::OnDeferredInitializationDone() once
771 // initialization is complete.
772 virtual Status InitializeVideoDecoder(
773 const VideoDecoderConfig& video_decoder_config) = 0;
774
775 // De-initializes the CDM decoder and sets it to an uninitialized state. The
776 // caller can initialize the decoder again after this call to re-initialize
777 // it. This can be used to reconfigure the decoder if the configuration
778 // changes.
779 virtual void DeinitializeDecoder(StreamType decoder_type) = 0;
780
781 // Resets the CDM decoder to an initialized clean state. All internal buffers
782 // MUST be flushed.
783 virtual void ResetDecoder(StreamType decoder_type) = 0;
784
785 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a
786 // |video_frame|. Upon end-of-stream, the caller should call this function
787 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty
788 // |video_frame| (|format| == kEmptyVideoFrame) is produced.
789 //
790 // Returns kSuccess if decryption and decoding both succeeded, in which case
791 // the callee will have filled the |video_frame| and passed the ownership of
792 // |frame_buffer| in |video_frame| to the caller.
793 // Returns kNoKey if the CDM did not have the necessary decryption key
794 // to decrypt.
795 // Returns kNeedMoreData if more data was needed by the decoder to generate
796 // a decoded frame (e.g. during initialization and end-of-stream).
797 // Returns kDecryptError if any decryption error happened.
798 // Returns kDecodeError if any decoding error happened.
799 // If the return value is not kSuccess, |video_frame| should be ignored by
800 // the caller.
801 virtual Status DecryptAndDecodeVideo(const InputBuffer& encrypted_buffer,
802 VideoFrame* video_frame) = 0;
803
804 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into
805 // |audio_frames|. Upon end-of-stream, the caller should call this function
806 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty
807 // |audio_frames| is produced.
808 //
809 // Returns kSuccess if decryption and decoding both succeeded, in which case
810 // the callee will have filled |audio_frames| and passed the ownership of
811 // |data| in |audio_frames| to the caller.
812 // Returns kNoKey if the CDM did not have the necessary decryption key
813 // to decrypt.
814 // Returns kNeedMoreData if more data was needed by the decoder to generate
815 // audio samples (e.g. during initialization and end-of-stream).
816 // Returns kDecryptError if any decryption error happened.
817 // Returns kDecodeError if any decoding error happened.
818 // If the return value is not kSuccess, |audio_frames| should be ignored by
819 // the caller.
820 virtual Status DecryptAndDecodeAudio(const InputBuffer& encrypted_buffer,
821 AudioFrames* audio_frames) = 0;
822
823 // Called by the host after a platform challenge was initiated via
824 // Host::SendPlatformChallenge().
825 virtual void OnPlatformChallengeResponse(
826 const PlatformChallengeResponse& response) = 0;
827
828 // Called by the host after a call to Host::SendHostChallenge(). This
829 // provides |response| as returned from the broker CDM challenge.
830 virtual void OnHostChallengeResponse(const uint8_t* response,
831 uint32_t response_size) = 0;
832
833 // Called by the host after a call to Host::QueryOutputProtectionStatus(). The
834 // |link_mask| is a bit mask of OutputLinkTypes and |output_protection_mask|
835 // is a bit mask of OutputProtectionMethods. If |result| is kQueryFailed,
836 // then |link_mask| and |output_protection_mask| are undefined and should
837 // be ignored.
838 virtual void OnQueryOutputProtectionStatus(
839 QueryResult result,
840 uint32_t link_mask,
841 uint32_t output_protection_mask) = 0;
842
843 // Destroys the object in the same context as it was created.
844 virtual void Destroy() = 0;
845
846 protected:
847 ContentDecryptionModule_9() {}
848 virtual ~ContentDecryptionModule_9() {}
849 };
850
851 typedef ContentDecryptionModule_9 ContentDecryptionModule;
659 852
660 // Represents a buffer created by Allocator implementations. 853 // Represents a buffer created by Allocator implementations.
661 class CDM_CLASS_API Buffer { 854 class CDM_CLASS_API Buffer {
662 public: 855 public:
663 // Destroys the buffer in the same context as it was created. 856 // Destroys the buffer in the same context as it was created.
664 virtual void Destroy() = 0; 857 virtual void Destroy() = 0;
665 858
666 virtual uint32_t Capacity() const = 0; 859 virtual uint32_t Capacity() const = 0;
667 virtual uint8_t* Data() = 0; 860 virtual uint8_t* Data() = 0;
668 virtual void SetSize(uint32_t size) = 0; 861 virtual void SetSize(uint32_t size) = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 // session could not be loaded. 897 // session could not be loaded.
705 virtual void OnResolveNewSessionPromise(uint32_t promise_id, 898 virtual void OnResolveNewSessionPromise(uint32_t promise_id,
706 const char* session_id, 899 const char* session_id,
707 uint32_t session_id_size) = 0; 900 uint32_t session_id_size) = 0;
708 901
709 // Called by the CDM when a session is updated or released. 902 // Called by the CDM when a session is updated or released.
710 virtual void OnResolvePromise(uint32_t promise_id) = 0; 903 virtual void OnResolvePromise(uint32_t promise_id) = 0;
711 904
712 // Called by the CDM when an error occurs as a result of one of the 905 // Called by the CDM when an error occurs as a result of one of the
713 // ContentDecryptionModule calls that accept a |promise_id|. 906 // ContentDecryptionModule calls that accept a |promise_id|.
714 // |error| must be specified, |error_message| and |system_code| 907 // |reason| must be specified, |error_message| and |system_code|
715 // are optional. |error_message_size| should not include null termination. 908 // are optional. |error_message_size| should not include null termination.
716 virtual void OnRejectPromise(uint32_t promise_id, 909 virtual void OnRejectPromise(uint32_t promise_id,
717 Error error, 910 RejectionReason reason,
718 uint32_t system_code, 911 uint32_t system_code,
719 const char* error_message, 912 const char* error_message,
720 uint32_t error_message_size) = 0; 913 uint32_t error_message_size) = 0;
721 914
722 // Called by the CDM when it has a message for session |session_id|. 915 // Called by the CDM when it has a message for session |session_id|.
723 // Size parameters should not include null termination. 916 // Size parameters should not include null termination.
724 // |legacy_destination_url| is only for supporting the prefixed EME API and 917 // |legacy_destination_url| is only for supporting the prefixed EME API and
725 // is ignored by unprefixed EME. It should only be non-null if |message_type| 918 // is ignored by unprefixed EME. It should only be non-null if |message_type|
726 // is kLicenseRenewal. 919 // is kLicenseRenewal.
727 virtual void OnSessionMessage(const char* session_id, 920 virtual void OnSessionMessage(const char* session_id,
(...skipping 27 matching lines...) Expand all
755 uint32_t session_id_size, 948 uint32_t session_id_size,
756 Time new_expiry_time) = 0; 949 Time new_expiry_time) = 0;
757 950
758 // Called by the CDM when session |session_id| is closed. Size 951 // Called by the CDM when session |session_id| is closed. Size
759 // parameter should not include null termination. 952 // parameter should not include null termination.
760 virtual void OnSessionClosed(const char* session_id, 953 virtual void OnSessionClosed(const char* session_id,
761 uint32_t session_id_size) = 0; 954 uint32_t session_id_size) = 0;
762 955
763 // Called by the CDM when an error occurs in session |session_id| 956 // Called by the CDM when an error occurs in session |session_id|
764 // unrelated to one of the ContentDecryptionModule calls that accept a 957 // unrelated to one of the ContentDecryptionModule calls that accept a
765 // |promise_id|. |error| must be specified, |error_message| and 958 // |promise_id|. |reason| must be specified, |error_message| and
766 // |system_code| are optional. Length parameters should not include null 959 // |system_code| are optional. Length parameters should not include null
767 // termination. 960 // termination.
768 // Note: 961 // Note:
769 // - This method is only for supporting prefixed EME API. 962 // - This method is only for supporting prefixed EME API.
770 // - This method will be ignored by unprefixed EME. All errors reported 963 // - This method will be ignored by unprefixed EME. All errors reported
771 // in this method should probably also be reported by one of other methods. 964 // in this method should probably also be reported by one of other methods.
772 virtual void OnLegacySessionError( 965 virtual void OnLegacySessionError(const char* session_id,
773 const char* session_id, uint32_t session_id_length, 966 uint32_t session_id_length,
774 Error error, 967 RejectionReason reason,
775 uint32_t system_code, 968 uint32_t system_code,
776 const char* error_message, uint32_t error_message_length) = 0; 969 const char* error_message,
970 uint32_t error_message_length) = 0;
777 971
778 // The following are optional methods that may not be implemented on all 972 // The following are optional methods that may not be implemented on all
779 // platforms. 973 // platforms.
780 974
781 // Sends a platform challenge for the given |service_id|. |challenge| is at 975 // Sends a platform challenge for the given |service_id|. |challenge| is at
782 // most 256 bits of data to be signed. Once the challenge has been completed, 976 // most 256 bits of data to be signed. Once the challenge has been completed,
783 // the host will call ContentDecryptionModule::OnPlatformChallengeResponse() 977 // the host will call ContentDecryptionModule::OnPlatformChallengeResponse()
784 // with the signed challenge response and platform certificate. Size 978 // with the signed challenge response and platform certificate. Size
785 // parameters should not include null termination. 979 // parameters should not include null termination.
786 virtual void SendPlatformChallenge(const char* service_id, 980 virtual void SendPlatformChallenge(const char* service_id,
(...skipping 20 matching lines...) Expand all
807 // if a FileIO object cannot be obtained. Once a valid FileIO object is 1001 // if a FileIO object cannot be obtained. Once a valid FileIO object is
808 // returned, |client| must be valid until FileIO::Close() is called. The 1002 // returned, |client| must be valid until FileIO::Close() is called. The
809 // CDM can call this method multiple times to operate on different files. 1003 // CDM can call this method multiple times to operate on different files.
810 virtual FileIO* CreateFileIO(FileIOClient* client) = 0; 1004 virtual FileIO* CreateFileIO(FileIOClient* client) = 0;
811 1005
812 protected: 1006 protected:
813 Host_8() {} 1007 Host_8() {}
814 virtual ~Host_8() {} 1008 virtual ~Host_8() {}
815 }; 1009 };
816 1010
1011 class CDM_CLASS_API Host_9 {
1012 public:
1013 static const int kVersion = 9;
1014
1015 // Returns a Buffer* containing non-zero members upon success, or NULL on
1016 // failure. The caller owns the Buffer* after this call. The buffer is not
1017 // guaranteed to be zero initialized. The capacity of the allocated Buffer
1018 // is guaranteed to be not less than |capacity|.
1019 virtual Buffer* Allocate(uint32_t capacity) = 0;
1020
1021 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms|
1022 // from now with |context|.
1023 virtual void SetTimer(int64_t delay_ms, void* context) = 0;
1024
1025 // Returns the current wall time in seconds.
1026 virtual Time GetCurrentWallTime() = 0;
1027
1028 // Called by the CDM when a session is created or loaded and the value for the
1029 // MediaKeySession's sessionId attribute is available (|session_id|).
1030 // This must be called before OnSessionMessage() or
1031 // OnSessionKeysChange() is called for the same session. |session_id_size|
1032 // should not include null termination.
1033 // When called in response to LoadSession(), the |session_id| must be the
1034 // same as the |session_id| passed in LoadSession(), or NULL if the
1035 // session could not be loaded.
1036 virtual void OnResolveNewSessionPromise(uint32_t promise_id,
1037 const char* session_id,
1038 uint32_t session_id_size) = 0;
1039
1040 // Called by the CDM when a session is updated or released.
1041 virtual void OnResolvePromise(uint32_t promise_id) = 0;
1042
1043 // Called by the CDM when an error occurs as a result of one of the
1044 // ContentDecryptionModule calls that accept a |promise_id|.
1045 // |reason| must be specified, |error_message| and |system_code|
1046 // are optional. |error_message_size| should not include null termination.
1047 virtual void OnRejectPromise(uint32_t promise_id,
1048 RejectionReason reason,
1049 uint32_t system_code,
1050 const char* error_message,
1051 uint32_t error_message_size) = 0;
1052
1053 // Called by the CDM when it has a message for session |session_id|.
1054 // Size parameters should not include null termination.
1055 virtual void OnSessionMessage(const char* session_id,
1056 uint32_t session_id_size,
1057 MessageType message_type,
1058 const char* message,
1059 uint32_t message_size) = 0;
1060
1061 // Called by the CDM when there has been a change in keys or their status for
1062 // session |session_id|. |has_additional_usable_key| should be set if a
1063 // key is newly usable (e.g. new key available, previously expired key has
1064 // been renewed, etc.) and the browser should attempt to resume playback.
1065 // |key_ids| is the list of key ids for this session along with their
1066 // current status. |key_ids_count| is the number of entries in |key_ids|.
1067 // Size parameter for |session_id| should not include null termination.
1068 virtual void OnSessionKeysChange(const char* session_id,
1069 uint32_t session_id_size,
1070 bool has_additional_usable_key,
1071 const KeyInformation* keys_info,
1072 uint32_t keys_info_count) = 0;
1073
1074 // Called by the CDM when there has been a change in the expiration time for
1075 // session |session_id|. This can happen as the result of an Update() call
1076 // or some other event. If this happens as a result of a call to Update(),
1077 // it must be called before resolving the Update() promise. |new_expiry_time|
1078 // can be 0 to represent "undefined". Size parameter should not include
1079 // null termination.
1080 virtual void OnExpirationChange(const char* session_id,
1081 uint32_t session_id_size,
1082 Time new_expiry_time) = 0;
1083
1084 // Called by the CDM when session |session_id| is closed. Size
1085 // parameter should not include null termination.
1086 virtual void OnSessionClosed(const char* session_id,
1087 uint32_t session_id_size) = 0;
1088
1089 // The following are optional methods that may not be implemented on all
1090 // platforms.
1091
1092 // Sends a platform challenge for the given |service_id|. |challenge| is at
1093 // most 256 bits of data to be signed. Once the challenge has been completed,
1094 // the host will call ContentDecryptionModule::OnPlatformChallengeResponse()
1095 // with the signed challenge response and platform certificate. Size
1096 // parameters should not include null termination.
1097 virtual void SendPlatformChallenge(const char* service_id,
1098 uint32_t service_id_size,
1099 const char* challenge,
1100 uint32_t challenge_size) = 0;
1101
1102 // Initiate the host challenge. If supported, sends the |challenge| data to
1103 // the host, and returns true. The actual response from the host will be
1104 // provided via OnHostChallengeResponse(). If not supported, this method
1105 // should return false.
1106 virtual bool SendHostChallenge(const uint8_t* challenge,
1107 uint32_t challenge_size) = 0;
1108
1109 // Attempts to enable output protection (e.g. HDCP) on the display link. The
1110 // |desired_protection_mask| is a bit mask of OutputProtectionMethods. No
1111 // status callback is issued, the CDM must call QueryOutputProtectionStatus()
1112 // periodically to ensure the desired protections are applied.
1113 virtual void EnableOutputProtection(uint32_t desired_protection_mask) = 0;
1114
1115 // Requests the current output protection status. Once the host has the status
1116 // it will call ContentDecryptionModule::OnQueryOutputProtectionStatus().
1117 virtual void QueryOutputProtectionStatus() = 0;
1118
1119 // Must be called by the CDM if it returned kDeferredInitialization during
1120 // InitializeAudioDecoder() or InitializeVideoDecoder().
1121 virtual void OnDeferredInitializationDone(StreamType stream_type,
1122 Status decoder_status) = 0;
1123
1124 // Creates a FileIO object from the host to do file IO operation. Returns NULL
1125 // if a FileIO object cannot be obtained. Once a valid FileIO object is
1126 // returned, |client| must be valid until FileIO::Close() is called. The
1127 // CDM can call this method multiple times to operate on different files.
1128 virtual FileIO* CreateFileIO(FileIOClient* client) = 0;
1129
1130 protected:
1131 Host_9() {}
1132 virtual ~Host_9() {}
1133 };
1134
817 // Represents a decrypted block that has not been decoded. 1135 // Represents a decrypted block that has not been decoded.
818 class CDM_CLASS_API DecryptedBlock { 1136 class CDM_CLASS_API DecryptedBlock {
819 public: 1137 public:
820 virtual void SetDecryptedBuffer(Buffer* buffer) = 0; 1138 virtual void SetDecryptedBuffer(Buffer* buffer) = 0;
821 virtual Buffer* DecryptedBuffer() = 0; 1139 virtual Buffer* DecryptedBuffer() = 0;
822 1140
823 // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not, 1141 // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not,
824 // we can just pass Buffer pointers around. 1142 // we can just pass Buffer pointers around.
825 virtual void SetTimestamp(int64_t timestamp) = 0; 1143 virtual void SetTimestamp(int64_t timestamp) = 0;
826 virtual int64_t Timestamp() const = 0; 1144 virtual int64_t Timestamp() const = 0;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 virtual void SetFormat(AudioFormat format) = 0; 1202 virtual void SetFormat(AudioFormat format) = 0;
885 virtual AudioFormat Format() const = 0; 1203 virtual AudioFormat Format() const = 0;
886 1204
887 protected: 1205 protected:
888 AudioFrames() {} 1206 AudioFrames() {}
889 virtual ~AudioFrames() {} 1207 virtual ~AudioFrames() {}
890 }; 1208 };
891 1209
892 } // namespace cdm 1210 } // namespace cdm
893 1211
1212 #undef CDM_API
1213 #undef CDM_CLASS_API
1214
894 #endif // CDM_CONTENT_DECRYPTION_MODULE_H_ 1215 #endif // CDM_CONTENT_DECRYPTION_MODULE_H_
OLDNEW
« no previous file with comments | « no previous file | content_decryption_module_broker.h » ('j') | content_decryption_module_broker.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698