diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-12 01:01:52 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-12 01:01:52 +0000 |
commit | b9490b9c31dccdec1ae72f24f13c91349ff96410 (patch) | |
tree | abee0338b4f54f664a60d5ba598df2e02e1104f6 /chrome/renderer | |
parent | 9a7b22e6fb1d115a694616fd5a12bfe6e491664b (diff) | |
download | chromium_src-b9490b9c31dccdec1ae72f24f13c91349ff96410.zip chromium_src-b9490b9c31dccdec1ae72f24f13c91349ff96410.tar.gz chromium_src-b9490b9c31dccdec1ae72f24f13c91349ff96410.tar.bz2 |
Implemented Pipeline seek callbacks and a big refactor of PipelineImplTest.
Now that I'm wiser writing tests, I'm trying to get rid of InitializationHelper and rely on simplier test fixtures classes. I also introduced MockFilterFactory which is capable of creating all the mock filters and is able to return instantiated instances of filters to permit testing for expectations (refer to PipelineImplTest.Seek for an example).
Review URL: http://codereview.chromium.org/115094
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15829 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/webmediaplayer_impl.cc | 22 | ||||
-rw-r--r-- | chrome/renderer/webmediaplayer_impl.h | 8 |
2 files changed, 17 insertions, 13 deletions
diff --git a/chrome/renderer/webmediaplayer_impl.cc b/chrome/renderer/webmediaplayer_impl.cc index 9cff367..781c49b 100644 --- a/chrome/renderer/webmediaplayer_impl.cc +++ b/chrome/renderer/webmediaplayer_impl.cc @@ -113,7 +113,7 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { // Initialize the pipeline pipeline_.Start(filter_factory_.get(), url.spec(), - NewCallback(this, &WebMediaPlayerImpl::DidInitializePipeline)); + NewCallback(this, &WebMediaPlayerImpl::OnPipelineInitialize)); } void WebMediaPlayerImpl::cancelLoad() { @@ -146,14 +146,11 @@ void WebMediaPlayerImpl::stop() { void WebMediaPlayerImpl::seek(float seconds) { DCHECK(main_loop_ && MessageLoop::current() == main_loop_); - pipeline_.Seek(base::TimeDelta::FromSeconds(static_cast<int64>(seconds))); - - // Even though the seek might be in progress, WebKit's HTMLMediaElement - // thinks we're seeking unless we notify that the time has changed. - // - // TODO(scherkus): add a seek completion callback to the pipeline. - PostTask(kTimeChangedTaskIndex, - &WebKit::WebMediaPlayerClient::timeChanged); + // Try to preserve as much accuracy as possible. + float microseconds = seconds * base::Time::kMicrosecondsPerSecond; + pipeline_.Seek( + base::TimeDelta::FromMicroseconds(static_cast<int64>(microseconds)), + NewCallback(this, &WebMediaPlayerImpl::OnPipelineSeek)); } void WebMediaPlayerImpl::setEndTime(float seconds) { @@ -297,7 +294,7 @@ void WebMediaPlayerImpl::WillDestroyCurrentMessageLoop() { pipeline_.Stop(); } -void WebMediaPlayerImpl::DidInitializePipeline(bool successful) { +void WebMediaPlayerImpl::OnPipelineInitialize(bool successful) { if (successful) { // Since we have initialized the pipeline, say we have everything. // TODO(hclam): change this to report the correct status. @@ -316,6 +313,11 @@ void WebMediaPlayerImpl::DidInitializePipeline(bool successful) { &WebKit::WebMediaPlayerClient::readyStateChanged); } +void WebMediaPlayerImpl::OnPipelineSeek(bool successful) { + PostTask(kTimeChangedTaskIndex, + &WebKit::WebMediaPlayerClient::timeChanged); +} + void WebMediaPlayerImpl::SetVideoRenderer(VideoRendererImpl* video_renderer) { video_renderer_ = video_renderer; } diff --git a/chrome/renderer/webmediaplayer_impl.h b/chrome/renderer/webmediaplayer_impl.h index bce6205..f2202bf 100644 --- a/chrome/renderer/webmediaplayer_impl.h +++ b/chrome/renderer/webmediaplayer_impl.h @@ -132,9 +132,11 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer, // to it. virtual void WillDestroyCurrentMessageLoop(); - // Notification callback for initialization from |pipeline_|. |successful| is - // true if the pipeline initialization is successful otherwise false. - void DidInitializePipeline(bool successful); + // Notification from |pipeline_| when initialization has finished. + void OnPipelineInitialize(bool successful); + + // Notification from |pipeline_| when a seek has finished. + void OnPipelineSeek(bool successful); // Called from tasks posted to |main_loop_| from this object to remove // reference of them. |