Go to the documentation of this file. 1 #ifndef NUPPELVIDEORECORDER
2 #define NUPPELVIDEORECORDER
10 #include <lame/lame.h>
25 #include "libmythbase/mythconfig.h"
31 #include "lzo/lzo1x.h"
34 #undef HAVE_AV_CONFIG_H
36 #include "libavcodec/avcodec.h"
54 void run(
void)
override;
65 void run(
void)
override;
78 void SetOption(
const QString &opt,
int value)
override;
79 void SetOption(
const QString &name,
const QString &value)
override;
82 const QString &videodev,
83 const QString &audiodev,
84 const QString &vbidev)
override;
87 void run(
void)
override;
90 bool IsPaused(
bool holding_lock =
false)
const override;
98 void Reset(
void)
override;
108 void StreamAllocate(
void);
109 void WriteHeader(
void);
110 void WriteSeekTable(
void);
111 void WriteKeyFrameAdjustTable(
112 const std::vector<struct kfatable_entry> &kfa_table);
113 void UpdateSeekTable(
int frame_num,
long offset = 0);
115 bool SetupAVCodecVideo(
void);
116 void SetupRTjpeg(
void);
117 int AudioInit(
bool skipdevice =
false);
120 bool forcekey =
false);
121 void WriteAudio(
unsigned char *buf,
int fnum, std::chrono::milliseconds timecode);
122 void WriteText(
unsigned char *buf,
int len, std::chrono::milliseconds timecode,
int pagenr);
124 void SetNewVideoParams(
double newaspect);
127 void doWriteThread(
void);
128 void doAudioThread(
void);
133 void WriteFileHeader(
void);
135 void InitBuffers(
void);
136 void ResizeVideoBuffers(
void);
138 bool MJPEGInit(
void);
140 void KillChildren(
void);
142 void BufferIt(
unsigned char *buf,
int len = -1,
bool forcekey =
false);
144 int CreateNuppelFile(
void);
146 void ProbeV4L2(
void);
147 bool SetFormatV4L2(
void);
152 void AddTextData(
unsigned char *buf,
int len, std::chrono::milliseconds timecode,
char type)
override;
154 void UpdateResolutions(
void);
157 signed char *m_strm {
nullptr};
158 unsigned int m_lf {0};
166 int m_compression {1};
167 bool m_compressAudio {
true};
169 unsigned long long m_audioBytes {0};
170 int m_audioChannels {2};
171 int m_audioBits {16};
172 int m_audioBytesPerSample {m_audioChannels * m_audioBits / 8};
173 int m_audioSampleRate {44100};
174 int m_effectiveDsp {0};
177 float m_videoAspect {1.33333F};
179 bool m_transcoding {
false};
181 int m_mp3Quality {3};
182 char *m_mp3Buf {
nullptr};
183 int m_mp3BufSize {0};
184 lame_global_flags *m_gf {
nullptr};
188 static constexpr
size_t kOutLen {1024*1024 + 1024*1024 / 64 + 16 + 3};
189 std::array<lzo_byte,kOutLen> m_out {};
191 alignas(8) std::array<uint8_t,LZO1X_1_MEM_COMPRESS> __LZO_MMODEL m_wrkmem {0} ;
197 int m_actVideoEncode {0};
198 int m_actVideoBuffer {0};
200 int m_actAudioEncode {0};
201 int m_actAudioBuffer {0};
202 long long m_actAudioSample {0};
204 int m_actTextEncode {0};
205 int m_actTextBuffer {0};
207 int m_videoBufferCount {0};
208 int m_audioBufferCount {0};
209 int m_textBufferCount {0};
211 long m_videoBufferSize {0};
212 long m_audioBufferSize {0};
213 long m_textBufferSize {0};
220 bool m_recording {
false};
223 std::vector<struct seektable_entry> *m_seekTable {
nullptr};
224 long long m_lastPositionMapPos {0};
226 long long m_extendedDataOffset {0};
228 long long m_framesWritten {0};
230 bool m_livetv {
false};
231 bool m_writePaused {
false};
232 bool m_audioPaused {
false};
233 bool m_mainPaused {
false};
235 double m_frameRateMultiplier {1.0};
236 double m_heightMultiplier {1.0};
239 std::chrono::milliseconds m_firstTc {0ms};
240 std::chrono::milliseconds m_oldTc {0ms};
242 int m_frameOfGop {0};
243 int m_lastTimecode {0};
244 int m_audioBehind {0};
246 bool m_useAvCodec {
false};
248 const AVCodec *m_mpaVidCodec {
nullptr};
249 AVCodecContext *m_mpaVidCtx {
nullptr};
251 int m_targetBitRate {2200};
252 int m_scaleBitRate {1};
253 int m_maxQuality {2};
254 int m_minQuality {31};
257 int m_mbDecision {FF_MB_DECISION_SIMPLE};
259 int m_encodingThreadCount {1};
262 AVPixelFormat m_pictureFormat {AV_PIX_FMT_YUV420P};
264 uint32_t m_v4l2PixelFormat {0};
269 bool m_hardwareEncode {
false};
270 int m_hmjpgQuality {80};
271 int m_hmjpgHDecimation {2};
272 int m_hmjpgVDecimation {2};
273 int m_hmjpgMaxW {640};
275 bool m_clearTimeOnPause {
false};
277 bool m_usingV4l2 {
false};
278 int m_channelFd {-1};
282 bool m_skipBtAudio {
false};
285 bool m_correctBttv {
false};
292 bool m_go7007 {
false};
293 bool m_resetCapture {
false};
NVRWriteThread(NuppelVideoRecorder *parent)
int GetVideoFd(void) override
Returns file descriptor of recorder device.
~NVRWriteThread() override
std::vector< struct vidbuffertype * > m_videoBuffer
void ResetForNewFile(void) override
Abstract base class for Video4Linux based recorders.
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
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.
static constexpr int8_t KEYFRAMEDIST
void SetOption(const QString &name, const QString &value) override
Set an specific option.
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)
void run(const QString &name, Class *object, void(Class::*fn)())
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 *)
void SetTranscoding(bool value)
virtual bool IsPaused(bool holding_lock=false) const
Returns true iff recorder is paused.