MythTV  master
mythavformatwriter.h
Go to the documentation of this file.
1 #ifndef AVFORMATWRITER_H_
2 #define AVFORMATWRITER_H_
3 
4 // Qt
5 #include <QList>
6 
7 // MythTV
8 #include "libmythbase/mythconfig.h"
11 #include "libmythtv/mythavutil.h"
12 
13 #undef HAVE_AV_CONFIG_H
14 extern "C" {
15 #include "libavcodec/avcodec.h"
16 #include "libavformat/avformat.h"
17 }
18 
20 {
21  public:
22  MythAVFormatWriter() = default;
23  ~MythAVFormatWriter() override;
24 
25  bool Init (void) override;
26  bool OpenFile (void) override;
27  bool CloseFile (void) override;
28  int WriteVideoFrame (MythVideoFrame *Frame) override;
29  int WriteAudioFrame (unsigned char *Buffer, int FrameNumber, std::chrono::milliseconds &Timecode) override;
30  int WriteTextFrame (int VBIMode, unsigned char *Buffer, int Length,
31  std::chrono::milliseconds Timecode, int PageNumber) override;
32  int WriteSeekTable (void) override;
33  bool SwitchToNextFile (void) override;
34 
35  bool NextFrameIsKeyFrame (void);
36  bool ReOpen (const QString& Filename);
37 
38  private:
39  bool openFileHelper();
40  AVStream* AddVideoStream (void);
41  bool OpenVideo (void);
42  AVStream* AddAudioStream (void);
43  bool OpenAudio (void);
44  AVFrame* AllocPicture (enum AVPixelFormat PixFmt);
45  void Cleanup (void);
46  AVRational GetCodecTimeBase (void);
47  static bool FindAudioFormat (AVCodecContext *Ctx, const AVCodec *Codec, AVSampleFormat Format);
48 
49  MythAVFormatBuffer *m_avfBuffer { nullptr };
50  MythMediaBuffer *m_buffer { nullptr };
51  AVOutputFormat m_fmt { };
52  AVFormatContext *m_ctx { nullptr };
54  AVStream *m_videoStream { nullptr };
55  const AVCodec *m_avVideoCodec { nullptr };
56  AVStream *m_audioStream { nullptr };
57  const AVCodec *m_avAudioCodec { nullptr };
58  AVFrame *m_picture { nullptr };
59  AVFrame *m_audPicture { nullptr };
60  unsigned char *m_audioInBuf { nullptr };
61  unsigned char *m_audioInPBuf { nullptr };
62  QList<std::chrono::milliseconds> m_bufferedVideoFrameTimes;
64  QList<std::chrono::milliseconds> m_bufferedAudioFrameTimes;
65 };
66 
67 #endif
68 
69 /* vim: set expandtab tabstop=4 shiftwidth=4: */
70 
mythmediawriter.h
Frame
Definition: zmdefines.h:102
VBIMode
Definition: tv.h:7
MythDate::Format
Format
Definition: mythdate.h:15
MythMediaBuffer
Definition: mythmediabuffer.h:59
MythMediaWriter::OpenFile
virtual bool OpenFile(void)=0
mythavformatbuffer.h
MythAVFormatWriter::m_codecMap
MythCodecMap m_codecMap
Definition: mythavformatwriter.h:53
MythAVFormatWriter::m_bufferedVideoFrameTypes
QList< int > m_bufferedVideoFrameTypes
Definition: mythavformatwriter.h:63
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
MythAVFormatWriter
Definition: mythavformatwriter.h:19
MythMediaWriter::WriteTextFrame
virtual int WriteTextFrame(int VBIMode, unsigned char *Buffer, int Length, std::chrono::milliseconds Timecode, int PageNumber)=0
MythMediaWriter::WriteVideoFrame
virtual int WriteVideoFrame(MythVideoFrame *Frame)=0
MythCodecMap
Definition: mythavutil.h:27
MythMediaWriter::SwitchToNextFile
virtual bool SwitchToNextFile(void)=0
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
Buffer
Definition: MythExternControl.h:36
MythAVFormatWriter::m_bufferedVideoFrameTimes
QList< std::chrono::milliseconds > m_bufferedVideoFrameTimes
Definition: mythavformatwriter.h:62
MythMediaWriter::CloseFile
virtual bool CloseFile(void)=0
MythMediaWriter::Init
virtual bool Init(void)=0
mythavutil.h
MythAVFormatWriter::m_bufferedAudioFrameTimes
QList< std::chrono::milliseconds > m_bufferedAudioFrameTimes
Definition: mythavformatwriter.h:64
MythMediaWriter::WriteAudioFrame
virtual int WriteAudioFrame(unsigned char *Buffer, int FrameNumber, std::chrono::milliseconds &Timecode)=0
MythVideoFrame
Definition: mythframe.h:87
MythMediaWriter::WriteSeekTable
virtual int WriteSeekTable(void)=0
MythAVFormatBuffer
Definition: mythavformatbuffer.h:12
MythMediaWriter
Definition: mythmediawriter.h:11