Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: media/filters/pipeline_controller.cc

Issue 2618883002: [Media, Video] Enable the video track for a new renderer. (Closed)
Patch Set: Immediate resume_cb_, fixed unittests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
121 if (pipeline_status != PIPELINE_OK) { 124 if (pipeline_status != PIPELINE_OK) {
122 error_cb_.Run(pipeline_status); 125 error_cb_.Run(pipeline_status);
123 return; 126 return;
124 } 127 }
125 128
129 State old_state = state_;
126 state_ = state; 130 state_ = state;
127 131
128 if (state == State::PLAYING) { 132 if (state == State::PLAYING) {
129 // Start(), Seek(), or Resume() completed; we can be sure that 133 // Start(), Seek(), or Resume() completed; we can be sure that
130 // |demuxer_| got the seek it was waiting for. 134 // |demuxer_| got the seek it was waiting for.
131 waiting_for_seek_ = false; 135 waiting_for_seek_ = false;
136
137 // TODO(avayvod): Remove resumed callback after https://crbug.com/678374 is
138 // properly fixed.
139 if (old_state == State::RESUMING)
140 resumed_cb_.Run();
132 } else if (state == State::SUSPENDED) { 141 } else if (state == State::SUSPENDED) {
133 // Warning: possibly reentrant. The state may change inside this callback. 142 // Warning: possibly reentrant. The state may change inside this callback.
134 // It must be safe to call Dispatch() twice in a row here. 143 // It must be safe to call Dispatch() twice in a row here.
135 suspended_cb_.Run(); 144 suspended_cb_.Run();
136 } 145 }
137 146
138 Dispatch(); 147 Dispatch();
139 } 148 }
140 149
141 // Note: Dispatch() may be called re-entrantly (by callbacks internally) or 150 // Note: Dispatch() may be called re-entrantly (by callbacks internally) or
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 pending_seeked_cb_ = false; 236 pending_seeked_cb_ = false;
228 bool was_pending_time_updated = pending_time_updated_; 237 bool was_pending_time_updated = pending_time_updated_;
229 pending_time_updated_ = false; 238 pending_time_updated_ = false;
230 seeked_cb_.Run(was_pending_time_updated); 239 seeked_cb_.Run(was_pending_time_updated);
231 return; 240 return;
232 } 241 }
233 } 242 }
234 } 243 }
235 244
236 } // namespace media 245 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698