summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-14 23:06:09 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-14 23:06:09 +0000
commit3f5d201c12cc91dbd009388b5f021e149fa1036c (patch)
treea17484836cfdd82e50cf21197a118bbebdb333b7 /media/base
parent4ef2170bc994581f69c50f6330de57b9e7cbc619 (diff)
downloadchromium_src-3f5d201c12cc91dbd009388b5f021e149fa1036c.zip
chromium_src-3f5d201c12cc91dbd009388b5f021e149fa1036c.tar.gz
chromium_src-3f5d201c12cc91dbd009388b5f021e149fa1036c.tar.bz2
Checking in basic pipeline interface and stubbed out media::PipelineImpl.
This interface is going to be updated some more in the future, but I'd like to get the basics in first. Review URL: http://codereview.chromium.org/17299 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8046 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/pipeline.h89
-rw-r--r--media/base/pipeline_impl.cc60
-rw-r--r--media/base/pipeline_impl.h46
3 files changed, 195 insertions, 0 deletions
diff --git a/media/base/pipeline.h b/media/base/pipeline.h
new file mode 100644
index 0000000..9e1e52f
--- /dev/null
+++ b/media/base/pipeline.h
@@ -0,0 +1,89 @@
+// Copyright (c) 2006-2008 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.
+
+// The pipeline is the public API clients use for playing back media. Clients
+// provide a filter factory containing the filters they want the pipeline to
+// use to render media.
+//
+// Playback controls (play, pause, seek) are asynchronous and clients are
+// notified via callbacks.
+
+#ifndef MEDIA_BASE_PIPELINE_H_
+#define MEDIA_BASE_PIPELINE_H_
+
+#include "base/task.h"
+
+namespace media {
+
+class FilterFactoryInterface;
+
+enum PipelineState {
+ PS_UNINITIALIZED,
+ PS_PLAY,
+ PS_PAUSE,
+ PS_SEEK,
+ PS_SHUTDOWN
+};
+
+class Pipeline : public base::RefCountedThreadSafe<Pipeline> {
+ public:
+ // Build a pipeline to render the given URI using the given filter factory to
+ // construct a filter chain. Returns true if successful, false otherwise
+ // (i.e., pipeline already initialized).
+ //
+ // This method is asynchronous and will execute a state change callback when
+ // completed.
+ virtual bool Initialize(FilterFactoryInterface* filter_factory,
+ const std::string& uri) = 0;
+
+ // Attempt to play the media. Returns true if successful, false otherwise
+ // (i.e., pipeline is unititalized).
+ //
+ // This method is asynchronous and will execute a state change callback when
+ // completed.
+ virtual bool Play() = 0;
+
+ // Attempt to pause the media. Returns true if successful, false otherwise
+ // (i.e., pipeline is unititalized). Pause() is not a toggle and should not
+ // resume playback if already paused.
+ //
+ // This method is asynchronous and will execute a state change callback when
+ // completed.
+ virtual bool Pause() = 0;
+
+ // Attempt to seek to the position in microseconds. Returns true if
+ // successful, false otherwise. Playback is paused after the seek completes.
+ //
+ // This method is asynchronous and will execute a state change callback when
+ // completed.
+ virtual bool Seek(int64 seek_position) = 0;
+
+ // Shutdown the pipeline and destroy the filter chain.
+ virtual void Shutdown() = 0;
+
+ // Returns the current playback position in microseconds.
+ virtual int64 GetTime() const = 0;
+
+ // Returns the media duration in microseconds. Returns zero if the duration
+ // is not known (i.e., streaming media).
+ virtual int64 GetDuration() const = 0;
+
+ // Set a callback to receive state change notifications. This callback is
+ // executed only after the state transition has been successfully carried out.
+ // For example, calling Play() will only execute a callback with PS_PLAY
+ // some time in the future.
+ virtual void SetStateChangedCallback(
+ Callback1<PipelineState>::Type* callback) = 0;
+
+ // Set a callback to receive time change notifications.
+ virtual void SetTimeChangedCallback(Callback1<int64>::Type* callback) = 0;
+
+ protected:
+ friend class base::RefCountedThreadSafe<Pipeline>;
+ virtual ~Pipeline() {}
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_PIPELINE_H_ \ No newline at end of file
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
new file mode 100644
index 0000000..691ab8b
--- /dev/null
+++ b/media/base/pipeline_impl.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2006-2008 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/pipeline_impl.h"
+
+namespace media {
+
+PipelineImpl::PipelineImpl() : time_(0), duration_(0) {}
+
+PipelineImpl::~PipelineImpl() {}
+
+bool PipelineImpl::Initialize(FilterFactoryInterface* filter_factory,
+ const std::string& uri) {
+ // TODO(scherkus): implement Initialize.
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool PipelineImpl::Play() {
+ // TODO(scherkus): implement Play.
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool PipelineImpl::Pause() {
+ // TODO(scherkus): implement Pause.
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool PipelineImpl::Seek(int64 seek_position) {
+ // TODO(scherkus): implement Seek.
+ NOTIMPLEMENTED();
+ return false;
+}
+
+void PipelineImpl::Shutdown() {
+ // TODO(scherkus): implement Shutdown.
+ NOTIMPLEMENTED();
+}
+
+int64 PipelineImpl::GetTime() const {
+ return time_;
+}
+
+int64 PipelineImpl::GetDuration() const {
+ return duration_;
+}
+
+void PipelineImpl::SetStateChangedCallback(
+ Callback1<PipelineState>::Type* callback) {
+ state_changed_callback_.reset(callback);
+}
+
+void PipelineImpl::SetTimeChangedCallback(Callback1<int64>::Type* callback) {
+ time_changed_callback_.reset(callback);
+}
+
+} // namespace media
diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h
new file mode 100644
index 0000000..941b5e6
--- /dev/null
+++ b/media/base/pipeline_impl.h
@@ -0,0 +1,46 @@
+// Copyright (c) 2006-2008 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.
+
+// Implementation of Pipeline.
+
+#ifndef MEDIA_BASE_PIPELINE_IMPL_H_
+#define MEDIA_BASE_PIPELINE_IMPL_H_
+
+#include "base/scoped_ptr.h"
+#include "media/base/pipeline.h"
+
+namespace media {
+
+class PipelineImpl : public Pipeline {
+ public:
+ PipelineImpl();
+
+ // Pipeline implementation.
+ virtual bool Initialize(FilterFactoryInterface* filter_factory,
+ const std::string& uri);
+ virtual bool Play();
+ virtual bool Pause();
+ virtual bool Seek(int64 seek_position);
+ virtual void Shutdown();
+ virtual int64 GetTime() const;
+ virtual int64 GetDuration() const;
+ virtual void SetStateChangedCallback(
+ Callback1<PipelineState>::Type* callback);
+ virtual void SetTimeChangedCallback(Callback1<int64>::Type* callback);
+
+ protected:
+ virtual ~PipelineImpl();
+
+ private:
+ int64 time_;
+ int64 duration_;
+ scoped_ptr<Callback1<PipelineState>::Type> state_changed_callback_;
+ scoped_ptr<Callback1<int64>::Type> time_changed_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(PipelineImpl);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_PIPELINE_IMPL_H_