MythTV  master
avformatwriter.h
Go to the documentation of this file.
1 #ifndef AVFORMATWRITER_H_
2 #define AVFORMATWRITER_H_
3 
4 #include "mythconfig.h"
5 #include "filewriterbase.h"
6 #include "avfringbuffer.h"
7 
8 #include <QList>
9 
10 #undef HAVE_AV_CONFIG_H
11 extern "C" {
12 #include "libavcodec/avcodec.h"
13 #include "libavformat/avformat.h"
14 }
15 
17 {
18  public:
20  ~AVFormatWriter();
21 
22  bool Init(void) override; // FileWriterBase
23  bool OpenFile(void) override; // FileWriterBase
24  bool CloseFile(void) override; // FileWriterBase
25 
26  int WriteVideoFrame(VideoFrame *frame) override; // FileWriterBase
27  int WriteAudioFrame(unsigned char *buf, int fnum, long long &timecode) override; // FileWriterBase
28  int WriteTextFrame(int vbimode, unsigned char *buf, int len,
29  long long timecode, int pagenr) override; // FileWriterBase
30 
31  bool NextFrameIsKeyFrame(void);
32  bool ReOpen(const QString& filename);
33 
34  private:
35  AVStream *AddVideoStream(void);
36  bool OpenVideo(void);
37  AVStream *AddAudioStream(void);
38  bool OpenAudio(void);
39  AVFrame *AllocPicture(enum AVPixelFormat pix_fmt);
40  void Cleanup(void);
41 
42  AVRational GetCodecTimeBase(void);
43  bool FindAudioFormat(AVCodecContext *ctx, AVCodec *c, AVSampleFormat format);
44 
45  AVFRingBuffer *m_avfRingBuffer {nullptr};
46  RingBuffer *m_ringBuffer {nullptr};
47 
48  AVOutputFormat m_fmt;
49  AVFormatContext *m_ctx {nullptr};
50  AVStream *m_videoStream {nullptr};
51  AVCodec *m_avVideoCodec {nullptr};
52  AVStream *m_audioStream {nullptr};
53  AVCodec *m_avAudioCodec {nullptr};
54  AVFrame *m_picture {nullptr};
55  AVFrame *m_audPicture {nullptr};
56  unsigned char *m_audioInBuf {nullptr};
57  unsigned char *m_audioInPBuf {nullptr};
58 
59  QList<long long> m_bufferedVideoFrameTimes;
61  QList<long long> m_bufferedAudioFrameTimes;
62 };
63 
64 #endif
65 
66 /* vim: set expandtab tabstop=4 shiftwidth=4: */
67 
virtual bool OpenFile(void)
vbimode
Definition: vbilut.h:20
virtual int WriteVideoFrame(VideoFrame *frame)
struct AVFrame AVFrame
virtual int WriteAudioFrame(unsigned char *buf, int fnum, long long &timecode)
#define MTV_PUBLIC
Definition: mythtvexp.h:15
QList< long long > m_bufferedVideoFrameTimes
virtual int WriteTextFrame(int, unsigned char *, int, long long, int)
QList< long long > m_bufferedAudioFrameTimes
Implements a file/stream reader/writer.
QList< int > m_bufferedVideoFrameTypes
AVOutputFormat m_fmt
virtual bool Init(void)
virtual bool CloseFile(void)