diff options
author | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-14 15:56:29 +0000 |
---|---|---|
committer | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-14 15:56:29 +0000 |
commit | b6c2955681cc0959a9754c02cab67b317fc59e8a (patch) | |
tree | 65bd81c3fe1ec4d0bde03510bcad2d4b222e1c21 /webkit/glue/webmediaplayer_impl.cc | |
parent | 42d2ebcb5bd1b2efc9cd32baf8656c859dff8313 (diff) | |
download | chromium_src-b6c2955681cc0959a9754c02cab67b317fc59e8a.zip chromium_src-b6c2955681cc0959a9754c02cab67b317fc59e8a.tar.gz chromium_src-b6c2955681cc0959a9754c02cab67b317fc59e8a.tar.bz2 |
Refactoring code to use factories to create DataSource objects.
BUG=72485
TEST=None for now. Existing unit tests cover this code.
Review URL: http://codereview.chromium.org/6480050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78033 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webmediaplayer_impl.cc')
-rw-r--r-- | webkit/glue/webmediaplayer_impl.cc | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc index 3801406..2d5e6a6 100644 --- a/webkit/glue/webmediaplayer_impl.cc +++ b/webkit/glue/webmediaplayer_impl.cc @@ -8,6 +8,7 @@ #include "base/callback.h" #include "base/command_line.h" +#include "media/base/composite_data_source_factory.h" #include "media/base/filter_collection.h" #include "media/base/limits.h" #include "media/base/media_format.h" @@ -113,10 +114,10 @@ void WebMediaPlayerImpl::Proxy::SetVideoRenderer( video_renderer_ = video_renderer; } -void WebMediaPlayerImpl::Proxy::AddDataSource( - scoped_refptr<WebDataSource> data_source) { - base::AutoLock auto_lock(data_sources_lock_); - data_sources_.push_back(data_source); +WebDataSourceBuildObserverHack* WebMediaPlayerImpl::Proxy::GetBuildObserver() { + if (!build_observer_.get()) + build_observer_.reset(NewCallback(this, &Proxy::AddDataSource)); + return build_observer_.get(); } void WebMediaPlayerImpl::Proxy::Paint(skia::PlatformCanvas* canvas, @@ -195,6 +196,11 @@ void WebMediaPlayerImpl::Proxy::NetworkEventCallback() { &WebMediaPlayerImpl::Proxy::NetworkEventTask)); } +void WebMediaPlayerImpl::Proxy::AddDataSource(WebDataSource* data_source) { + base::AutoLock auto_lock(data_sources_lock_); + data_sources_.push_back(make_scoped_refptr(data_source)); +} + void WebMediaPlayerImpl::Proxy::RepaintTask() { DCHECK(MessageLoop::current() == render_loop_); { @@ -309,22 +315,28 @@ bool WebMediaPlayerImpl::Initialize( &WebMediaPlayerImpl::Proxy::NetworkEventCallback)); // A simple data source that keeps all data in memory. - scoped_refptr<SimpleDataSource> simple_data_source( - new SimpleDataSource(MessageLoop::current(), frame)); + scoped_ptr<media::DataSourceFactory> simple_data_source_factory( + SimpleDataSource::CreateFactory(MessageLoop::current(), frame, + proxy_->GetBuildObserver())); // A sophisticated data source that does memory caching. - scoped_refptr<BufferedDataSource> buffered_data_source( - new BufferedDataSource(MessageLoop::current(), frame)); - proxy_->AddDataSource(buffered_data_source); + scoped_ptr<media::DataSourceFactory> buffered_data_source_factory( + BufferedDataSource::CreateFactory(MessageLoop::current(), frame, + proxy_->GetBuildObserver())); + + scoped_ptr<media::CompositeDataSourceFactory> data_source_factory( + new media::CompositeDataSourceFactory()); if (use_simple_data_source) { - filter_collection_->AddDataSource(simple_data_source); - filter_collection_->AddDataSource(buffered_data_source); + data_source_factory->AddFactory(simple_data_source_factory.release()); + data_source_factory->AddFactory(buffered_data_source_factory.release()); } else { - filter_collection_->AddDataSource(buffered_data_source); - filter_collection_->AddDataSource(simple_data_source); + data_source_factory->AddFactory(buffered_data_source_factory.release()); + data_source_factory->AddFactory(simple_data_source_factory.release()); } + filter_collection_->SetDataSourceFactory(data_source_factory.release()); + // Add in the default filter factories. filter_collection_->AddDemuxer(new media::FFmpegDemuxer( message_loop_factory_->GetMessageLoop("DemuxThread"))); @@ -797,6 +809,7 @@ void WebMediaPlayerImpl::OnPipelineError() { case media::DEMUXER_ERROR_COULD_NOT_PARSE: case media::DEMUXER_ERROR_NO_SUPPORTED_STREAMS: case media::DEMUXER_ERROR_COULD_NOT_CREATE_THREAD: + case media::DATASOURCE_ERROR_URL_NOT_SUPPORTED: // Format error. SetNetworkState(WebMediaPlayer::FormatError); break; |