summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 19:55:20 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 19:55:20 +0000
commita9415292f9aedca5c528532f1260118ad384aaed (patch)
treedf6dde3058efb3594a77ef78ce904c624f78da30 /media
parentd2353452f11b73f763ea0be9f1a608d03cfddeac (diff)
downloadchromium_src-a9415292f9aedca5c528532f1260118ad384aaed.zip
chromium_src-a9415292f9aedca5c528532f1260118ad384aaed.tar.gz
chromium_src-a9415292f9aedca5c528532f1260118ad384aaed.tar.bz2
Replace DataSourceFactory with explicitly initialized DataSources.
BUG=107324 TEST=layout tests Review URL: https://chromiumcodereview.appspot.com/9243016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/async_filter_factory_base.cc113
-rw-r--r--media/base/async_filter_factory_base.h121
-rw-r--r--media/base/composite_data_source_factory.cc98
-rw-r--r--media/base/composite_data_source_factory.h42
-rw-r--r--media/base/demuxer_factory.cc (renamed from media/base/filter_factories.cc)6
-rw-r--r--media/base/demuxer_factory.h (renamed from media/base/filter_factories.h)20
-rw-r--r--media/base/filter_collection.h2
-rw-r--r--media/filters/chunk_demuxer_factory.cc19
-rw-r--r--media/filters/chunk_demuxer_factory.h13
-rw-r--r--media/filters/dummy_demuxer_factory.h2
-rw-r--r--media/filters/ffmpeg_demuxer_factory.cc32
-rw-r--r--media/filters/ffmpeg_demuxer_factory.h6
-rw-r--r--media/filters/file_data_source_factory.cc34
-rw-r--r--media/filters/file_data_source_factory.h27
-rw-r--r--media/filters/pipeline_integration_test.cc13
-rw-r--r--media/media.gyp10
-rw-r--r--media/tools/player_wtl/movie.cc21
-rw-r--r--media/tools/player_x11/player_x11.cc15
18 files changed, 59 insertions, 535 deletions
diff --git a/media/base/async_filter_factory_base.cc b/media/base/async_filter_factory_base.cc
deleted file mode 100644
index 464f3b8..0000000
--- a/media/base/async_filter_factory_base.cc
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "media/base/async_filter_factory_base.h"
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/stl_util.h"
-
-namespace media {
-
-AsyncDataSourceFactoryBase::AsyncDataSourceFactoryBase() {}
-
-AsyncDataSourceFactoryBase::~AsyncDataSourceFactoryBase() {
- base::AutoLock auto_lock(lock_);
- STLDeleteElements(&outstanding_requests_);
-}
-
-void AsyncDataSourceFactoryBase::Build(const std::string& url,
- const BuildCallback& callback) {
- DCHECK(!callback.is_null());
- BuildRequest* request = NULL;
- {
- base::AutoLock auto_lock(lock_);
-
- if (url.empty()) {
- ReportError(PIPELINE_ERROR_URL_NOT_FOUND, callback);
- return;
- }
-
- if (!AllowRequests()) {
- ReportError(DATASOURCE_ERROR_URL_NOT_SUPPORTED, callback);
- return;
- }
-
- request = CreateRequest(url, callback);
-
- if (!request) {
- ReportError(DATASOURCE_ERROR_URL_NOT_SUPPORTED, callback);
- return;
- }
-
- outstanding_requests_.insert(request);
- }
-
- request->Start(base::Bind(
- &AsyncDataSourceFactoryBase::BuildRequestDone, base::Unretained(this)));
-}
-
-void AsyncDataSourceFactoryBase::ReportError(
- PipelineStatus error,
- const BuildCallback& callback) const {
- DCHECK_NE(error, PIPELINE_OK);
- DCHECK(!callback.is_null());
-
- callback.Run(error, NULL);
-}
-
-void AsyncDataSourceFactoryBase::BuildRequestDone(BuildRequest* request) {
- base::AutoLock auto_lock(lock_);
- outstanding_requests_.erase(request);
- delete request;
-}
-
-AsyncDataSourceFactoryBase::BuildRequest::BuildRequest(
- const std::string& url, const BuildCallback& callback)
- : url_(url),
- callback_(callback) {
-}
-
-AsyncDataSourceFactoryBase::BuildRequest::~BuildRequest() {}
-
-void AsyncDataSourceFactoryBase::BuildRequest::Start(
- const RequestDoneCallback& done_callback) {
- DCHECK(!done_callback.is_null());
- DCHECK(done_callback_.is_null());
-
- done_callback_ = done_callback;
- DoStart();
- // Don't do anything after this line since the object could
- // have been deleted at this point if the request was completed
- // inside the call.
-}
-
-void AsyncDataSourceFactoryBase::BuildRequest::RequestComplete(
- PipelineStatus status, DataSource* data_source) {
- DCHECK(!callback_.is_null());
- DCHECK(!done_callback_.is_null());
-
- // Transfer ownership to local variables just in case the
- // request object gets deleted by one of the callbacks.
- RequestDoneCallback done_callback;
- std::swap(done_callback, done_callback_);
- BuildCallback callback;
- std::swap(callback, callback_);
-
- // Notify factory that this request has completed. We do this before
- // calling |callback| so the factory doesn't consider this request
- // pending if |callback| happens to destroy the factory.
- //
- // NOTE: This BuildRequest object is destroyed inside this callback so
- // no modifications should be made to this object after this call.
- done_callback.Run(this);
-
- callback.Run(status, data_source);
-}
-
-const std::string& AsyncDataSourceFactoryBase::BuildRequest::url() const {
- return url_;
-}
-
-} // namespace media
diff --git a/media/base/async_filter_factory_base.h b/media/base/async_filter_factory_base.h
deleted file mode 100644
index 87b4b3e..0000000
--- a/media/base/async_filter_factory_base.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MEDIA_BASE_ASYNC_FILTER_FACTORY_BASE_H_
-#define MEDIA_BASE_ASYNC_FILTER_FACTORY_BASE_H_
-
-#include <set>
-
-#include "base/memory/scoped_ptr.h"
-#include "base/synchronization/lock.h"
-#include "media/base/filter_factories.h"
-
-namespace media {
-
-// This is a helper base class for DataSourceFactory implementation that
-// actually require asynchronous operations to build a data source. It
-// provides a common framework for dealing with an asychronous build.
-// Factories are expected to derive from this object and implement
-// AllowRequests(), CreateRequest(), and an custom implementation that derives
-// from BuildRequest.
-//
-// AllowRequests() just checks to see if the factory is in a state where it can
-// accept Build() requests. If it returns false, this base class will signal an
-// error through the BuildCallback and not call any of the other code. If
-// AllowRequests() returns true then this class will continue with the build
-// process by calling CreateRequest().
-//
-// CreateRequest() allows the derived implementation to create an instance of
-// their custom BuildRequest implementation that is specific to its asynchronous
-// build process. The custom BuildRequest should contain all of the state that
-// needs to be maintained for a particular build request. This state could
-// consist of partially initialized objects that require asynchronous operations
-// to complete before the build completes. This implementation MUST derive from
-// AsyncDataSourceFactoryBase::BuildRequest.
-//
-// Once CreateRequest() returns a BuildRequest implementation, this class adds
-// the object to its request list and then calls Start() on the BuildRequest
-// instance. BuildRequest::Start() manages storing the |done_callback| passed to
-// it and then call DoStart() on the derived object. DoStart() is where this
-// framework expects any neccesary asynchronous operations to be initiated.
-//
-// Once all asynchronous operations are completed and a fully initialized
-// DataSource object has been created, the BuildRequest instance should call
-// the RequestComplete() method. This call signals the end of the request and
-// the BuildRequest should be in a state where it can be deleted from inside
-// this call. If an error occurs during the build process, RequestComplete()
-// can also be called to signal the error.
-class MEDIA_EXPORT AsyncDataSourceFactoryBase : public DataSourceFactory {
- public:
- AsyncDataSourceFactoryBase();
- virtual ~AsyncDataSourceFactoryBase();
-
- // DataSourceFactory method.
- // Derived classes should not overload this Build() method. AllowRequests() &
- // CreateRequest() should be implemented instead.
- virtual void Build(const std::string& url,
- const BuildCallback& callback) OVERRIDE;
-
- protected:
- class MEDIA_EXPORT BuildRequest {
- public:
- BuildRequest(const std::string& url, const BuildCallback& callback);
- virtual ~BuildRequest();
-
- typedef base::Callback<void(BuildRequest*)> RequestDoneCallback;
- // Starts the build request.
- void Start(const RequestDoneCallback& done_callback);
-
- // Derived objects call this method to indicate that the build request
- // has completed. If the build was successful |status| should be set to
- // PIPELINE_OK and |data_source| should contain the DataSource object
- // that was built by this request. Ownership of |data_source| is being
- // passed in this call. If an error occurs during the build process, this
- // method should be called with |status| set to an appropriate status code
- // and |data_source| set to NULL.
- //
- // The derived object should be in a state where it can be deleted from
- // within this call. This class as well AsyncDataSourceFactoryBase use this
- // method to cleanup state associated with this request.
- void RequestComplete(media::PipelineStatus status, DataSource* data_source);
-
- protected:
- // Implemented by the derived object to start the build. Called by Start().
- virtual void DoStart() = 0;
-
- // Gets the requested URL.
- const std::string& url() const;
-
- private:
- std::string url_;
- BuildCallback callback_;
- RequestDoneCallback done_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(BuildRequest);
- };
-
- // Implemented by derived class. Called by Build() to check if the
- // factory is in a state where it can accept requests.
- virtual bool AllowRequests() const = 0;
-
- // Implemented by derived class. Called by Build() to allow derived objects
- // to create their own custom BuildRequest implementations.
- virtual BuildRequest* CreateRequest(const std::string& url,
- const BuildCallback& callback) = 0;
-
- private:
- void ReportError(PipelineStatus error, const BuildCallback& callback) const;
-
- void BuildRequestDone(BuildRequest* request);
-
- base::Lock lock_;
- typedef std::set<BuildRequest*> RequestSet;
- RequestSet outstanding_requests_;
-
- DISALLOW_COPY_AND_ASSIGN(AsyncDataSourceFactoryBase);
-};
-
-} // namespace media
-
-#endif // MEDIA_BASE_ASYNC_FILTER_FACTORY_BASE_H_
diff --git a/media/base/composite_data_source_factory.cc b/media/base/composite_data_source_factory.cc
deleted file mode 100644
index e91415f..0000000
--- a/media/base/composite_data_source_factory.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "media/base/composite_data_source_factory.h"
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/stl_util.h"
-
-namespace media {
-
-class CompositeDataSourceFactory::BuildRequest
- : public AsyncDataSourceFactoryBase::BuildRequest {
- public:
- BuildRequest(const std::string& url, const BuildCallback& callback,
- const FactoryList& factories);
- ~BuildRequest();
-
- protected:
- // AsyncDataSourceFactoryBase::BuildRequest method.
- virtual void DoStart();
-
- private:
- void CallNextFactory();
- void OnBuildDone(PipelineStatus status, DataSource* data_source);
-
- FactoryList factories_; // Not owned by this class.
-};
-
-CompositeDataSourceFactory::CompositeDataSourceFactory() {}
-
-CompositeDataSourceFactory::~CompositeDataSourceFactory() {
- STLDeleteElements(&factories_);
-}
-
-void CompositeDataSourceFactory::AddFactory(
- scoped_ptr<DataSourceFactory> factory) {
- DCHECK(factory.get());
- factories_.push_back(factory.release());
-}
-
-bool CompositeDataSourceFactory::AllowRequests() const {
- return !factories_.empty();
-}
-
-AsyncDataSourceFactoryBase::BuildRequest*
-CompositeDataSourceFactory::CreateRequest(const std::string& url,
- const BuildCallback& callback) {
- return new BuildRequest(url, callback, factories_);
-}
-
-CompositeDataSourceFactory::BuildRequest::BuildRequest(
- const std::string& url,
- const BuildCallback& callback,
- const FactoryList& factories)
- : AsyncDataSourceFactoryBase::BuildRequest(url, callback),
- factories_(factories){
- DCHECK(!factories.empty());
-}
-
-CompositeDataSourceFactory::BuildRequest::~BuildRequest() {}
-
-void CompositeDataSourceFactory::BuildRequest::DoStart() {
- CallNextFactory();
-}
-
-void CompositeDataSourceFactory::BuildRequest::CallNextFactory() {
- DCHECK(!factories_.empty());
-
- DataSourceFactory* factory = factories_.front();
- factories_.pop_front();
-
- factory->Build(url(), base::Bind(&BuildRequest::OnBuildDone,
- base::Unretained(this)));
-}
-
-void CompositeDataSourceFactory::BuildRequest::OnBuildDone(
- PipelineStatus status,
- DataSource* data_source) {
-
- if (status == PIPELINE_OK) {
- DCHECK(data_source);
- RequestComplete(status, data_source);
- return;
- }
-
- DCHECK(!data_source);
- if ((status == DATASOURCE_ERROR_URL_NOT_SUPPORTED) && !factories_.empty()) {
- CallNextFactory();
- return;
- }
-
- RequestComplete(status, data_source);
-}
-
-} // namespace media
diff --git a/media/base/composite_data_source_factory.h b/media/base/composite_data_source_factory.h
deleted file mode 100644
index 54f6387..0000000
--- a/media/base/composite_data_source_factory.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MEDIA_BASE_COMPOSITE_DATA_SOURCE_FACTORY_H_
-#define MEDIA_BASE_COMPOSITE_DATA_SOURCE_FACTORY_H_
-
-#include <list>
-#include <set>
-
-#include "base/synchronization/lock.h"
-#include "media/base/async_filter_factory_base.h"
-
-namespace media {
-
-class MEDIA_EXPORT CompositeDataSourceFactory
- : public AsyncDataSourceFactoryBase {
- public:
- CompositeDataSourceFactory();
- virtual ~CompositeDataSourceFactory();
-
- // Add factory to this composite.
- void AddFactory(scoped_ptr<DataSourceFactory> factory);
-
- protected:
- // AsyncDataSourceFactoryBase methods.
- virtual bool AllowRequests() const OVERRIDE;
- virtual AsyncDataSourceFactoryBase::BuildRequest* CreateRequest(
- const std::string& url, const BuildCallback& callback) OVERRIDE;
-
- private:
- class BuildRequest;
-
- typedef std::list<DataSourceFactory*> FactoryList;
- FactoryList factories_;
-
- DISALLOW_COPY_AND_ASSIGN(CompositeDataSourceFactory);
-};
-
-} // namespace media
-
-#endif // MEDIA_BASE_COMPOSITE_DATA_SOURCE_FACTORY_H_
diff --git a/media/base/filter_factories.cc b/media/base/demuxer_factory.cc
index c074cc6..1f968d7 100644
--- a/media/base/filter_factories.cc
+++ b/media/base/demuxer_factory.cc
@@ -1,13 +1,11 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "media/base/filter_factories.h"
+#include "media/base/demuxer_factory.h"
namespace media {
-DataSourceFactory::~DataSourceFactory() {}
-
DemuxerFactory::~DemuxerFactory() {}
} // namespace media
diff --git a/media/base/filter_factories.h b/media/base/demuxer_factory.h
index 0e004ef..6a13356 100644
--- a/media/base/filter_factories.h
+++ b/media/base/demuxer_factory.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MEDIA_BASE_FILTER_FACTORIES_H_
-#define MEDIA_BASE_FILTER_FACTORIES_H_
+#ifndef MEDIA_BASE_DEMUXER_FACTORY_H_
+#define MEDIA_BASE_DEMUXER_FACTORY_H_
#include <string>
@@ -13,20 +13,6 @@
namespace media {
-class DataSource;
-
-// Asynchronous factory interface for building DataSource objects.
-class MEDIA_EXPORT DataSourceFactory {
- public:
- // Ownership of the DataSource is transferred through this callback.
- typedef base::Callback<void(PipelineStatus, DataSource*)> BuildCallback;
-
- virtual ~DataSourceFactory();
-
- // Builds a DataSource for |url| and returns it via |callback|.
- virtual void Build(const std::string& url, const BuildCallback& callback) = 0;
-};
-
class Demuxer;
// Asynchronous factory interface for building Demuxer objects.
@@ -43,4 +29,4 @@ class MEDIA_EXPORT DemuxerFactory {
} // namespace media
-#endif // MEDIA_BASE_FILTER_FACTORIES_H_
+#endif // MEDIA_BASE_DEMUXER_FACTORY_H_
diff --git a/media/base/filter_collection.h b/media/base/filter_collection.h
index f129723..35bd1de 100644
--- a/media/base/filter_collection.h
+++ b/media/base/filter_collection.h
@@ -8,8 +8,8 @@
#include <list>
#include "base/memory/ref_counted.h"
+#include "media/base/demuxer_factory.h"
#include "media/base/filters.h"
-#include "media/base/filter_factories.h"
namespace media {
diff --git a/media/filters/chunk_demuxer_factory.cc b/media/filters/chunk_demuxer_factory.cc
index a441cf7..8455d58 100644
--- a/media/filters/chunk_demuxer_factory.cc
+++ b/media/filters/chunk_demuxer_factory.cc
@@ -19,28 +19,17 @@ static void InitDone(MessageLoop* message_loop,
message_loop->PostTask(FROM_HERE, base::Bind(cb, status, demuxer));
}
-ChunkDemuxerFactory::ChunkDemuxerFactory(
- const std::string& url,
- scoped_ptr<DemuxerFactory> delegate_factory,
- ChunkDemuxerClient* client)
- : url_(url),
- delegate_factory_(delegate_factory.Pass()),
- client_(client) {
- DCHECK(delegate_factory_.get());
+ChunkDemuxerFactory::ChunkDemuxerFactory(ChunkDemuxerClient* client)
+ : client_(client) {
+ DCHECK(client_);
}
ChunkDemuxerFactory::~ChunkDemuxerFactory() {}
void ChunkDemuxerFactory::Build(const std::string& url,
const BuildCallback& cb) {
- // Check to see if this is the URL we are looking for. If not delegate
- // building to the delegate factory.
- if (url != url_) {
- delegate_factory_->Build(url, cb);
- return;
- }
-
scoped_refptr<ChunkDemuxer> demuxer(new ChunkDemuxer(client_));
+
// Call Init() on demuxer. Note that ownership is being passed to the
// callback here.
demuxer->Init(base::Bind(&InitDone, MessageLoop::current(), cb, demuxer));
diff --git a/media/filters/chunk_demuxer_factory.h b/media/filters/chunk_demuxer_factory.h
index 7a3c9fc..9e34a12 100644
--- a/media/filters/chunk_demuxer_factory.h
+++ b/media/filters/chunk_demuxer_factory.h
@@ -8,7 +8,7 @@
#include <string>
#include "base/memory/scoped_ptr.h"
-#include "media/base/filter_factories.h"
+#include "media/base/demuxer_factory.h"
namespace media {
@@ -16,23 +16,16 @@ class ChunkDemuxer;
class ChunkDemuxerClient;
// Factory for building ChunkDemuxers. The factory will only build a
-// ChunkDemuxer for build URLs that match the one passed into the constructor.
-// All other URLs are delegated to |delegate_factory_|. The url passed to
-// the constructor represents the "special" URL that indicates that the
-// ChunkDemuxer should be used for playback.
+// ChunkDemuxer with the given client.
class MEDIA_EXPORT ChunkDemuxerFactory : public DemuxerFactory {
public:
- ChunkDemuxerFactory(const std::string& url,
- scoped_ptr<DemuxerFactory> delegate_factory,
- ChunkDemuxerClient* client);
+ ChunkDemuxerFactory(ChunkDemuxerClient* client);
virtual ~ChunkDemuxerFactory();
// DemuxerFactory methods.
virtual void Build(const std::string& url, const BuildCallback& cb) OVERRIDE;
private:
- std::string url_;
- scoped_ptr<DemuxerFactory> delegate_factory_;
ChunkDemuxerClient* client_;
DISALLOW_IMPLICIT_CONSTRUCTORS(ChunkDemuxerFactory);
diff --git a/media/filters/dummy_demuxer_factory.h b/media/filters/dummy_demuxer_factory.h
index 266314c..6bbf441 100644
--- a/media/filters/dummy_demuxer_factory.h
+++ b/media/filters/dummy_demuxer_factory.h
@@ -8,7 +8,7 @@
#define MEDIA_FILTERS_DUMMY_DEMUXER_FACTORY_H_
#include "base/compiler_specific.h"
-#include "media/base/filter_factories.h"
+#include "media/base/demuxer_factory.h"
namespace media {
diff --git a/media/filters/ffmpeg_demuxer_factory.cc b/media/filters/ffmpeg_demuxer_factory.cc
index 414c165..0c5e402 100644
--- a/media/filters/ffmpeg_demuxer_factory.cc
+++ b/media/filters/ffmpeg_demuxer_factory.cc
@@ -11,9 +11,11 @@
namespace media {
FFmpegDemuxerFactory::FFmpegDemuxerFactory(
- scoped_ptr<DataSourceFactory> data_source_factory,
+ const scoped_refptr<DataSource>& data_source,
MessageLoop* loop)
- : data_source_factory_(data_source_factory.Pass()), loop_(loop) {}
+ : data_source_(data_source),
+ loop_(loop) {
+}
FFmpegDemuxerFactory::~FFmpegDemuxerFactory() {}
@@ -24,32 +26,18 @@ static void DemuxerInitDone(const DemuxerFactory::BuildCallback& cb,
cb.Run(status, NULL);
return;
}
- cb.Run(PIPELINE_OK, demuxer.get());
-}
-
-static void InitializeDemuxerBasedOnDataSourceStatus(
- const DemuxerFactory::BuildCallback& cb,
- MessageLoop* loop, bool local_source,
- PipelineStatus status, DataSource* data_source) {
- if (status != PIPELINE_OK) {
- cb.Run(status, NULL);
- return;
- }
- DCHECK(data_source);
- scoped_refptr<FFmpegDemuxer> demuxer = new FFmpegDemuxer(loop, local_source);
- demuxer->Initialize(
- data_source,
- base::Bind(&DemuxerInitDone, cb, demuxer));
+ cb.Run(PIPELINE_OK, demuxer);
}
void FFmpegDemuxerFactory::Build(const std::string& url,
const BuildCallback& cb) {
GURL gurl = GURL(url);
bool local_source = !gurl.SchemeIs("http") && !gurl.SchemeIs("https");
- data_source_factory_->Build(
- url,
- base::Bind(&InitializeDemuxerBasedOnDataSourceStatus,
- cb, loop_, local_source));
+ scoped_refptr<FFmpegDemuxer> demuxer = new FFmpegDemuxer(loop_, local_source);
+
+ demuxer->Initialize(
+ data_source_,
+ base::Bind(&DemuxerInitDone, cb, demuxer));
}
} // namespace media
diff --git a/media/filters/ffmpeg_demuxer_factory.h b/media/filters/ffmpeg_demuxer_factory.h
index f35e5d5..6a9463f 100644
--- a/media/filters/ffmpeg_demuxer_factory.h
+++ b/media/filters/ffmpeg_demuxer_factory.h
@@ -9,7 +9,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
-#include "media/base/filter_factories.h"
+#include "media/base/demuxer_factory.h"
class MessageLoop;
@@ -17,7 +17,7 @@ namespace media {
class MEDIA_EXPORT FFmpegDemuxerFactory : public DemuxerFactory {
public:
- FFmpegDemuxerFactory(scoped_ptr<DataSourceFactory> data_source_factory,
+ FFmpegDemuxerFactory(const scoped_refptr<DataSource>& data_source,
MessageLoop* loop);
virtual ~FFmpegDemuxerFactory();
@@ -25,7 +25,7 @@ class MEDIA_EXPORT FFmpegDemuxerFactory : public DemuxerFactory {
virtual void Build(const std::string& url, const BuildCallback& cb) OVERRIDE;
private:
- scoped_ptr<DataSourceFactory> data_source_factory_;
+ scoped_refptr<DataSource> data_source_;
MessageLoop* loop_; // Unowned.
DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegDemuxerFactory);
diff --git a/media/filters/file_data_source_factory.cc b/media/filters/file_data_source_factory.cc
deleted file mode 100644
index 39b07f6..0000000
--- a/media/filters/file_data_source_factory.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "media/filters/file_data_source_factory.h"
-
-#include "base/logging.h"
-#include "media/filters/file_data_source.h"
-
-namespace media {
-
-FileDataSourceFactory::FileDataSourceFactory() {}
-
-FileDataSourceFactory::~FileDataSourceFactory() {}
-
-void FileDataSourceFactory::Build(const std::string& url,
- const BuildCallback& callback) {
- DCHECK(!callback.is_null());
-
- if (url.empty()) {
- callback.Run(media::PIPELINE_ERROR_URL_NOT_FOUND,
- static_cast<media::DataSource*>(NULL));
- return;
- }
-
- scoped_refptr<FileDataSource> file_data_source = new FileDataSource();
-
- PipelineStatus status = file_data_source->Initialize(url);
- DataSource* data_source =
- (status == PIPELINE_OK) ? file_data_source.get() : NULL;
- callback.Run(status, data_source);
-}
-
-} // namespace media
diff --git a/media/filters/file_data_source_factory.h b/media/filters/file_data_source_factory.h
deleted file mode 100644
index af15a1f..0000000
--- a/media/filters/file_data_source_factory.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MEDIA_FILTERS_FILE_DATA_SOURCE_FACTORY_H_
-#define MEDIA_FILTERS_FILE_DATA_SOURCE_FACTORY_H_
-
-#include "media/base/filter_factories.h"
-
-namespace media {
-
-class MEDIA_EXPORT FileDataSourceFactory : public DataSourceFactory {
- public:
- FileDataSourceFactory();
- virtual ~FileDataSourceFactory();
-
- // DataSourceFactory methods.
- virtual void Build(const std::string& url,
- const BuildCallback& callback) OVERRIDE;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FileDataSourceFactory);
-};
-
-} // namespace media
-
-#endif // MEDIA_FILTERS_FILE_DATA_SOURCE_FACTORY_H_
diff --git a/media/filters/pipeline_integration_test.cc b/media/filters/pipeline_integration_test.cc
index eeb6d60..b64ed09 100644
--- a/media/filters/pipeline_integration_test.cc
+++ b/media/filters/pipeline_integration_test.cc
@@ -12,7 +12,7 @@
#include "media/filters/ffmpeg_audio_decoder.h"
#include "media/filters/ffmpeg_demuxer_factory.h"
#include "media/filters/ffmpeg_video_decoder.h"
-#include "media/filters/file_data_source_factory.h"
+#include "media/filters/file_data_source.h"
#include "media/filters/null_audio_renderer.h"
#include "media/filters/video_renderer_base.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -82,7 +82,7 @@ class PipelineIntegrationTest : public testing::Test {
MOCK_METHOD1(OnError, void(PipelineStatus));
void Start(const std::string& url, PipelineStatus expected_status) {
- pipeline_->Start(CreateFilterCollection(), url,
+ pipeline_->Start(CreateFilterCollection(url), url,
QuitOnStatusCB(expected_status));
message_loop_.Run();
}
@@ -135,13 +135,14 @@ class PipelineIntegrationTest : public testing::Test {
message_loop_.Run();
}
- scoped_ptr<FilterCollection> CreateFilterCollection() {
+ scoped_ptr<FilterCollection> CreateFilterCollection(const std::string& url) {
+ scoped_refptr<FileDataSource> data_source = new FileDataSource();
+ CHECK_EQ(PIPELINE_OK, data_source->Initialize(url));
+
scoped_ptr<FilterCollection> collection(
new FilterCollection());
collection->SetDemuxerFactory(scoped_ptr<DemuxerFactory>(
- new FFmpegDemuxerFactory(
- scoped_ptr<DataSourceFactory>(new FileDataSourceFactory()),
- &message_loop_)));
+ new FFmpegDemuxerFactory(data_source, &message_loop_)));
collection->AddAudioDecoder(new FFmpegAudioDecoder(
message_loop_factory_->GetMessageLoop("AudioDecoderThread")));
collection->AddVideoDecoder(new FFmpegVideoDecoder(
diff --git a/media/media.gyp b/media/media.gyp
index 4d550df..d206ca4 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -96,8 +96,6 @@
'audio/win/wavein_input_win.h',
'audio/win/waveout_output_win.cc',
'audio/win/waveout_output_win.h',
- 'base/async_filter_factory_base.cc',
- 'base/async_filter_factory_base.h',
'base/audio_decoder_config.cc',
'base/audio_decoder_config.h',
'base/bitstream_buffer.h',
@@ -109,8 +107,6 @@
'base/channel_layout.h',
'base/clock.cc',
'base/clock.h',
- 'base/composite_data_source_factory.cc',
- 'base/composite_data_source_factory.h',
'base/composite_filter.cc',
'base/composite_filter.h',
'base/data_buffer.cc',
@@ -119,6 +115,8 @@
'base/data_source.h',
'base/demuxer.cc',
'base/demuxer.h',
+ 'base/demuxer_factory.cc',
+ 'base/demuxer_factory.h',
'base/demuxer_stream.cc',
'base/demuxer_stream.h',
'base/djb2.cc',
@@ -127,8 +125,6 @@
'base/download_rate_monitor.h',
'base/filter_collection.cc',
'base/filter_collection.h',
- 'base/filter_factories.cc',
- 'base/filter_factories.h',
'base/filter_host.h',
'base/filters.cc',
'base/filters.h',
@@ -203,8 +199,6 @@
'filters/ffmpeg_video_decoder.h',
'filters/file_data_source.cc',
'filters/file_data_source.h',
- 'filters/file_data_source_factory.cc',
- 'filters/file_data_source_factory.h',
'filters/gpu_video_decoder.cc',
'filters/gpu_video_decoder.h',
'filters/in_memory_url_protocol.cc',
diff --git a/media/tools/player_wtl/movie.cc b/media/tools/player_wtl/movie.cc
index f97f88a..fcecd5f 100644
--- a/media/tools/player_wtl/movie.cc
+++ b/media/tools/player_wtl/movie.cc
@@ -15,7 +15,7 @@
#include "media/filters/ffmpeg_audio_decoder.h"
#include "media/filters/ffmpeg_demuxer_factory.h"
#include "media/filters/ffmpeg_video_decoder.h"
-#include "media/filters/file_data_source_factory.h"
+#include "media/filters/file_data_source.h"
#include "media/filters/null_audio_renderer.h"
#include "media/filters/reference_audio_renderer.h"
#include "media/filters/video_renderer_base.h"
@@ -23,7 +23,7 @@
using media::FFmpegAudioDecoder;
using media::FFmpegDemuxerFactory;
using media::FFmpegVideoDecoder;
-using media::FileDataSourceFactory;
+using media::FileDataSource;
using media::FilterCollection;
using media::Pipeline;
using media::ReferenceAudioRenderer;
@@ -70,12 +70,17 @@ bool Movie::Open(const wchar_t* url, VideoRendererBase* video_renderer) {
message_loop_factory_->GetMessageLoop("PipelineThread");
pipeline_ = new Pipeline(pipeline_loop, new media::MediaLog());
+ // Open the file.
+ std::string url_utf8 = WideToUTF8(string16(url));
+ scoped_refptr<FileDataSource> data_source = new FileDataSource();
+ if (data_source->Initialize(url_utf8) != PIPELINE_OK) {
+ return false;
+ }
+
// Create filter collection.
scoped_ptr<FilterCollection> collection(new FilterCollection());
- collection->SetDemuxerFactory(
- scoped_ptr<DemuxerFactory>(new FFmpegDemuxerFactory(
- scoped_ptr<DataSourceFactory>(new FileDataSourceFactory()),
- pipeline_loop)));
+ collection->SetDemuxerFactory(scoped_ptr<DemuxerFactory>(
+ new FFmpegDemuxerFactory(data_source, pipeline_loop)));
collection->AddAudioDecoder(new FFmpegAudioDecoder(
message_loop_factory_->GetMessageLoop("AudioDecoderThread")));
collection->AddVideoDecoder(new FFmpegVideoDecoder(
@@ -91,8 +96,8 @@ bool Movie::Open(const wchar_t* url, VideoRendererBase* video_renderer) {
// Create and start our pipeline.
media::PipelineStatusNotification note;
- pipeline_->Start(collection.Pass(), WideToUTF8(string16(url)),
- note.Callback());
+ pipeline_->Start(collection.Pass(), url_utf8, note.Callback());
+
// Wait until the pipeline is fully initialized.
note.Wait();
if (note.status() != PIPELINE_OK)
diff --git a/media/tools/player_x11/player_x11.cc b/media/tools/player_x11/player_x11.cc
index f4b9fcc..ef4f126 100644
--- a/media/tools/player_x11/player_x11.cc
+++ b/media/tools/player_x11/player_x11.cc
@@ -26,7 +26,7 @@
#include "media/filters/ffmpeg_audio_decoder.h"
#include "media/filters/ffmpeg_demuxer_factory.h"
#include "media/filters/ffmpeg_video_decoder.h"
-#include "media/filters/file_data_source_factory.h"
+#include "media/filters/file_data_source.h"
#include "media/filters/null_audio_renderer.h"
#include "media/filters/reference_audio_renderer.h"
#include "media/filters/video_renderer_base.h"
@@ -109,13 +109,18 @@ bool InitPipeline(MessageLoop* message_loop,
return false;
}
+ // Open the file.
+ scoped_refptr<media::FileDataSource> data_source =
+ new media::FileDataSource();
+ if (data_source->Initialize(filename) != media::PIPELINE_OK) {
+ return false;
+ }
+
// Create our filter factories.
scoped_ptr<media::FilterCollection> collection(
new media::FilterCollection());
- collection->SetDemuxerFactory(
- scoped_ptr<media::DemuxerFactory>(
- new media::FFmpegDemuxerFactory(scoped_ptr<media::DataSourceFactory>(
- new media::FileDataSourceFactory()), message_loop)));
+ collection->SetDemuxerFactory(scoped_ptr<media::DemuxerFactory>(
+ new media::FFmpegDemuxerFactory(data_source, message_loop)));
collection->AddAudioDecoder(new media::FFmpegAudioDecoder(
message_loop_factory->GetMessageLoop("AudioDecoderThread")));
collection->AddVideoDecoder(new media::FFmpegVideoDecoder(