| 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 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 PipelineStatusCB& error_cb) | 17 const PipelineStatusCB& error_cb) |
| 18 : pipeline_(pipeline), | 18 : pipeline_(pipeline), |
| 19 renderer_factory_cb_(renderer_factory_cb), | 19 renderer_factory_cb_(renderer_factory_cb), |
| 20 seeked_cb_(seeked_cb), | 20 seeked_cb_(seeked_cb), |
| 21 suspended_cb_(suspended_cb), | 21 suspended_cb_(suspended_cb), |
| 22 error_cb_(error_cb), | 22 error_cb_(error_cb), |
| 23 remoting_controller_(new RemotingController(this)), |
| 23 weak_factory_(this) { | 24 weak_factory_(this) { |
| 24 DCHECK(pipeline_); | 25 DCHECK(pipeline_); |
| 25 DCHECK(!renderer_factory_cb_.is_null()); | 26 DCHECK(!renderer_factory_cb_.is_null()); |
| 26 DCHECK(!seeked_cb_.is_null()); | 27 DCHECK(!seeked_cb_.is_null()); |
| 27 DCHECK(!suspended_cb_.is_null()); | 28 DCHECK(!suspended_cb_.is_null()); |
| 28 DCHECK(!error_cb_.is_null()); | 29 DCHECK(!error_cb_.is_null()); |
| 29 } | 30 } |
| 30 | 31 |
| 31 PipelineController::~PipelineController() { | 32 PipelineController::~PipelineController() { |
| 32 DCHECK(thread_checker_.CalledOnValidThread()); | 33 DCHECK(thread_checker_.CalledOnValidThread()); |
| 34 remoting_controller_.reset(); |
| 33 } | 35 } |
| 34 | 36 |
| 35 // TODO(sandersd): If there is a pending suspend, don't call pipeline_.Start() | 37 // TODO(sandersd): If there is a pending suspend, don't call pipeline_.Start() |
| 36 // until Resume(). | 38 // until Resume(). |
| 37 void PipelineController::Start(Demuxer* demuxer, | 39 void PipelineController::Start(Demuxer* demuxer, |
| 38 Pipeline::Client* client, | 40 Pipeline::Client* client, |
| 39 bool is_streaming, | 41 bool is_streaming, |
| 40 bool is_static) { | 42 bool is_static) { |
| 41 DCHECK(thread_checker_.CalledOnValidThread()); | 43 DCHECK(thread_checker_.CalledOnValidThread()); |
| 42 DCHECK(state_ == State::CREATED); | 44 DCHECK(state_ == State::CREATED); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // immediately. | 228 // immediately. |
| 227 pending_seeked_cb_ = false; | 229 pending_seeked_cb_ = false; |
| 228 bool was_pending_time_updated = pending_time_updated_; | 230 bool was_pending_time_updated = pending_time_updated_; |
| 229 pending_time_updated_ = false; | 231 pending_time_updated_ = false; |
| 230 seeked_cb_.Run(was_pending_time_updated); | 232 seeked_cb_.Run(was_pending_time_updated); |
| 231 return; | 233 return; |
| 232 } | 234 } |
| 233 } | 235 } |
| 234 } | 236 } |
| 235 | 237 |
| 238 void PipelineController::SetFullscreenMode(bool is_fullscreen) { |
| 239 remoting_controller_->SetFullscreenMode(is_fullscreen); |
| 240 } |
| 241 |
| 242 void PipelineController::SetIsEncryptedContent() { |
| 243 remoting_controller_->SetIsEncryptedContent(); |
| 244 } |
| 245 |
| 246 // Switch media renderer between local playing back and remoting media renderer. |
| 247 // Note: The actual switching happens when starts or resumes the pipeline. |
| 248 void PipelineController::ToggleRenderer() { |
| 249 if (state_ == State::PLAYING) { |
| 250 Suspend(); |
| 251 // A new renderer will be created when pipeline resumes. |
| 252 Resume(); |
| 253 } |
| 254 } |
| 255 |
| 256 bool PipelineController::ShouldUseRemotingRenderer() const { |
| 257 return remoting_controller_->ShouldUseRemotingRenderer(); |
| 258 } |
| 259 |
| 260 VideoDecoderConfig PipelineController::GetVideoDecoderConfig() const { |
| 261 if (!pipeline_) |
| 262 return VideoDecoderConfig(); |
| 263 return pipeline_->GetVideoDecoderConfig(); |
| 264 } |
| 265 |
| 266 AudioDecoderConfig PipelineController::GetAudioDecoderConfig() const { |
| 267 if (!pipeline_) |
| 268 return AudioDecoderConfig(); |
| 269 return pipeline_->GetAudioDecoderConfig(); |
| 270 } |
| 271 |
| 236 } // namespace media | 272 } // namespace media |
| OLD | NEW |