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 ResumedCB& resumed_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), |
20 seeked_cb_(seeked_cb), | 21 seeked_cb_(seeked_cb), |
21 suspended_cb_(suspended_cb), | 22 suspended_cb_(suspended_cb), |
23 resumed_cb_(resumed_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()); |
26 DCHECK(!seeked_cb_.is_null()); | 28 DCHECK(!seeked_cb_.is_null()); |
27 DCHECK(!suspended_cb_.is_null()); | 29 DCHECK(!suspended_cb_.is_null()); |
30 DCHECK(!resumed_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() |
36 // until Resume(). | 39 // until Resume(). |
37 void PipelineController::Start(Demuxer* demuxer, | 40 void PipelineController::Start(Demuxer* demuxer, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 pending_time_updated_ = true; | 176 pending_time_updated_ = true; |
174 } | 177 } |
175 | 178 |
176 // Tell |demuxer_| to expect our resume. | 179 // Tell |demuxer_| to expect our resume. |
177 DCHECK(!waiting_for_seek_); | 180 DCHECK(!waiting_for_seek_); |
178 waiting_for_seek_ = true; | 181 waiting_for_seek_ = true; |
179 demuxer_->StartWaitingForSeek(seek_time_); | 182 demuxer_->StartWaitingForSeek(seek_time_); |
180 | 183 |
181 pending_resume_ = false; | 184 pending_resume_ = false; |
182 state_ = State::RESUMING; | 185 state_ = State::RESUMING; |
186 pending_resumed_cb_ = true; | |
183 pipeline_->Resume(renderer_factory_cb_.Run(), seek_time_, | 187 pipeline_->Resume(renderer_factory_cb_.Run(), seek_time_, |
184 base::Bind(&PipelineController::OnPipelineStatus, | 188 base::Bind(&PipelineController::OnPipelineStatus, |
185 weak_factory_.GetWeakPtr(), State::PLAYING)); | 189 weak_factory_.GetWeakPtr(), State::PLAYING)); |
186 return; | 190 return; |
187 } | 191 } |
188 | 192 |
189 // If we have pending operations, and a seek is ongoing, abort it. | 193 // If we have pending operations, and a seek is ongoing, abort it. |
190 if ((pending_seek_ || pending_suspend_) && waiting_for_seek_) { | 194 if ((pending_seek_ || pending_suspend_) && waiting_for_seek_) { |
191 // If there is no pending seek, return the current seek to pending status. | 195 // If there is no pending seek, return the current seek to pending status. |
192 if (!pending_seek_) { | 196 if (!pending_seek_) { |
(...skipping 30 matching lines...) Expand all Loading... | |
223 if (state_ == State::PLAYING) { | 227 if (state_ == State::PLAYING) { |
224 if (pending_seeked_cb_) { | 228 if (pending_seeked_cb_) { |
225 // |seeked_cb_| may be reentrant, so update state first and return | 229 // |seeked_cb_| may be reentrant, so update state first and return |
226 // immediately. | 230 // immediately. |
227 pending_seeked_cb_ = false; | 231 pending_seeked_cb_ = false; |
228 bool was_pending_time_updated = pending_time_updated_; | 232 bool was_pending_time_updated = pending_time_updated_; |
229 pending_time_updated_ = false; | 233 pending_time_updated_ = false; |
230 seeked_cb_.Run(was_pending_time_updated); | 234 seeked_cb_.Run(was_pending_time_updated); |
231 return; | 235 return; |
232 } | 236 } |
237 | |
238 if (pending_resumed_cb_) { | |
239 pending_resumed_cb_ = false; | |
240 resumed_cb_.Run(); | |
sandersd (OOO until July 31)
2017/01/07 00:56:17
This won't be called if |pending_seeked_cb_| is tr
whywhat
2017/01/07 02:02:35
Done. Would checking for state_ to be RESUMING and
| |
241 } | |
233 } | 242 } |
234 } | 243 } |
235 | 244 |
236 } // namespace media | 245 } // namespace media |
OLD | NEW |