summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-04 02:04:09 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-04 02:04:09 +0000
commitf23676abfed3df60d1be4455d422acdb70facf1c (patch)
tree7f4a926b34fe708f1dbf00407eca0f253d1c6ef0 /media/base
parent760afa9837be0fb92b2994360743ccac35fe7384 (diff)
downloadchromium_src-f23676abfed3df60d1be4455d422acdb70facf1c.zip
chromium_src-f23676abfed3df60d1be4455d422acdb70facf1c.tar.gz
chromium_src-f23676abfed3df60d1be4455d422acdb70facf1c.tar.bz2
Simplify VideoDecodeEngine interface by making everything synchronous.
Although I plan to remove VideoDecodeEngine entirely it requires detangling some of the code first. Other noteworthy changes: - It's no longer valid to call VideoFrameReady(NULL), instead FFmpegVideoDecoder will raise an error the moment it finds one - Buffer recycling has been vanquished (for now), with video frames always allocated in the decoder - Produce/ConsumeVideoFrame() has been replaced by Read() - Video decode byte statistics are only updated if more than 0 bytes were decoded - FFmpegVideoDecodeEngine no longer attempts to preroll Review URL: http://codereview.chromium.org/8417019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108612 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/filters.h35
-rw-r--r--media/base/mock_filters.h8
-rw-r--r--media/base/video_decoder_config.cc6
3 files changed, 19 insertions, 30 deletions
diff --git a/media/base/filters.h b/media/base/filters.h
index 1624a60..e464202 100644
--- a/media/base/filters.h
+++ b/media/base/filters.h
@@ -164,22 +164,20 @@ class MEDIA_EXPORT VideoDecoder : public Filter {
// Initialize a VideoDecoder with the given DemuxerStream, executing the
// callback upon completion.
// stats_callback is used to update global pipeline statistics.
+ //
+ // TODO(scherkus): switch to PipelineStatus callback.
virtual void Initialize(DemuxerStream* stream, const base::Closure& callback,
const StatisticsCallback& stats_callback) = 0;
- // Renderer provides an output buffer for Decoder to write to. These buffers
- // will be recycled to renderer via the permanent callback.
+ // Request a frame to be decoded and returned via the provided callback.
+ // Only one read may be in flight at any given time.
//
- // 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.
+ // Implementations guarantee that the callback will not be called from within
+ // this method.
//
- // A NULL frame represents a decoding error.
- typedef base::Callback<void(scoped_refptr<VideoFrame>)> ConsumeVideoFrameCB;
- void set_consume_video_frame_callback(const ConsumeVideoFrameCB& callback) {
- consume_video_frame_callback_ = callback;
- }
+ // Frames will be non-NULL yet may be end of stream frames.
+ typedef base::Callback<void(scoped_refptr<VideoFrame>)> ReadCB;
+ virtual void Read(const ReadCB& callback) = 0;
// Returns the natural width and height of decoded video in pixels.
//
@@ -188,22 +186,11 @@ class MEDIA_EXPORT VideoDecoder : public Filter {
//
// TODO(scherkus): why not rely on prerolling and decoding a single frame to
// get dimensions?
- virtual gfx::Size natural_size() = 0;
+ virtual const gfx::Size& natural_size() = 0;
protected:
- // 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);
- }
-
VideoDecoder();
virtual ~VideoDecoder();
-
- private:
- ConsumeVideoFrameCB consume_video_frame_callback_;
};
@@ -212,6 +199,8 @@ class MEDIA_EXPORT AudioDecoder : public Filter {
// Initialize a AudioDecoder with the given DemuxerStream, executing the
// callback upon completion.
// stats_callback is used to update global pipeline statistics.
+ //
+ // TODO(scherkus): switch to PipelineStatus callback.
virtual void Initialize(DemuxerStream* stream, const base::Closure& callback,
const StatisticsCallback& stats_callback) = 0;
diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h
index 8199b88..841629d 100644
--- a/media/base/mock_filters.h
+++ b/media/base/mock_filters.h
@@ -187,12 +187,8 @@ class MockVideoDecoder : public VideoDecoder {
MOCK_METHOD3(Initialize, void(DemuxerStream* stream,
const base::Closure& callback,
const StatisticsCallback& stats_callback));
- MOCK_METHOD1(ProduceVideoFrame, void(scoped_refptr<VideoFrame>));
- MOCK_METHOD0(natural_size, gfx::Size());
-
- void VideoFrameReadyForTest(scoped_refptr<VideoFrame> frame) {
- VideoDecoder::VideoFrameReady(frame);
- }
+ MOCK_METHOD1(Read, void(const ReadCB& callback));
+ MOCK_METHOD0(natural_size, const gfx::Size&());
protected:
virtual ~MockVideoDecoder();
diff --git a/media/base/video_decoder_config.cc b/media/base/video_decoder_config.cc
index d055f49..6a7add8 100644
--- a/media/base/video_decoder_config.cc
+++ b/media/base/video_decoder_config.cc
@@ -7,6 +7,7 @@
#include <cmath>
#include "base/logging.h"
+#include "media/base/limits.h"
namespace media {
@@ -90,7 +91,10 @@ bool VideoDecoderConfig::IsValidConfig() const {
frame_rate_numerator_ > 0 &&
frame_rate_denominator_ > 0 &&
aspect_ratio_numerator_ > 0 &&
- aspect_ratio_denominator_ > 0;
+ aspect_ratio_denominator_ > 0 &&
+ natural_size_.width() <= Limits::kMaxDimension &&
+ natural_size_.height() <= Limits::kMaxDimension &&
+ natural_size_.GetArea() <= Limits::kMaxCanvas;
}
VideoCodec VideoDecoderConfig::codec() const {