summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
Diffstat (limited to 'media/base')
-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
7 files changed, 6 insertions, 396 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 {