OLD | NEW |
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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 } | 391 } |
392 | 392 |
393 switch (status) { | 393 switch (status) { |
394 case DemuxerStream::kAborted: | 394 case DemuxerStream::kAborted: |
395 DVLOG(1) << __FUNCTION__ << " : Aborted"; | 395 DVLOG(1) << __FUNCTION__ << " : Aborted"; |
396 data->access_units[index].status = status; | 396 data->access_units[index].status = status; |
397 data->access_units.resize(index + 1); | 397 data->access_units.resize(index + 1); |
398 break; | 398 break; |
399 | 399 |
400 case DemuxerStream::kConfigChanged: | 400 case DemuxerStream::kConfigChanged: |
401 // In case of kConfigChanged, need to read decoder_config once | 401 CHECK((is_audio && audio_stream_) || (!is_audio && video_stream_)); |
402 // for the next reads. | 402 data->demuxer_configs.resize(1); |
403 // TODO(kjyoun): Investigate if we need to use this new config. See | 403 CHECK(GetDemuxerConfigFromStream(&data->demuxer_configs[0], is_audio)); |
404 // http://crbug.com/255783 | 404 if (!is_audio) { |
405 if (is_audio) { | 405 gfx::Size size = data->demuxer_configs[0].video_size; |
406 audio_stream_->audio_decoder_config(); | |
407 } else { | |
408 gfx::Size size = video_stream_->video_decoder_config().coded_size(); | |
409 DVLOG(1) << "Video config is changed: " << size.width() << "x" | 406 DVLOG(1) << "Video config is changed: " << size.width() << "x" |
410 << size.height(); | 407 << size.height(); |
411 } | 408 } |
412 data->access_units[index].status = status; | 409 data->access_units[index].status = status; |
413 data->access_units.resize(index + 1); | 410 data->access_units.resize(index + 1); |
414 break; | 411 break; |
415 | 412 |
416 case DemuxerStream::kOk: | 413 case DemuxerStream::kOk: |
417 data->access_units[index].status = status; | 414 data->access_units[index].status = status; |
418 if (buffer->end_of_stream()) { | 415 if (buffer->end_of_stream()) { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 base::Bind(&MediaSourceDelegate::DeleteSelf, base::Unretained(this))); | 639 base::Bind(&MediaSourceDelegate::DeleteSelf, base::Unretained(this))); |
643 } | 640 } |
644 | 641 |
645 void MediaSourceDelegate::DeleteSelf() { | 642 void MediaSourceDelegate::DeleteSelf() { |
646 DCHECK(main_loop_->BelongsToCurrentThread()); | 643 DCHECK(main_loop_->BelongsToCurrentThread()); |
647 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; | 644 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; |
648 chunk_demuxer_.reset(); | 645 chunk_demuxer_.reset(); |
649 delete this; | 646 delete this; |
650 } | 647 } |
651 | 648 |
652 void MediaSourceDelegate::OnMediaConfigRequest() { | |
653 DCHECK(media_loop_->BelongsToCurrentThread()); | |
654 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; | |
655 if (CanNotifyDemuxerReady()) | |
656 NotifyDemuxerReady(); | |
657 } | |
658 | |
659 bool MediaSourceDelegate::CanNotifyDemuxerReady() { | 649 bool MediaSourceDelegate::CanNotifyDemuxerReady() { |
660 DCHECK(media_loop_->BelongsToCurrentThread()); | 650 DCHECK(media_loop_->BelongsToCurrentThread()); |
661 return is_demuxer_ready_; | 651 return is_demuxer_ready_; |
662 } | 652 } |
663 | 653 |
664 void MediaSourceDelegate::NotifyDemuxerReady() { | 654 void MediaSourceDelegate::NotifyDemuxerReady() { |
665 DCHECK(media_loop_->BelongsToCurrentThread()); | 655 DCHECK(media_loop_->BelongsToCurrentThread()); |
666 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; | 656 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; |
667 DCHECK(CanNotifyDemuxerReady()); | 657 DCHECK(CanNotifyDemuxerReady()); |
668 | 658 |
669 scoped_ptr<DemuxerConfigs> configs(new DemuxerConfigs()); | 659 scoped_ptr<DemuxerConfigs> configs(new DemuxerConfigs()); |
670 if (audio_stream_) { | 660 GetDemuxerConfigFromStream(configs.get(), true); |
671 media::AudioDecoderConfig config = audio_stream_->audio_decoder_config(); | 661 GetDemuxerConfigFromStream(configs.get(), false); |
672 configs->audio_codec = config.codec(); | |
673 configs->audio_channels = | |
674 media::ChannelLayoutToChannelCount(config.channel_layout()); | |
675 configs->audio_sampling_rate = config.samples_per_second(); | |
676 configs->is_audio_encrypted = config.is_encrypted(); | |
677 configs->audio_extra_data = std::vector<uint8>( | |
678 config.extra_data(), config.extra_data() + config.extra_data_size()); | |
679 } | |
680 if (video_stream_) { | |
681 media::VideoDecoderConfig config = video_stream_->video_decoder_config(); | |
682 configs->video_codec = config.codec(); | |
683 configs->video_size = config.natural_size(); | |
684 configs->is_video_encrypted = config.is_encrypted(); | |
685 configs->video_extra_data = std::vector<uint8>( | |
686 config.extra_data(), config.extra_data() + config.extra_data_size()); | |
687 } | |
688 configs->duration = GetDuration(); | 662 configs->duration = GetDuration(); |
689 | 663 |
690 if (demuxer_client_) | 664 if (demuxer_client_) |
691 demuxer_client_->DemuxerReady(demuxer_client_id_, *configs); | 665 demuxer_client_->DemuxerReady(demuxer_client_id_, *configs); |
692 | 666 |
693 base::AutoLock auto_lock(is_video_encrypted_lock_); | 667 base::AutoLock auto_lock(is_video_encrypted_lock_); |
694 is_video_encrypted_ = configs->is_video_encrypted; | 668 is_video_encrypted_ = configs->is_video_encrypted; |
695 } | 669 } |
696 | 670 |
697 base::TimeDelta MediaSourceDelegate::GetDuration() const { | 671 base::TimeDelta MediaSourceDelegate::GetDuration() const { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 // |seek_time|. While possible that such data at and beyond the player's | 737 // |seek_time|. While possible that such data at and beyond the player's |
764 // current time have been garbage collected or removed by the web app, this is | 738 // current time have been garbage collected or removed by the web app, this is |
765 // unlikely. This may cause unexpected playback stall due to seek pending an | 739 // unlikely. This may cause unexpected playback stall due to seek pending an |
766 // append for a GOP prior to the last GOP demuxed. | 740 // append for a GOP prior to the last GOP demuxed. |
767 // TODO(wolenetz): Remove the possibility for this seek to cause unexpected | 741 // TODO(wolenetz): Remove the possibility for this seek to cause unexpected |
768 // player stall by replaying cached data since last keyframe in browser player | 742 // player stall by replaying cached data since last keyframe in browser player |
769 // rather than issuing browser seek. See http://crbug.com/304234. | 743 // rather than issuing browser seek. See http://crbug.com/304234. |
770 return seek_time; | 744 return seek_time; |
771 } | 745 } |
772 | 746 |
| 747 bool MediaSourceDelegate::GetDemuxerConfigFromStream( |
| 748 media::DemuxerConfigs* configs, bool is_audio) { |
| 749 DCHECK(media_loop_->BelongsToCurrentThread()); |
| 750 if (!CanNotifyDemuxerReady()) |
| 751 return false; |
| 752 if (is_audio && audio_stream_) { |
| 753 media::AudioDecoderConfig config = audio_stream_->audio_decoder_config(); |
| 754 configs->audio_codec = config.codec(); |
| 755 configs->audio_channels = |
| 756 media::ChannelLayoutToChannelCount(config.channel_layout()); |
| 757 configs->audio_sampling_rate = config.samples_per_second(); |
| 758 configs->is_audio_encrypted = config.is_encrypted(); |
| 759 configs->audio_extra_data = std::vector<uint8>( |
| 760 config.extra_data(), config.extra_data() + config.extra_data_size()); |
| 761 return true; |
| 762 } |
| 763 if (!is_audio && video_stream_) { |
| 764 media::VideoDecoderConfig config = video_stream_->video_decoder_config(); |
| 765 configs->video_codec = config.codec(); |
| 766 configs->video_size = config.natural_size(); |
| 767 configs->is_video_encrypted = config.is_encrypted(); |
| 768 configs->video_extra_data = std::vector<uint8>( |
| 769 config.extra_data(), config.extra_data() + config.extra_data_size()); |
| 770 return true; |
| 771 } |
| 772 return false; |
| 773 } |
| 774 |
773 } // namespace content | 775 } // namespace content |
OLD | NEW |