| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 chunk_demuxer_->Stop(); | 141 chunk_demuxer_->Stop(); |
| 142 chunk_demuxer_.reset(); | 142 chunk_demuxer_.reset(); |
| 143 | 143 |
| 144 // |this| may be destroyed at this point in time as a result of running | 144 // |this| may be destroyed at this point in time as a result of running |
| 145 // |stop_cb|. | 145 // |stop_cb|. |
| 146 stop_cb.Run(); | 146 stop_cb.Run(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void MediaSourceDelegate::InitializeMediaSource( | 149 void MediaSourceDelegate::InitializeMediaSource( |
| 150 const MediaSourceOpenedCB& media_source_opened_cb, | 150 const MediaSourceOpenedCB& media_source_opened_cb, |
| 151 const media::Demuxer::NeedKeyCB& need_key_cb, | 151 const media::Demuxer::EncryptedMediaInitDataCB& |
| 152 encrypted_media_init_data_cb, |
| 152 const media::SetDecryptorReadyCB& set_decryptor_ready_cb, | 153 const media::SetDecryptorReadyCB& set_decryptor_ready_cb, |
| 153 const UpdateNetworkStateCB& update_network_state_cb, | 154 const UpdateNetworkStateCB& update_network_state_cb, |
| 154 const DurationChangeCB& duration_change_cb) { | 155 const DurationChangeCB& duration_change_cb) { |
| 155 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 156 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 156 DCHECK(!media_source_opened_cb.is_null()); | 157 DCHECK(!media_source_opened_cb.is_null()); |
| 157 media_source_opened_cb_ = media_source_opened_cb; | 158 media_source_opened_cb_ = media_source_opened_cb; |
| 158 need_key_cb_ = need_key_cb; | 159 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; |
| 159 set_decryptor_ready_cb_ = set_decryptor_ready_cb; | 160 set_decryptor_ready_cb_ = set_decryptor_ready_cb; |
| 160 update_network_state_cb_ = media::BindToCurrentLoop(update_network_state_cb); | 161 update_network_state_cb_ = media::BindToCurrentLoop(update_network_state_cb); |
| 161 duration_change_cb_ = duration_change_cb; | 162 duration_change_cb_ = duration_change_cb; |
| 162 access_unit_size_ = kAccessUnitSizeForMediaSource; | 163 access_unit_size_ = kAccessUnitSizeForMediaSource; |
| 163 | 164 |
| 164 chunk_demuxer_.reset(new media::ChunkDemuxer( | 165 chunk_demuxer_.reset(new media::ChunkDemuxer( |
| 165 media::BindToCurrentLoop( | 166 media::BindToCurrentLoop( |
| 166 base::Bind(&MediaSourceDelegate::OnDemuxerOpened, main_weak_this_)), | 167 base::Bind(&MediaSourceDelegate::OnDemuxerOpened, main_weak_this_)), |
| 167 media::BindToCurrentLoop( | 168 media::BindToCurrentLoop(base::Bind( |
| 168 base::Bind(&MediaSourceDelegate::OnNeedKey, main_weak_this_)), | 169 &MediaSourceDelegate::OnEncryptedMediaInitData, main_weak_this_)), |
| 169 base::Bind(&LogMediaSourceError, media_log_), | 170 base::Bind(&LogMediaSourceError, media_log_), media_log_, false)); |
| 170 media_log_, | |
| 171 false)); | |
| 172 | 171 |
| 173 // |this| will be retained until StopDemuxer() is posted, so Unretained() is | 172 // |this| will be retained until StopDemuxer() is posted, so Unretained() is |
| 174 // safe here. | 173 // safe here. |
| 175 media_task_runner_->PostTask(FROM_HERE, | 174 media_task_runner_->PostTask(FROM_HERE, |
| 176 base::Bind(&MediaSourceDelegate::InitializeDemuxer, | 175 base::Bind(&MediaSourceDelegate::InitializeDemuxer, |
| 177 base::Unretained(this))); | 176 base::Unretained(this))); |
| 178 } | 177 } |
| 179 | 178 |
| 180 void MediaSourceDelegate::InitializeDemuxer() { | 179 void MediaSourceDelegate::InitializeDemuxer() { |
| 181 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 180 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 659 |
| 661 void MediaSourceDelegate::OnDemuxerOpened() { | 660 void MediaSourceDelegate::OnDemuxerOpened() { |
| 662 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 661 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 663 if (media_source_opened_cb_.is_null()) | 662 if (media_source_opened_cb_.is_null()) |
| 664 return; | 663 return; |
| 665 | 664 |
| 666 media_source_opened_cb_.Run(new media::WebMediaSourceImpl( | 665 media_source_opened_cb_.Run(new media::WebMediaSourceImpl( |
| 667 chunk_demuxer_.get(), base::Bind(&LogMediaSourceError, media_log_))); | 666 chunk_demuxer_.get(), base::Bind(&LogMediaSourceError, media_log_))); |
| 668 } | 667 } |
| 669 | 668 |
| 670 void MediaSourceDelegate::OnNeedKey(const std::string& init_data_type, | 669 void MediaSourceDelegate::OnEncryptedMediaInitData( |
| 671 const std::vector<uint8>& init_data) { | 670 const std::string& init_data_type, |
| 671 const std::vector<uint8>& init_data) { |
| 672 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 672 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 673 if (need_key_cb_.is_null()) | 673 if (encrypted_media_init_data_cb_.is_null()) |
| 674 return; | 674 return; |
| 675 | 675 |
| 676 need_key_cb_.Run(init_data_type, init_data); | 676 encrypted_media_init_data_cb_.Run(init_data_type, init_data); |
| 677 } | 677 } |
| 678 | 678 |
| 679 bool MediaSourceDelegate::IsSeeking() const { | 679 bool MediaSourceDelegate::IsSeeking() const { |
| 680 base::AutoLock auto_lock(seeking_lock_); | 680 base::AutoLock auto_lock(seeking_lock_); |
| 681 return seeking_; | 681 return seeking_; |
| 682 } | 682 } |
| 683 | 683 |
| 684 base::TimeDelta MediaSourceDelegate::FindBufferedBrowserSeekTime_Locked( | 684 base::TimeDelta MediaSourceDelegate::FindBufferedBrowserSeekTime_Locked( |
| 685 const base::TimeDelta& seek_time) const { | 685 const base::TimeDelta& seek_time) const { |
| 686 seeking_lock_.AssertAcquired(); | 686 seeking_lock_.AssertAcquired(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 configs->video_size = config.natural_size(); | 744 configs->video_size = config.natural_size(); |
| 745 configs->is_video_encrypted = config.is_encrypted(); | 745 configs->is_video_encrypted = config.is_encrypted(); |
| 746 configs->video_extra_data = std::vector<uint8>( | 746 configs->video_extra_data = std::vector<uint8>( |
| 747 config.extra_data(), config.extra_data() + config.extra_data_size()); | 747 config.extra_data(), config.extra_data() + config.extra_data_size()); |
| 748 return true; | 748 return true; |
| 749 } | 749 } |
| 750 return false; | 750 return false; |
| 751 } | 751 } |
| 752 | 752 |
| 753 } // namespace content | 753 } // namespace content |
| OLD | NEW |