| OLD | NEW |
| 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 "media/base/media_format.h" | 7 #include "media/base/media_format.h" |
| 8 #include "media/filters/ffmpeg_audio_decoder.h" | 8 #include "media/filters/ffmpeg_audio_decoder.h" |
| 9 #include "media/filters/ffmpeg_demuxer.h" | 9 #include "media/filters/ffmpeg_demuxer.h" |
| 10 #include "media/filters/ffmpeg_video_decoder.h" | 10 #include "media/filters/ffmpeg_video_decoder.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 return; | 288 return; |
| 289 } | 289 } |
| 290 | 290 |
| 291 // Drop our ready state if the media file isn't fully loaded. | 291 // Drop our ready state if the media file isn't fully loaded. |
| 292 if (!pipeline_->IsLoaded()) { | 292 if (!pipeline_->IsLoaded()) { |
| 293 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); | 293 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Try to preserve as much accuracy as possible. | 296 // Try to preserve as much accuracy as possible. |
| 297 float microseconds = seconds * base::Time::kMicrosecondsPerSecond; | 297 float microseconds = seconds * base::Time::kMicrosecondsPerSecond; |
| 298 base::TimeDelta seek_time = |
| 299 base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)); |
| 300 |
| 301 // Update our paused time. |
| 302 if (paused_) { |
| 303 paused_time_ = seek_time; |
| 304 } |
| 305 |
| 306 // Kick off the asynchronous seek! |
| 298 pipeline_->Seek( | 307 pipeline_->Seek( |
| 299 base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)), | 308 seek_time, |
| 300 NewCallback(proxy_.get(), | 309 NewCallback(proxy_.get(), |
| 301 &WebMediaPlayerImpl::Proxy::PipelineSeekCallback)); | 310 &WebMediaPlayerImpl::Proxy::PipelineSeekCallback)); |
| 302 } | 311 } |
| 303 | 312 |
| 304 void WebMediaPlayerImpl::setEndTime(float seconds) { | 313 void WebMediaPlayerImpl::setEndTime(float seconds) { |
| 305 DCHECK(MessageLoop::current() == main_loop_); | 314 DCHECK(MessageLoop::current() == main_loop_); |
| 306 | 315 |
| 307 // TODO(hclam): add method call when it has been implemented. | 316 // TODO(hclam): add method call when it has been implemented. |
| 308 return; | 317 return; |
| 309 } | 318 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 SetNetworkState(WebKit::WebMediaPlayer::FormatError); | 560 SetNetworkState(WebKit::WebMediaPlayer::FormatError); |
| 552 } | 561 } |
| 553 | 562 |
| 554 // Repaint to trigger UI update. | 563 // Repaint to trigger UI update. |
| 555 Repaint(); | 564 Repaint(); |
| 556 } | 565 } |
| 557 | 566 |
| 558 void WebMediaPlayerImpl::OnPipelineSeek() { | 567 void WebMediaPlayerImpl::OnPipelineSeek() { |
| 559 DCHECK(MessageLoop::current() == main_loop_); | 568 DCHECK(MessageLoop::current() == main_loop_); |
| 560 if (pipeline_->GetError() == media::PIPELINE_OK) { | 569 if (pipeline_->GetError() == media::PIPELINE_OK) { |
| 570 // Update our paused time. |
| 571 if (paused_) { |
| 572 paused_time_ = pipeline_->GetCurrentTime(); |
| 573 } |
| 574 |
| 561 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); | 575 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); |
| 562 GetClient()->timeChanged(); | 576 GetClient()->timeChanged(); |
| 563 } | 577 } |
| 564 } | 578 } |
| 565 | 579 |
| 566 void WebMediaPlayerImpl::OnPipelineEnded() { | 580 void WebMediaPlayerImpl::OnPipelineEnded() { |
| 567 DCHECK(MessageLoop::current() == main_loop_); | 581 DCHECK(MessageLoop::current() == main_loop_); |
| 568 if (pipeline_->GetError() == media::PIPELINE_OK) { | 582 if (pipeline_->GetError() == media::PIPELINE_OK) { |
| 569 GetClient()->timeChanged(); | 583 GetClient()->timeChanged(); |
| 570 } | 584 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 661 } |
| 648 } | 662 } |
| 649 | 663 |
| 650 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 664 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
| 651 DCHECK(MessageLoop::current() == main_loop_); | 665 DCHECK(MessageLoop::current() == main_loop_); |
| 652 DCHECK(client_); | 666 DCHECK(client_); |
| 653 return client_; | 667 return client_; |
| 654 } | 668 } |
| 655 | 669 |
| 656 } // namespace webkit_glue | 670 } // namespace webkit_glue |
| OLD | NEW |