diff options
author | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-16 17:14:25 +0000 |
---|---|---|
committer | acolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-16 17:14:25 +0000 |
commit | 236119cf32eb61f4b775ba573ecf46a1c504e7a3 (patch) | |
tree | 9a292fdefecf37aa48d448f3f7706ab5521e4d33 /media/base | |
parent | 7046bfcb6c8f46d0693c129d52de27bc68042af7 (diff) | |
download | chromium_src-236119cf32eb61f4b775ba573ecf46a1c504e7a3.zip chromium_src-236119cf32eb61f4b775ba573ecf46a1c504e7a3.tar.gz chromium_src-236119cf32eb61f4b775ba573ecf46a1c504e7a3.tar.bz2 |
Removing DataSource from Filter hierarchy and refactoring FilterHost into DemuxerHost & DataSourceHost.
Over the last year, several refactorings have caused DataSource to have almost nothing in common with the Filter interface. This change removes it from the Filter class hierarchy and splits up the FilterHost interface so that DataSource, Demuxer, and Filter have their own host interfaces. Splitting FilterHost improves encapsulation and makes it easier to reason about which host methods are required by different parts of the code.
BUG=
TEST=media_unittests
Review URL: http://codereview.chromium.org/8936014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/composite_filter.cc | 37 | ||||
-rw-r--r-- | media/base/data_source.cc | 30 | ||||
-rw-r--r-- | media/base/data_source.h | 86 | ||||
-rw-r--r-- | media/base/demuxer.cc | 4 | ||||
-rw-r--r-- | media/base/demuxer.h | 45 | ||||
-rw-r--r-- | media/base/filter_host.h | 28 | ||||
-rw-r--r-- | media/base/filters.cc | 3 | ||||
-rw-r--r-- | media/base/filters.h | 43 | ||||
-rw-r--r-- | media/base/mock_data_source_host.cc | 13 | ||||
-rw-r--r-- | media/base/mock_data_source_host.h | 32 | ||||
-rw-r--r-- | media/base/mock_demuxer_host.cc | 13 | ||||
-rw-r--r-- | media/base/mock_demuxer_host.h | 38 | ||||
-rw-r--r-- | media/base/mock_filters.cc | 8 | ||||
-rw-r--r-- | media/base/mock_filters.h | 7 | ||||
-rw-r--r-- | media/base/pipeline.h | 4 | ||||
-rw-r--r-- | media/base/pipeline_impl.cc | 9 | ||||
-rw-r--r-- | media/base/pipeline_impl.h | 23 | ||||
-rw-r--r-- | media/base/preload.h | 25 |
18 files changed, 304 insertions, 144 deletions
diff --git a/media/base/composite_filter.cc b/media/base/composite_filter.cc index 191280b..2b0166c 100644 --- a/media/base/composite_filter.cc +++ b/media/base/composite_filter.cc @@ -22,16 +22,9 @@ class CompositeFilter::FilterHostImpl : public FilterHost { virtual base::TimeDelta GetTime() const OVERRIDE; virtual base::TimeDelta GetDuration() const OVERRIDE; virtual void SetTime(base::TimeDelta time) OVERRIDE; - virtual void SetDuration(base::TimeDelta duration) OVERRIDE; - virtual void SetBufferedTime(base::TimeDelta buffered_time) OVERRIDE; - virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; - virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE; virtual void SetNaturalVideoSize(const gfx::Size& size) OVERRIDE; virtual void NotifyEnded() OVERRIDE; - virtual void SetNetworkActivity(bool network_activity) OVERRIDE; virtual void DisableAudioRenderer() OVERRIDE; - virtual void SetCurrentReadPosition(int64 offset) OVERRIDE; - virtual int64 GetCurrentReadPosition() OVERRIDE; private: CompositeFilter* parent_; @@ -507,23 +500,6 @@ void CompositeFilter::FilterHostImpl::SetTime(base::TimeDelta time) { host_->SetTime(time); } -void CompositeFilter::FilterHostImpl::SetDuration(base::TimeDelta duration) { - host_->SetDuration(duration); -} - -void CompositeFilter::FilterHostImpl::SetBufferedTime( - base::TimeDelta buffered_time) { - host_->SetBufferedTime(buffered_time); -} - -void CompositeFilter::FilterHostImpl::SetTotalBytes(int64 total_bytes) { - host_->SetTotalBytes(total_bytes); -} - -void CompositeFilter::FilterHostImpl::SetBufferedBytes(int64 buffered_bytes) { - host_->SetBufferedBytes(buffered_bytes); -} - void CompositeFilter::FilterHostImpl::SetNaturalVideoSize( const gfx::Size& size) { host_->SetNaturalVideoSize(size); @@ -533,21 +509,8 @@ void CompositeFilter::FilterHostImpl::NotifyEnded() { host_->NotifyEnded(); } -void CompositeFilter::FilterHostImpl::SetNetworkActivity( - bool network_activity) { - host_->SetNetworkActivity(network_activity); -} - void CompositeFilter::FilterHostImpl::DisableAudioRenderer() { host_->DisableAudioRenderer(); } -void CompositeFilter::FilterHostImpl::SetCurrentReadPosition(int64 offset) { - host_->SetCurrentReadPosition(offset); -} - -int64 CompositeFilter::FilterHostImpl::GetCurrentReadPosition() { - return host_->GetCurrentReadPosition(); -} - } // namespace media diff --git a/media/base/data_source.cc b/media/base/data_source.cc new file mode 100644 index 0000000..f310af8 --- /dev/null +++ b/media/base/data_source.cc @@ -0,0 +1,30 @@ +// Copyright (c) 2011 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/data_source.h" + +#include "base/logging.h" + +namespace media { + +// static +const size_t DataSource::kReadError = static_cast<size_t>(-1); + +DataSourceHost::~DataSourceHost() {} + +DataSource::DataSource() : host_(NULL) {} + +DataSource::~DataSource() {} + +void DataSource::set_host(DataSourceHost* host) { + DCHECK(host); + DCHECK(!host_); + host_ = host; +} + +void DataSource::SetPlaybackRate(float playback_rate) {} + +DataSourceHost* DataSource::host() { return host_; } + +} // namespace media diff --git a/media/base/data_source.h b/media/base/data_source.h new file mode 100644 index 0000000..9de147e --- /dev/null +++ b/media/base/data_source.h @@ -0,0 +1,86 @@ +// Copyright (c) 2011 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_DATA_SOURCE_H_ +#define MEDIA_BASE_DATA_SOURCE_H_ + +#include "base/callback.h" +#include "base/memory/ref_counted.h" +#include "media/base/media_export.h" +#include "media/base/preload.h" + +namespace media { + +class MEDIA_EXPORT DataSourceHost { + public: + virtual ~DataSourceHost(); + + // Set the total size of the media file. + virtual void SetTotalBytes(int64 total_bytes) = 0; + + // Sets the total number of bytes that are buffered on the client and ready to + // be played. + virtual void SetBufferedBytes(int64 buffered_bytes) = 0; + + // Sets the flag to indicate current network activity. + virtual void SetNetworkActivity(bool is_downloading_data) = 0; +}; + +class MEDIA_EXPORT DataSource : public base::RefCountedThreadSafe<DataSource> { + public: + typedef base::Callback<void(int64, int64)> StatusCallback; + typedef base::Callback<void(size_t)> ReadCallback; + static const size_t kReadError; + + DataSource(); + + virtual void set_host(DataSourceHost* host); + + // Reads |size| bytes from |position| into |data|. And when the read is done + // or failed, |read_callback| is called with the number of bytes read or + // kReadError in case of error. + // TODO(hclam): should change |size| to int! It makes the code so messy + // with size_t and int all over the place.. + virtual void Read(int64 position, size_t size, + uint8* data, + const DataSource::ReadCallback& read_callback) = 0; + + // Notifies the DataSource of a change in the current playback rate. + virtual void SetPlaybackRate(float playback_rate); + + // Stops the DataSource. Once this is called all future Read() calls will + // return an error. + virtual void Stop(const base::Closure& callback) = 0; + + // Returns true and the file size, false if the file size could not be + // retrieved. + virtual bool GetSize(int64* size_out) = 0; + + // Returns true if we are performing streaming. In this case seeking is + // not possible. + virtual bool IsStreaming() = 0; + + // Alert the DataSource that the video preload value has been changed. + virtual void SetPreload(Preload preload) = 0; + + // Notify the DataSource of the bitrate of the media. + // Values of |bitrate| <= 0 are invalid and should be ignored. + virtual void SetBitrate(int bitrate) = 0; + + protected: + // Only allow scoped_refptr<> to delete DataSource. + friend class base::RefCountedThreadSafe<DataSource>; + virtual ~DataSource(); + + DataSourceHost* host(); + + private: + DataSourceHost* host_; + + DISALLOW_COPY_AND_ASSIGN(DataSource); +}; + +} // namespace media + +#endif // MEDIA_BASE_DATA_SOURCE_H_ diff --git a/media/base/demuxer.cc b/media/base/demuxer.cc index 83bfce3..b6b2d18 100644 --- a/media/base/demuxer.cc +++ b/media/base/demuxer.cc @@ -8,11 +8,13 @@ namespace media { +DemuxerHost::~DemuxerHost() {} + Demuxer::Demuxer() : host_(NULL) {} Demuxer::~Demuxer() {} -void Demuxer::set_host(FilterHost* host) { +void Demuxer::set_host(DemuxerHost* host) { DCHECK(host); DCHECK(!host_); host_ = host; diff --git a/media/base/demuxer.h b/media/base/demuxer.h index 972d250..f049f6f 100644 --- a/media/base/demuxer.h +++ b/media/base/demuxer.h @@ -6,28 +6,45 @@ #define MEDIA_BASE_DEMUXER_H_ #include "base/memory/ref_counted.h" +#include "base/time.h" +#include "media/base/data_source.h" #include "media/base/demuxer_stream.h" #include "media/base/media_export.h" - -// TODO(acolwell): Remove include once DataSource & Preload are moved -// out of "media/base/filters.h" and Stop() is converted to use new callbacks. -#include "media/base/filters.h" #include "media/base/pipeline_status.h" +#include "media/base/preload.h" namespace media { -class FilterHost; +class MEDIA_EXPORT DemuxerHost : public DataSourceHost { + public: + virtual ~DemuxerHost(); + + // Get the duration of the media in microseconds. If the duration has not + // been determined yet, then returns 0. + virtual void SetDuration(base::TimeDelta duration) = 0; + + // Set the approximate amount of playable data buffered so far in micro- + // seconds. + virtual void SetBufferedTime(base::TimeDelta buffered_time) = 0; + + // Sets the byte offset at which the client is requesting the video. + virtual void SetCurrentReadPosition(int64 offset) = 0; + + // Stops execution of the pipeline due to a fatal error. Do not call this + // method with PIPELINE_OK. + virtual void OnDemuxerError(PipelineStatus error) = 0; +}; class MEDIA_EXPORT Demuxer : public base::RefCountedThreadSafe<Demuxer> { public: + Demuxer(); + // Sets the private member |host_|. This is the first method called by - // the FilterHost after a demuxer is created. The host holds a strong + // the DemuxerHost after a demuxer is created. The host holds a strong // reference to the demuxer. The reference held by the host is guaranteed // to be released before the host object is destroyed by the pipeline. - // - // TODO(acolwell): Change this to a narrow DemuxerHost interface. - virtual void set_host(FilterHost* host); + virtual void set_host(DemuxerHost* host); // The pipeline playback rate has been changed. Demuxers may implement this // method if they need to respond to this call. @@ -69,14 +86,18 @@ class MEDIA_EXPORT Demuxer virtual bool IsSeekable() = 0; protected: - Demuxer(); - FilterHost* host() { return host_; } + // Only allow derived objects access to the DemuxerHost. This is + // kept out of the public interface because demuxers need to be + // aware of all calls made to the host object so they can insure + // the state presented to the host is always consistent with its own + // state. + DemuxerHost* host() { return host_; } friend class base::RefCountedThreadSafe<Demuxer>; virtual ~Demuxer(); private: - FilterHost* host_; + DemuxerHost* host_; DISALLOW_COPY_AND_ASSIGN(Demuxer); }; diff --git a/media/base/filter_host.h b/media/base/filter_host.h index 807fd5f..864bc99 100644 --- a/media/base/filter_host.h +++ b/media/base/filter_host.h @@ -28,31 +28,16 @@ class MEDIA_EXPORT FilterHost { // method with PIPELINE_OK. virtual void SetError(PipelineStatus error) = 0; - // Gets the current time in microseconds. + // Gets the current time. virtual base::TimeDelta GetTime() const = 0; - // Gets the duration in microseconds. + // Gets the duration. virtual base::TimeDelta GetDuration() const = 0; // Updates the current time. Other filters should poll to examine the updated // time. virtual void SetTime(base::TimeDelta time) = 0; - // Get the duration of the media in microseconds. If the duration has not - // been determined yet, then returns 0. - virtual void SetDuration(base::TimeDelta duration) = 0; - - // Set the approximate amount of playable data buffered so far in micro- - // seconds. - virtual void SetBufferedTime(base::TimeDelta buffered_time) = 0; - - // Set the total size of the media file. - virtual void SetTotalBytes(int64 total_bytes) = 0; - - // Sets the total number of bytes that are buffered on the client and ready to - // be played. - virtual void SetBufferedBytes(int64 buffered_bytes) = 0; - // Sets the natural size of the video output in pixel units. virtual void SetNaturalVideoSize(const gfx::Size& size) = 0; @@ -60,19 +45,10 @@ class MEDIA_EXPORT FilterHost { // endpoints such as renderers. virtual void NotifyEnded() = 0; - // Sets the flag to indicate current network activity. - virtual void SetNetworkActivity(bool is_downloading_data) = 0; - // Disable audio renderer by calling OnAudioRendererDisabled() on all // filters. virtual void DisableAudioRenderer() = 0; - // Sets the byte offset at which the client is requesting the video. - virtual void SetCurrentReadPosition(int64 offset) = 0; - - // Gets the byte offset at which the client is requesting the video. - virtual int64 GetCurrentReadPosition() = 0; - protected: virtual ~FilterHost() {} }; diff --git a/media/base/filters.cc b/media/base/filters.cc index ace7d4e..c137216 100644 --- a/media/base/filters.cc +++ b/media/base/filters.cc @@ -8,9 +8,6 @@ namespace media { -// static -const size_t DataSource::kReadError = static_cast<size_t>(-1); - void ResetAndRunCB(FilterStatusCB* cb, PipelineStatus status) { DCHECK(!cb->is_null()); FilterStatusCB tmp_cb(*cb); diff --git a/media/base/filters.h b/media/base/filters.h index 5cd4cf8..654dae1 100644 --- a/media/base/filters.h +++ b/media/base/filters.h @@ -46,19 +46,6 @@ class FilterHost; struct PipelineStatistics; -// Used to specify video preload states. They are "hints" to the browser about -// how aggressively the browser should load and buffer data. -// Please see the HTML5 spec for the descriptions of these values: -// http://www.w3.org/TR/html5/video.html#attr-media-preload -// -// Enum values must match the values in WebCore::MediaPlayer::Preload and -// there will be assertions at compile time if they do not match. -enum Preload { - NONE, - METADATA, - AUTO, -}; - // Used for completing asynchronous methods. typedef base::Callback<void(PipelineStatus)> FilterStatusCB; @@ -133,36 +120,6 @@ class MEDIA_EXPORT Filter : public base::RefCountedThreadSafe<Filter> { DISALLOW_COPY_AND_ASSIGN(Filter); }; -class MEDIA_EXPORT DataSource : public Filter { - public: - typedef base::Callback<void(size_t)> ReadCallback; - static const size_t kReadError; - - // Reads |size| bytes from |position| into |data|. And when the read is done - // or failed, |read_callback| is called with the number of bytes read or - // kReadError in case of error. - // TODO(hclam): should change |size| to int! It makes the code so messy - // with size_t and int all over the place.. - virtual void Read(int64 position, size_t size, - uint8* data, - const DataSource::ReadCallback& read_callback) = 0; - - // Returns true and the file size, false if the file size could not be - // retrieved. - virtual bool GetSize(int64* size_out) = 0; - - // Returns true if we are performing streaming. In this case seeking is - // not possible. - virtual bool IsStreaming() = 0; - - // Alert the DataSource that the video preload value has been changed. - virtual void SetPreload(Preload preload) = 0; - - // Notify the DataSource of the bitrate of the media. - // Values of |bitrate| <= 0 are invalid and should be ignored. - virtual void SetBitrate(int bitrate) = 0; -}; - class MEDIA_EXPORT VideoDecoder : public Filter { public: // Initialize a VideoDecoder with the given DemuxerStream, executing the diff --git a/media/base/mock_data_source_host.cc b/media/base/mock_data_source_host.cc new file mode 100644 index 0000000..eff0b78 --- /dev/null +++ b/media/base/mock_data_source_host.cc @@ -0,0 +1,13 @@ +// Copyright (c) 2011 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/mock_data_source_host.h" + +namespace media { + +MockDataSourceHost::MockDataSourceHost() {} + +MockDataSourceHost::~MockDataSourceHost() {} + +} // namespace media diff --git a/media/base/mock_data_source_host.h b/media/base/mock_data_source_host.h new file mode 100644 index 0000000..b569b77 --- /dev/null +++ b/media/base/mock_data_source_host.h @@ -0,0 +1,32 @@ +// Copyright (c) 2011 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_MOCK_DATA_SOURCE_HOST_H_ +#define MEDIA_BASE_MOCK_DATA_SOURCE_HOST_H_ + +#include <string> + +#include "base/memory/scoped_ptr.h" +#include "media/base/data_source.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace media { + +class MockDataSourceHost : public DataSourceHost { + public: + MockDataSourceHost(); + virtual ~MockDataSourceHost(); + + // DataSourceHost implementation. + MOCK_METHOD1(SetTotalBytes, void(int64 total_bytes)); + MOCK_METHOD1(SetBufferedBytes, void(int64 buffered_bytes)); + MOCK_METHOD1(SetNetworkActivity, void(bool network_activity)); + + private: + DISALLOW_COPY_AND_ASSIGN(MockDataSourceHost); +}; + +} // namespace media + +#endif // MEDIA_BASE_MOCK_DATA_SOURCE_HOST_H_ diff --git a/media/base/mock_demuxer_host.cc b/media/base/mock_demuxer_host.cc new file mode 100644 index 0000000..100787f --- /dev/null +++ b/media/base/mock_demuxer_host.cc @@ -0,0 +1,13 @@ +// Copyright (c) 2011 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/mock_demuxer_host.h" + +namespace media { + +MockDemuxerHost::MockDemuxerHost() {} + +MockDemuxerHost::~MockDemuxerHost() {} + +} // namespace media diff --git a/media/base/mock_demuxer_host.h b/media/base/mock_demuxer_host.h new file mode 100644 index 0000000..ae86473 --- /dev/null +++ b/media/base/mock_demuxer_host.h @@ -0,0 +1,38 @@ +// Copyright (c) 2011 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_MOCK_DEMUXER_HOST_H_ +#define MEDIA_BASE_MOCK_DEMUXER_HOST_H_ + +#include <string> + +#include "base/memory/scoped_ptr.h" +#include "media/base/demuxer.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace media { + +class MockDemuxerHost : public DemuxerHost { + public: + MockDemuxerHost(); + virtual ~MockDemuxerHost(); + + // DataSourceHost implementation. + MOCK_METHOD1(SetTotalBytes, void(int64 total_bytes)); + MOCK_METHOD1(SetBufferedBytes, void(int64 buffered_bytes)); + MOCK_METHOD1(SetNetworkActivity, void(bool network_activity)); + + // DemuxerHost implementation. + MOCK_METHOD1(OnDemuxerError, void(PipelineStatus error)); + MOCK_METHOD1(SetDuration, void(base::TimeDelta duration)); + MOCK_METHOD1(SetBufferedTime, void(base::TimeDelta buffered_time)); + MOCK_METHOD1(SetCurrentReadPosition, void(int64 offset)); + + private: + DISALLOW_COPY_AND_ASSIGN(MockDemuxerHost); +}; + +} // namespace media + +#endif // MEDIA_BASE_MOCK_DEMUXER_HOST_H_ diff --git a/media/base/mock_filters.cc b/media/base/mock_filters.cc index d398448..a406620 100644 --- a/media/base/mock_filters.cc +++ b/media/base/mock_filters.cc @@ -20,8 +20,8 @@ MockDataSource::MockDataSource() MockDataSource::~MockDataSource() {} -void MockDataSource::set_host(FilterHost* filter_host) { - Filter::set_host(filter_host); +void MockDataSource::set_host(DataSourceHost* data_source_host) { + DataSource::set_host(data_source_host); if (total_bytes_ > 0) host()->SetTotalBytes(total_bytes_); @@ -74,8 +74,8 @@ MockDemuxer::MockDemuxer() MockDemuxer::~MockDemuxer() {} -void MockDemuxer::set_host(FilterHost* filter_host) { - Demuxer::set_host(filter_host); +void MockDemuxer::set_host(DemuxerHost* demuxer_host) { + Demuxer::set_host(demuxer_host); if (total_bytes_ > 0) host()->SetTotalBytes(total_bytes_); diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h index 28817e9..b3758f2 100644 --- a/media/base/mock_filters.h +++ b/media/base/mock_filters.h @@ -72,8 +72,7 @@ class MockDataSource : public DataSource { public: MockDataSource(); - // Filter implementation. - virtual void set_host(FilterHost* host); + virtual void set_host(DataSourceHost* data_source_host); MOCK_METHOD1(Stop, void(const base::Closure& callback)); MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); @@ -105,8 +104,8 @@ class MockDataSource : public DataSource { class MockDemuxer : public Demuxer { public: MockDemuxer(); - // Filter implementation. - virtual void set_host(FilterHost* host); + + virtual void set_host(DemuxerHost* demuxer_host); MOCK_METHOD1(Stop, void(const base::Closure& callback)); MOCK_METHOD1(SetPlaybackRate, void(float playback_rate)); MOCK_METHOD1(SetPreload, void(Preload preload)); diff --git a/media/base/pipeline.h b/media/base/pipeline.h index 1534ea5..cc38c4b 100644 --- a/media/base/pipeline.h +++ b/media/base/pipeline.h @@ -11,8 +11,10 @@ #include <string> -#include "media/base/filters.h" +#include "media/base/media_export.h" #include "media/base/pipeline_status.h" +#include "media/base/preload.h" +#include "ui/gfx/size.h" namespace base { class TimeDelta; diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index aa5ac3b..f4d8774 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc @@ -340,11 +340,6 @@ void PipelineImpl::SetCurrentReadPosition(int64 offset) { current_bytes_ = offset; } -int64 PipelineImpl::GetCurrentReadPosition() { - base::AutoLock auto_lock(lock_); - return current_bytes_; -} - void PipelineImpl::ResetState() { base::AutoLock auto_lock(lock_); const base::TimeDelta kZero; @@ -457,6 +452,10 @@ PipelineImpl::State PipelineImpl::FindNextState(State current) { } } +void PipelineImpl::OnDemuxerError(PipelineStatus error) { + SetError(error); +} + void PipelineImpl::SetError(PipelineStatus error) { DCHECK(IsRunning()); DCHECK_NE(PIPELINE_OK, error); diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h index 9426688..be55291 100644 --- a/media/base/pipeline_impl.h +++ b/media/base/pipeline_impl.h @@ -96,7 +96,10 @@ class MEDIA_EXPORT PipelineStatusNotification { // If any error ever happens, this object will transition to the "Error" state // from any state. If Stop() is ever called, this object will transition to // "Stopped" state. -class MEDIA_EXPORT PipelineImpl : public Pipeline, public FilterHost { +class MEDIA_EXPORT PipelineImpl + : public Pipeline, + public FilterHost, + public DemuxerHost { public: explicit PipelineImpl(MessageLoop* message_loop, MediaLog* media_log); @@ -190,21 +193,25 @@ class MEDIA_EXPORT PipelineImpl : public Pipeline, public FilterHost { // Given the current state, returns the next state. State FindNextState(State current); + // DataSourceHost (by way of DemuxerHost) implementation. + virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; + virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE; + virtual void SetNetworkActivity(bool is_downloading_data) OVERRIDE; + + // DemuxerHost implementaion. + virtual void SetDuration(base::TimeDelta duration) OVERRIDE; + virtual void SetBufferedTime(base::TimeDelta buffered_time) OVERRIDE; + virtual void SetCurrentReadPosition(int64 offset) OVERRIDE; + virtual void OnDemuxerError(PipelineStatus error) OVERRIDE; + // FilterHost implementation. virtual void SetError(PipelineStatus error) OVERRIDE; virtual base::TimeDelta GetTime() const OVERRIDE; virtual base::TimeDelta GetDuration() const OVERRIDE; virtual void SetTime(base::TimeDelta time) OVERRIDE; - virtual void SetDuration(base::TimeDelta duration) OVERRIDE; - virtual void SetBufferedTime(base::TimeDelta buffered_time) OVERRIDE; - virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; - virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE; virtual void SetNaturalVideoSize(const gfx::Size& size) OVERRIDE; - virtual void SetNetworkActivity(bool is_downloading_data) OVERRIDE; virtual void NotifyEnded() OVERRIDE; virtual void DisableAudioRenderer() OVERRIDE; - virtual void SetCurrentReadPosition(int64 offset) OVERRIDE; - virtual int64 GetCurrentReadPosition() OVERRIDE; // Callbacks executed by filters upon completing initialization. void OnFilterInitialize(PipelineStatus status); diff --git a/media/base/preload.h b/media/base/preload.h new file mode 100644 index 0000000..136e84c --- /dev/null +++ b/media/base/preload.h @@ -0,0 +1,25 @@ +// Copyright (c) 2011 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_PRELOAD_H_ +#define MEDIA_BASE_PRELOAD_H_ + +namespace media { + +// Used to specify video preload states. They are "hints" to the browser about +// how aggressively the browser should load and buffer data. +// Please see the HTML5 spec for the descriptions of these values: +// http://www.w3.org/TR/html5/video.html#attr-media-preload +// +// Enum values must match the values in WebCore::MediaPlayer::Preload and +// there will be assertions at compile time if they do not match. +enum Preload { + NONE, + METADATA, + AUTO, +}; + +} // namespace media + +#endif // MEDIA_BASE_PRELOAD_H_ |