00001 #ifndef AUDIOOUTPUTREENCODER 00002 #define AUDIOOUTPUTREENCODER 00003 00004 extern "C" { 00005 #include "libavcodec/avcodec.h" 00006 }; 00007 00008 class AudioOutputDigitalEncoder 00009 { 00010 public: 00011 AudioOutputDigitalEncoder(void); 00012 ~AudioOutputDigitalEncoder(); 00013 00014 bool Init(CodecID codec_id, int bitrate, int samplerate, int channels); 00015 void Dispose(void); 00016 size_t Encode(short * buff); 00017 00018 inline char *GetFrameBuffer(void); 00019 size_t FrameSize(void) const { return one_frame_bytes; } 00020 char *GetOutBuff(void) const { return outbuf; } 00021 00022 public: 00023 size_t audio_bytes_per_sample; 00024 00025 private: 00026 AVCodecContext *av_context; 00027 char *outbuf; 00028 int outbuf_size; 00029 char *frame_buffer; 00030 size_t one_frame_bytes; 00031 }; 00032 00033 inline char *AudioOutputDigitalEncoder::GetFrameBuffer(void) 00034 { 00035 if (!frame_buffer && av_context) 00036 frame_buffer = new char [one_frame_bytes]; 00037 00038 return frame_buffer; 00039 } 00040 00041 #endif
1.5.5