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

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

Issue 199037: Buffered time ranges for <video> (Closed)
Patch Set: DEPS Created 11 years, 3 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/base/media_format.h" 9 #include "media/base/media_format.h"
10 #include "media/filters/ffmpeg_audio_decoder.h" 10 #include "media/filters/ffmpeg_audio_decoder.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 DCHECK(MessageLoop::current() == main_loop_); 361 DCHECK(MessageLoop::current() == main_loop_);
362 362
363 return pipeline_->GetPlaybackRate() == 0.0f; 363 return pipeline_->GetPlaybackRate() == 0.0f;
364 } 364 }
365 365
366 bool WebMediaPlayerImpl::seeking() const { 366 bool WebMediaPlayerImpl::seeking() const {
367 DCHECK(MessageLoop::current() == main_loop_); 367 DCHECK(MessageLoop::current() == main_loop_);
368 368
369 if (ready_state_ == WebKit::WebMediaPlayer::HaveNothing) 369 if (ready_state_ == WebKit::WebMediaPlayer::HaveNothing)
370 return false; 370 return false;
371 371
372 return ready_state_ == WebKit::WebMediaPlayer::HaveMetadata; 372 return ready_state_ == WebKit::WebMediaPlayer::HaveMetadata;
373 } 373 }
374 374
375 float WebMediaPlayerImpl::duration() const { 375 float WebMediaPlayerImpl::duration() const {
376 DCHECK(MessageLoop::current() == main_loop_); 376 DCHECK(MessageLoop::current() == main_loop_);
377 377
378 return static_cast<float>(pipeline_->GetDuration().InSecondsF()); 378 return static_cast<float>(pipeline_->GetDuration().InSecondsF());
379 } 379 }
380 380
381 float WebMediaPlayerImpl::currentTime() const { 381 float WebMediaPlayerImpl::currentTime() const {
382 DCHECK(MessageLoop::current() == main_loop_); 382 DCHECK(MessageLoop::current() == main_loop_);
383 383
384 return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF()); 384 return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF());
385 } 385 }
386 386
387 int WebMediaPlayerImpl::dataRate() const { 387 int WebMediaPlayerImpl::dataRate() const {
388 DCHECK(MessageLoop::current() == main_loop_); 388 DCHECK(MessageLoop::current() == main_loop_);
389 389
390 // TODO(hclam): Add this method call if pipeline has it in the interface. 390 // TODO(hclam): Add this method call if pipeline has it in the interface.
391 return 0; 391 return 0;
392 } 392 }
393 393
394 float WebMediaPlayerImpl::maxTimeBuffered() const { 394 const WebKit::WebTimeRanges& WebMediaPlayerImpl::buffered() const {
395 DCHECK(MessageLoop::current() == main_loop_); 395 DCHECK(MessageLoop::current() == main_loop_);
396 396
397 return static_cast<float>(pipeline_->GetBufferedTime().InSecondsF()); 397 return buffered_;
398 } 398 }
399 399
400 float WebMediaPlayerImpl::maxTimeSeekable() const { 400 float WebMediaPlayerImpl::maxTimeSeekable() const {
401 DCHECK(MessageLoop::current() == main_loop_); 401 DCHECK(MessageLoop::current() == main_loop_);
402 402
403 // If we are performing streaming, we report that we cannot seek at all. 403 // If we are performing streaming, we report that we cannot seek at all.
404 // We are using this flag to indicate if the data source supports seeking 404 // We are using this flag to indicate if the data source supports seeking
405 // or not. We should be able to seek even if we are performing streaming. 405 // or not. We should be able to seek even if we are performing streaming.
406 // TODO(hclam): We need to update this when we have better caching. 406 // TODO(hclam): We need to update this when we have better caching.
407 if (pipeline_->IsStreaming()) 407 if (pipeline_->IsStreaming())
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } 464 }
465 465
466 void WebMediaPlayerImpl::Repaint() { 466 void WebMediaPlayerImpl::Repaint() {
467 DCHECK(MessageLoop::current() == main_loop_); 467 DCHECK(MessageLoop::current() == main_loop_);
468 GetClient()->repaint(); 468 GetClient()->repaint();
469 } 469 }
470 470
471 void WebMediaPlayerImpl::OnPipelineInitialize() { 471 void WebMediaPlayerImpl::OnPipelineInitialize() {
472 DCHECK(MessageLoop::current() == main_loop_); 472 DCHECK(MessageLoop::current() == main_loop_);
473 if (pipeline_->GetError() == media::PIPELINE_OK) { 473 if (pipeline_->GetError() == media::PIPELINE_OK) {
474 // Only keep one time range starting from 0.
475 buffered_.push_back(
476 WebKit::WebTimeRange(
477 0.0f,
478 static_cast<float>(pipeline_->GetBufferedTime().InSecondsF())));
479
474 // Since we have initialized the pipeline, say we have everything. 480 // Since we have initialized the pipeline, say we have everything.
475 // TODO(hclam): change this to report the correct status. 481 // TODO(hclam): change this to report the correct status.
476 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); 482 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata);
477 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); 483 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
478 if (pipeline_->IsLoaded()) { 484 if (pipeline_->IsLoaded()) {
479 SetNetworkState(WebKit::WebMediaPlayer::Loaded); 485 SetNetworkState(WebKit::WebMediaPlayer::Loaded);
480 } else { 486 } else {
481 SetNetworkState(WebKit::WebMediaPlayer::Loading); 487 SetNetworkState(WebKit::WebMediaPlayer::Loading);
482 } 488 }
483 } else { 489 } else {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } 581 }
576 } 582 }
577 583
578 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { 584 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() {
579 DCHECK(MessageLoop::current() == main_loop_); 585 DCHECK(MessageLoop::current() == main_loop_);
580 DCHECK(client_); 586 DCHECK(client_);
581 return client_; 587 return client_;
582 } 588 }
583 589
584 } // namespace webkit_glue 590 } // 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