diff options
author | xhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 23:04:03 +0000 |
---|---|---|
committer | xhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 23:04:03 +0000 |
commit | 82d7abd7b2726db828134466e4bd98910246d41f (patch) | |
tree | 4a16ab1817df9f1ba4e758c303ddef271fa7d27e /media/crypto | |
parent | a45d8566cf820425ce3c95d3b5d21950767f3b0e (diff) | |
download | chromium_src-82d7abd7b2726db828134466e4bd98910246d41f.zip chromium_src-82d7abd7b2726db828134466e4bd98910246d41f.tar.gz chromium_src-82d7abd7b2726db828134466e4bd98910246d41f.tar.bz2 |
Add RegisterKeyAddedCB in Decryptor interface.
Previously KeyAddedCB is registered with InitializeXXXDecoder calls. Generalize this to a separate RegisterKeyAddedCB call so that we can also support the decrypt-only path.
BUG=123421
TEST=media_unittests passes. EME demo page still works.
Review URL: https://chromiumcodereview.appspot.com/11348056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165792 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/crypto')
-rw-r--r-- | media/crypto/aes_decryptor.cc | 27 | ||||
-rw-r--r-- | media/crypto/aes_decryptor.h | 11 |
2 files changed, 30 insertions, 8 deletions
diff --git a/media/crypto/aes_decryptor.cc b/media/crypto/aes_decryptor.cc index fe964f6c..fb16486 100644 --- a/media/crypto/aes_decryptor.cc +++ b/media/crypto/aes_decryptor.cc @@ -194,6 +194,13 @@ void AesDecryptor::AddKey(const std::string& key_system, } SetKey(key_id_string, decryption_key.Pass()); + + if (!audio_key_added_cb_.is_null()) + audio_key_added_cb_.Run(); + + if (!video_key_added_cb_.is_null()) + video_key_added_cb_.Run(); + client_->KeyAdded(key_system, session_id); } @@ -201,6 +208,20 @@ void AesDecryptor::CancelKeyRequest(const std::string& key_system, const std::string& session_id) { } +void AesDecryptor::RegisterKeyAddedCB(StreamType stream_type, + const KeyAddedCB& key_added_cb) { + switch (stream_type) { + case kAudio: + audio_key_added_cb_ = key_added_cb; + break; + case kVideo: + video_key_added_cb_ = key_added_cb; + break; + default: + NOTREACHED(); + } +} + void AesDecryptor::Decrypt(StreamType stream_type, const scoped_refptr<DecoderBuffer>& encrypted, const DecryptCB& decrypt_cb) { @@ -240,15 +261,13 @@ void AesDecryptor::CancelDecrypt(StreamType stream_type) { } void AesDecryptor::InitializeAudioDecoder(scoped_ptr<AudioDecoderConfig> config, - const DecoderInitCB& init_cb, - const KeyAddedCB& key_added_cb) { + const DecoderInitCB& init_cb) { // AesDecryptor does not support audio decoding. init_cb.Run(false); } void AesDecryptor::InitializeVideoDecoder(scoped_ptr<VideoDecoderConfig> config, - const DecoderInitCB& init_cb, - const KeyAddedCB& key_added_cb) { + const DecoderInitCB& init_cb) { // AesDecryptor does not support video decoding. init_cb.Run(false); } diff --git a/media/crypto/aes_decryptor.h b/media/crypto/aes_decryptor.h index 966738b..e983805 100644 --- a/media/crypto/aes_decryptor.h +++ b/media/crypto/aes_decryptor.h @@ -46,16 +46,16 @@ class MEDIA_EXPORT AesDecryptor : public Decryptor { const std::string& session_id) OVERRIDE; virtual void CancelKeyRequest(const std::string& key_system, const std::string& session_id) OVERRIDE; + virtual void RegisterKeyAddedCB(StreamType stream_type, + const KeyAddedCB& key_added_cb) OVERRIDE; virtual void Decrypt(StreamType stream_type, const scoped_refptr<DecoderBuffer>& encrypted, const DecryptCB& decrypt_cb) OVERRIDE; virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; virtual void InitializeAudioDecoder(scoped_ptr<AudioDecoderConfig> config, - const DecoderInitCB& init_cb, - const KeyAddedCB& key_added_cb) OVERRIDE; + const DecoderInitCB& init_cb) OVERRIDE; virtual void InitializeVideoDecoder(scoped_ptr<VideoDecoderConfig> config, - const DecoderInitCB& init_cb, - const KeyAddedCB& key_added_cb) OVERRIDE; + const DecoderInitCB& init_cb) OVERRIDE; virtual void DecryptAndDecodeAudio( const scoped_refptr<DecoderBuffer>& encrypted, const AudioDecodeCB& audio_decode_cb) OVERRIDE; @@ -113,6 +113,9 @@ class MEDIA_EXPORT AesDecryptor : public Decryptor { DecryptorClient* const client_; + KeyAddedCB audio_key_added_cb_; + KeyAddedCB video_key_added_cb_; + DISALLOW_COPY_AND_ASSIGN(AesDecryptor); }; |