| 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 PipelineStatusCB& start_done_cb, |
| 15 const SeekedCB& seeked_cb, | 16 const SeekedCB& seeked_cb, |
| 16 const SuspendedCB& suspended_cb, | 17 const SuspendedCB& suspended_cb, |
| 17 const PipelineStatusCB& error_cb) | 18 const PipelineStatusCB& error_cb) |
| 18 : pipeline_(pipeline), | 19 : pipeline_(pipeline), |
| 19 renderer_factory_cb_(renderer_factory_cb), | 20 renderer_factory_cb_(renderer_factory_cb), |
| 21 start_done_cb_(start_done_cb), |
| 20 seeked_cb_(seeked_cb), | 22 seeked_cb_(seeked_cb), |
| 21 suspended_cb_(suspended_cb), | 23 suspended_cb_(suspended_cb), |
| 22 error_cb_(error_cb), | 24 error_cb_(error_cb), |
| 23 weak_factory_(this) { | 25 weak_factory_(this) { |
| 24 DCHECK(pipeline_); | 26 DCHECK(pipeline_); |
| 25 DCHECK(!renderer_factory_cb_.is_null()); | 27 DCHECK(!renderer_factory_cb_.is_null()); |
| 28 DCHECK(!start_done_cb.is_null()); |
| 26 DCHECK(!seeked_cb_.is_null()); | 29 DCHECK(!seeked_cb_.is_null()); |
| 27 DCHECK(!suspended_cb_.is_null()); | 30 DCHECK(!suspended_cb_.is_null()); |
| 28 DCHECK(!error_cb_.is_null()); | 31 DCHECK(!error_cb_.is_null()); |
| 29 } | 32 } |
| 30 | 33 |
| 31 PipelineController::~PipelineController() { | 34 PipelineController::~PipelineController() { |
| 32 DCHECK(thread_checker_.CalledOnValidThread()); | 35 DCHECK(thread_checker_.CalledOnValidThread()); |
| 33 } | 36 } |
| 34 | 37 |
| 35 // TODO(sandersd): If there is a pending suspend, don't call pipeline_.Start() | 38 // TODO(sandersd): If there is a pending suspend, don't call pipeline_.Start() |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 114 |
| 112 bool PipelineController::IsPipelineSuspended() { | 115 bool PipelineController::IsPipelineSuspended() { |
| 113 DCHECK(thread_checker_.CalledOnValidThread()); | 116 DCHECK(thread_checker_.CalledOnValidThread()); |
| 114 return state_ == State::SUSPENDED; | 117 return state_ == State::SUSPENDED; |
| 115 } | 118 } |
| 116 | 119 |
| 117 void PipelineController::OnPipelineStatus(State state, | 120 void PipelineController::OnPipelineStatus(State state, |
| 118 PipelineStatus pipeline_status) { | 121 PipelineStatus pipeline_status) { |
| 119 DCHECK(thread_checker_.CalledOnValidThread()); | 122 DCHECK(thread_checker_.CalledOnValidThread()); |
| 120 | 123 |
| 124 if (state_ == State::STARTING) { |
| 125 start_done_cb_.Run(pipeline_status); |
| 126 } |
| 127 |
| 121 if (pipeline_status != PIPELINE_OK) { | 128 if (pipeline_status != PIPELINE_OK) { |
| 122 error_cb_.Run(pipeline_status); | 129 error_cb_.Run(pipeline_status); |
| 123 return; | 130 return; |
| 124 } | 131 } |
| 125 | 132 |
| 126 state_ = state; | 133 state_ = state; |
| 127 | 134 |
| 128 if (state == State::PLAYING) { | 135 if (state == State::PLAYING) { |
| 129 // Start(), Seek(), or Resume() completed; we can be sure that | 136 // Start(), Seek(), or Resume() completed; we can be sure that |
| 130 // |demuxer_| got the seek it was waiting for. | 137 // |demuxer_| got the seek it was waiting for. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 pending_seeked_cb_ = false; | 234 pending_seeked_cb_ = false; |
| 228 bool was_pending_time_updated = pending_time_updated_; | 235 bool was_pending_time_updated = pending_time_updated_; |
| 229 pending_time_updated_ = false; | 236 pending_time_updated_ = false; |
| 230 seeked_cb_.Run(was_pending_time_updated); | 237 seeked_cb_.Run(was_pending_time_updated); |
| 231 return; | 238 return; |
| 232 } | 239 } |
| 233 } | 240 } |
| 234 } | 241 } |
| 235 | 242 |
| 236 } // namespace media | 243 } // namespace media |
| OLD | NEW |