Chromium Code Reviews| Index: media/base/decryptor.h |
| diff --git a/media/base/decryptor.h b/media/base/decryptor.h |
| index b422dc586a696dde763aaa019dd7216ae17613e9..f898c9255978257cb3b686e167cee5f072f9382b 100644 |
| --- a/media/base/decryptor.h |
| +++ b/media/base/decryptor.h |
| @@ -5,15 +5,19 @@ |
| #ifndef MEDIA_BASE_DECRYPTOR_H_ |
| #define MEDIA_BASE_DECRYPTOR_H_ |
| +#include <list> |
| #include <string> |
| #include "base/basictypes.h" |
| #include "base/callback.h" |
| #include "base/memory/ref_counted.h" |
| +#include "media/base/audio_decoder.h" |
| #include "media/base/media_export.h" |
| namespace media { |
| +class AudioDecoderConfig; |
| +class Buffer; |
| class DecoderBuffer; |
| class VideoDecoderConfig; |
| class VideoFrame; |
| @@ -46,6 +50,11 @@ class MEDIA_EXPORT Decryptor { |
| kError // Key is available but an error occurred during decryption. |
| }; |
| + enum StreamType { |
| + kAudio, |
| + kVideo |
| + }; |
| + |
| Decryptor(); |
| virtual ~Decryptor(); |
| @@ -89,17 +98,20 @@ class MEDIA_EXPORT Decryptor { |
| // Decrypts the |encrypted| buffer. The decrypt status and decrypted buffer |
| // are returned via the provided callback |decrypt_cb|. The |encrypted| buffer |
| // must not be NULL. |
| - // Decrypt() should not be called until any previous DecryptCB has completed. |
| - // Thus, only one DecryptCB may be pending at a time. |
| - virtual void Decrypt(const scoped_refptr<DecoderBuffer>& encrypted, |
| + // Decrypt() should not be called until any previous DecryptCB of the same |
| + // |stream_type| has completed. Thus, only one DecryptCB may be pending at |
| + // a time for a given |stream_type|. |
| + virtual void Decrypt(StreamType stream_type, |
| + const scoped_refptr<DecoderBuffer>& encrypted, |
| const DecryptCB& decrypt_cb) = 0; |
| - // Cancels the scheduled decryption operation and fires the pending DecryptCB |
| - // immediately with kSuccess and NULL. |
| - // Decrypt() should not be called again before the pending DecryptCB is fired. |
| - virtual void CancelDecrypt() = 0; |
| + // Cancels the scheduled decryption operation for |stream_type| and fires the |
| + // pending DecryptCB immediately with kSuccess and NULL. |
| + // Decrypt() should not be called again before the pending DecryptCB for the |
| + // same |stream_type| is fired. |
| + virtual void CancelDecrypt(StreamType stream_type) = 0; |
| - // Indicates completion of decoder initialization. |
| + // Indicates completion of audio/video decoder initialization. |
| // |
| // First Parameter: Indicates initialization success. |
| // - Set to true if initialization was successful. False if an error occurred. |
| @@ -108,50 +120,69 @@ class MEDIA_EXPORT Decryptor { |
| // Indicates that a key has been added to the Decryptor. |
| typedef base::Callback<void()> KeyAddedCB; |
| - // Initializes a video decoder with the given |config|, executing the |
| - // |init_cb| upon completion. |
| - // Note: DecryptAndDecodeVideo(), ResetVideoDecoder() and StopVideoDecoder() |
| - // can only be called after InitializeVideoDecoder() succeeded. |
| + // Initializes a decoder with the given |config|, executing the |init_cb| |
| + // upon completion. |
| + // |key_added_cb| should be called when a key is added to the decryptor. |
| + virtual void InitializeAudioDecoder(scoped_ptr<AudioDecoderConfig> config, |
| + const DecoderInitCB& init_cb, |
| + const KeyAddedCB& key_added_cb) = 0; |
| virtual void InitializeVideoDecoder(scoped_ptr<VideoDecoderConfig> config, |
| const DecoderInitCB& init_cb, |
| const KeyAddedCB& key_added_cb) = 0; |
| - // Indicates completion of video decrypting and decoding operation. |
| + // Helper structure for managing multiple decoded audio buffers per input. |
| + typedef std::list<scoped_refptr<Buffer> > AudioBuffers; |
|
xhwang
2012/10/17 00:18:59
One status per decode call should be sufficient. D
|
| + |
| + // Indicates completion of audio/video decrypt-and-decode operation. |
| // |
| - // First parameter: The status of the decrypting and decoding operation. |
| + // First parameter: The status of the decrypt-and-decode operation. |
| // - Set to kSuccess if the encrypted buffer is successfully decrypted and |
| - // decoded. In this case, the decoded video frame can be: |
| + // decoded. In this case, the decoded frame/buffers can be/contain: |
| // 1) NULL, which means the operation has been aborted. |
| // 2) End-of-stream (EOS) frame, which means that the decoder has hit EOS, |
| // flushed all internal buffers and cannot produce more video frames. |
| - // 3) Decrypted and decoded video frame. |
| + // 3) Decrypted and decoded video frame or audio buffer. |
| // - Set to kNoKey if no decryption key is available to decrypt the encrypted |
| - // buffer. In this case the decoded video frame must be NULL. |
| + // buffer. In this case the second parameter must be NULL. |
|
ddorwin
2012/10/17 02:52:33
s/second/buffer/ (or data or something)
I realize
xhwang
2012/10/17 22:29:06
Done.
|
| // - Set to kNeedMoreData if more data is needed to produce a video frame. In |
| - // this case the decoded video frame must be NULL. |
| + // this case the second parameter must be NULL. |
| // - Set to kError if unexpected error has occurred. In this case the |
| - // decoded video frame must be NULL. |
| - // Second parameter: The decoded video frame. |
| + // second parameter must be NULL. |
| + // Second parameter: The decoded video frame or audio buffers. |
| + typedef base::Callback<void(Status, |
| + const scoped_ptr<AudioBuffers>&)> AudioDecodeCB; |
| typedef base::Callback<void(Status, |
| const scoped_refptr<VideoFrame>&)> VideoDecodeCB; |
| // Decrypts and decodes the |encrypted| buffer. The status and the decrypted |
| - // buffer are returned via the provided callback |video_decode_cb|. |
| + // buffer are returned via the provided callback. |
| // The |encrypted| buffer must not be NULL. |
| // At end-of-stream, this method should be called repeatedly with |
| - // end-of-stream DecoderBuffer until no video frame can be produced. |
| + // end-of-stream DecoderBuffer until no frame/buffer can be produced. |
| + // These two methods can only be called after the corresponding decoder has |
|
ddorwin
2012/10/17 02:52:33
s/two//
xhwang
2012/10/17 22:29:06
Done.
|
| + // been successfully initialized. |
| + virtual void DecryptAndDecodeAudio( |
| + const scoped_refptr<DecoderBuffer>& encrypted, |
| + const AudioDecodeCB& audio_decode_cb) = 0; |
| virtual void DecryptAndDecodeVideo( |
| const scoped_refptr<DecoderBuffer>& encrypted, |
| const VideoDecodeCB& video_decode_cb) = 0; |
| - // Cancels scheduled video decrypt-and-decode operations and fires any pending |
| - // VideoDecodeCB immediately with kError and NULL frame. |
| - virtual void CancelDecryptAndDecodeVideo() = 0; |
| - |
| - // Stops decoder and sets it to an uninitialized state. |
| - // The decoder can be reinitialized by calling InitializeVideoDecoder() after |
| - // it is stopped. |
| - virtual void StopVideoDecoder() = 0; |
| + // Resets the decoder to an initialized clean state, cancels any scheduled |
| + // decrypt-and-decode operations and fires any pending |
|
ddorwin
2012/10/17 02:52:33
A comma before a >2 item "and" would probably be h
xhwang
2012/10/17 22:29:06
Done.
|
| + // AudioDecodeCB/VideoDecodeCB immediately with kError and NULL. |
| + // This method can only be called after the corresponding decoder has been |
| + // successfully initialized. |
| + virtual void ResetDecoder(StreamType stream_type) = 0; |
| + |
| + // Uninitializes the decoder and sets it to an uninitialized state, cancels |
|
ddorwin
2012/10/17 02:52:33
// Frees decoder resources and...?
ddorwin
2012/10/17 07:16:05
s/Frees/Releases/
xhwang
2012/10/17 22:29:06
Done.
xhwang
2012/10/17 22:29:06
Done.
|
| + // any scheduled initialization or decrypt-and-decode operations and fires |
| + // any pending DecoderInitCB/AudioDecodeCB/VideoDecodeCB immediately with |
| + // false or kError/NULL respectively. |
|
ddorwin
2012/10/17 02:52:33
It's not clear how these map respectively since th
xhwang
2012/10/17 22:29:06
Done.
|
| + // This method can be called any time after Initialize{Audio|Video}Decoder() |
| + // has been called (with the correct stream type). |
| + // The decoder can be reinitialized after it is uninitialized. |
| + virtual void DeinitializeDecoder(StreamType stream_type) = 0; |
| private: |
| DISALLOW_COPY_AND_ASSIGN(Decryptor); |