diff options
author | xhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-30 00:40:57 +0000 |
---|---|---|
committer | xhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-30 00:40:57 +0000 |
commit | 15b05a7d37381e8487fb7eebf2d90355a8774431 (patch) | |
tree | 3bfd05db47b68792b3dbd9c6b72f158e47cccb10 /media/base/decryptor.h | |
parent | 2dcec1fbb4343693721ec1b81452a93883efbc2e (diff) | |
download | chromium_src-15b05a7d37381e8487fb7eebf2d90355a8774431.zip chromium_src-15b05a7d37381e8487fb7eebf2d90355a8774431.tar.gz chromium_src-15b05a7d37381e8487fb7eebf2d90355a8774431.tar.bz2 |
Separate MediaKeys interface from Decryptor interface.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/15772012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/decryptor.h')
-rw-r--r-- | media/base/decryptor.h | 80 |
1 files changed, 11 insertions, 69 deletions
diff --git a/media/base/decryptor.h b/media/base/decryptor.h index e3a2cb6..f3a3c22 100644 --- a/media/base/decryptor.h +++ b/media/base/decryptor.h @@ -6,7 +6,6 @@ #define MEDIA_BASE_DECRYPTOR_H_ #include <list> -#include <string> #include "base/basictypes.h" #include "base/callback.h" @@ -18,34 +17,18 @@ namespace media { class AudioDecoderConfig; class DataBuffer; class DecoderBuffer; +class MediaKeys; class VideoDecoderConfig; class VideoFrame; -// Performs key operations and decrypts (and decodes) encrypted buffer. +// 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. +// All methods are called on the (video/audio) decoder thread. Decryptor +// implementations must be thread safe when methods are called this way. // Depending on the implementation callbacks may be fired synchronously or // asynchronously. class MEDIA_EXPORT Decryptor { public: - // Reported to UMA, so never reuse a value! - // Must be kept in sync with WebKit::WebMediaPlayerClient::MediaKeyErrorCode - // (enforced in webmediaplayer_impl.cc). - enum KeyError { - kUnknownError = 1, - kClientError, - kServiceError, - kOutputError, - kHardwareChangeError, - kDomainError, - kMaxKeyError // Must be last and greater than any legit value. - }; - // TODO(xhwang): Replace kError with kDecryptError and kDecodeError. // TODO(xhwang): Replace kNeedMoreData with kNotEnoughData. enum Status { @@ -64,32 +47,13 @@ class MEDIA_EXPORT Decryptor { Decryptor(); virtual ~Decryptor(); - // Generates a key request for the |key_system| with |type| and - // |init_data| provided. - // Returns true if generating key request succeeded, false otherwise. - // Note: AddKey() and CancelKeyRequest() should only be called after - // GenerateKeyRequest() returns true. - virtual bool GenerateKeyRequest(const std::string& key_system, - const std::string& type, - const uint8* init_data, - int init_data_length) = 0; - - // Adds a |key| to the |key_system|. The |key| is not limited to a decryption - // key. It can be any data that the key system accepts, such as a license. - // If multiple calls of this function set different keys for the same - // key ID, the older key will be replaced by the newer key. - virtual void AddKey(const std::string& key_system, - const uint8* key, - int key_length, - const uint8* init_data, - int init_data_length, - const std::string& session_id) = 0; - - // Cancels the key request specified by |session_id|. - virtual void CancelKeyRequest(const std::string& key_system, - const std::string& session_id) = 0; - - // Indicates that a new key has been added to the Decryptor. + // Gets the MediaKey object associated with the Decryptor. Returns NULL if + // no MediaKey object is associated. The returned object is only guaranteed + // to be valid during the Decryptor's lifetime. + virtual MediaKeys* GetMediaKeys() = 0; + + // Indicates that a new key has been added to the MediaKeys object associated + // with the Decryptor. typedef base::Callback<void()> NewKeyCB; // Registers a NewKeyCB which should be called when a new key is added to the @@ -215,28 +179,6 @@ typedef base::Callback<void(Decryptor*)> DecryptorReadyCB; // fired immediately with NULL. typedef base::Callback<void(const DecryptorReadyCB&)> SetDecryptorReadyCB; - -// Key event callbacks. See the spec for details: -// http://dvcs.w3.org/hg/html-media/raw-file/eme-v0.1b/encrypted-media/encrypted-media.html#event-summary -typedef base::Callback<void(const std::string& key_system, - const std::string& session_id)> KeyAddedCB; - -typedef base::Callback<void(const std::string& key_system, - const std::string& session_id, - media::Decryptor::KeyError error_code, - int system_code)> KeyErrorCB; - -typedef base::Callback<void(const std::string& key_system, - const std::string& session_id, - const std::string& message, - const std::string& default_url)> KeyMessageCB; - -typedef base::Callback<void(const std::string& key_system, - const std::string& session_id, - const std::string& type, - scoped_ptr<uint8[]> init_data, - int init_data_size)> NeedKeyCB; - } // namespace media #endif // MEDIA_BASE_DECRYPTOR_H_ |