Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / media / cdm / ppapi / external_clear_key / ffmpeg_cdm_video_decoder.h
blob70bd2bf46c74d7e8a28731f942ac58cfe44391e9
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_EXTERNAL_CLEAR_KEY_FFMPEG_CDM_VIDEO_DECODER_H_
6 #define MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_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/external_clear_key/cdm_video_decoder.h"
12 #include "media/cdm/ppapi/external_clear_key/clear_key_cdm_common.h"
13 #include "media/ffmpeg/ffmpeg_deleters.h"
15 struct AVCodecContext;
16 struct AVFrame;
18 namespace media {
20 class FFmpegCdmVideoDecoder : public CdmVideoDecoder {
21 public:
22 explicit FFmpegCdmVideoDecoder(ClearKeyCdmHost* host);
23 ~FFmpegCdmVideoDecoder() override;
25 // CdmVideoDecoder implementation.
26 bool Initialize(const cdm::VideoDecoderConfig& config) override;
27 void Deinitialize() override;
28 void Reset() override;
29 cdm::Status DecodeFrame(const uint8_t* compressed_frame,
30 int32_t compressed_frame_size,
31 int64_t timestamp,
32 cdm::VideoFrame* decoded_frame) override;
33 bool is_initialized() const override { return is_initialized_; }
35 // Returns true when |format| and |data_size| specify a supported video
36 // output configuration.
37 static bool IsValidOutputConfig(cdm::VideoFormat format,
38 const cdm::Size& data_size);
40 private:
41 // Allocates storage, then copies video frame stored in |av_frame_| to
42 // |cdm_video_frame|. Returns true when allocation and copy succeed.
43 bool CopyAvFrameTo(cdm::VideoFrame* cdm_video_frame);
45 void ReleaseFFmpegResources();
47 // FFmpeg structures owned by this object.
48 scoped_ptr<AVCodecContext, ScopedPtrAVFreeContext> codec_context_;
49 scoped_ptr<AVFrame, ScopedPtrAVFreeFrame> av_frame_;
51 bool is_initialized_;
53 ClearKeyCdmHost* const host_;
55 DISALLOW_COPY_AND_ASSIGN(FFmpegCdmVideoDecoder);
58 } // namespace media
60 #endif // MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_FFMPEG_CDM_VIDEO_DECODER_H_