1 /* 2 * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>. 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 #ifndef AVCODEC_ENCODER_H 6 #define AVCODEC_ENCODER_H 7 8 9 #include <MediaFormats.h> 10 11 extern "C" { 12 #include "avcodec.h" 13 #include "swscale.h" 14 } 15 16 #include "EncoderPlugin.h" 17 18 19 class AVCodecEncoder : public Encoder { 20 public: 21 AVCodecEncoder(uint32 codecID); 22 23 virtual ~AVCodecEncoder(); 24 25 virtual status_t AcceptedFormat( 26 const media_format* proposedInputFormat, 27 media_format* _acceptedInputFormat = NULL); 28 29 virtual status_t SetUp(const media_format* inputFormat); 30 31 virtual status_t GetEncodeParameters( 32 encode_parameters* parameters) const; 33 virtual status_t SetEncodeParameters( 34 encode_parameters* parameters) const; 35 36 virtual status_t Encode(const void* buffer, int64 frameCount, 37 media_encode_info* info); 38 39 private: 40 status_t _EncodeAudio(const void* buffer, 41 int64 frameCount, 42 media_encode_info* info); 43 44 status_t _EncodeVideo(const void* buffer, 45 int64 frameCount, 46 media_encode_info* info); 47 48 private: 49 media_format fInputFormat; 50 51 // FFmpeg related members 52 // TODO: Refactor common base class from AVCodec[De|En]Coder! 53 AVCodec* fCodec; 54 AVCodecContext* fContext; 55 bool fCodecInitDone; 56 57 AVPicture fSrcFrame; 58 AVPicture fDstFrame; 59 AVFrame* fFrame; 60 SwsContext* fSwsContext; 61 62 int64 fFramesWritten; 63 64 uint8* fChunkBuffer; 65 }; 66 67 #endif // AVCODEC_ENCODER_H 68