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

Side by Side Diff: webkit/glue/webmediaplayer_impl.cc

Issue 155404: Fixed bug where playbackRate wasn't being respected. (Closed)
Patch Set: Uploaded too much Created 11 years, 5 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
« no previous file with comments | « webkit/glue/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 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 "webkit/glue/webmediaplayer_impl.h" 5 #include "webkit/glue/webmediaplayer_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "media/filters/ffmpeg_audio_decoder.h" 9 #include "media/filters/ffmpeg_audio_decoder.h"
10 #include "media/filters/ffmpeg_demuxer.h" 10 #include "media/filters/ffmpeg_demuxer.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 ///////////////////////////////////////////////////////////////////////////// 160 /////////////////////////////////////////////////////////////////////////////
161 // WebMediaPlayerImpl implementation 161 // WebMediaPlayerImpl implementation
162 162
163 WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client, 163 WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client,
164 media::FilterFactoryCollection* factory) 164 media::FilterFactoryCollection* factory)
165 : network_state_(WebKit::WebMediaPlayer::Empty), 165 : network_state_(WebKit::WebMediaPlayer::Empty),
166 ready_state_(WebKit::WebMediaPlayer::HaveNothing), 166 ready_state_(WebKit::WebMediaPlayer::HaveNothing),
167 main_loop_(NULL), 167 main_loop_(NULL),
168 filter_factory_(factory), 168 filter_factory_(factory),
169 pipeline_thread_("PipelineThread"), 169 pipeline_thread_("PipelineThread"),
170 paused_(true),
171 playback_rate_(0.0f),
170 client_(client) { 172 client_(client) {
171 // Saves the current message loop. 173 // Saves the current message loop.
172 DCHECK(!main_loop_); 174 DCHECK(!main_loop_);
173 main_loop_ = MessageLoop::current(); 175 main_loop_ = MessageLoop::current();
174 176
175 // Create the pipeline and its thread. 177 // Create the pipeline and its thread.
176 if (!pipeline_thread_.Start()) { 178 if (!pipeline_thread_.Start()) {
177 NOTREACHED() << "Could not start PipelineThread"; 179 NOTREACHED() << "Could not start PipelineThread";
178 } else { 180 } else {
179 pipeline_.reset(new media::PipelineImpl(pipeline_thread_.message_loop())); 181 pipeline_.reset(new media::PipelineImpl(pipeline_thread_.message_loop()));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback)); 219 &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback));
218 } 220 }
219 221
220 void WebMediaPlayerImpl::cancelLoad() { 222 void WebMediaPlayerImpl::cancelLoad() {
221 DCHECK(MessageLoop::current() == main_loop_); 223 DCHECK(MessageLoop::current() == main_loop_);
222 } 224 }
223 225
224 void WebMediaPlayerImpl::play() { 226 void WebMediaPlayerImpl::play() {
225 DCHECK(MessageLoop::current() == main_loop_); 227 DCHECK(MessageLoop::current() == main_loop_);
226 228
227 // TODO(hclam): We should restore the previous playback rate rather than 229 paused_ = false;
228 // having it at 1.0. 230 pipeline_->SetPlaybackRate(playback_rate_);
229 pipeline_->SetPlaybackRate(1.0f);
230 } 231 }
231 232
232 void WebMediaPlayerImpl::pause() { 233 void WebMediaPlayerImpl::pause() {
233 DCHECK(MessageLoop::current() == main_loop_); 234 DCHECK(MessageLoop::current() == main_loop_);
234 235
236 paused_ = true;
235 pipeline_->SetPlaybackRate(0.0f); 237 pipeline_->SetPlaybackRate(0.0f);
236 } 238 }
237 239
238 void WebMediaPlayerImpl::seek(float seconds) { 240 void WebMediaPlayerImpl::seek(float seconds) {
239 DCHECK(MessageLoop::current() == main_loop_); 241 DCHECK(MessageLoop::current() == main_loop_);
240 242
241 // Try to preserve as much accuracy as possible. 243 // Try to preserve as much accuracy as possible.
242 float microseconds = seconds * base::Time::kMicrosecondsPerSecond; 244 float microseconds = seconds * base::Time::kMicrosecondsPerSecond;
243 if (seconds != 0) 245 if (seconds != 0)
244 pipeline_->Seek( 246 pipeline_->Seek(
245 base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)), 247 base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)),
246 NewCallback(proxy_.get(), 248 NewCallback(proxy_.get(),
247 &WebMediaPlayerImpl::Proxy::PipelineSeekCallback)); 249 &WebMediaPlayerImpl::Proxy::PipelineSeekCallback));
248 } 250 }
249 251
250 void WebMediaPlayerImpl::setEndTime(float seconds) { 252 void WebMediaPlayerImpl::setEndTime(float seconds) {
251 DCHECK(MessageLoop::current() == main_loop_); 253 DCHECK(MessageLoop::current() == main_loop_);
252 254
253 // TODO(hclam): add method call when it has been implemented. 255 // TODO(hclam): add method call when it has been implemented.
254 return; 256 return;
255 } 257 }
256 258
257 void WebMediaPlayerImpl::setRate(float rate) { 259 void WebMediaPlayerImpl::setRate(float rate) {
258 DCHECK(MessageLoop::current() == main_loop_); 260 DCHECK(MessageLoop::current() == main_loop_);
259 261
260 pipeline_->SetPlaybackRate(rate); 262 playback_rate_ = rate;
263 if (!paused_) {
264 pipeline_->SetPlaybackRate(rate);
265 }
261 } 266 }
262 267
263 void WebMediaPlayerImpl::setVolume(float volume) { 268 void WebMediaPlayerImpl::setVolume(float volume) {
264 DCHECK(MessageLoop::current() == main_loop_); 269 DCHECK(MessageLoop::current() == main_loop_);
265 270
266 pipeline_->SetVolume(volume); 271 pipeline_->SetVolume(volume);
267 } 272 }
268 273
269 void WebMediaPlayerImpl::setVisible(bool visible) { 274 void WebMediaPlayerImpl::setVisible(bool visible) {
270 DCHECK(MessageLoop::current() == main_loop_); 275 DCHECK(MessageLoop::current() == main_loop_);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 432 }
428 } 433 }
429 434
430 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { 435 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() {
431 DCHECK(MessageLoop::current() == main_loop_); 436 DCHECK(MessageLoop::current() == main_loop_);
432 DCHECK(client_); 437 DCHECK(client_);
433 return client_; 438 return client_;
434 } 439 }
435 440
436 } // namespace webkit_glue 441 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698