Go to the documentation of this file.
22 #include <sys/ioctl.h>
36 #define LOC QString("V4L2Rec[%1](%2): ") \
37 .arg(m_tvrec ? m_tvrec->GetInputId() : -1) \
38 .arg(m_channel->GetDevice())
45 m_error =
"Failed to open device";
73 const QString &videodev,
74 [[maybe_unused]]
const QString &audiodev,
75 [[maybe_unused]]
const QString &vbidev)
77 LOG(VB_GENERAL, LOG_INFO,
LOC +
"SetOptionsFromProfile() -- begin");
116 LOG(VB_GENERAL, LOG_INFO,
LOC +
"SetOptionsFromProfile -- end");
121 LOG(VB_RECORD, LOG_INFO,
LOC +
"StartNewFile -- begin");
125 LOG(VB_RECORD, LOG_INFO,
LOC +
"StartNewFile -- end");
131 LOG(VB_RECORD, LOG_INFO,
LOC +
"run() -- begin");
137 m_error =
"MPEGStreamData pointer has not been set";
159 LOG(VB_GENERAL, LOG_INFO,
LOC +
"PMT set");
167 LOG(VB_RECORD, LOG_INFO,
LOC +
"mpeg2ts");
173 LOG(VB_RECORD, LOG_INFO,
LOC +
"program stream (non mpeg2ts)");
188 LOG(VB_GENERAL, LOG_WARNING,
LOC +
189 "Recording will not commence until a PMT is set.");
190 std::this_thread::sleep_for(5ms);
194 bool failing =
false;
200 m_error =
"Stream handler died unexpectedly.";
209 LOG(VB_RECORD, LOG_INFO,
LOC +
"Shutting down");
232 LOG(VB_RECORD, LOG_INFO,
LOC +
"run() -- end");
237 LOG(VB_RECORD, LOG_INFO,
LOC +
"Open() -- begin");
241 LOG(VB_RECORD, LOG_WARNING,
LOC +
"Open() -- Card already open");
252 LOG(VB_GENERAL, LOG_ERR,
LOC +
253 "Open() -- Failed to get a stream handler.");
259 LOG(VB_GENERAL, LOG_ERR,
LOC +
260 QString(
"Open() -- Failed to open recorder: %1")
269 LOG(VB_RECORD, LOG_INFO,
LOC +
"Open() -- Success.");
275 LOG(VB_RECORD, LOG_INFO,
LOC +
"Close() -- begin");
282 LOG(VB_RECORD, LOG_INFO,
LOC +
"Close() -- end");
292 LOG(VB_RECORD, LOG_INFO,
LOC +
"PauseAndWait() -- pause");
305 LOG(VB_RECORD, LOG_INFO,
LOC +
"PauseAndWait() -- unpause");
322 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"V4L2encRecorder::StartEncoding() -- begin");
328 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"V4L2encRecorder::StartEncoding() -- end");
334 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"V4L2encRecorder::StopEncoding()");
void HandleSingleProgramPMT(ProgramMapTable *pmt, bool insert) override
static void Return(V4L2encStreamHandler *&ref, int inputid)
uint ProgramPID(uint i) const
bool PauseAndWait(std::chrono::milliseconds timeout=500ms) override
If m_requestPause is true, sets pause and blocks up to timeout milliseconds or until unpaused,...
void run(void) override
run() starts the recording process, and does not exit until the recording is complete.
ProgramMapTable * m_inputPmt
PMT on input side.
Abstract base class for Video4Linux based recorders.
void SetOptionsFromProfile(RecordingProfile *profile, const QString &videodev, const QString &audiodev, const QString &vbidev) override
Sets basic recorder options.
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
bool IsErrored(void) override
Tells us whether an unrecoverable error has been encountered.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void FinishRecording(void) override
Flushes the ringbuffer, and if this is not a live LiveTV recording saves the position map and filesiz...
void SetIntOption(RecordingProfile *profile, const QString &name)
const ProgramMapTable * GetGeneratedPMT(void) const
const ProgramMapTable * PMTSingleProgram(void) const
bool SetOption(const QString &opt, int value)
virtual void RemoveListener(MPEGStreamData *data)
void SetOption(const QString &name, const QString &value) override
Set an specific option.
QWaitCondition m_recordingWait
void RecorderPaused(void)
This is a callback, called by the "recorder" instance when it has actually paused.
uint GetInputId(void) const
Returns the inputid.
const ProgramAssociationTable * PATSingleProgram(void) const
void HandleSingleProgramPAT(ProgramAssociationTable *pat, bool insert) override
void AddPSStreamListener(PSStreamListener *val)
uint ProgramNumber(uint i) const
V4L2encStreamHandler * m_streamHandler
virtual bool HandleTables(uint pid, const PSIPTable &psip)
Process PSIP packets.
const ProgramAssociationTable * GetGeneratedPAT(void) const
void RemoveWritingListener(TSPacketListener *val)
V4L2encRecorder(TVRec *rec, V4LChannel *channel)
QString ErrorString(void) const
virtual bool IsRecordingRequested(void)
Tells us if StopRecording() has been called.
H2645Parser * m_h2645Parser
virtual QString getValue(void) const
void SetStrOption(RecordingProfile *profile, const QString &name)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
The Program Association Table lists all the programs in a stream, and is always found on PID 0.
QWaitCondition m_pauseWait
void RemovePSStreamListener(PSStreamListener *val)
void AddAVListener(TSPacketListenerAV *val)
bool Status(bool &failed, bool &failing)
bool m_waitForKeyframeOption
Wait for the a GOP/SEQ-start before sending data.
virtual void SetRecordingStatus(RecStatus::Type status, const QString &file, int line)
MPEGStreamData * m_streamData
void AddWritingListener(TSPacketListener *val)
int DesiredProgram(void) const
QString m_error
non-empty iff irrecoverable recording error detected
QString GetAudioDevice(void) const
This is the coordinating class of the Recorder Subsystem.
bool m_recording
True while recording is actually being performed.
virtual void AddListener(MPEGStreamData *data, bool allow_section_reader=false, bool needs_buffering=false, const QString &output_file=QString())
bool HasGeneratedPAT(void) const
static V4L2encStreamHandler * Get(const QString &devname, int audioinput, int inputid)
QWaitCondition m_unpauseWait
void RemoveAVListener(TSPacketListenerAV *val)
Implements tuning for TV cards using the V4L driver API, both versions 1 and 2.
virtual bool IsPaused(bool holding_lock=false) const
Returns true iff recorder is paused.
QString GetDevice(void) const override
Returns String representing device, useful for debugging.
void StartNewFile(void) override
QString GetSetting(const QString &key, const QString &defaultval="")
bool m_requestRecording
True if API call has requested a recording be [re]started.