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 "content_decryption_module_export.h" |
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 enum RejectionReason { |
106 // http://www.w3.org/TR/dom/#domexception | 99 // The values used are the legacy code values from |
107 // Some DOM4 exceptions are not included as they are not expected to be used. | 100 // https://heycam.github.io/webidl/#idl-DOMException-error-names |
108 enum Error { | |
109 kNotSupportedError = 9, | 101 kNotSupportedError = 9, |
110 kInvalidStateError = 11, | 102 kInvalidStateError = 11, |
111 kInvalidAccessError = 15, | |
112 kQuotaExceededError = 22, | 103 kQuotaExceededError = 22, |
113 | 104 |
114 // Additional exceptions that do not have assigned codes. | 105 // Additional exceptions that do not have assigned legacy codes. |
115 // There are other non-EME-specific values, not included in this list. | 106 kTypeError = 50, |
116 kUnknownError = 30, | |
117 | 107 |
118 // Additional values from previous EME versions. They currently have no | 108 // Additional values from previous EME versions. They are deprecated and |
119 // matching DOMException. | 109 // should not be used. |
120 kClientError = 100, | 110 kDeprecatedInvalidAccessErrorWillBeTreatedAsTypeError = 15, |
121 kOutputError = 101 | 111 kDeprecatedUnknownError = 30, |
| 112 kDeprecatedClientErrorWillBeTreatedAsUnknownError = 100, |
| 113 kDeprecatedOutputErrorWillBeTreatedAsUnknownError = 101 |
122 }; | 114 }; |
123 | 115 |
124 // Time is defined as the number of seconds since the | 116 // Time is defined as the number of seconds since the |
125 // Epoch (00:00:00 UTC, January 1, 1970). | 117 // Epoch (00:00:00 UTC, January 1, 1970). |
126 typedef double Time; | 118 typedef double Time; |
127 | 119 |
128 // An input buffer can be split into several continuous subsamples. | 120 // An input buffer can be split into several continuous subsamples. |
129 // A SubsampleEntry specifies the number of clear and cipher bytes in each | 121 // A SubsampleEntry specifies the number of clear and cipher bytes in each |
130 // subsample. For example, the following buffer has three subsamples: | 122 // subsample. For example, the following buffer has three subsamples: |
131 // | 123 // |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 kAudioFormatS16, // Interleaved signed 16-bit. | 209 kAudioFormatS16, // Interleaved signed 16-bit. |
218 kAudioFormatS32, // Interleaved signed 32-bit. | 210 kAudioFormatS32, // Interleaved signed 32-bit. |
219 kAudioFormatF32, // Interleaved float 32-bit. | 211 kAudioFormatF32, // Interleaved float 32-bit. |
220 kAudioFormatPlanarS16, // Signed 16-bit planar. | 212 kAudioFormatPlanarS16, // Signed 16-bit planar. |
221 kAudioFormatPlanarF32, // Float 32-bit planar. | 213 kAudioFormatPlanarF32, // Float 32-bit planar. |
222 }; | 214 }; |
223 | 215 |
224 // Surface formats based on FOURCC labels, see: http://www.fourcc.org/yuv.php | 216 // Surface formats based on FOURCC labels, see: http://www.fourcc.org/yuv.php |
225 enum VideoFormat { | 217 enum VideoFormat { |
226 kUnknownVideoFormat = 0, // Unknown format value. Used for error reporting. | 218 kUnknownVideoFormat = 0, // Unknown format value. Used for error reporting. |
227 kYv12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples. | 219 kYv12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples. |
228 kI420 // 12bpp YVU planar 1x1 Y, 2x2 UV samples. | 220 kI420 // 12bpp YUV planar 1x1 Y, 2x2 UV samples. |
229 }; | 221 }; |
230 | 222 |
231 struct Size { | 223 struct Size { |
232 Size() : width(0), height(0) {} | 224 Size() : width(0), height(0) {} |
233 Size(int32_t width, int32_t height) : width(width), height(height) {} | 225 Size(int32_t width, int32_t height) : width(width), height(height) {} |
234 | 226 |
235 int32_t width; | 227 int32_t width; |
236 int32_t height; | 228 int32_t height; |
237 }; | 229 }; |
238 | 230 |
(...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 | 548 // If the return value is not kSuccess, |decrypted_buffer| should be ignored |
557 // by the caller. | 549 // by the caller. |
558 virtual Status Decrypt(const InputBuffer& encrypted_buffer, | 550 virtual Status Decrypt(const InputBuffer& encrypted_buffer, |
559 DecryptedBlock* decrypted_buffer) = 0; | 551 DecryptedBlock* decrypted_buffer) = 0; |
560 | 552 |
561 // Initializes the CDM audio decoder with |audio_decoder_config|. This | 553 // Initializes the CDM audio decoder with |audio_decoder_config|. This |
562 // function must be called before DecryptAndDecodeSamples() is called. | 554 // function must be called before DecryptAndDecodeSamples() is called. |
563 // | 555 // |
564 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM | 556 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM |
565 // audio decoder is successfully initialized. | 557 // audio decoder is successfully initialized. |
566 // Returns kSessionError if |audio_decoder_config| is not supported. The CDM | 558 // Returns kInitializationError if |audio_decoder_config| is not supported. |
567 // may still be able to do Decrypt(). | 559 // The CDM may still be able to do Decrypt(). |
568 // Returns kDeferredInitialization if the CDM is not ready to initialize the | 560 // Returns kDeferredInitialization if the CDM is not ready to initialize the |
569 // decoder at this time. Must call Host::OnDeferredInitializationDone() once | 561 // decoder at this time. Must call Host::OnDeferredInitializationDone() once |
570 // initialization is complete. | 562 // initialization is complete. |
571 virtual Status InitializeAudioDecoder( | 563 virtual Status InitializeAudioDecoder( |
572 const AudioDecoderConfig& audio_decoder_config) = 0; | 564 const AudioDecoderConfig& audio_decoder_config) = 0; |
573 | 565 |
574 // Initializes the CDM video decoder with |video_decoder_config|. This | 566 // Initializes the CDM video decoder with |video_decoder_config|. This |
575 // function must be called before DecryptAndDecodeFrame() is called. | 567 // function must be called before DecryptAndDecodeFrame() is called. |
576 // | 568 // |
577 // Returns kSuccess if the |video_decoder_config| is supported and the CDM | 569 // Returns kSuccess if the |video_decoder_config| is supported and the CDM |
578 // video decoder is successfully initialized. | 570 // video decoder is successfully initialized. |
579 // Returns kSessionError if |video_decoder_config| is not supported. The CDM | 571 // Returns kInitializationError if |video_decoder_config| is not supported. |
580 // may still be able to do Decrypt(). | 572 // The CDM may still be able to do Decrypt(). |
581 // Returns kDeferredInitialization if the CDM is not ready to initialize the | 573 // Returns kDeferredInitialization if the CDM is not ready to initialize the |
582 // decoder at this time. Must call Host::OnDeferredInitializationDone() once | 574 // decoder at this time. Must call Host::OnDeferredInitializationDone() once |
583 // initialization is complete. | 575 // initialization is complete. |
584 virtual Status InitializeVideoDecoder( | 576 virtual Status InitializeVideoDecoder( |
585 const VideoDecoderConfig& video_decoder_config) = 0; | 577 const VideoDecoderConfig& video_decoder_config) = 0; |
586 | 578 |
587 // De-initializes the CDM decoder and sets it to an uninitialized state. The | 579 // 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 | 580 // 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 | 581 // it. This can be used to reconfigure the decoder if the configuration |
590 // changes. | 582 // changes. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 uint32_t output_protection_mask) = 0; | 640 uint32_t output_protection_mask) = 0; |
649 | 641 |
650 // Destroys the object in the same context as it was created. | 642 // Destroys the object in the same context as it was created. |
651 virtual void Destroy() = 0; | 643 virtual void Destroy() = 0; |
652 | 644 |
653 protected: | 645 protected: |
654 ContentDecryptionModule_8() {} | 646 ContentDecryptionModule_8() {} |
655 virtual ~ContentDecryptionModule_8() {} | 647 virtual ~ContentDecryptionModule_8() {} |
656 }; | 648 }; |
657 | 649 |
658 typedef ContentDecryptionModule_8 ContentDecryptionModule; | 650 // ContentDecryptionModule interface that all CDMs need to implement. |
| 651 // The interface is versioned for backward compatibility. |
| 652 // Note: ContentDecryptionModule implementations must use the allocator |
| 653 // provided in CreateCdmInstance() to allocate any Buffer that needs to |
| 654 // be passed back to the caller. Implementations must call Buffer::Destroy() |
| 655 // when a Buffer is created that will never be returned to the caller. |
| 656 class CDM_CLASS_API ContentDecryptionModule_9 { |
| 657 public: |
| 658 static const int kVersion = 9; |
| 659 typedef Host_9 Host; |
| 660 |
| 661 // Initializes the CDM instance, providing information about permitted |
| 662 // functionalities. |
| 663 // If |allow_distinctive_identifier| is false, messages from the CDM, |
| 664 // such as message events, must not contain a Distinctive Identifier, |
| 665 // even in an encrypted form. |
| 666 // If |allow_persistent_state| is false, the CDM must not attempt to |
| 667 // persist state. Calls to CreateFileIO() will fail. |
| 668 virtual void Initialize(bool allow_distinctive_identifier, |
| 669 bool allow_persistent_state) = 0; |
| 670 |
| 671 // SetServerCertificate(), CreateSessionAndGenerateRequest(), LoadSession(), |
| 672 // UpdateSession(), CloseSession(), and RemoveSession() all accept a |
| 673 // |promise_id|, which must be passed to the completion Host method |
| 674 // (e.g. Host::OnResolveNewSessionPromise()). |
| 675 |
| 676 // Provides a server certificate to be used to encrypt messages to the |
| 677 // license server. The CDM must respond by calling either |
| 678 // Host::OnResolvePromise() or Host::OnRejectPromise(). |
| 679 virtual void SetServerCertificate(uint32_t promise_id, |
| 680 const uint8_t* server_certificate_data, |
| 681 uint32_t server_certificate_data_size) = 0; |
| 682 |
| 683 // Creates a session given |session_type|, |init_data_type|, and |init_data|. |
| 684 // The CDM must respond by calling either Host::OnResolveNewSessionPromise() |
| 685 // or Host::OnRejectPromise(). |
| 686 virtual void CreateSessionAndGenerateRequest(uint32_t promise_id, |
| 687 SessionType session_type, |
| 688 InitDataType init_data_type, |
| 689 const uint8_t* init_data, |
| 690 uint32_t init_data_size) = 0; |
| 691 |
| 692 // Loads the session of type |session_type| specified by |session_id|. |
| 693 // The CDM must respond by calling either Host::OnResolveNewSessionPromise() |
| 694 // or Host::OnRejectPromise(). If the session is not found, call |
| 695 // Host::OnResolveNewSessionPromise() with session_id = NULL. |
| 696 virtual void LoadSession(uint32_t promise_id, |
| 697 SessionType session_type, |
| 698 const char* session_id, |
| 699 uint32_t session_id_size) = 0; |
| 700 |
| 701 // Updates the session with |response|. The CDM must respond by calling |
| 702 // either Host::OnResolvePromise() or Host::OnRejectPromise(). |
| 703 virtual void UpdateSession(uint32_t promise_id, |
| 704 const char* session_id, |
| 705 uint32_t session_id_size, |
| 706 const uint8_t* response, |
| 707 uint32_t response_size) = 0; |
| 708 |
| 709 // Requests that the CDM close the session. The CDM must respond by calling |
| 710 // either Host::OnResolvePromise() or Host::OnRejectPromise() when the request |
| 711 // has been processed. This may be before the session is closed. Once the |
| 712 // session is closed, Host::OnSessionClosed() must also be called. |
| 713 virtual void CloseSession(uint32_t promise_id, |
| 714 const char* session_id, |
| 715 uint32_t session_id_size) = 0; |
| 716 |
| 717 // Removes any stored session data associated with this session. Will only be |
| 718 // called for persistent sessions. The CDM must respond by calling either |
| 719 // Host::OnResolvePromise() or Host::OnRejectPromise() when the request has |
| 720 // been processed. |
| 721 virtual void RemoveSession(uint32_t promise_id, |
| 722 const char* session_id, |
| 723 uint32_t session_id_size) = 0; |
| 724 |
| 725 // Performs scheduled operation with |context| when the timer fires. |
| 726 virtual void TimerExpired(void* context) = 0; |
| 727 |
| 728 // Decrypts the |encrypted_buffer|. |
| 729 // |
| 730 // Returns kSuccess if decryption succeeded, in which case the callee |
| 731 // should have filled the |decrypted_buffer| and passed the ownership of |
| 732 // |data| in |decrypted_buffer| to the caller. |
| 733 // Returns kNoKey if the CDM did not have the necessary decryption key |
| 734 // to decrypt. |
| 735 // Returns kDecryptError if any other error happened. |
| 736 // If the return value is not kSuccess, |decrypted_buffer| should be ignored |
| 737 // by the caller. |
| 738 virtual Status Decrypt(const InputBuffer& encrypted_buffer, |
| 739 DecryptedBlock* decrypted_buffer) = 0; |
| 740 |
| 741 // Initializes the CDM audio decoder with |audio_decoder_config|. This |
| 742 // function must be called before DecryptAndDecodeSamples() is called. |
| 743 // |
| 744 // Returns kSuccess if the |audio_decoder_config| is supported and the CDM |
| 745 // audio decoder is successfully initialized. |
| 746 // Returns kInitializationError if |audio_decoder_config| is not supported. |
| 747 // The CDM may still be able to do Decrypt(). |
| 748 // Returns kDeferredInitialization if the CDM is not ready to initialize the |
| 749 // decoder at this time. Must call Host::OnDeferredInitializationDone() once |
| 750 // initialization is complete. |
| 751 virtual Status InitializeAudioDecoder( |
| 752 const AudioDecoderConfig& audio_decoder_config) = 0; |
| 753 |
| 754 // Initializes the CDM video decoder with |video_decoder_config|. This |
| 755 // function must be called before DecryptAndDecodeVideo() is called. |
| 756 // |
| 757 // Returns kSuccess if the |video_decoder_config| is supported and the CDM |
| 758 // video decoder is successfully initialized. |
| 759 // Returns kInitializationError if |video_decoder_config| is not supported. |
| 760 // The CDM may still be able to do Decrypt(). |
| 761 // Returns kDeferredInitialization if the CDM is not ready to initialize the |
| 762 // decoder at this time. Must call Host::OnDeferredInitializationDone() once |
| 763 // initialization is complete. |
| 764 virtual Status InitializeVideoDecoder( |
| 765 const VideoDecoderConfig& video_decoder_config) = 0; |
| 766 |
| 767 // De-initializes the CDM decoder and sets it to an uninitialized state. The |
| 768 // caller can initialize the decoder again after this call to re-initialize |
| 769 // it. This can be used to reconfigure the decoder if the configuration |
| 770 // changes. |
| 771 virtual void DeinitializeDecoder(StreamType decoder_type) = 0; |
| 772 |
| 773 // Resets the CDM decoder to an initialized clean state. All internal buffers |
| 774 // MUST be flushed. |
| 775 virtual void ResetDecoder(StreamType decoder_type) = 0; |
| 776 |
| 777 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a |
| 778 // |video_frame|. Upon end-of-stream, the caller should call this function |
| 779 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty |
| 780 // |video_frame| (|format| == kEmptyVideoFrame) is produced. |
| 781 // |
| 782 // Returns kSuccess if decryption and decoding both succeeded, in which case |
| 783 // the callee will have filled the |video_frame| and passed the ownership of |
| 784 // |frame_buffer| in |video_frame| to the caller. |
| 785 // Returns kNoKey if the CDM did not have the necessary decryption key |
| 786 // to decrypt. |
| 787 // Returns kNeedMoreData if more data was needed by the decoder to generate |
| 788 // a decoded frame (e.g. during initialization and end-of-stream). |
| 789 // Returns kDecryptError if any decryption error happened. |
| 790 // Returns kDecodeError if any decoding error happened. |
| 791 // If the return value is not kSuccess, |video_frame| should be ignored by |
| 792 // the caller. |
| 793 virtual Status DecryptAndDecodeVideo(const InputBuffer& encrypted_buffer, |
| 794 VideoFrame* video_frame) = 0; |
| 795 |
| 796 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into |
| 797 // |audio_frames|. Upon end-of-stream, the caller should call this function |
| 798 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty |
| 799 // |audio_frames| is produced. |
| 800 // |
| 801 // Returns kSuccess if decryption and decoding both succeeded, in which case |
| 802 // the callee will have filled |audio_frames| and passed the ownership of |
| 803 // |data| in |audio_frames| to the caller. |
| 804 // Returns kNoKey if the CDM did not have the necessary decryption key |
| 805 // to decrypt. |
| 806 // Returns kNeedMoreData if more data was needed by the decoder to generate |
| 807 // audio samples (e.g. during initialization and end-of-stream). |
| 808 // Returns kDecryptError if any decryption error happened. |
| 809 // Returns kDecodeError if any decoding error happened. |
| 810 // If the return value is not kSuccess, |audio_frames| should be ignored by |
| 811 // the caller. |
| 812 virtual Status DecryptAndDecodeAudio(const InputBuffer& encrypted_buffer, |
| 813 AudioFrames* audio_frames) = 0; |
| 814 |
| 815 // Called by the host after a platform challenge was initiated via |
| 816 // Host::SendPlatformChallenge(). |
| 817 virtual void OnPlatformChallengeResponse( |
| 818 const PlatformChallengeResponse& response) = 0; |
| 819 |
| 820 // Called by the host after a call to Host::SendHostChallenge(). This |
| 821 // provides |response| as returned from the broker CDM challenge. |
| 822 virtual void OnHostChallengeResponse(const uint8_t* response, |
| 823 uint32_t response_size) = 0; |
| 824 |
| 825 // Called by the host after a call to Host::QueryOutputProtectionStatus(). The |
| 826 // |link_mask| is a bit mask of OutputLinkTypes and |output_protection_mask| |
| 827 // is a bit mask of OutputProtectionMethods. If |result| is kQueryFailed, |
| 828 // then |link_mask| and |output_protection_mask| are undefined and should |
| 829 // be ignored. |
| 830 virtual void OnQueryOutputProtectionStatus( |
| 831 QueryResult result, |
| 832 uint32_t link_mask, |
| 833 uint32_t output_protection_mask) = 0; |
| 834 |
| 835 // Destroys the object in the same context as it was created. |
| 836 virtual void Destroy() = 0; |
| 837 |
| 838 protected: |
| 839 ContentDecryptionModule_9() {} |
| 840 virtual ~ContentDecryptionModule_9() {} |
| 841 }; |
| 842 |
| 843 typedef ContentDecryptionModule_9 ContentDecryptionModule; |
659 | 844 |
660 // Represents a buffer created by Allocator implementations. | 845 // Represents a buffer created by Allocator implementations. |
661 class CDM_CLASS_API Buffer { | 846 class CDM_CLASS_API Buffer { |
662 public: | 847 public: |
663 // Destroys the buffer in the same context as it was created. | 848 // Destroys the buffer in the same context as it was created. |
664 virtual void Destroy() = 0; | 849 virtual void Destroy() = 0; |
665 | 850 |
666 virtual uint32_t Capacity() const = 0; | 851 virtual uint32_t Capacity() const = 0; |
667 virtual uint8_t* Data() = 0; | 852 virtual uint8_t* Data() = 0; |
668 virtual void SetSize(uint32_t size) = 0; | 853 virtual void SetSize(uint32_t size) = 0; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 // session could not be loaded. | 889 // session could not be loaded. |
705 virtual void OnResolveNewSessionPromise(uint32_t promise_id, | 890 virtual void OnResolveNewSessionPromise(uint32_t promise_id, |
706 const char* session_id, | 891 const char* session_id, |
707 uint32_t session_id_size) = 0; | 892 uint32_t session_id_size) = 0; |
708 | 893 |
709 // Called by the CDM when a session is updated or released. | 894 // Called by the CDM when a session is updated or released. |
710 virtual void OnResolvePromise(uint32_t promise_id) = 0; | 895 virtual void OnResolvePromise(uint32_t promise_id) = 0; |
711 | 896 |
712 // Called by the CDM when an error occurs as a result of one of the | 897 // Called by the CDM when an error occurs as a result of one of the |
713 // ContentDecryptionModule calls that accept a |promise_id|. | 898 // ContentDecryptionModule calls that accept a |promise_id|. |
714 // |error| must be specified, |error_message| and |system_code| | 899 // |reason| must be specified, |error_message| and |system_code| |
715 // are optional. |error_message_size| should not include null termination. | 900 // are optional. |error_message_size| should not include null termination. |
716 virtual void OnRejectPromise(uint32_t promise_id, | 901 virtual void OnRejectPromise(uint32_t promise_id, |
717 Error error, | 902 RejectionReason reason, |
718 uint32_t system_code, | 903 uint32_t system_code, |
719 const char* error_message, | 904 const char* error_message, |
720 uint32_t error_message_size) = 0; | 905 uint32_t error_message_size) = 0; |
721 | 906 |
722 // Called by the CDM when it has a message for session |session_id|. | 907 // Called by the CDM when it has a message for session |session_id|. |
723 // Size parameters should not include null termination. | 908 // Size parameters should not include null termination. |
724 // |legacy_destination_url| is only for supporting the prefixed EME API and | 909 // |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| | 910 // is ignored by unprefixed EME. It should only be non-null if |message_type| |
726 // is kLicenseRenewal. | 911 // is kLicenseRenewal. |
727 virtual void OnSessionMessage(const char* session_id, | 912 virtual void OnSessionMessage(const char* session_id, |
(...skipping 27 matching lines...) Expand all Loading... |
755 uint32_t session_id_size, | 940 uint32_t session_id_size, |
756 Time new_expiry_time) = 0; | 941 Time new_expiry_time) = 0; |
757 | 942 |
758 // Called by the CDM when session |session_id| is closed. Size | 943 // Called by the CDM when session |session_id| is closed. Size |
759 // parameter should not include null termination. | 944 // parameter should not include null termination. |
760 virtual void OnSessionClosed(const char* session_id, | 945 virtual void OnSessionClosed(const char* session_id, |
761 uint32_t session_id_size) = 0; | 946 uint32_t session_id_size) = 0; |
762 | 947 |
763 // Called by the CDM when an error occurs in session |session_id| | 948 // Called by the CDM when an error occurs in session |session_id| |
764 // unrelated to one of the ContentDecryptionModule calls that accept a | 949 // unrelated to one of the ContentDecryptionModule calls that accept a |
765 // |promise_id|. |error| must be specified, |error_message| and | 950 // |promise_id|. |reason| must be specified, |error_message| and |
766 // |system_code| are optional. Length parameters should not include null | 951 // |system_code| are optional. Length parameters should not include null |
767 // termination. | 952 // termination. |
768 // Note: | 953 // Note: |
769 // - This method is only for supporting prefixed EME API. | 954 // - This method is only for supporting prefixed EME API. |
770 // - This method will be ignored by unprefixed EME. All errors reported | 955 // - 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. | 956 // in this method should probably also be reported by one of other methods. |
772 virtual void OnLegacySessionError( | 957 virtual void OnLegacySessionError(const char* session_id, |
773 const char* session_id, uint32_t session_id_length, | 958 uint32_t session_id_length, |
774 Error error, | 959 RejectionReason reason, |
775 uint32_t system_code, | 960 uint32_t system_code, |
776 const char* error_message, uint32_t error_message_length) = 0; | 961 const char* error_message, |
| 962 uint32_t error_message_length) = 0; |
777 | 963 |
778 // The following are optional methods that may not be implemented on all | 964 // The following are optional methods that may not be implemented on all |
779 // platforms. | 965 // platforms. |
780 | 966 |
781 // Sends a platform challenge for the given |service_id|. |challenge| is at | 967 // 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, | 968 // most 256 bits of data to be signed. Once the challenge has been completed, |
783 // the host will call ContentDecryptionModule::OnPlatformChallengeResponse() | 969 // the host will call ContentDecryptionModule::OnPlatformChallengeResponse() |
784 // with the signed challenge response and platform certificate. Size | 970 // with the signed challenge response and platform certificate. Size |
785 // parameters should not include null termination. | 971 // parameters should not include null termination. |
786 virtual void SendPlatformChallenge(const char* service_id, | 972 virtual void SendPlatformChallenge(const char* service_id, |
(...skipping 20 matching lines...) Expand all 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 // |reason| 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 RejectionReason reason, |
| 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, |
| 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 |