diff options
author | jiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 23:24:58 +0000 |
---|---|---|
committer | jiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 23:24:58 +0000 |
commit | 3d54fc6b8271fd58e4f239c169650a90225e4688 (patch) | |
tree | dcf0c96315ca079edd94f41f939af9314296f2b9 /media/base | |
parent | d461264aa483e2ace1e0225ebb442dbf4c753ada (diff) | |
download | chromium_src-3d54fc6b8271fd58e4f239c169650a90225e4688.zip chromium_src-3d54fc6b8271fd58e4f239c169650a90225e4688.tar.gz chromium_src-3d54fc6b8271fd58e4f239c169650a90225e4688.tar.bz2 |
preparation for recycling buffer, patch 2
1. add ProvidesBuffer in Filter interface, not used yet.
2. add Flush stage in pipeline. not used. Render's pause work is moved to Renderer's flush().
3. merge decoder_base with ffmpeg_video_decoder. because it is shared by audio.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=55603
Review URL: http://codereview.chromium.org/3030013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55807 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/filters.h | 25 | ||||
-rw-r--r-- | media/base/mock_filters.h | 2 | ||||
-rw-r--r-- | media/base/pipeline_impl.cc | 19 | ||||
-rw-r--r-- | media/base/pipeline_impl.h | 1 |
4 files changed, 28 insertions, 19 deletions
diff --git a/media/base/filters.h b/media/base/filters.h index 8879233..e9d2c27 100644 --- a/media/base/filters.h +++ b/media/base/filters.h @@ -92,7 +92,7 @@ class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> { // The pipeline has resumed playback. Filters can continue requesting reads. // Filters may implement this method if they need to respond to this call. - // TODO(boliu): Check that callback is not NULL in sublcasses. + // TODO(boliu): Check that callback is not NULL in subclasses. virtual void Play(FilterCallback* callback) { DCHECK(callback); if (callback) { @@ -101,10 +101,9 @@ class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> { } } - // The pipeline has paused playback. Filters should fulfill any existing read - // requests and then idle. Filters may implement this method if they need to - // respond to this call. - // TODO(boliu): Check that callback is not NULL in sublcasses. + // The pipeline has paused playback. Filters should stop buffer exchange. + // Filters may implement this method if they need to respond to this call. + // TODO(boliu): Check that callback is not NULL in subclasses. virtual void Pause(FilterCallback* callback) { DCHECK(callback); if (callback) { @@ -113,9 +112,20 @@ class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> { } } + // The pipeline has been flushed. Filters should return buffer to owners. + // Filters may implement this method if they need to respond to this call. + // TODO(boliu): Check that callback is not NULL in subclasses. + virtual void Flush(FilterCallback* callback) { + DCHECK(callback); + if (callback) { + callback->Run(); + delete callback; + } + } + // The pipeline is being stopped either as a result of an error or because // the client called Stop(). - // TODO(boliu): Check that callback is not NULL in sublcasses. + // TODO(boliu): Check that callback is not NULL in subclasses. virtual void Stop(FilterCallback* callback) { DCHECK(callback); if (callback) { @@ -293,6 +303,9 @@ class VideoDecoder : public MediaFilter { // We could also pass empty pointer here to let decoder provide buffers pool. virtual void FillThisBuffer(scoped_refptr<VideoFrame> frame) = 0; + // Indicate whether decoder provides its own output buffers + virtual bool ProvidesBuffer() = 0; + private: scoped_ptr<FillBufferDoneCallback> fill_buffer_done_callback_; }; diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h index ac9aab6..7f1bdaf 100644 --- a/media/base/mock_filters.h +++ b/media/base/mock_filters.h @@ -172,6 +172,7 @@ class MockVideoDecoder : public VideoDecoder { FilterCallback* callback)); MOCK_METHOD0(media_format, const MediaFormat&()); MOCK_METHOD1(FillThisBuffer, void(scoped_refptr<VideoFrame>)); + MOCK_METHOD0(ProvidesBuffer, bool()); protected: virtual ~MockVideoDecoder() {} @@ -222,6 +223,7 @@ class MockVideoRenderer : public VideoRenderer { MOCK_METHOD2(Initialize, void(VideoDecoder* decoder, FilterCallback* callback)); MOCK_METHOD0(HasEnded, bool()); + MOCK_METHOD1(FillThisBufferDone, void(scoped_refptr<VideoFrame> frame)); protected: virtual ~MockVideoRenderer() {} diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index e15492e..d8b3192 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc @@ -57,19 +57,6 @@ const char* GetThreadName() { } } -// Helper function used with NewRunnableMethod to implement a (very) crude -// blocking counter. -// -// TODO(scherkus): remove this as soon as Stop() is made asynchronous. -void DecrementCounter(Lock* lock, ConditionVariable* cond_var, int* count) { - AutoLock auto_lock(*lock); - --(*count); - CHECK(*count >= 0); - if (*count == 0) { - cond_var->Signal(); - } -} - } // namespace PipelineImpl::PipelineImpl(MessageLoop* message_loop) @@ -149,6 +136,7 @@ bool PipelineImpl::IsInitialized() const { AutoLock auto_lock(lock_); switch (state_) { case kPausing: + case kFlushing: case kSeeking: case kStarting: case kStarted: @@ -382,6 +370,7 @@ void PipelineImpl::FinishInitialization() { // static bool PipelineImpl::TransientState(State state) { return state == kPausing || + state == kFlushing || state == kSeeking || state == kStarting || state == kStopping; @@ -391,6 +380,8 @@ bool PipelineImpl::TransientState(State state) { PipelineImpl::State PipelineImpl::FindNextState(State current) { // TODO(scherkus): refactor InitializeTask() to make use of this function. if (current == kPausing) + return kFlushing; + if (current == kFlushing) return kSeeking; if (current == kSeeking) return kStarting; @@ -842,6 +833,8 @@ void PipelineImpl::FilterStateTransitionTask() { MediaFilter* filter = filters_[filters_.size() - remaining_transitions_]; if (state_ == kPausing) { filter->Pause(NewCallback(this, &PipelineImpl::OnFilterStateTransition)); + } else if (state_ == kFlushing) { + filter->Flush(NewCallback(this, &PipelineImpl::OnFilterStateTransition)); } else if (state_ == kSeeking) { filter->Seek(seek_timestamp_, NewCallback(this, &PipelineImpl::OnFilterStateTransition)); diff --git a/media/base/pipeline_impl.h b/media/base/pipeline_impl.h index a590b47..2486f0a 100644 --- a/media/base/pipeline_impl.h +++ b/media/base/pipeline_impl.h @@ -118,6 +118,7 @@ class PipelineImpl : public Pipeline, public FilterHost { kInitVideoRenderer, kPausing, kSeeking, + kFlushing, kStarting, kStarted, kEnded, |