summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-27 22:45:43 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-27 22:45:43 +0000
commitc369bb8e7bc858d9df963550c16f7e0ffcbf52f5 (patch)
tree4493338d4fb9647e85ebc485b9ff37fbfb0a898c /media
parent86f8bcbe064f1bb59fff9ff2caba239a1895aca9 (diff)
downloadchromium_src-c369bb8e7bc858d9df963550c16f7e0ffcbf52f5.zip
chromium_src-c369bb8e7bc858d9df963550c16f7e0ffcbf52f5.tar.gz
chromium_src-c369bb8e7bc858d9df963550c16f7e0ffcbf52f5.tar.bz2
Switch VideoDecoder over to the new hot callbacks.
BUG=none TEST=media_unittests, compiles, etc. Review URL: http://codereview.chromium.org/6905071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83240 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/filters.h30
-rw-r--r--media/base/mock_filters.h6
-rw-r--r--media/filters/ffmpeg_video_decoder_unittest.cc4
-rw-r--r--media/filters/rtc_video_decoder_unittest.cc10
-rw-r--r--media/filters/video_renderer_base.cc5
-rw-r--r--media/filters/video_renderer_base_unittest.cc2
6 files changed, 35 insertions, 22 deletions
diff --git a/media/base/filters.h b/media/base/filters.h
index 36d7017..a3e5afb 100644
--- a/media/base/filters.h
+++ b/media/base/filters.h
@@ -197,19 +197,18 @@ class VideoDecoder : public Filter {
virtual void Initialize(DemuxerStream* stream, FilterCallback* callback,
StatisticsCallback* stats_callback) = 0;
- // |set_fill_buffer_done_callback| install permanent callback from downstream
- // filter (i.e. Renderer). The callback is used to deliver video frames at
- // runtime to downstream filter
- typedef Callback1<scoped_refptr<VideoFrame> >::Type ConsumeVideoFrameCallback;
- void set_consume_video_frame_callback(ConsumeVideoFrameCallback* callback) {
- consume_video_frame_callback_.reset(callback);
- }
-
// Renderer provides an output buffer for Decoder to write to. These buffers
- // will be recycled to renderer by |fill_buffer_done_callback_|.
+ // will be recycled to renderer via the permanent callback.
+ //
// We could also pass empty pointer here to let decoder provide buffers pool.
virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> frame) = 0;
+ // Installs a permanent callback for passing decoded video output.
+ typedef base::Callback<void(scoped_refptr<VideoFrame>)> ConsumeVideoFrameCB;
+ void set_consume_video_frame_callback(const ConsumeVideoFrameCB& callback) {
+ consume_video_frame_callback_ = callback;
+ }
+
// Indicate whether decoder provides its own output buffers
virtual bool ProvidesBuffer() = 0;
@@ -217,17 +216,19 @@ class VideoDecoder : public Filter {
virtual const MediaFormat& media_format() = 0;
protected:
- // A video frame is ready to be consumed. This method invoke
- // |consume_video_frame_callback_| internally.
+ // Executes the permanent callback to pass off decoded video.
+ //
+ // TODO(scherkus): name this ConsumeVideoFrame() once we fix the TODO in
+ // VideoDecodeEngine::EventHandler to remove ConsumeVideoFrame() from there.
void VideoFrameReady(scoped_refptr<VideoFrame> frame) {
- consume_video_frame_callback_->Run(frame);
+ consume_video_frame_callback_.Run(frame);
}
VideoDecoder();
virtual ~VideoDecoder();
private:
- scoped_ptr<ConsumeVideoFrameCallback> consume_video_frame_callback_;
+ ConsumeVideoFrameCB consume_video_frame_callback_;
};
@@ -242,7 +243,8 @@ class AudioDecoder : public Filter {
virtual AudioDecoderConfig config() = 0;
// Renderer provides an output buffer for Decoder to write to. These buffers
- // will be recycled to renderer by fill_buffer_done_callback_;
+ // will be recycled to renderer via the permanent callback.
+ //
// We could also pass empty pointer here to let decoder provide buffers pool.
virtual void ProduceAudioSamples(scoped_refptr<Buffer> buffer) = 0;
diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h
index edc3b26..bf66b0c 100644
--- a/media/base/mock_filters.h
+++ b/media/base/mock_filters.h
@@ -188,8 +188,7 @@ class MockVideoDecoder : public VideoDecoder {
MOCK_METHOD1(ProduceVideoFrame, void(scoped_refptr<VideoFrame>));
MOCK_METHOD0(ProvidesBuffer, bool());
- // Make this method public so that tests can make use of it.
- void VideoFrameReady(scoped_refptr<VideoFrame> frame) {
+ void VideoFrameReadyForTest(scoped_refptr<VideoFrame> frame) {
VideoDecoder::VideoFrameReady(frame);
}
@@ -243,6 +242,9 @@ class MockVideoRenderer : public VideoRenderer {
FilterCallback* callback,
StatisticsCallback* stats_callback));
MOCK_METHOD0(HasEnded, bool());
+
+ // TODO(scherkus): although VideoRendererBase defines this method, this really
+ // shouldn't be here OR should be renamed.
MOCK_METHOD1(ConsumeVideoFrame, void(scoped_refptr<VideoFrame> frame));
protected:
diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc
index 5a8303b..75c1c2d 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -4,6 +4,7 @@
#include <deque>
+#include "base/bind.h"
#include "base/memory/singleton.h"
#include "base/string_util.h"
#include "media/base/data_buffer.h"
@@ -311,7 +312,8 @@ TEST_F(FFmpegVideoDecoderTest, DoDecode_TestStateTransition) {
InitializeDecoderSuccessfully();
decoder_->set_consume_video_frame_callback(
- NewCallback(renderer_.get(), &MockVideoRenderer::ConsumeVideoFrame));
+ base::Bind(&MockVideoRenderer::ConsumeVideoFrame,
+ base::Unretained(renderer_.get())));
// Setup initial state and check that it is sane.
ASSERT_EQ(FFmpegVideoDecoder::kNormal, decoder_->state_);
diff --git a/media/filters/rtc_video_decoder_unittest.cc b/media/filters/rtc_video_decoder_unittest.cc
index aa00493..f0970ad 100644
--- a/media/filters/rtc_video_decoder_unittest.cc
+++ b/media/filters/rtc_video_decoder_unittest.cc
@@ -4,6 +4,7 @@
#include <deque>
+#include "base/bind.h"
#include "base/memory/singleton.h"
#include "base/string_util.h"
#include "media/base/data_buffer.h"
@@ -104,7 +105,8 @@ TEST_F(RTCVideoDecoderTest, DoSeek) {
InitializeDecoderSuccessfully();
decoder_->set_consume_video_frame_callback(
- NewCallback(renderer_.get(), &MockVideoRenderer::ConsumeVideoFrame));
+ base::Bind(&MockVideoRenderer::ConsumeVideoFrame,
+ base::Unretained(renderer_.get())));
// Expect Seek and verify the results.
EXPECT_CALL(*renderer_.get(), ConsumeVideoFrame(_))
@@ -123,11 +125,13 @@ TEST_F(RTCVideoDecoderTest, DoDeliverFrame) {
// Pass the frame back to decoder
decoder_->set_consume_video_frame_callback(
- NewCallback(decoder_.get(), &RTCVideoDecoder::ProduceVideoFrame));
+ base::Bind(&RTCVideoDecoder::ProduceVideoFrame,
+ base::Unretained(decoder_.get())));
decoder_->Seek(kZero, NewExpectedCallback());
decoder_->set_consume_video_frame_callback(
- NewCallback(renderer_.get(), &MockVideoRenderer::ConsumeVideoFrame));
+ base::Bind(&MockVideoRenderer::ConsumeVideoFrame,
+ base::Unretained(renderer_.get())));
EXPECT_CALL(*renderer_.get(), ConsumeVideoFrame(_))
.Times(Limits::kMaxVideoFrames);
diff --git a/media/filters/video_renderer_base.cc b/media/filters/video_renderer_base.cc
index 1c39964..2d32880 100644
--- a/media/filters/video_renderer_base.cc
+++ b/media/filters/video_renderer_base.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
#include "base/callback.h"
#include "base/threading/platform_thread.h"
#include "media/base/buffers.h"
@@ -166,7 +167,9 @@ void VideoRendererBase::Initialize(VideoDecoder* decoder,
statistics_callback_.reset(stats_callback);
decoder_->set_consume_video_frame_callback(
- NewCallback(this, &VideoRendererBase::ConsumeVideoFrame));
+ base::Bind(&VideoRendererBase::ConsumeVideoFrame,
+ base::Unretained(this)));
+
// Notify the pipeline of the video dimensions.
if (!ParseMediaFormat(decoder->media_format(),
&surface_type_,
diff --git a/media/filters/video_renderer_base_unittest.cc b/media/filters/video_renderer_base_unittest.cc
index 60861f9..3e0578c 100644
--- a/media/filters/video_renderer_base_unittest.cc
+++ b/media/filters/video_renderer_base_unittest.cc
@@ -143,7 +143,7 @@ class VideoRendererBaseTest : public ::testing::Test {
base::TimeDelta::FromMicroseconds(timestamp),
base::TimeDelta::FromMicroseconds(duration),
&frame);
- decoder_->VideoFrameReady(frame);
+ decoder_->VideoFrameReadyForTest(frame);
}
void ExpectCurrentTimestamp(int64 timestamp) {