#ifndef MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_FFMPEG_CDM_VIDEO_DECODER_H_
#define MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_FFMPEG_CDM_VIDEO_DECODER_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "media/cdm/ppapi/external_clear_key/cdm_video_decoder.h"
#include "media/cdm/ppapi/external_clear_key/clear_key_cdm_common.h"
#include "media/ffmpeg/ffmpeg_deleters.h"
struct AVCodecContext;
struct AVFrame;
namespace media {
class FFmpegCdmVideoDecoder : public CdmVideoDecoder {
public:
explicit FFmpegCdmVideoDecoder(ClearKeyCdmHost* host);
virtual ~FFmpegCdmVideoDecoder();
virtual bool Initialize(const cdm::VideoDecoderConfig& config) OVERRIDE;
virtual void Deinitialize() OVERRIDE;
virtual void Reset() OVERRIDE;
virtual cdm::Status DecodeFrame(const uint8_t* compressed_frame,
int32_t compressed_frame_size,
int64_t timestamp,
cdm::VideoFrame* decoded_frame) OVERRIDE;
virtual bool is_initialized() const OVERRIDE { return is_initialized_; }
static bool IsValidOutputConfig(cdm::VideoFormat format,
const cdm::Size& data_size);
private:
bool CopyAvFrameTo(cdm::VideoFrame* cdm_video_frame);
void ReleaseFFmpegResources();
scoped_ptr<AVCodecContext, ScopedPtrAVFreeContext> codec_context_;
scoped_ptr<AVFrame, ScopedPtrAVFreeFrame> av_frame_;
bool is_initialized_;
ClearKeyCdmHost* const host_;
DISALLOW_COPY_AND_ASSIGN(FFmpegCdmVideoDecoder);
};
}
#endif