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; |
11 typedef int int32_t; | 11 typedef int int32_t; |
12 typedef __int64 int64_t; | 12 typedef __int64 int64_t; |
13 #else | 13 #else |
14 #include <stdint.h> | 14 #include <stdint.h> |
15 #endif | 15 #endif |
16 | 16 |
17 // Define CDM_API so that functionality implemented by the CDM module | 17 #include "media/cdm/api/content_decryption_module_export.h" |
ddorwin
2016/10/26 03:54:45
This assumes the Chrome code structure, which may
xhwang
2016/10/28 17:42:02
Can we just have this here:
#include "content_dec
jrummell
2016/10/31 21:04:37
Done.
jrummell
2016/10/31 21:04:37
I've merged the header into both files to avoid th
| |
18 // can be exported to consumers. Note: the implementation lives in | 18 |
19 // a dynamic library even in a non-component build. | 19 // Define CDM_CLASS_API to export class types. We have to add |
20 // Also define CDM_CLASS_API to export class types. We have to add | |
21 // visibility attributes to make sure virtual tables in CDM consumer | 20 // visibility attributes to make sure virtual tables in CDM consumer |
22 // and CDM implementation are the same. Generally, it was always a | 21 // and CDM implementation are the same. Generally, it was always a |
23 // good idea, as there're no guarantees about that for the internal | 22 // good idea, as there're no guarantees about that for the internal |
24 // symbols, but it has only become a practical issue after | 23 // symbols, but it has only become a practical issue after |
25 // introduction of LTO devirtualization. See more details on | 24 // introduction of LTO devirtualization. See more details on |
26 // https://crbug.com/609564#c35 | 25 // https://crbug.com/609564#c35 |
27 #if defined(WIN32) | 26 #if defined(WIN32) |
28 | 27 |
29 #if defined(__clang__) | 28 #if defined(__clang__) |
30 #define CDM_CLASS_API [[clang::lto_visibility_public]] | 29 #define CDM_CLASS_API [[clang::lto_visibility_public]] |
31 #else | 30 #else |
32 #define CDM_CLASS_API | 31 #define CDM_CLASS_API |
33 #endif | 32 #endif |
34 | 33 |
35 #if defined(CDM_IMPLEMENTATION) | |
36 #define CDM_API __declspec(dllexport) | |
37 #else | |
38 #define CDM_API __declspec(dllimport) | |
39 #endif // defined(CDM_IMPLEMENTATION) | |
40 | |
41 #else // defined(WIN32) | 34 #else // defined(WIN32) |
42 #define CDM_API __attribute__((visibility("default"))) | |
43 #define CDM_CLASS_API __attribute__((visibility("default"))) | 35 #define CDM_CLASS_API __attribute__((visibility("default"))) |
44 #endif // defined(WIN32) | 36 #endif // defined(WIN32) |
45 | 37 |
46 // The version number must be rolled when the exported functions are updated! | 38 // 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 | 39 // If the CDM and the adapter use different versions of these functions, the |
48 // adapter will fail to load or crash! | 40 // adapter will fail to load or crash! |
49 #define CDM_MODULE_VERSION 4 | 41 #define CDM_MODULE_VERSION 4 |
50 | 42 |
51 // Build the versioned entrypoint name. | 43 // Build the versioned entrypoint name. |
52 // The extra macros are necessary to expand version to an actual value. | 44 // The extra macros are necessary to expand version to an actual value. |
(...skipping 29 matching lines...) Expand all Loading... | |
82 CDM_API const char* GetCdmVersion(); | 74 CDM_API const char* GetCdmVersion(); |
83 } | 75 } |
84 | 76 |
85 namespace cdm { | 77 namespace cdm { |
86 | 78 |
87 class AudioFrames; | 79 class AudioFrames; |
88 class DecryptedBlock; | 80 class DecryptedBlock; |
89 class VideoFrame; | 81 class VideoFrame; |
90 | 82 |
91 class Host_8; | 83 class Host_8; |
84 class Host_9; | |
92 | 85 |
93 enum Status { | 86 enum Status { |
94 kSuccess = 0, | 87 kSuccess = 0, |
95 kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample. | 88 kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample. |
96 kNoKey, // The required decryption key is not available. | 89 kNoKey, // The required decryption key is not available. |
97 kSessionError, // Session management error. | 90 kInitializationError, // Initialization failed. |
98 kDecryptError, // Decryption failed. | 91 kDecryptError, // Decryption failed. |
99 kDecodeError, // Error decoding audio or video. | 92 kDecodeError, // Error decoding audio or video. |
100 kDeferredInitialization // Decoder is not ready for initialization. | 93 kDeferredInitialization // Decoder is not ready for initialization. |
101 }; | 94 }; |
102 | 95 |
103 // This must at least contain the exceptions defined in the spec: | 96 // This must at least contain the exceptions defined in the spec: |
104 // https://w3c.github.io/encrypted-media/#exceptions | 97 // https://w3c.github.io/encrypted-media/#exceptions |
105 // The following starts with the list of DOM4 exceptions from: | 98 // The following starts with the list of DOM4 exceptions from: |
ddorwin
2016/10/26 23:58:49
Remove this sentence and the next one. Maybe just
jrummell
2016/10/31 21:04:37
Done.
| |
106 // http://www.w3.org/TR/dom/#domexception | 99 // http://www.w3.org/TR/dom/#domexception |
ddorwin
2016/10/26 23:58:50
These were moved to https://heycam.github.io/webid
jrummell
2016/10/31 21:04:37
Done.
| |
107 // Some DOM4 exceptions are not included as they are not expected to be used. | 100 // Some DOM4 exceptions are not included as they are not expected to be used. |
108 enum Error { | 101 enum Error { |
ddorwin
2016/10/27 00:40:21
These are exceptions intended to be used in OnReje
jrummell
2016/10/31 21:04:37
Changed to RejectionReason (since it's still used
| |
109 kNotSupportedError = 9, | 102 kNotSupportedError = 9, |
110 kInvalidStateError = 11, | 103 kInvalidStateError = 11, |
111 kInvalidAccessError = 15, | 104 kInvalidAccessError = 15, |
ddorwin
2016/10/26 23:58:49
Can we rename this to kTypeError?
Rename may not
jrummell
2016/10/31 21:04:37
Done (the long name).
| |
112 kQuotaExceededError = 22, | 105 kQuotaExceededError = 22, |
113 | 106 |
114 // Additional exceptions that do not have assigned codes. | 107 // Additional exceptions that do not have assigned codes. |
ddorwin
2016/10/26 23:58:50
Are these three still used in CDM_8 implementation
jrummell
2016/10/31 21:04:37
The only 1 not used appears to be kClientError. Re
| |
115 // There are other non-EME-specific values, not included in this list. | 108 // There are other non-EME-specific values, not included in this list. |
116 kUnknownError = 30, | 109 kUnknownError = 30, |
117 | 110 |
118 // Additional values from previous EME versions. They currently have no | 111 // Additional values from previous EME versions. They currently have no |
119 // matching DOMException. | 112 // matching DOMException. |
120 kClientError = 100, | 113 kClientError = 100, |
121 kOutputError = 101 | 114 kOutputError = 101 |
122 }; | 115 }; |
123 | 116 |
124 // Time is defined as the number of seconds since the | 117 // Time is defined as the number of seconds since the |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 kAudioFormatS16, // Interleaved signed 16-bit. | 210 kAudioFormatS16, // Interleaved signed 16-bit. |
218 kAudioFormatS32, // Interleaved signed 32-bit. | 211 kAudioFormatS32, // Interleaved signed 32-bit. |
219 kAudioFormatF32, // Interleaved float 32-bit. | 212 kAudioFormatF32, // Interleaved float 32-bit. |
220 kAudioFormatPlanarS16, // Signed 16-bit planar. | 213 kAudioFormatPlanarS16, // Signed 16-bit planar. |
221 kAudioFormatPlanarF32, // Float 32-bit planar. | 214 kAudioFormatPlanarF32, // Float 32-bit planar. |
222 }; | 215 }; |
223 | 216 |
224 // Surface formats based on FOURCC labels, see: http://www.fourcc.org/yuv.php | 217 // Surface formats based on FOURCC labels, see: http://www.fourcc.org/yuv.php |
225 enum VideoFormat { | 218 enum VideoFormat { |
226 kUnknownVideoFormat = 0, // Unknown format value. Used for error reporting. | 219 kUnknownVideoFormat = 0, // Unknown format value. Used for error reporting. |
227 kYv12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples. | 220 kYv12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples. |
228 kI420 // 12bpp YVU planar 1x1 Y, 2x2 UV samples. | 221 kI420 // 12bpp YUV planar 1x1 Y, 2x2 UV samples. |
229 }; | 222 }; |
230 | 223 |
231 struct Size { | 224 struct Size { |
232 Size() : width(0), height(0) {} | 225 Size() : width(0), height(0) {} |
233 Size(int32_t width, int32_t height) : width(width), height(height) {} | 226 Size(int32_t width, int32_t height) : width(width), height(height) {} |
234 | 227 |
235 int32_t width; | 228 int32_t width; |
236 int32_t height; | 229 int32_t height; |
237 }; | 230 }; |
238 | 231 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 // If the return value is not kSuccess, |decrypted_buffer| should be ignored | 549 // If the return value is not kSuccess, |decrypted_buffer| should be ignored |
557 // by the caller. | 550 // by the caller. |
558 virtual Status Decrypt(const InputBuffer& encrypted_buffer, | 551 virtual Status Decrypt(const InputBuffer& encrypted_buffer, |
559 DecryptedBlock* decrypted_buffer) = 0; | 552 DecryptedBlock* decrypted_buffer) = 0; |
560 | 553 |
561 // Initializes the CDM audio decoder with |audio_decoder_config|. This | 554 // Initializes the CDM audio decoder with |audio_decoder_config|. This |
562 // function must be called before DecryptAndDecodeSamples() is called. | 555 // function must be called before DecryptAndDecodeSamples() is called. |
563 // | 556 // |
564 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM | 557 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM |
565 // audio decoder is successfully initialized. | 558 // audio decoder is successfully initialized. |
566 // Returns kSessionError if |audio_decoder_config| is not supported. The CDM | 559 // Returns kInitializationError if |audio_decoder_config| is not supported. |
567 // may still be able to do Decrypt(). | 560 // The CDM may still be able to do Decrypt(). |
568 // Returns kDeferredInitialization if the CDM is not ready to initialize the | 561 // Returns kDeferredInitialization if the CDM is not ready to initialize the |
569 // decoder at this time. Must call Host::OnDeferredInitializationDone() once | 562 // decoder at this time. Must call Host::OnDeferredInitializationDone() once |
570 // initialization is complete. | 563 // initialization is complete. |
571 virtual Status InitializeAudioDecoder( | 564 virtual Status InitializeAudioDecoder( |
572 const AudioDecoderConfig& audio_decoder_config) = 0; | 565 const AudioDecoderConfig& audio_decoder_config) = 0; |
573 | 566 |
574 // Initializes the CDM video decoder with |video_decoder_config|. This | 567 // Initializes the CDM video decoder with |video_decoder_config|. This |
575 // function must be called before DecryptAndDecodeFrame() is called. | 568 // function must be called before DecryptAndDecodeFrame() is called. |
576 // | 569 // |
577 // Returns kSuccess if the |video_decoder_config| is supported and the CDM | 570 // Returns kSuccess if the |video_decoder_config| is supported and the CDM |
578 // video decoder is successfully initialized. | 571 // video decoder is successfully initialized. |
579 // Returns kSessionError if |video_decoder_config| is not supported. The CDM | 572 // Returns kInitializationError if |video_decoder_config| is not supported. |
580 // may still be able to do Decrypt(). | 573 // The CDM may still be able to do Decrypt(). |
581 // Returns kDeferredInitialization if the CDM is not ready to initialize the | 574 // Returns kDeferredInitialization if the CDM is not ready to initialize the |
582 // decoder at this time. Must call Host::OnDeferredInitializationDone() once | 575 // decoder at this time. Must call Host::OnDeferredInitializationDone() once |
583 // initialization is complete. | 576 // initialization is complete. |
584 virtual Status InitializeVideoDecoder( | 577 virtual Status InitializeVideoDecoder( |
585 const VideoDecoderConfig& video_decoder_config) = 0; | 578 const VideoDecoderConfig& video_decoder_config) = 0; |
586 | 579 |
587 // De-initializes the CDM decoder and sets it to an uninitialized state. The | 580 // 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 | 581 // 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 | 582 // it. This can be used to reconfigure the decoder if the configuration |
590 // changes. | 583 // changes. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
648 uint32_t output_protection_mask) = 0; | 641 uint32_t output_protection_mask) = 0; |
649 | 642 |
650 // Destroys the object in the same context as it was created. | 643 // Destroys the object in the same context as it was created. |
651 virtual void Destroy() = 0; | 644 virtual void Destroy() = 0; |
652 | 645 |
653 protected: | 646 protected: |
654 ContentDecryptionModule_8() {} | 647 ContentDecryptionModule_8() {} |
655 virtual ~ContentDecryptionModule_8() {} | 648 virtual ~ContentDecryptionModule_8() {} |
656 }; | 649 }; |
657 | 650 |
658 typedef ContentDecryptionModule_8 ContentDecryptionModule; | 651 // ContentDecryptionModule interface that all CDMs need to implement. |
652 // The interface is versioned for backward compatibility. | |
653 // Note: ContentDecryptionModule implementations must use the allocator | |
654 // provided in CreateCdmInstance() to allocate any Buffer that needs to | |
655 // be passed back to the caller. Implementations must call Buffer::Destroy() | |
656 // when a Buffer is created that will never be returned to the caller. | |
657 class CDM_CLASS_API ContentDecryptionModule_9 { | |
658 public: | |
659 static const int kVersion = 9; | |
660 typedef Host_9 Host; | |
661 | |
662 // Initializes the CDM instance, providing information about permitted | |
663 // functionalities. | |
664 // If |allow_distinctive_identifier| is false, messages from the CDM, | |
665 // such as message events, must not contain a Distinctive Identifier, | |
666 // even in an encrypted form. | |
667 // If |allow_persistent_state| is false, the CDM must not attempt to | |
668 // persist state. Calls to CreateFileIO() will fail. | |
669 virtual void Initialize(bool allow_distinctive_identifier, | |
670 bool allow_persistent_state) = 0; | |
671 | |
672 // SetServerCertificate(), CreateSessionAndGenerateRequest(), LoadSession(), | |
673 // UpdateSession(), CloseSession(), and RemoveSession() all accept a | |
674 // |promise_id|, which must be passed to the completion Host method | |
675 // (e.g. Host::OnResolveNewSessionPromise()). | |
676 | |
677 // Provides a server certificate to be used to encrypt messages to the | |
678 // license server. The CDM must respond by calling either | |
679 // Host::OnResolvePromise() or Host::OnRejectPromise(). | |
680 virtual void SetServerCertificate(uint32_t promise_id, | |
681 const uint8_t* server_certificate_data, | |
682 uint32_t server_certificate_data_size) = 0; | |
683 | |
684 // Creates a session given |session_type|, |init_data_type|, and |init_data|. | |
685 // The CDM must respond by calling either Host::OnResolveNewSessionPromise() | |
686 // or Host::OnRejectPromise(). | |
687 virtual void CreateSessionAndGenerateRequest(uint32_t promise_id, | |
688 SessionType session_type, | |
689 InitDataType init_data_type, | |
690 const uint8_t* init_data, | |
691 uint32_t init_data_size) = 0; | |
692 | |
693 // Loads the session of type |session_type| specified by |session_id|. | |
694 // The CDM must respond by calling either Host::OnResolveNewSessionPromise() | |
695 // or Host::OnRejectPromise(). If the session is not found, call | |
696 // Host::OnResolveNewSessionPromise() with session_id = NULL. | |
697 virtual void LoadSession(uint32_t promise_id, | |
698 SessionType session_type, | |
699 const char* session_id, | |
700 uint32_t session_id_size) = 0; | |
701 | |
702 // Updates the session with |response|. The CDM must respond by calling | |
703 // either Host::OnResolvePromise() or Host::OnRejectPromise(). | |
704 virtual void UpdateSession(uint32_t promise_id, | |
705 const char* session_id, | |
706 uint32_t session_id_size, | |
707 const uint8_t* response, | |
708 uint32_t response_size) = 0; | |
709 | |
710 // Requests that the CDM close the session. The CDM must respond by calling | |
711 // either Host::OnResolvePromise() or Host::OnRejectPromise() when the request | |
712 // has been processed. This may be before the session is closed. Once the | |
713 // session is closed, Host::OnSessionClosed() must also be called. | |
714 virtual void CloseSession(uint32_t promise_id, | |
715 const char* session_id, | |
716 uint32_t session_id_size) = 0; | |
717 | |
718 // Removes any stored session data associated with this session. Will only be | |
719 // called for persistent sessions. The CDM must respond by calling either | |
720 // Host::OnResolvePromise() or Host::OnRejectPromise() when the request has | |
721 // been processed. | |
722 virtual void RemoveSession(uint32_t promise_id, | |
723 const char* session_id, | |
724 uint32_t session_id_size) = 0; | |
725 | |
726 // Performs scheduled operation with |context| when the timer fires. | |
727 virtual void TimerExpired(void* context) = 0; | |
728 | |
729 // Decrypts the |encrypted_buffer|. | |
730 // | |
731 // Returns kSuccess if decryption succeeded, in which case the callee | |
732 // should have filled the |decrypted_buffer| and passed the ownership of | |
733 // |data| in |decrypted_buffer| to the caller. | |
734 // Returns kNoKey if the CDM did not have the necessary decryption key | |
735 // to decrypt. | |
736 // Returns kDecryptError if any other error happened. | |
737 // If the return value is not kSuccess, |decrypted_buffer| should be ignored | |
738 // by the caller. | |
739 virtual Status Decrypt(const InputBuffer& encrypted_buffer, | |
740 DecryptedBlock* decrypted_buffer) = 0; | |
741 | |
742 // Initializes the CDM audio decoder with |audio_decoder_config|. This | |
743 // function must be called before DecryptAndDecodeSamples() is called. | |
744 // | |
745 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM | |
746 // audio decoder is successfully initialized. | |
747 // Returns kInitializationError if |audio_decoder_config| is not supported. | |
748 // The CDM may still be able to do Decrypt(). | |
749 // Returns kDeferredInitialization if the CDM is not ready to initialize the | |
750 // decoder at this time. Must call Host::OnDeferredInitializationDone() once | |
751 // initialization is complete. | |
752 virtual Status InitializeAudioDecoder( | |
753 const AudioDecoderConfig& audio_decoder_config) = 0; | |
754 | |
755 // Initializes the CDM video decoder with |video_decoder_config|. This | |
756 // function must be called before DecryptAndDecodeVideo() is called. | |
757 // | |
758 // Returns kSuccess if the |video_decoder_config| is supported and the CDM | |
759 // video decoder is successfully initialized. | |
760 // Returns kInitializationError if |video_decoder_config| is not supported. | |
761 // The CDM may still be able to do Decrypt(). | |
762 // Returns kDeferredInitialization if the CDM is not ready to initialize the | |
763 // decoder at this time. Must call Host::OnDeferredInitializationDone() once | |
764 // initialization is complete. | |
765 virtual Status InitializeVideoDecoder( | |
766 const VideoDecoderConfig& video_decoder_config) = 0; | |
767 | |
768 // De-initializes the CDM decoder and sets it to an uninitialized state. The | |
769 // caller can initialize the decoder again after this call to re-initialize | |
770 // it. This can be used to reconfigure the decoder if the configuration | |
771 // changes. | |
772 virtual void DeinitializeDecoder(StreamType decoder_type) = 0; | |
773 | |
774 // Resets the CDM decoder to an initialized clean state. All internal buffers | |
775 // MUST be flushed. | |
776 virtual void ResetDecoder(StreamType decoder_type) = 0; | |
777 | |
778 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a | |
779 // |video_frame|. Upon end-of-stream, the caller should call this function | |
780 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty | |
781 // |video_frame| (|format| == kEmptyVideoFrame) is produced. | |
782 // | |
783 // Returns kSuccess if decryption and decoding both succeeded, in which case | |
784 // the callee will have filled the |video_frame| and passed the ownership of | |
785 // |frame_buffer| in |video_frame| to the caller. | |
786 // Returns kNoKey if the CDM did not have the necessary decryption key | |
787 // to decrypt. | |
788 // Returns kNeedMoreData if more data was needed by the decoder to generate | |
789 // a decoded frame (e.g. during initialization and end-of-stream). | |
790 // Returns kDecryptError if any decryption error happened. | |
791 // Returns kDecodeError if any decoding error happened. | |
792 // If the return value is not kSuccess, |video_frame| should be ignored by | |
793 // the caller. | |
794 virtual Status DecryptAndDecodeVideo(const InputBuffer& encrypted_buffer, | |
795 VideoFrame* video_frame) = 0; | |
796 | |
797 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into | |
798 // |audio_frames|. Upon end-of-stream, the caller should call this function | |
799 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty | |
800 // |audio_frames| is produced. | |
801 // | |
802 // Returns kSuccess if decryption and decoding both succeeded, in which case | |
803 // the callee will have filled |audio_frames| and passed the ownership of | |
804 // |data| in |audio_frames| to the caller. | |
805 // Returns kNoKey if the CDM did not have the necessary decryption key | |
806 // to decrypt. | |
807 // Returns kNeedMoreData if more data was needed by the decoder to generate | |
808 // audio samples (e.g. during initialization and end-of-stream). | |
809 // Returns kDecryptError if any decryption error happened. | |
810 // Returns kDecodeError if any decoding error happened. | |
811 // If the return value is not kSuccess, |audio_frames| should be ignored by | |
812 // the caller. | |
813 virtual Status DecryptAndDecodeAudio(const InputBuffer& encrypted_buffer, | |
814 AudioFrames* audio_frames) = 0; | |
815 | |
816 // Called by the host after a platform challenge was initiated via | |
817 // Host::SendPlatformChallenge(). | |
818 virtual void OnPlatformChallengeResponse( | |
819 const PlatformChallengeResponse& response) = 0; | |
820 | |
821 // Called by the host after a call to Host::SendHostChallenge(). This | |
822 // provides |response| as returned from the broker CDM challenge. | |
823 virtual void OnHostChallengeResponse(const uint8_t* response, | |
824 uint32_t response_size) = 0; | |
825 | |
826 // Called by the host after a call to Host::QueryOutputProtectionStatus(). The | |
827 // |link_mask| is a bit mask of OutputLinkTypes and |output_protection_mask| | |
828 // is a bit mask of OutputProtectionMethods. If |result| is kQueryFailed, | |
829 // then |link_mask| and |output_protection_mask| are undefined and should | |
830 // be ignored. | |
831 virtual void OnQueryOutputProtectionStatus( | |
832 QueryResult result, | |
833 uint32_t link_mask, | |
834 uint32_t output_protection_mask) = 0; | |
835 | |
836 // Destroys the object in the same context as it was created. | |
837 virtual void Destroy() = 0; | |
838 | |
839 protected: | |
840 ContentDecryptionModule_9() {} | |
841 virtual ~ContentDecryptionModule_9() {} | |
842 }; | |
843 | |
844 typedef ContentDecryptionModule_9 ContentDecryptionModule; | |
659 | 845 |
660 // Represents a buffer created by Allocator implementations. | 846 // Represents a buffer created by Allocator implementations. |
661 class CDM_CLASS_API Buffer { | 847 class CDM_CLASS_API Buffer { |
662 public: | 848 public: |
663 // Destroys the buffer in the same context as it was created. | 849 // Destroys the buffer in the same context as it was created. |
664 virtual void Destroy() = 0; | 850 virtual void Destroy() = 0; |
665 | 851 |
666 virtual uint32_t Capacity() const = 0; | 852 virtual uint32_t Capacity() const = 0; |
667 virtual uint8_t* Data() = 0; | 853 virtual uint8_t* Data() = 0; |
668 virtual void SetSize(uint32_t size) = 0; | 854 virtual void SetSize(uint32_t size) = 0; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 // if a FileIO object cannot be obtained. Once a valid FileIO object is | 993 // 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 | 994 // returned, |client| must be valid until FileIO::Close() is called. The |
809 // CDM can call this method multiple times to operate on different files. | 995 // CDM can call this method multiple times to operate on different files. |
810 virtual FileIO* CreateFileIO(FileIOClient* client) = 0; | 996 virtual FileIO* CreateFileIO(FileIOClient* client) = 0; |
811 | 997 |
812 protected: | 998 protected: |
813 Host_8() {} | 999 Host_8() {} |
814 virtual ~Host_8() {} | 1000 virtual ~Host_8() {} |
815 }; | 1001 }; |
816 | 1002 |
1003 class CDM_CLASS_API Host_9 { | |
1004 public: | |
1005 static const int kVersion = 9; | |
1006 | |
1007 // Returns a Buffer* containing non-zero members upon success, or NULL on | |
1008 // failure. The caller owns the Buffer* after this call. The buffer is not | |
1009 // guaranteed to be zero initialized. The capacity of the allocated Buffer | |
1010 // is guaranteed to be not less than |capacity|. | |
1011 virtual Buffer* Allocate(uint32_t capacity) = 0; | |
1012 | |
1013 // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms| | |
1014 // from now with |context|. | |
1015 virtual void SetTimer(int64_t delay_ms, void* context) = 0; | |
1016 | |
1017 // Returns the current wall time in seconds. | |
1018 virtual Time GetCurrentWallTime() = 0; | |
1019 | |
1020 // Called by the CDM when a session is created or loaded and the value for the | |
1021 // MediaKeySession's sessionId attribute is available (|session_id|). | |
1022 // This must be called before OnSessionMessage() or | |
1023 // OnSessionKeysChange() is called for the same session. |session_id_size| | |
1024 // should not include null termination. | |
1025 // When called in response to LoadSession(), the |session_id| must be the | |
1026 // same as the |session_id| passed in LoadSession(), or NULL if the | |
1027 // session could not be loaded. | |
1028 virtual void OnResolveNewSessionPromise(uint32_t promise_id, | |
1029 const char* session_id, | |
1030 uint32_t session_id_size) = 0; | |
1031 | |
1032 // Called by the CDM when a session is updated or released. | |
1033 virtual void OnResolvePromise(uint32_t promise_id) = 0; | |
1034 | |
1035 // Called by the CDM when an error occurs as a result of one of the | |
1036 // ContentDecryptionModule calls that accept a |promise_id|. | |
1037 // |error| must be specified, |error_message| and |system_code| | |
1038 // are optional. |error_message_size| should not include null termination. | |
1039 virtual void OnRejectPromise(uint32_t promise_id, | |
1040 Error error, | |
1041 uint32_t system_code, | |
1042 const char* error_message, | |
1043 uint32_t error_message_size) = 0; | |
1044 | |
1045 // Called by the CDM when it has a message for session |session_id|. | |
1046 // Size parameters should not include null termination. | |
1047 virtual void OnSessionMessage(const char* session_id, | |
1048 uint32_t session_id_size, | |
1049 MessageType message_type, | |
1050 const char* message, | |
1051 uint32_t message_size) = 0; | |
1052 | |
1053 // Called by the CDM when there has been a change in keys or their status for | |
1054 // session |session_id|. |has_additional_usable_key| should be set if a | |
1055 // key is newly usable (e.g. new key available, previously expired key has | |
1056 // been renewed, etc.) and the browser should attempt to resume playback. | |
1057 // |key_ids| is the list of key ids for this session along with their | |
1058 // current status. |key_ids_count| is the number of entries in |key_ids|. | |
1059 // Size parameter for |session_id| should not include null termination. | |
1060 virtual void OnSessionKeysChange(const char* session_id, | |
1061 uint32_t session_id_size, | |
1062 bool has_additional_usable_key, | |
1063 const KeyInformation* keys_info, | |
1064 uint32_t keys_info_count) = 0; | |
1065 | |
1066 // Called by the CDM when there has been a change in the expiration time for | |
1067 // session |session_id|. This can happen as the result of an Update() call | |
1068 // or some other event. If this happens as a result of a call to Update(), | |
1069 // it must be called before resolving the Update() promise. |new_expiry_time| | |
1070 // can be 0 to represent "undefined". Size parameter should not include | |
1071 // null termination. | |
1072 virtual void OnExpirationChange(const char* session_id, | |
1073 uint32_t session_id_size, | |
1074 Time new_expiry_time) = 0; | |
1075 | |
1076 // Called by the CDM when session |session_id| is closed. Size | |
1077 // parameter should not include null termination. | |
1078 virtual void OnSessionClosed(const char* session_id, | |
1079 uint32_t session_id_size) = 0; | |
1080 | |
1081 // The following are optional methods that may not be implemented on all | |
1082 // platforms. | |
1083 | |
1084 // Sends a platform challenge for the given |service_id|. |challenge| is at | |
1085 // most 256 bits of data to be signed. Once the challenge has been completed, | |
1086 // the host will call ContentDecryptionModule::OnPlatformChallengeResponse() | |
1087 // with the signed challenge response and platform certificate. Size | |
1088 // parameters should not include null termination. | |
1089 virtual void SendPlatformChallenge(const char* service_id, | |
tinskip
2016/10/27 00:32:47
I believe keeping the single PlatformChallenge API
| |
1090 uint32_t service_id_size, | |
1091 const char* challenge, | |
1092 uint32_t challenge_size) = 0; | |
1093 | |
1094 // Initiate the host challenge. If supported, sends the |challenge| data to | |
1095 // the host, and returns true. The actual response from the host will be | |
1096 // provided via OnHostChallengeResponse(). If not supported, this method | |
1097 // should return false. | |
1098 virtual bool SendHostChallenge(const uint8_t* challenge, | |
1099 uint32_t challenge_size) = 0; | |
1100 | |
1101 // Attempts to enable output protection (e.g. HDCP) on the display link. The | |
1102 // |desired_protection_mask| is a bit mask of OutputProtectionMethods. No | |
1103 // status callback is issued, the CDM must call QueryOutputProtectionStatus() | |
1104 // periodically to ensure the desired protections are applied. | |
1105 virtual void EnableOutputProtection(uint32_t desired_protection_mask) = 0; | |
1106 | |
1107 // Requests the current output protection status. Once the host has the status | |
1108 // it will call ContentDecryptionModule::OnQueryOutputProtectionStatus(). | |
1109 virtual void QueryOutputProtectionStatus() = 0; | |
1110 | |
1111 // Must be called by the CDM if it returned kDeferredInitialization during | |
1112 // InitializeAudioDecoder() or InitializeVideoDecoder(). | |
1113 virtual void OnDeferredInitializationDone(StreamType stream_type, | |
1114 Status decoder_status) = 0; | |
1115 | |
1116 // Creates a FileIO object from the host to do file IO operation. Returns NULL | |
1117 // if a FileIO object cannot be obtained. Once a valid FileIO object is | |
1118 // returned, |client| must be valid until FileIO::Close() is called. The | |
1119 // CDM can call this method multiple times to operate on different files. | |
1120 virtual FileIO* CreateFileIO(FileIOClient* client) = 0; | |
1121 | |
1122 protected: | |
1123 Host_9() {} | |
1124 virtual ~Host_9() {} | |
1125 }; | |
1126 | |
817 // Represents a decrypted block that has not been decoded. | 1127 // Represents a decrypted block that has not been decoded. |
818 class CDM_CLASS_API DecryptedBlock { | 1128 class CDM_CLASS_API DecryptedBlock { |
819 public: | 1129 public: |
820 virtual void SetDecryptedBuffer(Buffer* buffer) = 0; | 1130 virtual void SetDecryptedBuffer(Buffer* buffer) = 0; |
821 virtual Buffer* DecryptedBuffer() = 0; | 1131 virtual Buffer* DecryptedBuffer() = 0; |
822 | 1132 |
823 // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not, | 1133 // TODO(tomfinegan): Figure out if timestamp is really needed. If it is not, |
824 // we can just pass Buffer pointers around. | 1134 // we can just pass Buffer pointers around. |
825 virtual void SetTimestamp(int64_t timestamp) = 0; | 1135 virtual void SetTimestamp(int64_t timestamp) = 0; |
826 virtual int64_t Timestamp() const = 0; | 1136 virtual int64_t Timestamp() const = 0; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 virtual AudioFormat Format() const = 0; | 1195 virtual AudioFormat Format() const = 0; |
886 | 1196 |
887 protected: | 1197 protected: |
888 AudioFrames() {} | 1198 AudioFrames() {} |
889 virtual ~AudioFrames() {} | 1199 virtual ~AudioFrames() {} |
890 }; | 1200 }; |
891 | 1201 |
892 } // namespace cdm | 1202 } // namespace cdm |
893 | 1203 |
894 #endif // CDM_CONTENT_DECRYPTION_MODULE_H_ | 1204 #endif // CDM_CONTENT_DECRYPTION_MODULE_H_ |
OLD | NEW |