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

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

Issue 257323003: Remove the IPC to request DemuxerConfigs when config changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 7 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 | Annotate | Revision Log
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 <vector> 9 #include <vector>
10 10
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } 383 }
384 384
385 switch (status) { 385 switch (status) {
386 case DemuxerStream::kAborted: 386 case DemuxerStream::kAborted:
387 DVLOG(1) << __FUNCTION__ << " : Aborted"; 387 DVLOG(1) << __FUNCTION__ << " : Aborted";
388 data->access_units[index].status = status; 388 data->access_units[index].status = status;
389 data->access_units.resize(index + 1); 389 data->access_units.resize(index + 1);
390 break; 390 break;
391 391
392 case DemuxerStream::kConfigChanged: 392 case DemuxerStream::kConfigChanged:
393 // In case of kConfigChanged, need to read decoder_config once 393 CHECK((is_audio && audio_stream_) || (!is_audio && video_stream_));
394 // for the next reads. 394 data->demuxer_configs.resize(1);
jschuh 2014/05/08 16:52:53 It looks like we could end up sending an empty con
qinmin 2014/05/08 17:20:04 Done.
395 // TODO(kjyoun): Investigate if we need to use this new config. See 395 GetDemuxerConfigFromStream(&data->demuxer_configs[0], is_audio);
396 // http://crbug.com/255783 396 if (!is_audio) {
397 if (is_audio) { 397 gfx::Size size = data->demuxer_configs[0].video_size;
398 audio_stream_->audio_decoder_config();
399 } else {
400 gfx::Size size = video_stream_->video_decoder_config().coded_size();
401 DVLOG(1) << "Video config is changed: " << size.width() << "x" 398 DVLOG(1) << "Video config is changed: " << size.width() << "x"
402 << size.height(); 399 << size.height();
403 } 400 }
404 data->access_units[index].status = status; 401 data->access_units[index].status = status;
405 data->access_units.resize(index + 1); 402 data->access_units.resize(index + 1);
406 break; 403 break;
407 404
408 case DemuxerStream::kOk: 405 case DemuxerStream::kOk:
409 data->access_units[index].status = status; 406 data->access_units[index].status = status;
410 if (buffer->end_of_stream()) { 407 if (buffer->end_of_stream()) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 base::Bind(&MediaSourceDelegate::DeleteSelf, base::Unretained(this))); 631 base::Bind(&MediaSourceDelegate::DeleteSelf, base::Unretained(this)));
635 } 632 }
636 633
637 void MediaSourceDelegate::DeleteSelf() { 634 void MediaSourceDelegate::DeleteSelf() {
638 DCHECK(main_loop_->BelongsToCurrentThread()); 635 DCHECK(main_loop_->BelongsToCurrentThread());
639 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; 636 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_;
640 chunk_demuxer_.reset(); 637 chunk_demuxer_.reset();
641 delete this; 638 delete this;
642 } 639 }
643 640
644 void MediaSourceDelegate::OnMediaConfigRequest() {
645 DCHECK(media_loop_->BelongsToCurrentThread());
646 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_;
647 if (CanNotifyDemuxerReady())
648 NotifyDemuxerReady();
649 }
650
651 bool MediaSourceDelegate::CanNotifyDemuxerReady() { 641 bool MediaSourceDelegate::CanNotifyDemuxerReady() {
652 DCHECK(media_loop_->BelongsToCurrentThread()); 642 DCHECK(media_loop_->BelongsToCurrentThread());
653 return is_demuxer_ready_; 643 return is_demuxer_ready_;
654 } 644 }
655 645
656 void MediaSourceDelegate::NotifyDemuxerReady() { 646 void MediaSourceDelegate::NotifyDemuxerReady() {
657 DCHECK(media_loop_->BelongsToCurrentThread()); 647 DCHECK(media_loop_->BelongsToCurrentThread());
658 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; 648 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_;
659 DCHECK(CanNotifyDemuxerReady()); 649 DCHECK(CanNotifyDemuxerReady());
660 650
661 scoped_ptr<DemuxerConfigs> configs(new DemuxerConfigs()); 651 scoped_ptr<DemuxerConfigs> configs(new DemuxerConfigs());
662 if (audio_stream_) { 652 GetDemuxerConfigFromStream(configs.get(), true);
663 media::AudioDecoderConfig config = audio_stream_->audio_decoder_config(); 653 GetDemuxerConfigFromStream(configs.get(), false);
664 configs->audio_codec = config.codec();
665 configs->audio_channels =
666 media::ChannelLayoutToChannelCount(config.channel_layout());
667 configs->audio_sampling_rate = config.samples_per_second();
668 configs->is_audio_encrypted = config.is_encrypted();
669 configs->audio_extra_data = std::vector<uint8>(
670 config.extra_data(), config.extra_data() + config.extra_data_size());
671 }
672 if (video_stream_) {
673 media::VideoDecoderConfig config = video_stream_->video_decoder_config();
674 configs->video_codec = config.codec();
675 configs->video_size = config.natural_size();
676 configs->is_video_encrypted = config.is_encrypted();
677 configs->video_extra_data = std::vector<uint8>(
678 config.extra_data(), config.extra_data() + config.extra_data_size());
679 }
680 configs->duration = GetDuration(); 654 configs->duration = GetDuration();
681 655
682 if (demuxer_client_) 656 if (demuxer_client_)
683 demuxer_client_->DemuxerReady(demuxer_client_id_, *configs); 657 demuxer_client_->DemuxerReady(demuxer_client_id_, *configs);
684 658
685 base::AutoLock auto_lock(is_video_encrypted_lock_); 659 base::AutoLock auto_lock(is_video_encrypted_lock_);
686 is_video_encrypted_ = configs->is_video_encrypted; 660 is_video_encrypted_ = configs->is_video_encrypted;
687 } 661 }
688 662
689 base::TimeDelta MediaSourceDelegate::GetDuration() const { 663 base::TimeDelta MediaSourceDelegate::GetDuration() const {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 // |seek_time|. While possible that such data at and beyond the player's 729 // |seek_time|. While possible that such data at and beyond the player's
756 // current time have been garbage collected or removed by the web app, this is 730 // current time have been garbage collected or removed by the web app, this is
757 // unlikely. This may cause unexpected playback stall due to seek pending an 731 // unlikely. This may cause unexpected playback stall due to seek pending an
758 // append for a GOP prior to the last GOP demuxed. 732 // append for a GOP prior to the last GOP demuxed.
759 // TODO(wolenetz): Remove the possibility for this seek to cause unexpected 733 // TODO(wolenetz): Remove the possibility for this seek to cause unexpected
760 // player stall by replaying cached data since last keyframe in browser player 734 // player stall by replaying cached data since last keyframe in browser player
761 // rather than issuing browser seek. See http://crbug.com/304234. 735 // rather than issuing browser seek. See http://crbug.com/304234.
762 return seek_time; 736 return seek_time;
763 } 737 }
764 738
739 void MediaSourceDelegate::GetDemuxerConfigFromStream(
740 media::DemuxerConfigs* configs, bool is_audio) {
741 DCHECK(media_loop_->BelongsToCurrentThread());
742 if (!CanNotifyDemuxerReady())
743 return;
744 if (is_audio && audio_stream_) {
745 media::AudioDecoderConfig config = audio_stream_->audio_decoder_config();
746 configs->audio_codec = config.codec();
747 configs->audio_channels =
748 media::ChannelLayoutToChannelCount(config.channel_layout());
749 configs->audio_sampling_rate = config.samples_per_second();
750 configs->is_audio_encrypted = config.is_encrypted();
751 configs->audio_extra_data = std::vector<uint8>(
752 config.extra_data(), config.extra_data() + config.extra_data_size());
753 return;
754 }
755 if (!is_audio && video_stream_) {
756 media::VideoDecoderConfig config = video_stream_->video_decoder_config();
757 configs->video_codec = config.codec();
758 configs->video_size = config.natural_size();
759 configs->is_video_encrypted = config.is_encrypted();
760 configs->video_extra_data = std::vector<uint8>(
761 config.extra_data(), config.extra_data() + config.extra_data_size());
762 }
763 }
764
765 } // namespace content 765 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698