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 const QString &audiodev,
75 const QString &vbidev)
77 LOG(VB_GENERAL, LOG_INFO,
LOC +
"SetOptionsFromProfile() -- begin");
119 LOG(VB_GENERAL, LOG_INFO,
LOC +
"SetOptionsFromProfile -- end");
124 LOG(VB_RECORD, LOG_INFO,
LOC +
"StartNewFile -- begin");
128 LOG(VB_RECORD, LOG_INFO,
LOC +
"StartNewFile -- end");
134 LOG(VB_RECORD, LOG_INFO,
LOC +
"run() -- begin");
140 m_error =
"MPEGStreamData pointer has not been set";
162 LOG(VB_GENERAL, LOG_INFO,
LOC +
"PMT set");
170 LOG(VB_RECORD, LOG_INFO,
LOC +
"mpeg2ts");
176 LOG(VB_RECORD, LOG_INFO,
LOC +
"program stream (non mpeg2ts)");
191 LOG(VB_GENERAL, LOG_WARNING,
LOC +
192 "Recording will not commence until a PMT is set.");
193 std::this_thread::sleep_for(5ms);
197 bool failing =
false;
203 m_error =
"Stream handler died unexpectedly.";
212 LOG(VB_RECORD, LOG_INFO,
LOC +
"Shutting down");
233 LOG(VB_RECORD, LOG_INFO,
LOC +
"run() -- end");
238 LOG(VB_RECORD, LOG_INFO,
LOC +
"Open() -- begin");
242 LOG(VB_RECORD, LOG_WARNING,
LOC +
"Open() -- Card already open");
253 LOG(VB_GENERAL, LOG_ERR,
LOC +
254 "Open() -- Failed to get a stream handler.");
260 LOG(VB_GENERAL, LOG_ERR,
LOC +
261 QString(
"Open() -- Failed to open recorder: %1")
270 LOG(VB_RECORD, LOG_INFO,
LOC +
"Open() -- Success.");
276 LOG(VB_RECORD, LOG_INFO,
LOC +
"Close() -- begin");
283 LOG(VB_RECORD, LOG_INFO,
LOC +
"Close() -- end");
293 LOG(VB_RECORD, LOG_INFO,
LOC +
"PauseAndWait() -- pause");
306 LOG(VB_RECORD, LOG_INFO,
LOC +
"PauseAndWait() -- unpause");
323 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"V4L2encRecorder::StartEncoding() -- begin");
329 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"V4L2encRecorder::StartEncoding() -- end");
335 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.