diff options
author | jrummell <jrummell@chromium.org> | 2014-11-03 16:07:44 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-04 00:07:58 +0000 |
commit | 5b104332eb9ca3161a69e75ef168c62c765b3e29 (patch) | |
tree | 69be2824e0ce5fbf517a886809f177f70c9e222e /content/renderer | |
parent | da3c4f9c6d8b2c0e62bb25b7a9ef6b82e7903c6a (diff) | |
download | chromium_src-5b104332eb9ca3161a69e75ef168c62c765b3e29.zip chromium_src-5b104332eb9ca3161a69e75ef168c62c765b3e29.tar.gz chromium_src-5b104332eb9ca3161a69e75ef168c62c765b3e29.tar.bz2 |
Resume playback of EME stream only on SessionKeysChange event.
Now that the CDM is generating SessionKeysChange events, it is no
longer necessary to intercept Update() and Load() promises and
call ResumePlayback() when they are resolved.
BUG=370251,413413
TEST=existing EME tests pass
Review URL: https://codereview.chromium.org/697203003
Cr-Commit-Position: refs/heads/master@{#302526}
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/media/crypto/ppapi_decryptor.cc | 95 | ||||
-rw-r--r-- | content/renderer/media/crypto/ppapi_decryptor.h | 3 |
2 files changed, 6 insertions, 92 deletions
diff --git a/content/renderer/media/crypto/ppapi_decryptor.cc b/content/renderer/media/crypto/ppapi_decryptor.cc index 137e16c..1af098c 100644 --- a/content/renderer/media/crypto/ppapi_decryptor.cc +++ b/content/renderer/media/crypto/ppapi_decryptor.cc @@ -7,9 +7,6 @@ #include <string> #include "base/bind.h" -#include "base/callback.h" -#include "base/callback_helpers.h" -#include "base/location.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop_proxy.h" @@ -17,7 +14,6 @@ #include "content/renderer/pepper/content_decryptor_delegate.h" #include "content/renderer/pepper/pepper_plugin_instance_impl.h" #include "media/base/audio_decoder_config.h" -#include "media/base/cdm_promise.h" #include "media/base/data_buffer.h" #include "media/base/decoder_buffer.h" #include "media/base/video_decoder_config.h" @@ -25,63 +21,6 @@ namespace content { -// This class is needed so that resolving an Update() promise triggers playback -// of the stream. It intercepts the resolve() call to invoke an additional -// callback. -class SessionUpdatedPromise : public media::CdmPromiseTemplate<> { - public: - SessionUpdatedPromise(scoped_ptr<media::SimpleCdmPromise> caller_promise, - const base::Closure& additional_resolve_cb) - : caller_promise_(caller_promise.Pass()), - additional_resolve_cb_(additional_resolve_cb) {} - - void resolve() override { - MarkPromiseSettled(); - additional_resolve_cb_.Run(); - caller_promise_->resolve(); - } - - void reject(media::MediaKeys::Exception exception_code, - uint32 system_code, - const std::string& error_message) override { - MarkPromiseSettled(); - caller_promise_->reject(exception_code, system_code, error_message); - } - - protected: - scoped_ptr<media::SimpleCdmPromise> caller_promise_; - base::Closure additional_resolve_cb_; -}; - -// This class is needed so that resolving a SessionLoaded() promise triggers -// playback of the stream. It intercepts the resolve() call to invoke an -// additional callback. This is only needed until KeysChange event gets passed -// through Pepper. -class SessionLoadedPromise : public media::CdmPromiseTemplate<std::string> { - public: - SessionLoadedPromise(scoped_ptr<media::NewSessionCdmPromise> caller_promise, - const base::Closure& additional_resolve_cb) - : caller_promise_(caller_promise.Pass()), - additional_resolve_cb_(additional_resolve_cb) {} - - void resolve(const std::string& web_session_id) override { - MarkPromiseSettled(); - additional_resolve_cb_.Run(); - caller_promise_->resolve(web_session_id); - } - - void reject(media::MediaKeys::Exception exception_code, - uint32 system_code, - const std::string& error_message) override { - MarkPromiseSettled(); - caller_promise_->reject(exception_code, system_code, error_message); - } - - protected: - scoped_ptr<media::NewSessionCdmPromise> caller_promise_; - base::Closure additional_resolve_cb_; -}; - scoped_ptr<PpapiDecryptor> PpapiDecryptor::Create( const std::string& key_system, const GURL& security_origin, @@ -201,15 +140,7 @@ void PpapiDecryptor::LoadSession( promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); return; } - - // TODO(jrummell): Intercepting the promise should not be necessary once - // OnSessionKeysChange() is called in all cases. http://crbug.com/413413. - scoped_ptr<SessionLoadedPromise> session_loaded_promise( - new SessionLoadedPromise(promise.Pass(), - base::Bind(&PpapiDecryptor::ResumePlayback, - weak_ptr_factory_.GetWeakPtr()))); - - CdmDelegate()->LoadSession(web_session_id, session_loaded_promise.Pass()); + CdmDelegate()->LoadSession(web_session_id, promise.Pass()); } void PpapiDecryptor::UpdateSession( @@ -223,17 +154,8 @@ void PpapiDecryptor::UpdateSession( promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); return; } - - // TODO(jrummell): Intercepting the promise should not be necessary once - // OnSessionKeysChange() is called in all cases. http://crbug.com/413413. - scoped_ptr<SessionUpdatedPromise> session_updated_promise( - new SessionUpdatedPromise(promise.Pass(), - base::Bind(&PpapiDecryptor::ResumePlayback, - weak_ptr_factory_.GetWeakPtr()))); - CdmDelegate()->UpdateSession(web_session_id, - response, - response_length, - session_updated_promise.Pass()); + CdmDelegate()->UpdateSession(web_session_id, response, response_length, + promise.Pass()); } void PpapiDecryptor::CloseSession(const std::string& web_session_id, @@ -492,7 +414,7 @@ void PpapiDecryptor::OnSessionKeysChange(const std::string& web_session_id, // TODO(jrummell): Handling resume playback should be done in the media // player, not in the Decryptors. http://crbug.com/413413. if (has_additional_usable_key) - ResumePlayback(); + AttemptToResumePlayback(); session_keys_change_cb_.Run(web_session_id, has_additional_usable_key); } @@ -506,10 +428,6 @@ void PpapiDecryptor::OnSessionExpirationUpdate( void PpapiDecryptor::OnSessionReady(const std::string& web_session_id) { DCHECK(render_loop_proxy_->BelongsToCurrentThread()); - - // TODO(jrummell): Calling ResumePlayback() here should not be necessary once - // OnSessionKeysChange() is called in all cases. http://crbug.com/413413. - ResumePlayback(); session_ready_cb_.Run(web_session_id); } @@ -527,10 +445,7 @@ void PpapiDecryptor::OnSessionError(const std::string& web_session_id, web_session_id, exception_code, system_code, error_description); } -void PpapiDecryptor::ResumePlayback() { - // Based on the spec, we need to resume playback when update() completes - // successfully, or when a session is successfully loaded (triggered by - // OnSessionReady()). So we choose to call the NewKeyCBs here. +void PpapiDecryptor::AttemptToResumePlayback() { if (!new_audio_key_cb_.is_null()) new_audio_key_cb_.Run(); diff --git a/content/renderer/media/crypto/ppapi_decryptor.h b/content/renderer/media/crypto/ppapi_decryptor.h index 0c4c0dd..39c38c2 100644 --- a/content/renderer/media/crypto/ppapi_decryptor.h +++ b/content/renderer/media/crypto/ppapi_decryptor.h @@ -116,8 +116,7 @@ class PpapiDecryptor : public media::MediaKeys, public media::Decryptor { uint32 system_code, const std::string& error_description); - // On a successful Update() or SessionReady event, trigger playback to resume. - void ResumePlayback(); + void AttemptToResumePlayback(); // Callback to notify that a fatal error happened in |plugin_cdm_delegate_|. // The error is terminal and |plugin_cdm_delegate_| should not be used after |