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

Unified Diff: media/base/android/media_source_player.cc

Issue 1512173003: media: Refactor MediaCrypto creation and notification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
Index: media/base/android/media_source_player.cc
diff --git a/media/base/android/media_source_player.cc b/media/base/android/media_source_player.cc
index 8aec0ab31f907c76f5cfcae34d2b4a707390bde8..38afb9a30850b3baf6ed80d26b0655f4c7adacf9 100644
--- a/media/base/android/media_source_player.cc
+++ b/media/base/android/media_source_player.cc
@@ -266,11 +266,16 @@ void MediaSourcePlayer::OnDemuxerDurationChanged(base::TimeDelta duration) {
}
void MediaSourcePlayer::OnMediaCryptoReady(
- MediaDrmBridge::JavaObjectPtr /* media_crypto */,
+ MediaDrmBridge::JavaObjectPtr media_crypto,
bool /* needs_protected_surface */) {
- // Callback parameters are ignored in this player. They are intended for
- // MediaCodecPlayer which uses a different threading scheme.
- DCHECK(!static_cast<MediaDrmBridge*>(cdm_.get())->GetMediaCrypto().is_null());
+ DCHECK(media_crypto);
+ DCHECK(static_cast<MediaDrmBridge*>(cdm_.get())->GetMediaCrypto());
Tima Vaisburd 2015/12/11 02:15:21 Shall we propagate |media_crypto| parameter to Med
xhwang 2015/12/11 05:50:19 Yes, that would be the correct fix. However, sinc
Tima Vaisburd 2015/12/11 19:31:24 As far as I know the switching between MediaSource
xhwang 2015/12/11 21:45:16 Yes, in that case, it's nice to make this change.
+
+ if (media_crypto->is_null()) {
+ // TODO(xhwang): Fail playback nicely here.
+ LOG(ERROR) << "MediaCrypto creation failed!";
+ return;
+ }
// Retry decoder creation if the decoders are waiting for MediaCrypto.
RetryDecoderCreation(true, true);
@@ -306,16 +311,9 @@ void MediaSourcePlayer::SetCdm(const scoped_refptr<MediaKeys>& cdm) {
audio_decoder_job_->SetDrmBridge(drm_bridge);
video_decoder_job_->SetDrmBridge(drm_bridge);
- if (drm_bridge->GetMediaCrypto().is_null()) {
- // Use BindToCurrentLoop to avoid reentrancy.
- MediaDrmBridge::MediaCryptoReadyCB cb = BindToCurrentLoop(
- base::Bind(&MediaSourcePlayer::OnMediaCryptoReady, weak_this_));
- drm_bridge->SetMediaCryptoReadyCB(cb);
- return;
- }
-
- // If the player is previously waiting for CDM, retry decoder creation.
- RetryDecoderCreation(true, true);
+ // Use BindToCurrentLoop to avoid reentrancy.
+ drm_bridge->SetMediaCryptoReadyCB(BindToCurrentLoop(
+ base::Bind(&MediaSourcePlayer::OnMediaCryptoReady, weak_this_)));
}
void MediaSourcePlayer::OnDemuxerSeekDone(

Powered by Google App Engine
This is Rietveld 408576698