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 <limits> |
| 8 |
7 #include "base/callback.h" | 9 #include "base/callback.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "media/base/limits.h" | 11 #include "media/base/limits.h" |
10 #include "media/base/media_format.h" | 12 #include "media/base/media_format.h" |
11 #include "media/base/media_switches.h" | 13 #include "media/base/media_switches.h" |
12 #include "media/filters/ffmpeg_audio_decoder.h" | 14 #include "media/filters/ffmpeg_audio_decoder.h" |
13 #include "media/filters/ffmpeg_demuxer.h" | 15 #include "media/filters/ffmpeg_demuxer.h" |
14 #include "media/filters/ffmpeg_video_decoder.h" | 16 #include "media/filters/ffmpeg_video_decoder.h" |
15 #include "media/filters/null_audio_renderer.h" | 17 #include "media/filters/null_audio_renderer.h" |
16 #include "skia/ext/platform_canvas.h" | 18 #include "skia/ext/platform_canvas.h" |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 412 |
411 if (ready_state_ == WebKit::WebMediaPlayer::HaveNothing) | 413 if (ready_state_ == WebKit::WebMediaPlayer::HaveNothing) |
412 return false; | 414 return false; |
413 | 415 |
414 return ready_state_ == WebKit::WebMediaPlayer::HaveMetadata; | 416 return ready_state_ == WebKit::WebMediaPlayer::HaveMetadata; |
415 } | 417 } |
416 | 418 |
417 float WebMediaPlayerImpl::duration() const { | 419 float WebMediaPlayerImpl::duration() const { |
418 DCHECK(MessageLoop::current() == main_loop_); | 420 DCHECK(MessageLoop::current() == main_loop_); |
419 | 421 |
420 return static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); | 422 base::TimeDelta duration = pipeline_->GetMediaDuration(); |
| 423 if (duration.InMicroseconds() == media::Limits::kMaxTimeInMicroseconds) |
| 424 return std::numeric_limits<float>::infinity(); |
| 425 return static_cast<float>(duration.InSecondsF()); |
421 } | 426 } |
422 | 427 |
423 float WebMediaPlayerImpl::currentTime() const { | 428 float WebMediaPlayerImpl::currentTime() const { |
424 DCHECK(MessageLoop::current() == main_loop_); | 429 DCHECK(MessageLoop::current() == main_loop_); |
425 | 430 |
426 if (paused_) { | 431 if (paused_) { |
427 return static_cast<float>(paused_time_.InSecondsF()); | 432 return static_cast<float>(paused_time_.InSecondsF()); |
428 } | 433 } |
429 return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF()); | 434 return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF()); |
430 } | 435 } |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 pipeline_stopped_.Signal(); | 713 pipeline_stopped_.Signal(); |
709 } | 714 } |
710 | 715 |
711 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 716 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
712 DCHECK(MessageLoop::current() == main_loop_); | 717 DCHECK(MessageLoop::current() == main_loop_); |
713 DCHECK(client_); | 718 DCHECK(client_); |
714 return client_; | 719 return client_; |
715 } | 720 } |
716 | 721 |
717 } // namespace webkit_glue | 722 } // namespace webkit_glue |
OLD | NEW |