diff options
Diffstat (limited to 'media/video/ffmpeg_video_decode_engine.h')
-rw-r--r-- | media/video/ffmpeg_video_decode_engine.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/media/video/ffmpeg_video_decode_engine.h b/media/video/ffmpeg_video_decode_engine.h new file mode 100644 index 0000000..3e030db --- /dev/null +++ b/media/video/ffmpeg_video_decode_engine.h @@ -0,0 +1,85 @@ +// Copyright (c) 2010 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_VIDEO_FFMPEG_VIDEO_DECODE_ENGINE_H_ +#define MEDIA_VIDEO_FFMPEG_VIDEO_DECODE_ENGINE_H_ + +#include <deque> + +#include "base/scoped_ptr.h" +#include "media/ffmpeg/ffmpeg_common.h" +#include "media/video/video_decode_engine.h" + +// FFmpeg types. +struct AVCodecContext; +struct AVFrame; +struct AVStream; + +namespace media { + +class FFmpegVideoAllocator; + +class FFmpegVideoDecodeEngine : public VideoDecodeEngine { + public: + FFmpegVideoDecodeEngine(); + virtual ~FFmpegVideoDecodeEngine(); + + // Implementation of the VideoDecodeEngine Interface. + virtual void Initialize(MessageLoop* message_loop, + VideoDecodeEngine::EventHandler* event_handler, + const VideoCodecConfig& config); + virtual void EmptyThisBuffer(scoped_refptr<Buffer> buffer); + virtual void FillThisBuffer(scoped_refptr<VideoFrame> frame); + virtual void Uninitialize(); + virtual void Flush(); + virtual void Seek(); + + virtual AVCodecContext* codec_context() const { return codec_context_; } + + virtual void SetCodecContextForTest(AVCodecContext* context) { + codec_context_ = context; + } + + VideoFrame::Format GetSurfaceFormat() const; + private: + void DecodeFrame(scoped_refptr<Buffer> buffer); + void ReadInput(); + void TryToFinishPendingFlush(); + + AVCodecContext* codec_context_; + AVStream* av_stream_; + scoped_ptr_malloc<AVFrame, ScopedPtrAVFree> av_frame_; + VideoDecodeEngine::EventHandler* event_handler_; + + // Whether direct rendering is used. + bool direct_rendering_; + + // Used when direct rendering is used to recycle output buffers. + scoped_ptr<FFmpegVideoAllocator> allocator_; + + // Indicate how many buffers are pending on input port of this filter: + // Increment when engine receive one input packet from demuxer; + // Decrement when engine send one input packet to demuxer; + int pending_input_buffers_; + + // Indicate how many buffers are pending on output port of this filter: + // Increment when engine receive one output frame from renderer; + // Decrement when engine send one output frame to renderer; + int pending_output_buffers_; + + // Whether end of stream had been reached at output side. + bool output_eos_reached_; + + // Used when direct rendering is disabled to hold available output buffers. + std::deque<scoped_refptr<VideoFrame> > frame_queue_available_; + + // Whether flush operation is pending. + bool flush_pending_; + + DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecodeEngine); +}; + +} // namespace media + +#endif // MEDIA_VIDEO_FFMPEG_VIDEO_DECODE_ENGINE_H_ |