00001 #ifndef AVFORMATWRITER_H_
00002 #define AVFORMATWRITER_H_
00003
00004 #include "filewriterbase.h"
00005 #include "avfringbuffer.h"
00006
00007 #undef HAVE_AV_CONFIG_H
00008 extern "C" {
00009 #include "libavcodec/avcodec.h"
00010 #include "libavformat/avformat.h"
00011 }
00012
00013 class MTV_PUBLIC AVFormatWriter : public FileWriterBase
00014 {
00015 public:
00016 AVFormatWriter();
00017 ~AVFormatWriter();
00018
00019 bool Init(void);
00020 bool OpenFile(void);
00021 bool CloseFile(void);
00022
00023 bool WriteVideoFrame(VideoFrame *frame);
00024 bool WriteAudioFrame(unsigned char *buf, int fnum, int timecode);
00025 bool WriteTextFrame(int vbimode, unsigned char *buf, int len,
00026 int timecode, int pagenr);
00027
00028 bool NextFrameIsKeyFrame(void);
00029 bool ReOpen(QString filename);
00030
00031 private:
00032 AVStream *AddVideoStream(void);
00033 bool OpenVideo(void);
00034 AVStream *AddAudioStream(void);
00035 bool OpenAudio(void);
00036 AVFrame *AllocPicture(enum PixelFormat pix_fmt);
00037
00038 AVRational GetCodecTimeBase(void);
00039
00040 AVFRingBuffer *m_avfRingBuffer;
00041 RingBuffer *m_ringBuffer;
00042
00043 AVOutputFormat m_fmt;
00044 AVFormatContext *m_ctx;
00045 AVStream *m_videoStream;
00046 AVCodec *m_avVideoCodec;
00047 AVStream *m_audioStream;
00048 AVCodec *m_avAudioCodec;
00049 AVFrame *m_picture;
00050 AVFrame *m_tmpPicture;
00051 AVPacket *m_pkt;
00052 AVFrame *m_audPicture;
00053 AVPacket *m_audPkt;
00054 unsigned char *m_videoOutBuf;
00055 int m_videoOutBufSize;
00056 unsigned int *m_audioSamples;
00057 unsigned char *m_audioOutBuf;
00058 int m_audioOutBufSize;
00059 int m_audioInputFrameSize;
00060 };
00061
00062 #endif
00063
00064
00065