1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_CDM_PPAPI_FFMPEG_CDM_VIDEO_DECODER_H_
6 #define MEDIA_CDM_PPAPI_FFMPEG_CDM_VIDEO_DECODER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "media/cdm/ppapi/api/content_decryption_module.h"
12 #include "media/cdm/ppapi/cdm_video_decoder.h"
14 struct AVCodecContext
;
19 class ScopedPtrAVFreeContext
;
20 class ScopedPtrAVFreeFrame
;
22 class FFmpegCdmVideoDecoder
: public CdmVideoDecoder
{
24 explicit FFmpegCdmVideoDecoder(cdm::Host
* host
);
25 virtual ~FFmpegCdmVideoDecoder();
27 // CdmVideoDecoder implementation.
28 virtual bool Initialize(const cdm::VideoDecoderConfig
& config
) OVERRIDE
;
29 virtual void Deinitialize() OVERRIDE
;
30 virtual void Reset() OVERRIDE
;
31 virtual cdm::Status
DecodeFrame(const uint8_t* compressed_frame
,
32 int32_t compressed_frame_size
,
34 cdm::VideoFrame
* decoded_frame
) OVERRIDE
;
35 virtual bool is_initialized() const OVERRIDE
{ return is_initialized_
; }
37 // Returns true when |format| and |data_size| specify a supported video
38 // output configuration.
39 static bool IsValidOutputConfig(cdm::VideoFormat format
,
40 const cdm::Size
& data_size
);
43 // Allocates storage, then copies video frame stored in |av_frame_| to
44 // |cdm_video_frame|. Returns true when allocation and copy succeed.
45 bool CopyAvFrameTo(cdm::VideoFrame
* cdm_video_frame
);
47 void ReleaseFFmpegResources();
49 // FFmpeg structures owned by this object.
50 scoped_ptr_malloc
<AVCodecContext
, ScopedPtrAVFreeContext
> codec_context_
;
51 scoped_ptr_malloc
<AVFrame
, ScopedPtrAVFreeFrame
> av_frame_
;
55 cdm::Host
* const host_
;
57 DISALLOW_COPY_AND_ASSIGN(FFmpegCdmVideoDecoder
);
62 #endif // MEDIA_CDM_PPAPI_FFMPEG_CDM_VIDEO_DECODER_H_