diff options
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/filters.h | 35 | ||||
-rw-r--r-- | media/base/mock_filters.h | 8 | ||||
-rw-r--r-- | media/base/video_decoder_config.cc | 6 |
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 { |