Go to the documentation of this file. 1 #ifndef NUPPELVIDEORECORDER
2 #define NUPPELVIDEORECORDER
10 #include <lame/lame.h>
15 #include "mythconfig.h"
17 #undef HAVE_AV_CONFIG_H
19 #include "libavcodec/avcodec.h"
34 #include "lzo/lzo1x.h"
40 #define KEYFRAMEDIST 30
55 void run(
void)
override;
66 void run(
void)
override;
79 void SetOption(
const QString &opt,
int value)
override;
80 void SetOption(
const QString &name,
const QString &value)
override;
83 const QString &videodev,
84 const QString &audiodev,
85 const QString &vbidev)
override;
88 void run(
void)
override;
91 bool IsPaused(
bool holding_lock =
false)
const override;
99 void Reset(
void)
override;
109 void StreamAllocate(
void);
110 void WriteHeader(
void);
111 void WriteSeekTable(
void);
112 void WriteKeyFrameAdjustTable(
113 const std::vector<struct kfatable_entry> &kfa_table);
114 void UpdateSeekTable(
int frame_num,
long offset = 0);
116 bool SetupAVCodecVideo(
void);
117 void SetupRTjpeg(
void);
118 int AudioInit(
bool skipdevice =
false);
121 bool forcekey =
false);
122 void WriteAudio(
unsigned char *buf,
int fnum,
int timecode);
123 void WriteText(
unsigned char *buf,
int len,
int timecode,
int pagenr);
125 void SetNewVideoParams(
double newaspect);
128 void doWriteThread(
void);
129 void doAudioThread(
void);
134 void WriteFileHeader(
void);
136 void InitBuffers(
void);
137 void ResizeVideoBuffers(
void);
139 bool MJPEGInit(
void);
141 void KillChildren(
void);
143 void BufferIt(
unsigned char *buf,
int len = -1,
bool forcekey =
false);
145 int CreateNuppelFile(
void);
147 void ProbeV4L2(
void);
148 bool SetFormatV4L2(
void);
155 void AddTextData(
unsigned char*buf,
int len, int64_t timecode,
char type)
override;
157 void UpdateResolutions(
void);
160 signed char *m_strm {
nullptr};
161 unsigned int m_lf {0};
169 int m_compression {1};
170 bool m_compressAudio {
true};
172 unsigned long long m_audioBytes {0};
173 int m_audioChannels {2};
174 int m_audioBits {16};
175 int m_audioBytesPerSample {m_audioChannels * m_audioBits / 8};
176 int m_audioSampleRate {44100};
177 int m_effectiveDsp {0};
180 float m_videoAspect {1.33333F};
182 bool m_transcoding {
false};
184 int m_mp3Quality {3};
185 char *m_mp3Buf {
nullptr};
186 int m_mp3BufSize {0};
187 lame_global_flags *m_gf {
nullptr};
191 #define OUT_LEN (1024*1024 + 1024*1024 / 64 + 16 + 3)
192 std::array<lzo_byte,OUT_LEN> m_out {};
193 #define HEAP_ALLOC(var,size) \
194 std::array<long,((size) + (sizeof(long) - 1)) / sizeof(long)> __LZO_MMODEL var
197 std::vector<struct vidbuffertype *> m_videoBuffer;
201 int m_actVideoEncode {0};
202 int m_actVideoBuffer {0};
204 int m_actAudioEncode {0};
205 int m_actAudioBuffer {0};
206 long long m_actAudioSample {0};
208 int m_actTextEncode {0};
209 int m_actTextBuffer {0};
211 int m_videoBufferCount {0};
212 int m_audioBufferCount {0};
213 int m_textBufferCount {0};
215 long m_videoBufferSize {0};
216 long m_audioBufferSize {0};
217 long m_textBufferSize {0};
224 bool m_recording {
false};
227 std::vector<struct seektable_entry> *m_seekTable {
nullptr};
228 long long m_lastPositionMapPos {0};
230 long long m_extendedDataOffset {0};
232 long long m_framesWritten {0};
234 bool m_livetv {
false};
235 bool m_writePaused {
false};
236 bool m_audioPaused {
false};
237 bool m_mainPaused {
false};
239 double m_frameRateMultiplier {1.0};
240 double m_heightMultiplier {1.0};
244 long int m_oldTc {0};
246 int m_frameOfGop {0};
247 int m_lastTimecode {0};
248 int m_audioBehind {0};
250 bool m_useAvCodec {
false};
252 AVCodec *m_mpaVidCodec {
nullptr};
253 AVCodecContext *m_mpaVidCtx {
nullptr};
255 int m_targetBitRate {2200};
256 int m_scaleBitRate {1};
257 int m_maxQuality {2};
258 int m_minQuality {31};
261 int m_mbDecision {FF_MB_DECISION_SIMPLE};
263 int m_encodingThreadCount {1};
266 AVPixelFormat m_pictureFormat {AV_PIX_FMT_YUV420P};
268 uint32_t m_v4l2PixelFormat {0};
273 bool m_hardwareEncode {
false};
274 int m_hmjpgQuality {80};
275 int m_hmjpgHDecimation {2};
276 int m_hmjpgVDecimation {2};
277 int m_hmjpgMaxW {640};
279 bool m_clearTimeOnPause {
false};
281 bool m_usingV4l2 {
false};
282 int m_channelFd {-1};
286 bool m_skipBtAudio {
false};
289 bool m_correctBttv {
false};
296 bool m_go7007 {
false};
297 bool m_resetCapture {
false};
NVRWriteThread(NuppelVideoRecorder *parent)
int GetVideoFd(void) override
Returns file descriptor of recorder device.
~NVRWriteThread() override
void ResetForNewFile(void) override
Abstract base class for Video4Linux based recorders.
void SetVideoFilters(QString &) override
Tells recorder which filters to use.
std::vector< struct txtbuffertype * > m_textBuffer
void SetOptionsFromProfile(RecordingProfile *profile, const QString &videodev, const QString &audiodev, const QString &vbidev) override
Sets basic recorder options.
void Reset(void) override
Reset the recorder to the startup state.
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
void FinishRecording(void) override
Flushes the ringbuffer, and if this is not a live LiveTV recording saves the position map and filesiz...
virtual void Pause(bool clear=true)
Pause tells recorder to pause, it should not block.
void SetOption(const QString &name, const QString &value) override
Set an specific option.
#define HEAP_ALLOC(var, size)
std::vector< struct audbuffertype * > m_audioBuffer
~NVRAudioThread() override
void SetVideoAspect(float newAspect)
NuppelVideoRecorder * m_parent
Abstract class providing a generic interface to tuning hardware.
NuppelVideoRecorder * m_parent
long long GetFramesWritten(void) override
Returns number of frames written to disk.
void Initialize(void) override
This is called between SetOptionsFromProfile() and run() to initialize any devices,...
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
virtual bool IsRecording(void)
Tells whether the StartRecorder() loop is running.
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
NVRAudioThread(NuppelVideoRecorder *parent)
virtual void StartNewFile(void)
This is the coordinating class of the Recorder Subsystem.
This is a wrapper around QThread that does several additional things.
virtual void FormatCC(uint, uint)
virtual void FormatTT(struct VBIData *)
bool wait(unsigned long time=ULONG_MAX)
Wait for the MThread to exit, with a maximum timeout.
void SetTranscoding(bool value)
virtual bool IsPaused(bool holding_lock=false) const
Returns true iff recorder is paused.