Index: content_decryption_module.h |
diff --git a/content_decryption_module.h b/content_decryption_module.h |
index 05ce82e8c864e000630517cbb61c9cf952e48881..aeab366df56722c6372cf31c7e266b4bdcc9a75a 100644 |
--- a/content_decryption_module.h |
+++ b/content_decryption_module.h |
@@ -75,12 +75,9 @@ CDM_EXPORT const char* GetCdmVersion(); |
namespace cdm { |
-class AudioFrames_1; |
class AudioFrames_2; |
typedef AudioFrames_2 AudioFrames; |
-class Host_1; |
-class Host_2; |
class Host_4; |
class DecryptedBlock; |
@@ -379,284 +376,6 @@ class FileIOClient { |
virtual ~FileIOClient() {} |
}; |
-// WARNING: Deprecated. Will be removed in the near future. CDMs should |
-// implement ContentDecryptionModule_2 instead. |
- |
-// ContentDecryptionModule interface that all CDMs need to implement. |
-// The interface is versioned for backward compatibility. |
-// Note: ContentDecryptionModule implementations must use the allocator |
-// provided in CreateCdmInstance() to allocate any Buffer that needs to |
-// be passed back to the caller. Implementations must call Buffer::Destroy() |
-// when a Buffer is created that will never be returned to the caller. |
-class ContentDecryptionModule_1 { |
- public: |
- static const int kVersion = 1; |
- typedef Host_1 Host; |
- |
- // Generates a |key_request| given |type| and |init_data|. |
- // |
- // Returns kSuccess if the key request was successfully generated, in which |
- // case the CDM must send the key message by calling Host::SendKeyMessage(). |
- // Returns kSessionError if any error happened, in which case the CDM must |
- // send a key error by calling Host::SendKeyError(). |
- virtual Status GenerateKeyRequest( |
- const char* type, uint32_t type_size, |
- const uint8_t* init_data, uint32_t init_data_size) = 0; |
- |
- // Adds the |key| to the CDM to be associated with |key_id|. |
- // |
- // Returns kSuccess if the key was successfully added, kSessionError |
- // otherwise. |
- virtual Status AddKey(const char* session_id, uint32_t session_id_size, |
- const uint8_t* key, uint32_t key_size, |
- const uint8_t* key_id, uint32_t key_id_size) = 0; |
- |
- // Cancels any pending key request made to the CDM for |session_id|. |
- // |
- // Returns kSuccess if all pending key requests for |session_id| were |
- // successfully canceled or there was no key request to be canceled, |
- // kSessionError otherwise. |
- virtual Status CancelKeyRequest( |
- const char* session_id, uint32_t session_id_size) = 0; |
- |
- // Performs scheduled operation with |context| when the timer fires. |
- virtual void TimerExpired(void* context) = 0; |
- |
- // Decrypts the |encrypted_buffer|. |
- // |
- // Returns kSuccess if decryption succeeded, in which case the callee |
- // should have filled the |decrypted_buffer| and passed the ownership of |
- // |data| in |decrypted_buffer| to the caller. |
- // Returns kNoKey if the CDM did not have the necessary decryption key |
- // to decrypt. |
- // Returns kDecryptError if any other error happened. |
- // If the return value is not kSuccess, |decrypted_buffer| should be ignored |
- // by the caller. |
- virtual Status Decrypt(const InputBuffer& encrypted_buffer, |
- DecryptedBlock* decrypted_buffer) = 0; |
- |
- // Initializes the CDM audio decoder with |audio_decoder_config|. This |
- // function must be called before DecryptAndDecodeSamples() is called. |
- // |
- // Returns kSuccess if the |audio_decoder_config| is supported and the CDM |
- // audio decoder is successfully initialized. |
- // Returns kSessionError if |audio_decoder_config| is not supported. The CDM |
- // may still be able to do Decrypt(). |
- virtual Status InitializeAudioDecoder( |
- const AudioDecoderConfig& audio_decoder_config) = 0; |
- |
- // Initializes the CDM video decoder with |video_decoder_config|. This |
- // function must be called before DecryptAndDecodeFrame() is called. |
- // |
- // Returns kSuccess if the |video_decoder_config| is supported and the CDM |
- // video decoder is successfully initialized. |
- // Returns kSessionError if |video_decoder_config| is not supported. The CDM |
- // may still be able to do Decrypt(). |
- virtual Status InitializeVideoDecoder( |
- const VideoDecoderConfig& video_decoder_config) = 0; |
- |
- // De-initializes the CDM decoder and sets it to an uninitialized state. The |
- // caller can initialize the decoder again after this call to re-initialize |
- // it. This can be used to reconfigure the decoder if the configuration |
- // changes. |
- virtual void DeinitializeDecoder(StreamType decoder_type) = 0; |
- |
- // Resets the CDM decoder to an initialized clean state. All internal buffers |
- // MUST be flushed. |
- virtual void ResetDecoder(StreamType decoder_type) = 0; |
- |
- // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a |
- // |video_frame|. Upon end-of-stream, the caller should call this function |
- // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty |
- // |video_frame| (|format| == kEmptyVideoFrame) is produced. |
- // |
- // Returns kSuccess if decryption and decoding both succeeded, in which case |
- // the callee will have filled the |video_frame| and passed the ownership of |
- // |frame_buffer| in |video_frame| to the caller. |
- // Returns kNoKey if the CDM did not have the necessary decryption key |
- // to decrypt. |
- // Returns kNeedMoreData if more data was needed by the decoder to generate |
- // a decoded frame (e.g. during initialization and end-of-stream). |
- // Returns kDecryptError if any decryption error happened. |
- // Returns kDecodeError if any decoding error happened. |
- // If the return value is not kSuccess, |video_frame| should be ignored by |
- // the caller. |
- virtual Status DecryptAndDecodeFrame(const InputBuffer& encrypted_buffer, |
- VideoFrame* video_frame) = 0; |
- |
- // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into |
- // |audio_frames|. Upon end-of-stream, the caller should call this function |
- // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty |
- // |audio_frames| is produced. |
- // |
- // Returns kSuccess if decryption and decoding both succeeded, in which case |
- // the callee will have filled |audio_frames| and passed the ownership of |
- // |data| in |audio_frames| to the caller. |
- // Returns kNoKey if the CDM did not have the necessary decryption key |
- // to decrypt. |
- // Returns kNeedMoreData if more data was needed by the decoder to generate |
- // audio samples (e.g. during initialization and end-of-stream). |
- // Returns kDecryptError if any decryption error happened. |
- // Returns kDecodeError if any decoding error happened. |
- // If the return value is not kSuccess, |audio_frames| should be ignored by |
- // the caller. |
- virtual Status DecryptAndDecodeSamples(const InputBuffer& encrypted_buffer, |
- AudioFrames_1* audio_frames) = 0; |
- |
- // Destroys the object in the same context as it was created. |
- virtual void Destroy() = 0; |
- |
- protected: |
- ContentDecryptionModule_1() {} |
- virtual ~ContentDecryptionModule_1() {} |
-}; |
- |
-// ContentDecryptionModule interface that all CDMs need to implement. |
-// The interface is versioned for backward compatibility. |
-// Note: ContentDecryptionModule implementations must use the allocator |
-// provided in CreateCdmInstance() to allocate any Buffer that needs to |
-// be passed back to the caller. Implementations must call Buffer::Destroy() |
-// when a Buffer is created that will never be returned to the caller. |
-class ContentDecryptionModule_2 { |
- public: |
- static const int kVersion = 2; |
- typedef Host_2 Host; |
- |
- // Generates a |key_request| given |type| and |init_data|. |
- // |
- // Returns kSuccess if the key request was successfully generated, in which |
- // case the CDM must send the key message by calling Host::SendKeyMessage(). |
- // Returns kSessionError if any error happened, in which case the CDM must |
- // send a key error by calling Host::SendKeyError(). |
- virtual Status GenerateKeyRequest( |
- const char* type, uint32_t type_size, |
- const uint8_t* init_data, uint32_t init_data_size) = 0; |
- |
- // Adds the |key| to the CDM to be associated with |key_id|. |
- // |
- // Returns kSuccess if the key was successfully added, kSessionError |
- // otherwise. |
- virtual Status AddKey(const char* session_id, uint32_t session_id_size, |
- const uint8_t* key, uint32_t key_size, |
- const uint8_t* key_id, uint32_t key_id_size) = 0; |
- |
- // Cancels any pending key request made to the CDM for |session_id|. |
- // |
- // Returns kSuccess if all pending key requests for |session_id| were |
- // successfully canceled or there was no key request to be canceled, |
- // kSessionError otherwise. |
- virtual Status CancelKeyRequest( |
- const char* session_id, uint32_t session_id_size) = 0; |
- |
- // Performs scheduled operation with |context| when the timer fires. |
- virtual void TimerExpired(void* context) = 0; |
- |
- // Decrypts the |encrypted_buffer|. |
- // |
- // Returns kSuccess if decryption succeeded, in which case the callee |
- // should have filled the |decrypted_buffer| and passed the ownership of |
- // |data| in |decrypted_buffer| to the caller. |
- // Returns kNoKey if the CDM did not have the necessary decryption key |
- // to decrypt. |
- // Returns kDecryptError if any other error happened. |
- // If the return value is not kSuccess, |decrypted_buffer| should be ignored |
- // by the caller. |
- virtual Status Decrypt(const InputBuffer& encrypted_buffer, |
- DecryptedBlock* decrypted_buffer) = 0; |
- |
- // Initializes the CDM audio decoder with |audio_decoder_config|. This |
- // function must be called before DecryptAndDecodeSamples() is called. |
- // |
- // Returns kSuccess if the |audio_decoder_config| is supported and the CDM |
- // audio decoder is successfully initialized. |
- // Returns kSessionError if |audio_decoder_config| is not supported. The CDM |
- // may still be able to do Decrypt(). |
- // Returns kDeferredInitialization if the CDM is not ready to initialize the |
- // decoder at this time. Must call Host::OnDeferredInitializationDone() once |
- // initialization is complete. |
- virtual Status InitializeAudioDecoder( |
- const AudioDecoderConfig& audio_decoder_config) = 0; |
- |
- // Initializes the CDM video decoder with |video_decoder_config|. This |
- // function must be called before DecryptAndDecodeFrame() is called. |
- // |
- // Returns kSuccess if the |video_decoder_config| is supported and the CDM |
- // video decoder is successfully initialized. |
- // Returns kSessionError if |video_decoder_config| is not supported. The CDM |
- // may still be able to do Decrypt(). |
- // Returns kDeferredInitialization if the CDM is not ready to initialize the |
- // decoder at this time. Must call Host::OnDeferredInitializationDone() once |
- // initialization is complete. |
- virtual Status InitializeVideoDecoder( |
- const VideoDecoderConfig& video_decoder_config) = 0; |
- |
- // De-initializes the CDM decoder and sets it to an uninitialized state. The |
- // caller can initialize the decoder again after this call to re-initialize |
- // it. This can be used to reconfigure the decoder if the configuration |
- // changes. |
- virtual void DeinitializeDecoder(StreamType decoder_type) = 0; |
- |
- // Resets the CDM decoder to an initialized clean state. All internal buffers |
- // MUST be flushed. |
- virtual void ResetDecoder(StreamType decoder_type) = 0; |
- |
- // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a |
- // |video_frame|. Upon end-of-stream, the caller should call this function |
- // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty |
- // |video_frame| (|format| == kEmptyVideoFrame) is produced. |
- // |
- // Returns kSuccess if decryption and decoding both succeeded, in which case |
- // the callee will have filled the |video_frame| and passed the ownership of |
- // |frame_buffer| in |video_frame| to the caller. |
- // Returns kNoKey if the CDM did not have the necessary decryption key |
- // to decrypt. |
- // Returns kNeedMoreData if more data was needed by the decoder to generate |
- // a decoded frame (e.g. during initialization and end-of-stream). |
- // Returns kDecryptError if any decryption error happened. |
- // Returns kDecodeError if any decoding error happened. |
- // If the return value is not kSuccess, |video_frame| should be ignored by |
- // the caller. |
- virtual Status DecryptAndDecodeFrame(const InputBuffer& encrypted_buffer, |
- VideoFrame* video_frame) = 0; |
- |
- // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into |
- // |audio_frames|. Upon end-of-stream, the caller should call this function |
- // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty |
- // |audio_frames| is produced. |
- // |
- // Returns kSuccess if decryption and decoding both succeeded, in which case |
- // the callee will have filled |audio_frames| and passed the ownership of |
- // |data| in |audio_frames| to the caller. |
- // Returns kNoKey if the CDM did not have the necessary decryption key |
- // to decrypt. |
- // Returns kNeedMoreData if more data was needed by the decoder to generate |
- // audio samples (e.g. during initialization and end-of-stream). |
- // Returns kDecryptError if any decryption error happened. |
- // Returns kDecodeError if any decoding error happened. |
- // If the return value is not kSuccess, |audio_frames| should be ignored by |
- // the caller. |
- virtual Status DecryptAndDecodeSamples(const InputBuffer& encrypted_buffer, |
- AudioFrames* audio_frames) = 0; |
- |
- // Called by the host after a platform challenge was initiated via |
- // Host::SendPlatformChallenge(). |
- virtual void OnPlatformChallengeResponse( |
- const PlatformChallengeResponse& response) = 0; |
- |
- // Called by the host after a call to Host::QueryOutputProtectionStatus(). The |
- // |link_mask| is a bit mask of OutputLinkTypes and |output_protection_mask| |
- // is a bit mask of OutputProtectionMethods. |
- virtual void OnQueryOutputProtectionStatus( |
- uint32_t link_mask, uint32_t output_protection_mask) = 0; |
- |
- // Destroys the object in the same context as it was created. |
- virtual void Destroy() = 0; |
- |
- protected: |
- ContentDecryptionModule_2() {} |
- virtual ~ContentDecryptionModule_2() {} |
-}; |
- |
// ContentDecryptionModule interface that all CDMs need to implement. |
// The interface is versioned for backward compatibility. |
// Note: ContentDecryptionModule implementations must use the allocator |
@@ -824,114 +543,6 @@ class Buffer { |
void operator=(const Buffer&); |
}; |
-// Host interface that the CDM can call into to access browser side services. |
-// Host interfaces are versioned for backward compatibility. CDM should use |
-// HostFactory object to request a Host interface of a particular version. |
-class Host_1 { |
- public: |
- static const int kVersion = 1; |
- |
- // Returns a Buffer* containing non-zero members upon success, or NULL on |
- // failure. The caller owns the Buffer* after this call. The buffer is not |
- // guaranteed to be zero initialized. The capacity of the allocated Buffer |
- // is guaranteed to be not less than |capacity|. |
- virtual Buffer* Allocate(uint32_t capacity) = 0; |
- |
- // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms| |
- // from now with |context|. |
- virtual void SetTimer(int64_t delay_ms, void* context) = 0; |
- |
- // Returns the current epoch wall time in seconds. |
- virtual double GetCurrentWallTimeInSeconds() = 0; |
- |
- // Sends a keymessage event to the application. |
- // Length parameters should not include null termination. |
- virtual void SendKeyMessage( |
- const char* session_id, uint32_t session_id_length, |
- const char* message, uint32_t message_length, |
- const char* default_url, uint32_t default_url_length) = 0; |
- |
- // Sends a keyerror event to the application. |
- // |session_id_length| should not include null termination. |
- virtual void SendKeyError(const char* session_id, |
- uint32_t session_id_length, |
- MediaKeyError error_code, |
- uint32_t system_code) = 0; |
- |
- // Get private data from the host. This function is limited to internal use. |
- typedef const void* (*GetPrivateInterface)(const char* interface_name); |
- virtual void GetPrivateData(int32_t* instance, |
- GetPrivateInterface* get_interface) = 0; |
- |
- protected: |
- Host_1() {} |
- virtual ~Host_1() {} |
-}; |
- |
-class Host_2 { |
- public: |
- static const int kVersion = 2; |
- |
- // Returns a Buffer* containing non-zero members upon success, or NULL on |
- // failure. The caller owns the Buffer* after this call. The buffer is not |
- // guaranteed to be zero initialized. The capacity of the allocated Buffer |
- // is guaranteed to be not less than |capacity|. |
- virtual Buffer* Allocate(uint32_t capacity) = 0; |
- |
- // Requests the host to call ContentDecryptionModule::TimerFired() |delay_ms| |
- // from now with |context|. |
- virtual void SetTimer(int64_t delay_ms, void* context) = 0; |
- |
- // Returns the current epoch wall time in seconds. |
- virtual double GetCurrentWallTimeInSeconds() = 0; |
- |
- // Sends a keymessage event to the application. |
- // Length parameters should not include null termination. |
- virtual void SendKeyMessage( |
- const char* session_id, uint32_t session_id_length, |
- const char* message, uint32_t message_length, |
- const char* default_url, uint32_t default_url_length) = 0; |
- |
- // Sends a keyerror event to the application. |
- // |session_id_length| should not include null termination. |
- virtual void SendKeyError(const char* session_id, |
- uint32_t session_id_length, |
- MediaKeyError error_code, |
- uint32_t system_code) = 0; |
- |
- // Get private data from the host. This function is limited to internal use. |
- virtual void GetPrivateData(int32_t* instance, |
- Host_1::GetPrivateInterface* get_interface) = 0; |
- |
- // Sends a platform challenge for the given |service_id|. |challenge| is at |
- // most 256 bits of data to be signed. Once the challenge has been completed, |
- // the host will call ContentDecryptionModule::OnPlatformChallengeResponse() |
- // with the signed challenge response and platform certificate. Length |
- // parameters should not include null termination. |
- virtual void SendPlatformChallenge( |
- const char* service_id, uint32_t service_id_length, |
- const char* challenge, uint32_t challenge_length) = 0; |
- |
- // Attempts to enable output protection (e.g. HDCP) on the display link. The |
- // |desired_protection_mask| is a bit mask of OutputProtectionMethods. No |
- // status callback is issued, the CDM must call QueryOutputProtectionStatus() |
- // periodically to ensure the desired protections are applied. |
- virtual void EnableOutputProtection(uint32_t desired_protection_mask) = 0; |
- |
- // Requests the current output protection status. Once the host has the status |
- // it will call ContentDecryptionModule::OnQueryOutputProtectionStatus(). |
- virtual void QueryOutputProtectionStatus() = 0; |
- |
- // Must be called by the CDM if it returned kDeferredInitialization during |
- // InitializeAudioDecoder() or InitializeVideoDecoder(). |
- virtual void OnDeferredInitializationDone(StreamType stream_type, |
- Status decoder_status) = 0; |
- |
- protected: |
- Host_2() {} |
- virtual ~Host_2() {} |
-}; |
- |
class Host_4 { |
public: |
static const int kVersion = 4; |
@@ -1066,10 +677,6 @@ class VideoFrame { |
virtual ~VideoFrame() {} |
}; |
-// |
-// WARNING: Deprecated. Will be removed in the near future. CDMs should be |
-// implementing ContentDecryptionModule_2 instead which uses AudioFrames_2. |
-// |
// Represents decrypted and decoded audio frames. AudioFrames can contain |
// multiple audio output buffers, which are serialized into this format: |
// |
@@ -1081,26 +688,14 @@ class VideoFrame { |
// |
// |<----------------- AudioFrames ------------------>| |
// | audio buffer 0 | audio buffer 1 | audio buffer 2 | |
-class AudioFrames_1 { |
- public: |
- virtual void SetFrameBuffer(Buffer* buffer) = 0; |
- virtual Buffer* FrameBuffer() = 0; |
- |
- protected: |
- AudioFrames_1() {} |
- virtual ~AudioFrames_1() {} |
-}; |
- |
-// Same as AudioFrames except the format of the data may be specified to avoid |
-// unnecessary conversion steps. Planar data should be stored end to end; e.g., |
-// |ch1 sample1||ch1 sample2|....|ch1 sample_last||ch2 sample1|... |
class AudioFrames_2 { |
public: |
virtual void SetFrameBuffer(Buffer* buffer) = 0; |
virtual Buffer* FrameBuffer() = 0; |
// The CDM must call this method, providing a valid format, when providing |
- // frame buffers. |
+ // frame buffers. Planar data should be stored end to end; e.g., |
+ // |ch1 sample1||ch1 sample2|....|ch1 sample_last||ch2 sample1|... |
virtual void SetFormat(AudioFormat format) = 0; |
virtual AudioFormat Format() const = 0; |