Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 3f1b97b

Browse files
MediaSourceDelegate: Fix DecryptingDemuxerStream initialization logic.
Different CDMs are supported differently. For CDMs that support a Decryptor, we'll try to use DecryptingDemuxerStream in the render side. Otherwise, we'll try to use the CDMs in the browser side. Therefore, if DecryptingDemuxerStream initialization failed, it's still possible that we can handle the audio with a CDM in the browser. Declare demuxer ready now to try that path. Note there's no need to try DecryptingDemuxerStream for video here since it is impossible to handle audio in the browser and handle video in the render process. This also fixes the issue where CdmAttachedCB is fired twice with "false". BUG=578203 TEST=No DCHECK when playing media/L3_audio_L3_video.mp4.mpd. Review URL: https://codereview.chromium.org/1613793002 Cr-Commit-Position: refs/heads/master@{#372842} (cherry picked from commit e261467) Review URL: https://codereview.chromium.org/1659013002 . Cr-Commit-Position: refs/branch-heads/2623@{#234} Cr-Branched-From: 92d7753-refs/heads/master@{#369907}
1 parent a28c9ad commit 3f1b97b

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

content/renderer/media/android/media_source_delegate.cc

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ void MediaSourceDelegate::InitializeMediaSource(
153153
const base::Closure& waiting_for_decryption_key_cb) {
154154
DCHECK(main_task_runner_->BelongsToCurrentThread());
155155
DCHECK(!media_source_opened_cb.is_null());
156+
DCHECK(!encrypted_media_init_data_cb.is_null());
157+
DCHECK(!set_cdm_ready_cb.is_null());
158+
DCHECK(!update_network_state_cb.is_null());
159+
DCHECK(!duration_change_cb.is_null());
160+
DCHECK(!waiting_for_decryption_key_cb.is_null());
161+
156162
media_source_opened_cb_ = media_source_opened_cb;
157163
encrypted_media_init_data_cb_ = encrypted_media_init_data_cb;
158164
set_cdm_ready_cb_ = media::BindToCurrentLoop(set_cdm_ready_cb);
@@ -496,16 +502,14 @@ void MediaSourceDelegate::OnDemuxerInitDone(media::PipelineStatus status) {
496502
audio_stream_ = chunk_demuxer_->GetStream(DemuxerStream::AUDIO);
497503
video_stream_ = chunk_demuxer_->GetStream(DemuxerStream::VIDEO);
498504

499-
if (audio_stream_ && audio_stream_->audio_decoder_config().is_encrypted() &&
500-
!set_cdm_ready_cb_.is_null()) {
505+
if (audio_stream_ && audio_stream_->audio_decoder_config().is_encrypted()) {
501506
InitAudioDecryptingDemuxerStream();
502507
// InitVideoDecryptingDemuxerStream() will be called in
503508
// OnAudioDecryptingDemuxerStreamInitDone().
504509
return;
505510
}
506511

507-
if (video_stream_ && video_stream_->video_decoder_config().is_encrypted() &&
508-
!set_cdm_ready_cb_.is_null()) {
512+
if (video_stream_ && video_stream_->video_decoder_config().is_encrypted()) {
509513
InitVideoDecryptingDemuxerStream();
510514
return;
511515
}
@@ -519,7 +523,6 @@ void MediaSourceDelegate::InitAudioDecryptingDemuxerStream() {
519523
DCHECK(media_task_runner_->BelongsToCurrentThread());
520524
DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_;
521525
DCHECK(!set_cdm_ready_cb_.is_null());
522-
523526
audio_decrypting_demuxer_stream_.reset(new media::DecryptingDemuxerStream(
524527
media_task_runner_, media_log_, waiting_for_decryption_key_cb_));
525528
audio_decrypting_demuxer_stream_->Initialize(
@@ -547,10 +550,22 @@ void MediaSourceDelegate::OnAudioDecryptingDemuxerStreamInitDone(
547550
DVLOG(1) << __FUNCTION__ << "(" << status << ") : " << demuxer_client_id_;
548551
DCHECK(chunk_demuxer_);
549552

550-
if (status != media::PIPELINE_OK)
553+
if (status != media::PIPELINE_OK) {
551554
audio_decrypting_demuxer_stream_.reset();
552-
else
553-
audio_stream_ = audio_decrypting_demuxer_stream_.get();
555+
// Different CDMs are supported differently. For CDMs that support a
556+
// Decryptor, we'll try to use DecryptingDemuxerStream in the render side.
557+
// Otherwise, we'll try to use the CDMs in the browser side. Therefore, if
558+
// DecryptingDemuxerStream initialization failed, it's still possible that
559+
// we can handle the audio with a CDM in the browser. Declare demuxer ready
560+
// now to try that path. Note there's no need to try DecryptingDemuxerStream
561+
// for video here since it is impossible to handle audio in the browser and
562+
// handle video in the render process.
563+
is_demuxer_ready_ = true;
564+
NotifyDemuxerReady();
565+
return;
566+
}
567+
568+
audio_stream_ = audio_decrypting_demuxer_stream_.get();
554569

555570
if (video_stream_ && video_stream_->video_decoder_config().is_encrypted()) {
556571
InitVideoDecryptingDemuxerStream();

0 commit comments

Comments
 (0)