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

Unified Diff: media/base/decryptor.h

Issue 10969028: Add video decoding methods in Decryptor and add DecryptingVideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reorder methods in the unittest Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/base/decryptor.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/decryptor.h
diff --git a/media/base/decryptor.h b/media/base/decryptor.h
index 01372cbbeed2435fca1fc74c4233cdf167cfa6c8..876129a24aedff316017bc2d978eef5487eb2763 100644
--- a/media/base/decryptor.h
+++ b/media/base/decryptor.h
@@ -15,12 +15,19 @@
namespace media {
class DecoderBuffer;
-
-// Performs key operations and decrypts encrypted buffer.
-// All public methods other than Decrypt() will be called on the renderer
-// thread. Therefore, these calls should be fast and nonblocking, with key
-// events fired asynchronously. Decrypt() will be called on the (video/audio)
-// decoder thread.
+class VideoDecoderConfig;
+class VideoFrame;
+
+// Performs key operations and decrypts (and decodes) encrypted buffer.
+//
+// Key operations (GenerateKeyRequest(), AddKey() and CancelKeyRequest())
+// are called on the renderer thread. Therefore, these calls should be fast
+// and nonblocking; key events should be fired asynchronously.
+// All other methods are called on the (video/audio) decoder thread.
+// Decryptor implementations must be thread safe when methods are called
+// following the above model.
+// Depending on the implementation callbacks may be fired synchronously or
+// asynchronously.
class MEDIA_EXPORT Decryptor {
public:
enum KeyError {
@@ -35,11 +42,12 @@ class MEDIA_EXPORT Decryptor {
enum Status {
kSuccess, // Decryption successfully completed. Decrypted buffer ready.
kNoKey, // No key is available to decrypt.
+ kNeedMoreData, // Decoder needs more data to produce a frame.
kError // Key is available but an error occurred during decryption.
};
- Decryptor() {}
- virtual ~Decryptor() {}
+ Decryptor();
+ virtual ~Decryptor();
// Generates a key request for the |key_system| with |init_data| provided.
// Returns true if generating key request succeeded, false otherwise.
@@ -64,21 +72,25 @@ class MEDIA_EXPORT Decryptor {
virtual void CancelKeyRequest(const std::string& key_system,
const std::string& session_id) = 0;
+ // Indicates completion of a decryption operation.
+ //
+ // First parameter: The status of the decryption operation.
+ // - Set to kSuccess if the encrypted buffer is successfully decrypted and
+ // the decrypted buffer is ready to be read.
+ // - Set to kNoKey if no decryption key is available to decrypt the encrypted
+ // buffer. In this case the decrypted buffer must be NULL.
+ // - Set to kError if unexpected error has occurred. In this case the
+ // decrypted buffer must be NULL.
+ // - This parameter should not be set to kNeedMoreData.
+ // Second parameter: The decrypted buffer.
+ typedef base::Callback<void(Status,
+ const scoped_refptr<DecoderBuffer>&)> DecryptCB;
+
// 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.
- // Note that the callback maybe called synchronously or asynchronously.
- //
- // If the returned status is kSuccess, the |encrypted| buffer is successfully
- // decrypted and the decrypted buffer is ready to be read.
- // If the returned status is kNoKey, no decryption key is available to decrypt
- // |encrypted| buffer. In this case the decrypted buffer must be NULL.
- // If the returned status is kError, unexpected error has occurred. In this
- // case the decrypted buffer must be NULL.
- typedef base::Callback<void(Status,
- const scoped_refptr<DecoderBuffer>&)> DecryptCB;
virtual void Decrypt(const scoped_refptr<DecoderBuffer>& encrypted,
const DecryptCB& decrypt_cb) = 0;
@@ -87,6 +99,56 @@ class MEDIA_EXPORT Decryptor {
// Decrypt() should not be called again before the pending DecryptCB is fired.
virtual void CancelDecrypt() = 0;
+ // Indicates completion of decoder initialization.
+ //
+ // First Parameter: Indicates initialization success.
+ // - Set to true if initialization was successful. False if an error occurred.
+ typedef base::Callback<void(bool)> DecoderInitCB;
+
+ // 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.
+ virtual void InitializeVideoDecoder(const VideoDecoderConfig& config,
+ const DecoderInitCB& init_cb) = 0;
+
+ // Indicates completion of video decrypting and decoding operation.
+ //
+ // First parameter: The status of the decrypting and decoding operation.
+ // - Set to kSuccess if the encrypted buffer is successfully decrypted and
+ // decoded. In this case, the decoded video frame can be:
+ // 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.
+ // - Set to kNoKey if no decryption key is available to decrypt the encrypted
+ // buffer. In this case the decoded video frame must be NULL.
+ // - Set to kNeedMoreData if more data is needed to produce a video frame. In
+ // this case the decoded video frame 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.
+ 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|.
+ // 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.
+ 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;
+
private:
DISALLOW_COPY_AND_ASSIGN(Decryptor);
};
« no previous file with comments | « no previous file | media/base/decryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698