Go to the documentation of this file.
42 #define TVREC_CARDNUM \
43 ((m_tvrec != nullptr) ? QString::number(m_tvrec->GetInputId()) : "NULL")
45 #define LOC QString("RecBase[%1](%2): ") \
46 .arg(TVREC_CARDNUM, m_videodevice)
81 msg =
" '" +
Buffer->GetFilename() +
"'";
82 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"SetRingBuffer(0x%1)")
83 .arg((uint64_t)
Buffer,0,16) + msg);
93 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"SetRecording(0x%1) title(%2)")
94 .arg((uint64_t)pginfo,0,16).arg(pginfo->GetTitle()));
98 LOG(VB_RECORD, LOG_INFO,
LOC +
"SetRecording(0x0)");
126 LOG(VB_RECORD, LOG_INFO,
LOC + QString(
"SetNextRecording(0x%1, 0x%2)")
127 .arg(
reinterpret_cast<intptr_t
>(ri),0,16)
128 .arg(
reinterpret_cast<intptr_t
>(
Buffer),0,16));
155 if (name ==
"videocodec")
157 else if (name ==
"videodevice")
159 else if (name ==
"tvformat")
162 if (value.toLower() ==
"ntsc" || value.toLower() ==
"ntsc-jp")
167 else if (value.toLower() ==
"pal-m")
169 else if (value.toLower() ==
"atsc")
186 LOG(VB_GENERAL, LOG_WARNING,
LOC +
187 QString(
"SetOption(%1,%2): Option not recognized")
194 LOG(VB_GENERAL, LOG_ERR,
LOC +
195 QString(
"SetOption(): Unknown int option: %1: %2")
196 .arg(name).arg(value));
205 LOG(VB_GENERAL, LOG_ERR,
LOC +
206 QString(
"SetIntOption(...%1): Option not in profile.").arg(name));
215 LOG(VB_GENERAL, LOG_ERR,
LOC +
216 QString(
"SetStrOption(...%1): Option not in profile.").arg(name));
234 LOG(VB_GENERAL, LOG_ERR,
LOC +
235 "Programmer Error: Recorder started while we were in "
306 std::chrono::milliseconds wait =
timeout -
t.elapsed();
353 bool did_switch =
false;
396 const QString&
file,
int line)
400 LOG(VB_RECORD, LOG_INFO,
401 QString(
"Modifying recording status from %1 to %2 at %3:%4")
405 QString::number(line)));
415 MythEvent me(QString(
"UPDATE_RECORDING_STATUS %1 %2 %3 %4 %5")
484 LOG(VB_GENERAL, LOG_CRIT,
"RecordingFile object is NULL. No video file metadata can be stored");
492 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Finished Recording: "
494 "Video Codec: %1 (%2x%3 A/R: %4 %5fps) "
529 frm_pos_map_t::const_iterator it =
m_positionMap.lowerBound(desired);
532 else if ((it.key() == desired) ||
548 frm_pos_map_t::const_iterator it =
m_positionMap.lowerBound(start);
549 end = (end < 0) ? INT64_MAX : end;
551 (it.key() <= end); ++it)
554 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
555 QString(
"GetKeyframePositions(%1,%2,#%3) out of %4")
556 .arg(start).arg(end).arg(map.size()).arg(
m_positionMap.size()));
570 frm_pos_map_t::const_iterator it =
m_durationMap.lowerBound(start);
571 end = (end < 0) ? INT64_MAX : end;
573 (it.key() <= end); ++it)
576 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
577 QString(
"GetKeyframeDurations(%1,%2,#%3) out of %4")
578 .arg(start).arg(end).arg(map.size()).arg(
m_durationMap.size()));
593 bool needToSave =
force;
602 has_delta && (pm_elapsed >= 1.5s);
604 needToSave |= has_delta && (pm_elapsed >= 10s);
652 LOG(VB_RECORD, LOG_WARNING,
LOC +
653 "Ringbuffer was switched due to timeout instead of keyframe.");
663 LOG(VB_RECORD, LOG_DEBUG,
664 QString(
"No progstart mark needed because delta=%1")
668 frm_pos_map_t::const_iterator first_it = durationDeltaCopy.begin();
669 if (first_it == durationDeltaCopy.end())
671 LOG(VB_RECORD, LOG_DEBUG,
"No progstart mark because map is empty");
674 frm_pos_map_t::const_iterator last_it = durationDeltaCopy.end();
676 long long bookmarkFrame = 0;
677 long long first_time { first_it.value() };
678 long long last_time { last_it.value() };
679 LOG(VB_RECORD, LOG_DEBUG,
680 QString(
"durationDeltaCopy.begin() = (%1,%2)")
682 .arg(first_it.value()));
686 LOG(VB_RECORD, LOG_DEBUG,
687 QString(
"No progstart mark yet because estimatedProgStartMS=%1 "
695 LOG(VB_RECORD, LOG_DEBUG,
696 QString(
"Set progstart mark=%1 because %2<=%3<%4")
704 frm_pos_map_t::const_iterator upper_it = first_it;
705 for (; upper_it != durationDeltaCopy.end(); ++upper_it)
711 LOG(VB_RECORD, LOG_DEBUG,
712 QString(
"Set progstart mark=%1 because "
713 "estimatedProgStartMS=%2 and upper_it.value()=%3")
715 .arg(upper_it.value()));
716 bookmarkFrame = upper_it.key();
724 LOG(VB_RECORD, LOG_DEBUG,
"No progstart mark due to fallthrough");
734 LOG(VB_RECORD, LOG_DEBUG,
735 QString(
"Setting lastSavedKeyframe=%1 lastSavedDuration=%2 "
736 "for progstart mark calculations")
743 uint customAspect = 0;
747 customAspect = aspect;
896 #ifdef USING_FIREWIRE
902 #endif // USING_FIREWIRE
903 #ifdef USING_HDHOMERUN
912 #endif // USING_HDHOMERUN
922 #endif // USING_CETON
956 #endif // USING_SATIP
967 #if CONFIG_LIBMP3LAME && defined(USING_V4L2)
987 QString msg =
"Need %1 recorder, but compiled without %2 support!";
989 LOG(VB_GENERAL, LOG_ERR,
990 "RecorderBase::CreateRecorder() Error, " + msg);
MythTimer m_positionMapTimer
virtual bool WaitForPause(std::chrono::milliseconds timeout=1s)
WaitForPause blocks until recorder is actually paused, or timeout milliseconds elapse.
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
QString MakeUniqueKey(void) const
Creates a unique string that can be used to identify an existing recording.
void SaveMarkupMap(const frm_dir_map_t &marks, MarkTypes type=MARK_ALL, int64_t min_frame=-1, int64_t max_frame=-1) const
This is a specialization of DTVRecorder used to handle DVB and ATSC streams from a firewire input.
qint64 m_estimatedProgStartMS
QDateTime m_timeOfLatestData
void VideoCodecChange(AVCodecID vCodec)
Note a change in video codec.
void SetRecordingStatus(RecStatus::Type status)
uint QueryAverageFrameRate(void) const
If present in recording this loads average frame rate of the main video stream from database's stream...
static RecorderBase * CreateRecorder(TVRec *tvrec, ChannelBase *channel, RecordingProfile &profile, const GeneralDBOptions &genOpt)
QDateTime GetDesiredStartTime(void) const
A QElapsedTimer based timer to replace use of QTime as a timer.
void SavePositionMapDelta(frm_pos_map_t &posMap, MarkTypes type) const
void SaveTotalFrames(int64_t frames)
Store the Total Frames at frame 0 in the recordedmarkup table.
Holds information on a TV Program one might wish to record.
virtual void Unpause(void)
Unpause tells recorder to unpause.
long long m_lastSavedDuration
This class is used as a container for messages.
static bool VERBOSE_LEVEL_CHECK(uint64_t mask, LogLevel_t level)
bool isRunning(void) const
Returns true if start() or restart() has been called at least once since construction and since any c...
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Holds information on a recording file and it's video and audio streams.
MythMediaBuffer * m_nextRingBuffer
bool GetKeyframePositions(long long start, long long end, frm_pos_map_t &map) const
void start(void)
starts measuring elapsed time.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static QString AVContainerToString(AVContainer format)
virtual void Pause(bool clear=true)
Pause tells recorder to pause, it should not block.
QDateTime GetRecordingEndTime(void) const
Approximate time the recording should have ended, did end, or is intended to end.
QAtomicInt m_timeOfLatestDataPacketInterval
bool GetKeyframeDurations(long long start, long long end, frm_pos_map_t &map) const
def scan(profile, smoonURL, gate)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
RecordingInfo * m_nextRecording
static QString toString(RecStatus::Type recstatus, uint id)
Converts "recstatus" into a short (unreadable) string.
This is a specialization of DTVRecorder used to handle streams from ASI drivers.
QWaitCondition m_recordingWait
RecordingInfo * m_curRecording
void RecorderPaused(void)
This is a callback, called by the "recorder" instance when it has actually paused.
frm_pos_map_t m_durationMapDelta
void SaveVideoProperties(uint mask, uint video_property_flags)
void SaveResolution(uint64_t frame, uint width, uint height)
Store the Resolution at frame in the recordedmarkup table.
MythTimer m_ringBufferCheckTimer
void SetStrOption(RecordingProfile *profile, const QString &name)
Convenience function used to set QString options from a profile.
RecordingFile * GetRecordingFile() const
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
RecStatus::Type GetRecordingStatus(void) const
MarkTypes QueryAverageAspectRatio(void) const
Abstract class providing a generic interface to tuning hardware.
void SetRingBuffer(MythMediaBuffer *Buffer)
Tells recorder to use an externally created ringbuffer.
void AspectChange(uint aspect, long long frame)
Note a change in aspect ratio in the recordedmark table.
uint QueryAverageWidth(void) const
If present in recording this loads average width of the main video stream from database's stream mark...
void SaveFilesize(uint64_t fsize) override
Sets recording file size in database, and sets "filesize" field.
void SaveAspect(uint64_t frame, MarkTypes type, uint customAspect)
Store aspect ratio of a frame in the recordedmark table.
FirewireChannel Copyright (c) 2005 by Jim Westfall and Dave Abrahams Distributed as part of MythTV un...
RecordingGaps m_recordingGaps
virtual void ClearStatistics(void)
AVContainer m_containerFormat
virtual RecordingQuality * GetRecordingQuality(const RecordingInfo *ri) const
Returns a report about the current recordings quality.
void SetDesiredStartTime(const QDateTime &dt)
std::chrono::milliseconds restart(void)
Returns milliseconds elapsed since last start() or restart() and resets the count.
void ResolutionChange(uint width, uint height, long long frame)
Note a change in video size in the recordedmark table.
double GetFrameRate(void) const
Returns the latest frame rate.
void SaveTotalDuration(std::chrono::milliseconds duration)
Store the Total Duration at frame 0 in the recordedmarkup table.
void AudioCodecChange(AVCodecID aCodec)
Note a change in audio codec.
virtual bool IsRecordingRequested(void)
Tells us if StopRecording() has been called.
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
long long m_lastSavedKeyframe
frm_pos_map_t m_durationMap
virtual bool IsRecording(void)
Tells whether the StartRecorder() loop is running.
void SetTotalFrames(uint64_t total_frames)
Note the total frames in the recordedmark table.
virtual QString getValue(void) const
QMutex m_nextRingBufferLock
frm_pos_map_t m_positionMap
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
AVContainer m_containerFormat
void SetDuration(std::chrono::milliseconds duration)
Note the total duration in the recordedmark table.
void FrameRateChange(uint framerate, uint64_t frame)
Note a change in video frame rate in the recordedmark table.
void TryWriteProgStartMark(const frm_pos_map_t &durationDeltaCopy)
static bool IsV4L(const QString &rawtype)
This is a specialization of DTVRecorder used to handle streams from DVB drivers.
virtual void FinishRecording(void)
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
frm_pos_map_t m_positionMapDelta
void SaveFrameRate(uint64_t frame, uint framerate)
Store the Frame Rate at frame in the recordedmarkup table.
virtual void StopRecording(void)
StopRecording() signals to the recorder that it should stop recording and exit cleanly.
void SetFrameRate(double rate)
Sets the video frame rate.
uint GetInputID(void) const
void SavePositionMap(bool force=false, bool finished=false)
Save the seektable to the DB.
QWaitCondition m_pauseWait
MarkTypes m_positionMapType
This is a specialization of DTVRecorder used to handle streams from External 'blackbox' recorders.
MythMediaBuffer * m_ringBuffer
Provides interface to the tuning hardware when using DVB drivers.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
@ MARK_ASPECT_1_1
deprecated, it is only 1:1 sample aspect ratio
Holds information on recordings and videos.
virtual void SetRecordingStatus(RecStatus::Type status, const QString &file, int line)
QDateTime m_timeOfFirstData
void RingBufferChanged(MythMediaBuffer *Buffer, RecordingInfo *pginfo, RecordingQuality *recq)
virtual void StartNewFile(void)
uint QueryAverageHeight(void) const
If present in recording this loads average height of the main video stream from database's stream mar...
void SetNextRecording(const RecordingInfo *ri, MythMediaBuffer *Buffer)
Sets next recording info, to be applied as soon as practical.
QAtomicInt m_timeOfFirstDataIsSet
This is the abstract base class for supporting recorder hardware.
This is the coordinating class of the Recorder Subsystem.
bool m_recording
True while recording is actually being performed.
AVCodecID m_primaryAudioCodec
ImportRecorder imports files, creating a seek map and other stuff that MythTV likes to have for recor...
virtual void SetOption(const QString &name, const QString &value)
Set an specific option.
AVCodecID m_primaryVideoCodec
void SaveVideoScanType(uint64_t frame, bool progressive)
Store the Progressive/Interlaced state in the recordedmarkup table.
double m_videoAspectRatio
void SendMythSystemRecEvent(const QString &msg, const RecordingInfo *pginfo)
This is a specialization of DTVRecorder used to handle streams from V4L2 recorders.
long long GetKeyframePosition(long long desired) const
Returns closest keyframe position before the desired frame.
QDateTime GetDesiredEndTime(void) const
QWaitCondition m_unpauseWait
virtual bool CheckForRingBufferSwitch(void)
If requested, switch to new RingBuffer/ProgramInfo objects.
Implements tuning for TV cards using the V4L driver API, both versions 1 and 2.
void dispatch(const MythEvent &event)
QAtomicInt m_timeOfLatestDataCount
virtual bool IsPaused(bool holding_lock=false) const
Returns true iff recorder is paused.
void SetRecording(const RecordingInfo *pginfo)
Changes the Recording from the one set initially with SetOptionsFromProfile().
virtual void ResetForNewFile(void)=0
void VideoScanChange(SCAN_t scan, uint64_t frame)
Note a change in video scan type in the recordedmark table.
virtual bool PauseAndWait(std::chrono::milliseconds timeout=100ms)
If m_requestPause is true, sets pause and blocks up to timeout milliseconds or until unpaused,...
void SetDesiredEndTime(const QDateTime &dt)
bool m_requestRecording
True if API call has requested a recording be [re]started.
void SetIntOption(RecordingProfile *profile, const QString &name)
Convenience function used to set integer options from a profile.