OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "media/base/limits.h" | 9 #include "media/base/limits.h" |
10 #include "media/base/media_format.h" | 10 #include "media/base/media_format.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 // TODO(hclam): Add this method call if pipeline has it in the interface. | 439 // TODO(hclam): Add this method call if pipeline has it in the interface. |
440 return 0; | 440 return 0; |
441 } | 441 } |
442 | 442 |
443 const WebKit::WebTimeRanges& WebMediaPlayerImpl::buffered() const { | 443 const WebKit::WebTimeRanges& WebMediaPlayerImpl::buffered() const { |
444 DCHECK(MessageLoop::current() == main_loop_); | 444 DCHECK(MessageLoop::current() == main_loop_); |
445 | 445 |
446 return buffered_; | 446 return buffered_; |
447 } | 447 } |
448 | 448 |
| 449 const WebKit::WebTimeRanges& WebMediaPlayerImpl::buffered() { |
| 450 DCHECK(MessageLoop::current() == main_loop_); |
| 451 |
| 452 // Update buffered_ with the most recent buffered time. |
| 453 if (buffered_.size() > 0) { |
| 454 float buffered_time = static_cast<float>( |
| 455 pipeline_->GetBufferedTime().InSecondsF()); |
| 456 if (buffered_time >= buffered_[0].start) |
| 457 buffered_[0].end = buffered_time; |
| 458 } |
| 459 |
| 460 return buffered_; |
| 461 } |
| 462 |
449 float WebMediaPlayerImpl::maxTimeSeekable() const { | 463 float WebMediaPlayerImpl::maxTimeSeekable() const { |
450 DCHECK(MessageLoop::current() == main_loop_); | 464 DCHECK(MessageLoop::current() == main_loop_); |
451 | 465 |
452 // If we are performing streaming, we report that we cannot seek at all. | 466 // If we are performing streaming, we report that we cannot seek at all. |
453 // We are using this flag to indicate if the data source supports seeking | 467 // We are using this flag to indicate if the data source supports seeking |
454 // or not. We should be able to seek even if we are performing streaming. | 468 // or not. We should be able to seek even if we are performing streaming. |
455 // TODO(hclam): We need to update this when we have better caching. | 469 // TODO(hclam): We need to update this when we have better caching. |
456 if (pipeline_->IsStreaming()) | 470 if (pipeline_->IsStreaming()) |
457 return 0.0f; | 471 return 0.0f; |
458 return static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); | 472 return static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 } | 710 } |
697 } | 711 } |
698 | 712 |
699 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 713 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
700 DCHECK(MessageLoop::current() == main_loop_); | 714 DCHECK(MessageLoop::current() == main_loop_); |
701 DCHECK(client_); | 715 DCHECK(client_); |
702 return client_; | 716 return client_; |
703 } | 717 } |
704 | 718 |
705 } // namespace webkit_glue | 719 } // namespace webkit_glue |
OLD | NEW |