Chromium Code Reviews| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 data->demuxer_configs.resize(1); |
| 394 // for the next reads. | 394 GetDemuxerConfigFromStream(&data->demuxer_configs[0], is_audio); |
|
wolenetz
2014/05/02 22:25:30
Previous code would null-reference crash if the re
qinmin
2014/05/05 20:52:19
Done.
| |
| 395 // TODO(kjyoun): Investigate if we need to use this new config. See | 395 if (!is_audio) { |
| 396 // http://crbug.com/255783 | 396 gfx::Size size = data->demuxer_configs[0].video_size; |
| 397 if (is_audio) { | |
| 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" | 397 DVLOG(1) << "Video config is changed: " << size.width() << "x" |
| 402 << size.height(); | 398 << size.height(); |
| 403 } | 399 } |
| 404 data->access_units[index].status = status; | 400 data->access_units[index].status = status; |
| 405 data->access_units.resize(index + 1); | 401 data->access_units.resize(index + 1); |
| 406 break; | 402 break; |
| 407 | 403 |
| 408 case DemuxerStream::kOk: | 404 case DemuxerStream::kOk: |
| 409 data->access_units[index].status = status; | 405 data->access_units[index].status = status; |
| 410 if (buffer->end_of_stream()) { | 406 if (buffer->end_of_stream()) { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 634 base::Bind(&MediaSourceDelegate::DeleteSelf, base::Unretained(this))); | 630 base::Bind(&MediaSourceDelegate::DeleteSelf, base::Unretained(this))); |
| 635 } | 631 } |
| 636 | 632 |
| 637 void MediaSourceDelegate::DeleteSelf() { | 633 void MediaSourceDelegate::DeleteSelf() { |
| 638 DCHECK(main_loop_->BelongsToCurrentThread()); | 634 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 639 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; | 635 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; |
| 640 chunk_demuxer_.reset(); | 636 chunk_demuxer_.reset(); |
| 641 delete this; | 637 delete this; |
| 642 } | 638 } |
| 643 | 639 |
| 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() { | 640 bool MediaSourceDelegate::CanNotifyDemuxerReady() { |
| 652 DCHECK(media_loop_->BelongsToCurrentThread()); | 641 DCHECK(media_loop_->BelongsToCurrentThread()); |
| 653 return is_demuxer_ready_; | 642 return is_demuxer_ready_; |
| 654 } | 643 } |
| 655 | 644 |
| 656 void MediaSourceDelegate::NotifyDemuxerReady() { | 645 void MediaSourceDelegate::NotifyDemuxerReady() { |
| 657 DCHECK(media_loop_->BelongsToCurrentThread()); | 646 DCHECK(media_loop_->BelongsToCurrentThread()); |
| 658 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; | 647 DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_; |
| 659 DCHECK(CanNotifyDemuxerReady()); | 648 DCHECK(CanNotifyDemuxerReady()); |
| 660 | 649 |
| 661 scoped_ptr<DemuxerConfigs> configs(new DemuxerConfigs()); | 650 scoped_ptr<DemuxerConfigs> configs(new DemuxerConfigs()); |
| 662 if (audio_stream_) { | 651 GetDemuxerConfigFromStream(configs.get(), true); |
| 663 media::AudioDecoderConfig config = audio_stream_->audio_decoder_config(); | 652 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(); | 653 configs->duration = GetDuration(); |
| 681 | 654 |
| 682 if (demuxer_client_) | 655 if (demuxer_client_) |
| 683 demuxer_client_->DemuxerReady(demuxer_client_id_, *configs); | 656 demuxer_client_->DemuxerReady(demuxer_client_id_, *configs); |
| 684 | 657 |
| 685 base::AutoLock auto_lock(is_video_encrypted_lock_); | 658 base::AutoLock auto_lock(is_video_encrypted_lock_); |
| 686 is_video_encrypted_ = configs->is_video_encrypted; | 659 is_video_encrypted_ = configs->is_video_encrypted; |
| 687 } | 660 } |
| 688 | 661 |
| 689 base::TimeDelta MediaSourceDelegate::GetDuration() const { | 662 base::TimeDelta MediaSourceDelegate::GetDuration() const { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 // |seek_time|. While possible that such data at and beyond the player's | 728 // |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 | 729 // 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 | 730 // unlikely. This may cause unexpected playback stall due to seek pending an |
| 758 // append for a GOP prior to the last GOP demuxed. | 731 // append for a GOP prior to the last GOP demuxed. |
| 759 // TODO(wolenetz): Remove the possibility for this seek to cause unexpected | 732 // TODO(wolenetz): Remove the possibility for this seek to cause unexpected |
| 760 // player stall by replaying cached data since last keyframe in browser player | 733 // player stall by replaying cached data since last keyframe in browser player |
| 761 // rather than issuing browser seek. See http://crbug.com/304234. | 734 // rather than issuing browser seek. See http://crbug.com/304234. |
| 762 return seek_time; | 735 return seek_time; |
| 763 } | 736 } |
| 764 | 737 |
| 738 void MediaSourceDelegate::GetDemuxerConfigFromStream( | |
| 739 media::DemuxerConfigs* configs, bool is_audio) { | |
| 740 DCHECK(media_loop_->BelongsToCurrentThread()); | |
| 741 if (!CanNotifyDemuxerReady()) | |
| 742 return; | |
| 743 if (is_audio && audio_stream_) { | |
| 744 media::AudioDecoderConfig config = audio_stream_->audio_decoder_config(); | |
| 745 configs->audio_codec = config.codec(); | |
| 746 configs->audio_channels = | |
| 747 media::ChannelLayoutToChannelCount(config.channel_layout()); | |
| 748 configs->audio_sampling_rate = config.samples_per_second(); | |
| 749 configs->is_audio_encrypted = config.is_encrypted(); | |
| 750 configs->audio_extra_data = std::vector<uint8>( | |
| 751 config.extra_data(), config.extra_data() + config.extra_data_size()); | |
| 752 return; | |
| 753 } | |
| 754 if (!is_audio && video_stream_) { | |
| 755 media::VideoDecoderConfig config = video_stream_->video_decoder_config(); | |
| 756 configs->video_codec = config.codec(); | |
| 757 configs->video_size = config.natural_size(); | |
| 758 configs->is_video_encrypted = config.is_encrypted(); | |
| 759 configs->video_extra_data = std::vector<uint8>( | |
| 760 config.extra_data(), config.extra_data() + config.extra_data_size()); | |
| 761 } | |
| 762 } | |
| 763 | |
| 765 } // namespace content | 764 } // namespace content |
| OLD | NEW |