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

Side by Side Diff: content/renderer/media/android/media_source_delegate.cc

Issue 1613793002: MediaSourceDelegate: Fix DecryptingDemuxerStream initialization logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/android/media_source_delegate.h" 5 #include "content/renderer/media/android/media_source_delegate.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 void MediaSourceDelegate::InitializeMediaSource( 146 void MediaSourceDelegate::InitializeMediaSource(
147 const MediaSourceOpenedCB& media_source_opened_cb, 147 const MediaSourceOpenedCB& media_source_opened_cb,
148 const media::Demuxer::EncryptedMediaInitDataCB& 148 const media::Demuxer::EncryptedMediaInitDataCB&
149 encrypted_media_init_data_cb, 149 encrypted_media_init_data_cb,
150 const media::SetCdmReadyCB& set_cdm_ready_cb, 150 const media::SetCdmReadyCB& set_cdm_ready_cb,
151 const UpdateNetworkStateCB& update_network_state_cb, 151 const UpdateNetworkStateCB& update_network_state_cb,
152 const DurationChangeCB& duration_change_cb, 152 const DurationChangeCB& duration_change_cb,
153 const base::Closure& waiting_for_decryption_key_cb) { 153 const base::Closure& waiting_for_decryption_key_cb) {
154 DCHECK(main_task_runner_->BelongsToCurrentThread()); 154 DCHECK(main_task_runner_->BelongsToCurrentThread());
155 DCHECK(!media_source_opened_cb.is_null()); 155 DCHECK(!media_source_opened_cb.is_null());
156 DCHECK(!encrypted_media_init_data_cb.is_null());
157 DCHECK(!update_network_state_cb.is_null());
158 DCHECK(!duration_change_cb.is_null());
159 DCHECK(!waiting_for_decryption_key_cb.is_null());
160 DCHECK(!set_cdm_ready_cb.is_null());
ddorwin 2016/01/29 18:16:28 nit: This one is out of order.
xhwang 2016/02/01 23:35:25 Done.
161
156 media_source_opened_cb_ = media_source_opened_cb; 162 media_source_opened_cb_ = media_source_opened_cb;
157 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; 163 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb;
158 set_cdm_ready_cb_ = media::BindToCurrentLoop(set_cdm_ready_cb); 164 set_cdm_ready_cb_ = media::BindToCurrentLoop(set_cdm_ready_cb);
159 update_network_state_cb_ = media::BindToCurrentLoop(update_network_state_cb); 165 update_network_state_cb_ = media::BindToCurrentLoop(update_network_state_cb);
160 duration_change_cb_ = duration_change_cb; 166 duration_change_cb_ = duration_change_cb;
161 waiting_for_decryption_key_cb_ = 167 waiting_for_decryption_key_cb_ =
162 media::BindToCurrentLoop(waiting_for_decryption_key_cb); 168 media::BindToCurrentLoop(waiting_for_decryption_key_cb);
163 access_unit_size_ = kAccessUnitSizeForMediaSource; 169 access_unit_size_ = kAccessUnitSizeForMediaSource;
164 170
165 chunk_demuxer_.reset(new media::ChunkDemuxer( 171 chunk_demuxer_.reset(new media::ChunkDemuxer(
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 DCHECK(chunk_demuxer_); 495 DCHECK(chunk_demuxer_);
490 496
491 if (status != media::PIPELINE_OK) { 497 if (status != media::PIPELINE_OK) {
492 OnDemuxerError(status); 498 OnDemuxerError(status);
493 return; 499 return;
494 } 500 }
495 501
496 audio_stream_ = chunk_demuxer_->GetStream(DemuxerStream::AUDIO); 502 audio_stream_ = chunk_demuxer_->GetStream(DemuxerStream::AUDIO);
497 video_stream_ = chunk_demuxer_->GetStream(DemuxerStream::VIDEO); 503 video_stream_ = chunk_demuxer_->GetStream(DemuxerStream::VIDEO);
498 504
499 if (audio_stream_ && audio_stream_->audio_decoder_config().is_encrypted() && 505 if (audio_stream_ && audio_stream_->audio_decoder_config().is_encrypted()) {
500 !set_cdm_ready_cb_.is_null()) {
501 InitAudioDecryptingDemuxerStream(); 506 InitAudioDecryptingDemuxerStream();
502 // InitVideoDecryptingDemuxerStream() will be called in 507 // InitVideoDecryptingDemuxerStream() will be called in
503 // OnAudioDecryptingDemuxerStreamInitDone(). 508 // OnAudioDecryptingDemuxerStreamInitDone().
504 return; 509 return;
505 } 510 }
506 511
507 if (video_stream_ && video_stream_->video_decoder_config().is_encrypted() && 512 if (video_stream_ && video_stream_->video_decoder_config().is_encrypted()) {
508 !set_cdm_ready_cb_.is_null()) {
509 InitVideoDecryptingDemuxerStream(); 513 InitVideoDecryptingDemuxerStream();
510 return; 514 return;
511 } 515 }
512 516
513 // Notify demuxer ready when both streams are not encrypted. 517 // Notify demuxer ready when both streams are not encrypted.
514 is_demuxer_ready_ = true; 518 is_demuxer_ready_ = true;
515 NotifyDemuxerReady(); 519 NotifyDemuxerReady();
516 } 520 }
517 521
518 void MediaSourceDelegate::InitAudioDecryptingDemuxerStream() { 522 void MediaSourceDelegate::InitAudioDecryptingDemuxerStream() {
519 DCHECK(media_task_runner_->BelongsToCurrentThread()); 523 DCHECK(media_task_runner_->BelongsToCurrentThread());
520 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; 524 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_;
521 DCHECK(!set_cdm_ready_cb_.is_null()); 525 DCHECK(!set_cdm_ready_cb_.is_null());
522
523 audio_decrypting_demuxer_stream_.reset(new media::DecryptingDemuxerStream( 526 audio_decrypting_demuxer_stream_.reset(new media::DecryptingDemuxerStream(
524 media_task_runner_, media_log_, waiting_for_decryption_key_cb_)); 527 media_task_runner_, media_log_, waiting_for_decryption_key_cb_));
525 audio_decrypting_demuxer_stream_->Initialize( 528 audio_decrypting_demuxer_stream_->Initialize(
526 audio_stream_, set_cdm_ready_cb_, 529 audio_stream_, set_cdm_ready_cb_,
527 base::Bind(&MediaSourceDelegate::OnAudioDecryptingDemuxerStreamInitDone, 530 base::Bind(&MediaSourceDelegate::OnAudioDecryptingDemuxerStreamInitDone,
528 media_weak_factory_.GetWeakPtr())); 531 media_weak_factory_.GetWeakPtr()));
529 } 532 }
530 533
531 void MediaSourceDelegate::InitVideoDecryptingDemuxerStream() { 534 void MediaSourceDelegate::InitVideoDecryptingDemuxerStream() {
532 DCHECK(media_task_runner_->BelongsToCurrentThread()); 535 DCHECK(media_task_runner_->BelongsToCurrentThread());
533 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; 536 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_;
534 DCHECK(!set_cdm_ready_cb_.is_null()); 537 DCHECK(!set_cdm_ready_cb_.is_null());
535 538
536 video_decrypting_demuxer_stream_.reset(new media::DecryptingDemuxerStream( 539 video_decrypting_demuxer_stream_.reset(new media::DecryptingDemuxerStream(
537 media_task_runner_, media_log_, waiting_for_decryption_key_cb_)); 540 media_task_runner_, media_log_, waiting_for_decryption_key_cb_));
538 video_decrypting_demuxer_stream_->Initialize( 541 video_decrypting_demuxer_stream_->Initialize(
539 video_stream_, set_cdm_ready_cb_, 542 video_stream_, set_cdm_ready_cb_,
540 base::Bind(&MediaSourceDelegate::OnVideoDecryptingDemuxerStreamInitDone, 543 base::Bind(&MediaSourceDelegate::OnVideoDecryptingDemuxerStreamInitDone,
541 media_weak_factory_.GetWeakPtr())); 544 media_weak_factory_.GetWeakPtr()));
542 } 545 }
543 546
544 void MediaSourceDelegate::OnAudioDecryptingDemuxerStreamInitDone( 547 void MediaSourceDelegate::OnAudioDecryptingDemuxerStreamInitDone(
545 media::PipelineStatus status) { 548 media::PipelineStatus status) {
546 DCHECK(media_task_runner_->BelongsToCurrentThread()); 549 DCHECK(media_task_runner_->BelongsToCurrentThread());
547 DVLOG(1) << __FUNCTION__ << "(" << status << ") : " << demuxer_client_id_; 550 DVLOG(1) << __FUNCTION__ << "(" << status << ") : " << demuxer_client_id_;
548 DCHECK(chunk_demuxer_); 551 DCHECK(chunk_demuxer_);
549 552
550 if (status != media::PIPELINE_OK) 553 if (status != media::PIPELINE_OK) {
551 audio_decrypting_demuxer_stream_.reset(); 554 audio_decrypting_demuxer_stream_.reset();
552 else 555 // DecryptingDemuxerStream cannot be used to decrypt the audio stream (e.g.
553 audio_stream_ = audio_decrypting_demuxer_stream_.get(); 556 // the CDM doesn't support decrypt-only). It's still possible that we can
557 // decrypt and decode audio in the browser. Declare demuxer ready now to try
558 // that path.
559 // Note there's no need to try DecryptingDemuxerStream for video here since
560 // it is impossible to decrypt and decode audio in the browser and do
ddorwin 2016/01/29 18:16:28 Thanks - this is helpful. I believe the fundamenta
xhwang 2016/02/01 23:35:25 Done.
561 // decrypt-only in the render process.
562 is_demuxer_ready_ = true;
563 NotifyDemuxerReady();
564 return;
565 }
566
567 audio_stream_ = audio_decrypting_demuxer_stream_.get();
554 568
555 if (video_stream_ && video_stream_->video_decoder_config().is_encrypted()) { 569 if (video_stream_ && video_stream_->video_decoder_config().is_encrypted()) {
556 InitVideoDecryptingDemuxerStream(); 570 InitVideoDecryptingDemuxerStream();
557 return; 571 return;
558 } 572 }
559 573
560 // Try to notify demuxer ready when audio DDS initialization finished and 574 // Try to notify demuxer ready when audio DDS initialization finished and
561 // video is not encrypted. 575 // video is not encrypted.
562 is_demuxer_ready_ = true; 576 is_demuxer_ready_ = true;
563 NotifyDemuxerReady(); 577 NotifyDemuxerReady();
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 configs->video_codec = config.codec(); 764 configs->video_codec = config.codec();
751 configs->video_size = config.natural_size(); 765 configs->video_size = config.natural_size();
752 configs->is_video_encrypted = config.is_encrypted(); 766 configs->is_video_encrypted = config.is_encrypted();
753 configs->video_extra_data = config.extra_data(); 767 configs->video_extra_data = config.extra_data();
754 return true; 768 return true;
755 } 769 }
756 return false; 770 return false;
757 } 771 }
758 772
759 } // namespace content 773 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698