OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "media/filters/pipeline_controller.h" | 5 #include "media/filters/pipeline_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "media/base/demuxer.h" | 8 #include "media/base/demuxer.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 PipelineController::PipelineController( | 12 PipelineController::PipelineController( |
13 Pipeline* pipeline, | 13 std::unique_ptr<Pipeline> pipeline, |
14 const RendererFactoryCB& renderer_factory_cb, | 14 const RendererFactoryCB& renderer_factory_cb, |
15 const SeekedCB& seeked_cb, | 15 const SeekedCB& seeked_cb, |
16 const SuspendedCB& suspended_cb, | 16 const SuspendedCB& suspended_cb, |
17 const BeforeResumeCB& before_resume_cb, | 17 const BeforeResumeCB& before_resume_cb, |
18 const ResumedCB& resumed_cb, | 18 const ResumedCB& resumed_cb, |
19 const PipelineStatusCB& error_cb) | 19 const PipelineStatusCB& error_cb) |
20 : pipeline_(pipeline), | 20 : pipeline_(std::move(pipeline)), |
21 renderer_factory_cb_(renderer_factory_cb), | 21 renderer_factory_cb_(renderer_factory_cb), |
22 seeked_cb_(seeked_cb), | 22 seeked_cb_(seeked_cb), |
23 suspended_cb_(suspended_cb), | 23 suspended_cb_(suspended_cb), |
24 before_resume_cb_(before_resume_cb), | 24 before_resume_cb_(before_resume_cb), |
25 resumed_cb_(resumed_cb), | 25 resumed_cb_(resumed_cb), |
26 error_cb_(error_cb), | 26 error_cb_(error_cb), |
27 weak_factory_(this) { | 27 weak_factory_(this) { |
28 DCHECK(pipeline_); | 28 DCHECK(pipeline_); |
29 DCHECK(!renderer_factory_cb_.is_null()); | 29 DCHECK(!renderer_factory_cb_.is_null()); |
30 DCHECK(!seeked_cb_.is_null()); | 30 DCHECK(!seeked_cb_.is_null()); |
31 DCHECK(!suspended_cb_.is_null()); | 31 DCHECK(!suspended_cb_.is_null()); |
32 DCHECK(!before_resume_cb_.is_null()); | 32 DCHECK(!before_resume_cb_.is_null()); |
33 DCHECK(!resumed_cb_.is_null()); | 33 DCHECK(!resumed_cb_.is_null()); |
34 DCHECK(!error_cb_.is_null()); | 34 DCHECK(!error_cb_.is_null()); |
35 } | 35 } |
36 | 36 |
37 PipelineController::~PipelineController() { | 37 PipelineController::~PipelineController() { |
38 DCHECK(thread_checker_.CalledOnValidThread()); | 38 DCHECK(thread_checker_.CalledOnValidThread()); |
39 } | 39 } |
40 | 40 |
41 // TODO(sandersd): If there is a pending suspend, don't call pipeline_.Start() | 41 // TODO(sandersd): If there is a pending suspend, don't call pipeline_->Start() |
42 // until Resume(). | 42 // until Resume(). |
43 void PipelineController::Start(Demuxer* demuxer, | 43 void PipelineController::Start(Demuxer* demuxer, |
44 Pipeline::Client* client, | 44 Pipeline::Client* client, |
45 bool is_streaming, | 45 bool is_streaming, |
46 bool is_static) { | 46 bool is_static) { |
47 DCHECK(thread_checker_.CalledOnValidThread()); | 47 DCHECK(thread_checker_.CalledOnValidThread()); |
48 DCHECK(state_ == State::CREATED); | 48 DCHECK(state_ == State::CREATED); |
49 DCHECK(demuxer); | 49 DCHECK(demuxer); |
50 | 50 |
51 // Once the pipeline is started, we want to call the seeked callback but | 51 // Once the pipeline is started, we want to call the seeked callback but |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // immediately. | 239 // immediately. |
240 pending_seeked_cb_ = false; | 240 pending_seeked_cb_ = false; |
241 bool was_pending_time_updated = pending_time_updated_; | 241 bool was_pending_time_updated = pending_time_updated_; |
242 pending_time_updated_ = false; | 242 pending_time_updated_ = false; |
243 seeked_cb_.Run(was_pending_time_updated); | 243 seeked_cb_.Run(was_pending_time_updated); |
244 return; | 244 return; |
245 } | 245 } |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
| 249 void PipelineController::Stop() { |
| 250 // For the moment, Stop() is only called on WMPI destruction, and updating the |
| 251 // state of |this| is not relevant. Eventually, Start()/Stop() will be called |
| 252 // in order to swap between demuxer types, and this will need to be adressed. |
| 253 // |
| 254 // TODO(tguilbert): Clarify the appropriate state changes when Stop() is |
| 255 // called. See crbug.com/695734. |
| 256 pipeline_->Stop(); |
| 257 } |
| 258 |
| 259 bool PipelineController::IsPipelineRunning() const { |
| 260 return pipeline_->IsRunning(); |
| 261 } |
| 262 |
| 263 double PipelineController::GetPlaybackRate() const { |
| 264 return pipeline_->GetPlaybackRate(); |
| 265 } |
| 266 |
| 267 void PipelineController::SetPlaybackRate(double playback_rate) { |
| 268 pipeline_->SetPlaybackRate(playback_rate); |
| 269 } |
| 270 |
| 271 float PipelineController::GetVolume() const { |
| 272 return pipeline_->GetVolume(); |
| 273 } |
| 274 |
| 275 void PipelineController::SetVolume(float volume) { |
| 276 pipeline_->SetVolume(volume); |
| 277 } |
| 278 |
| 279 base::TimeDelta PipelineController::GetMediaTime() const { |
| 280 return pipeline_->GetMediaTime(); |
| 281 } |
| 282 |
| 283 Ranges<base::TimeDelta> PipelineController::GetBufferedTimeRanges() const { |
| 284 return pipeline_->GetBufferedTimeRanges(); |
| 285 } |
| 286 |
| 287 base::TimeDelta PipelineController::GetMediaDuration() const { |
| 288 return pipeline_->GetMediaDuration(); |
| 289 } |
| 290 |
| 291 bool PipelineController::DidLoadingProgress() { |
| 292 return pipeline_->DidLoadingProgress(); |
| 293 } |
| 294 |
| 295 PipelineStatistics PipelineController::GetStatistics() const { |
| 296 return pipeline_->GetStatistics(); |
| 297 } |
| 298 |
| 299 void PipelineController::SetCdm(CdmContext* cdm_context, |
| 300 const CdmAttachedCB& cdm_attached_cb) { |
| 301 pipeline_->SetCdm(cdm_context, cdm_attached_cb); |
| 302 } |
| 303 |
| 304 void PipelineController::OnEnabledAudioTracksChanged( |
| 305 const std::vector<MediaTrack::Id>& enabledTrackIds) { |
| 306 pipeline_->OnEnabledAudioTracksChanged(enabledTrackIds); |
| 307 } |
| 308 |
| 309 void PipelineController::OnSelectedVideoTrackChanged( |
| 310 base::Optional<MediaTrack::Id> selected_track_id) { |
| 311 pipeline_->OnSelectedVideoTrackChanged(selected_track_id); |
| 312 } |
| 313 |
249 } // namespace media | 314 } // namespace media |
OLD | NEW |