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

Side by Side Diff: chrome/renderer/webmediaplayer_delegate_impl.cc

Issue 100131: Finished implementing seeking in WebMediaPlayerDelegateImpl. (Closed)
Patch Set: Typo Created 11 years, 7 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 | « chrome/renderer/webmediaplayer_delegate_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 "chrome/renderer/webmediaplayer_delegate_impl.h" 5 #include "chrome/renderer/webmediaplayer_delegate_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/common/chrome_switches.h" 8 #include "chrome/common/chrome_switches.h"
9 #include "chrome/renderer/media/audio_renderer_impl.h" 9 #include "chrome/renderer/media/audio_renderer_impl.h"
10 #include "chrome/renderer/media/data_source_impl.h" 10 #include "chrome/renderer/media/data_source_impl.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 146 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
147 147
148 // We can fire Stop() multiple times. 148 // We can fire Stop() multiple times.
149 pipeline_.Stop(); 149 pipeline_.Stop();
150 } 150 }
151 151
152 void WebMediaPlayerDelegateImpl::Seek(float seconds) { 152 void WebMediaPlayerDelegateImpl::Seek(float seconds) {
153 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 153 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
154 154
155 pipeline_.Seek(base::TimeDelta::FromSeconds(static_cast<int64>(seconds))); 155 pipeline_.Seek(base::TimeDelta::FromSeconds(static_cast<int64>(seconds)));
156
157 // Even though the seek might be in progress, WebKit's HTMLMediaElement
158 // thinks we're seeking unless we notify that the time has changed.
159 //
160 // TODO(scherkus): add a seek completion callback to the pipeline.
161 PostTask(kTimeChangedTaskIndex,
162 &webkit_glue::WebMediaPlayer::NotifyTimeChange);
156 } 163 }
157 164
158 void WebMediaPlayerDelegateImpl::SetEndTime(float seconds) { 165 void WebMediaPlayerDelegateImpl::SetEndTime(float seconds) {
159 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 166 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
160 167
161 // TODO(hclam): add method call when it has been implemented. 168 // TODO(hclam): add method call when it has been implemented.
162 return; 169 return;
163 } 170 }
164 171
165 void WebMediaPlayerDelegateImpl::SetPlaybackRate(float rate) { 172 void WebMediaPlayerDelegateImpl::SetPlaybackRate(float rate) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 220
214 bool WebMediaPlayerDelegateImpl::IsPaused() const { 221 bool WebMediaPlayerDelegateImpl::IsPaused() const {
215 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 222 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
216 223
217 return pipeline_.GetPlaybackRate() == 0.0f; 224 return pipeline_.GetPlaybackRate() == 0.0f;
218 } 225 }
219 226
220 bool WebMediaPlayerDelegateImpl::IsSeeking() const { 227 bool WebMediaPlayerDelegateImpl::IsSeeking() const {
221 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 228 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
222 229
223 // TODO(hclam): Add this method call if pipeline has it in the interface. 230 return tasks_[kTimeChangedTaskIndex] != NULL;
224 return false;
225 } 231 }
226 232
227 float WebMediaPlayerDelegateImpl::GetDuration() const { 233 float WebMediaPlayerDelegateImpl::GetDuration() const {
228 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 234 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
229 235
230 return static_cast<float>(pipeline_.GetDuration().InSecondsF()); 236 return static_cast<float>(pipeline_.GetDuration().InSecondsF());
231 } 237 }
232 238
233 float WebMediaPlayerDelegateImpl::GetCurrentTime() const { 239 float WebMediaPlayerDelegateImpl::GetCurrentTime() const {
234 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 240 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
(...skipping 23 matching lines...) Expand all
258 264
259 float WebMediaPlayerDelegateImpl::GetMaxTimeBuffered() const { 265 float WebMediaPlayerDelegateImpl::GetMaxTimeBuffered() const {
260 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 266 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
261 267
262 return static_cast<float>(pipeline_.GetBufferedTime().InSecondsF()); 268 return static_cast<float>(pipeline_.GetBufferedTime().InSecondsF());
263 } 269 }
264 270
265 float WebMediaPlayerDelegateImpl::GetMaxTimeSeekable() const { 271 float WebMediaPlayerDelegateImpl::GetMaxTimeSeekable() const {
266 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 272 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
267 273
268 // TODO(hclam): add this method when pipeline has this method implemented. 274 // TODO(scherkus): move this logic down into the pipeline.
269 return 0.0f; 275 if (pipeline_.GetTotalBytes() == 0) {
276 return 0.0f;
277 }
278 double total_bytes = static_cast<double>(pipeline_.GetTotalBytes());
279 double buffered_bytes = static_cast<double>(pipeline_.GetBufferedBytes());
280 double duration = static_cast<double>(pipeline_.GetDuration().InSecondsF());
281 return static_cast<float>(duration * (buffered_bytes / total_bytes));
270 } 282 }
271 283
272 int64 WebMediaPlayerDelegateImpl::GetBytesLoaded() const { 284 int64 WebMediaPlayerDelegateImpl::GetBytesLoaded() const {
273 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 285 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
274 286
275 return pipeline_.GetBufferedBytes(); 287 return pipeline_.GetBufferedBytes();
276 } 288 }
277 289
278 int64 WebMediaPlayerDelegateImpl::GetTotalBytes() const { 290 int64 WebMediaPlayerDelegateImpl::GetTotalBytes() const {
279 DCHECK(main_loop_ && MessageLoop::current() == main_loop_); 291 DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 if(!tasks_[index]) { 366 if(!tasks_[index]) {
355 CancelableTask* task = new NotifyWebMediaPlayerTask(this, method); 367 CancelableTask* task = new NotifyWebMediaPlayerTask(this, method);
356 tasks_[index] = task; 368 tasks_[index] = task;
357 main_loop_->PostTask(FROM_HERE, task); 369 main_loop_->PostTask(FROM_HERE, task);
358 } 370 }
359 } 371 }
360 372
361 void WebMediaPlayerDelegateImpl::PostRepaintTask() { 373 void WebMediaPlayerDelegateImpl::PostRepaintTask() {
362 PostTask(kRepaintTaskIndex, &webkit_glue::WebMediaPlayer::Repaint); 374 PostTask(kRepaintTaskIndex, &webkit_glue::WebMediaPlayer::Repaint);
363 } 375 }
OLDNEW
« no previous file with comments | « chrome/renderer/webmediaplayer_delegate_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698