| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_DECODER_H_ | 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_DECODER_H_ |
| 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_DECODER_H_ | 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_DECODER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "webkit/media/crypto/ppapi/cdm_video_decoder.h" |
| 10 #include "webkit/media/crypto/ppapi/content_decryption_module.h" | 11 #include "webkit/media/crypto/ppapi/content_decryption_module.h" |
| 11 | 12 |
| 12 struct AVCodecContext; | 13 struct AVCodecContext; |
| 13 struct AVFrame; | 14 struct AVFrame; |
| 14 | 15 |
| 15 namespace webkit_media { | 16 namespace webkit_media { |
| 16 | 17 |
| 17 class FFmpegCdmVideoDecoder { | 18 class FFmpegCdmVideoDecoder : public CdmVideoDecoder { |
| 18 public: | 19 public: |
| 19 explicit FFmpegCdmVideoDecoder(cdm::Allocator* allocator); | 20 explicit FFmpegCdmVideoDecoder(cdm::Allocator* allocator); |
| 20 ~FFmpegCdmVideoDecoder(); | 21 virtual ~FFmpegCdmVideoDecoder(); |
| 21 bool Initialize(const cdm::VideoDecoderConfig& config); | 22 |
| 22 void Deinitialize(); | 23 // CdmVideoDecoder implementation. |
| 23 void Reset(); | 24 virtual bool Initialize(const cdm::VideoDecoderConfig& config) OVERRIDE; |
| 25 virtual void Deinitialize() OVERRIDE; |
| 26 virtual void Reset() OVERRIDE; |
| 27 virtual cdm::Status DecodeFrame(const uint8_t* compressed_frame, |
| 28 int32_t compressed_frame_size, |
| 29 int64_t timestamp, |
| 30 cdm::VideoFrame* decoded_frame) OVERRIDE; |
| 31 virtual bool is_initialized() const OVERRIDE { return is_initialized_; } |
| 24 | 32 |
| 25 // Returns true when |format| and |data_size| specify a supported video | 33 // Returns true when |format| and |data_size| specify a supported video |
| 26 // output configuration. | 34 // output configuration. |
| 27 static bool IsValidOutputConfig(cdm::VideoFormat format, | 35 static bool IsValidOutputConfig(cdm::VideoFormat format, |
| 28 const cdm::Size& data_size); | 36 const cdm::Size& data_size); |
| 29 | 37 |
| 30 // Decodes |compressed_frame|. Stores output frame in |decoded_frame| and | |
| 31 // returns |cdm::kSuccess| when an output frame is available. Returns | |
| 32 // |cdm::kNeedMoreData| when |compressed_frame| does not produce an output | |
| 33 // frame. Returns |cdm::kDecodeError| when decoding fails. | |
| 34 cdm::Status DecodeFrame(const uint8_t* compressed_frame, | |
| 35 int32_t compressed_frame_size, | |
| 36 int64_t timestamp, | |
| 37 cdm::VideoFrame* decoded_frame); | |
| 38 | |
| 39 private: | 38 private: |
| 40 // Allocates storage, then copies video frame stored in |av_frame_| to | 39 // Allocates storage, then copies video frame stored in |av_frame_| to |
| 41 // |cdm_video_frame|. Returns true when allocation and copy succeed. | 40 // |cdm_video_frame|. Returns true when allocation and copy succeed. |
| 42 bool CopyAvFrameTo(cdm::VideoFrame* cdm_video_frame); | 41 bool CopyAvFrameTo(cdm::VideoFrame* cdm_video_frame); |
| 43 | 42 |
| 44 void ReleaseFFmpegResources(); | 43 void ReleaseFFmpegResources(); |
| 45 | 44 |
| 46 // FFmpeg structures owned by this object. | 45 // FFmpeg structures owned by this object. |
| 47 AVCodecContext* codec_context_; | 46 AVCodecContext* codec_context_; |
| 48 AVFrame* av_frame_; | 47 AVFrame* av_frame_; |
| 49 | 48 |
| 50 bool is_initialized_; | 49 bool is_initialized_; |
| 51 | 50 |
| 52 cdm::Allocator* const allocator_; | 51 cdm::Allocator* const allocator_; |
| 53 | 52 |
| 54 DISALLOW_COPY_AND_ASSIGN(FFmpegCdmVideoDecoder); | 53 DISALLOW_COPY_AND_ASSIGN(FFmpegCdmVideoDecoder); |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 } // namespace webkit_media | 56 } // namespace webkit_media |
| 58 | 57 |
| 59 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_DECODER_H_ | 58 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_DECODER_H_ |
| OLD | NEW |