23#include <sys/select.h>
45#define TVREC_CARDNUM \
46 ((m_tvrec != nullptr) ? QString::number(m_tvrec->GetInputId()) : "NULL")
48#define LOC QString("ImportRec[%1](%2): ") \
49 .arg(TVREC_CARDNUM, m_videodevice)
52 const QString &videodev,
53 [[maybe_unused]]
const QString &audiodev,
54 [[maybe_unused]]
const QString &vbidev)
56 QString testVideoDev = videodev;
58 if (videodev.startsWith(
"file:", Qt::CaseInsensitive))
59 testVideoDev = videodev.mid(5);
61 QFileInfo fi(testVideoDev);
62 if (fi.exists() && fi.isReadable() && fi.isFile() && fi.size() > 1560)
93 LOG(VB_RECORD, LOG_INFO,
LOC +
"run -- begin");
102 LOG(VB_RECORD, LOG_INFO,
LOC +
"run -- " +
103 QString(
"attempting to open '%1'")
127 ctx->SetRingBuffer(buffer);
132 cfp->RebuildSeekTable(
false,
UpdateFS,
this);
150 LOG(VB_RECORD, LOG_INFO,
LOC +
"run -- end");
160 LOG(VB_RECORD, LOG_ERR,
LOC +
"no current recording!");
173 if (preRecorded.exists() && (!
copy.exists() ||
copy.size() == 0))
178 targetDir.remove(fn);
181 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"Trying to link %1 to %2")
184 if (preRecorded.link(fn))
185 LOG(VB_RECORD, LOG_DEBUG,
LOC +
"success!");
187 LOG(VB_RECORD, LOG_ERR,
LOC + preRecorded.errorString());
190 if (fn.startsWith(
"myth://", Qt::CaseInsensitive))
192 LOG(VB_RECORD, LOG_ERR,
LOC +
"Malformed recording ProgramInfo.");
199 LOG(VB_RECORD, LOG_INFO,
LOC +
200 QString(
"'%1' does not exist yet").arg(fn));
205 std::this_thread::sleep_for(250ms);
211 LOG(VB_GENERAL, LOG_ERR,
LOC +
212 QString(
"'%1' is not readable").arg(fn));
217 LOG(VB_GENERAL, LOG_ERR,
LOC +
218 QString(
"'%1' is empty").arg(fn));
222 m_importFd = open(fn.toLocal8Bit().constData(), O_RDONLY);
225 LOG(VB_GENERAL, LOG_ERR,
LOC +
226 QString(
"Couldn't open '%1'").arg(fn) +
ENO);
void FinishRecording(void) override
Flushes the ringbuffer, and if this is not a live LiveTV recording saves the position map and filesiz...
bool IsErrored(void) override
Tells us whether an unrecoverable error has been encountered.
void ResetForNewFile(void) override
void SetOption(const QString &name, const QString &value) override
Set an specific option.
long long GetFramesRead(void) const
ImportRecorder imports files, creating a seek map and other stuff that MythTV likes to have for recor...
void run(void) override
run() starts the recording process, and does not exit until the recording is complete.
void SetOptionsFromProfile(RecordingProfile *profile, const QString &videodev, const QString &audiodev, const QString &vbidev) override
Sets basic recorder options.
long long GetFramesWritten(void) override
Returns number of frames written to disk.
MythCommFlagPlayer * m_cfp
QString GetSetting(const QString &key, const QString &defaultval="")
void RegisterFileForWrite(const QString &file, uint64_t size=0LL)
void UnregisterFileForWrite(const QString &file)
DecoderBase * GetDecoder(void)
Returns the stream decoder currently in use.
QString GetPathname(void) const
virtual bool IsRecordingRequested(void)
Tells us if StopRecording() has been called.
bool m_recording
True while recording is actually being performed.
virtual void SetRecordingStatus(RecStatus::Type status, const QString &file, int line)
MythMediaBuffer * m_ringBuffer
bool m_requestRecording
True if API call has requested a recording be [re]started.
RecordingInfo * m_curRecording
QWaitCondition m_unpauseWait
QWaitCondition m_recordingWait
void SaveFilesize(uint64_t fsize) override
Sets recording file size in database, and sets "filesize" field.
void UpdateFS(int pc, void *ir)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static bool VERBOSE_LEVEL_CHECK(uint64_t mask, LogLevel_t level)
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MBASE_PUBLIC long long copy(QFile &dst, QFile &src, uint block_size=0)
Copies src file to dst file.
const QString kImportRecorderInUseID