Go to the documentation of this file.
24 #define LOC QString("EncoderLink(%1): ").arg(m_inputid)
25 #define LOC_ERR QString("EncoderLink(%1) Error: ").arg(m_inputid)
47 : m_inputid(inputid), m_sock(lsock), m_hostname(
std::move(lhostname)),
52 m_startRecordingTime(m_endRecordingTime)
61 : m_inputid(inputid), m_tv(ltv), m_local(
true),
66 m_startRecordingTime(m_endRecordingTime)
210 LOG(VB_GENERAL, LOG_ERR, QString(
"Broken for input: %1")
235 LOG(VB_GENERAL, LOG_ERR,
LOC +
"GetFlags failed");
267 std::this_thread::sleep_for(100us);
299 std::chrono::seconds secsleft,
448 LOG(VB_GENERAL, LOG_ERR,
449 QString(
"Wanted to start recording on recorder %1,\n\t\t\t"
450 "but the backend is not there anymore\n")
479 LOG(VB_GENERAL, LOG_ERR,
480 QString(
"Wanted to get status on recorder %1,\n\t\t\t"
481 "but the backend is not there anymore\n")
561 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: IsReallyRecording");
577 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetFramerate");
593 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetFramesWritten");
608 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetFilePosition");
623 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetKeyframePosition");
632 LOG(VB_GENERAL, LOG_ERR,
633 "Should be local only query: GetKeyframePositions");
645 LOG(VB_GENERAL, LOG_ERR,
646 "Should be local only query: GetKeyframeDurations");
663 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: FrontendReady");
701 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SpawnLiveTV");
712 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SpawnLiveTV");
726 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: StopLiveTV");
740 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: PauseRecorder");
753 LOG(VB_GENERAL, LOG_ERR,
754 "Should be local only query: SetLiveRecording");
782 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetInput");
801 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SetInput");
815 LOG(VB_GENERAL, LOG_ERR,
816 "Should be local only query: ToggleChannelFavorite");
830 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: ChangeChannel");
845 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SetChannel");
860 LOG(VB_GENERAL, LOG_ERR,
861 "Should be local only query: GetPictureAttribute");
882 LOG(VB_GENERAL, LOG_ERR,
883 "Should be local only query: ChangePictureAttribute");
904 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: CheckChannel");
922 LOG(VB_GENERAL, LOG_ERR,
923 "Should be local only query: ShouldSwitchToAnotherInput");
936 uint &complete_valid_channel_on_rec,
937 bool &is_extra_char_useful,
938 QString &needed_spacer)
943 prefix, complete_valid_channel_on_rec,
944 is_extra_char_useful, needed_spacer);
947 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: CheckChannelPrefix");
948 complete_valid_channel_on_rec = 0;
949 is_extra_char_useful =
false;
960 QString &title, QString &subtitle,
961 QString &desc, QString &category,
962 QString &starttime, QString &endtime,
963 QString &callsign, QString &iconpath,
964 QString &channelname,
uint &_chanid,
965 QString &seriesid, QString &programid)
970 title, subtitle, desc, category, starttime,
971 endtime, callsign, iconpath, channelname,
972 _chanid, seriesid, programid);
975 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetNextProgram");
979 QString &callsign, QString &channum,
980 QString &channame, QString &xmltv)
const
984 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetChannelInfo");
989 callsign, channum, channame, xmltv);
993 const QString& oldchannum,
994 const QString& callsign,
const QString& channum,
995 const QString& channame,
const QString& xmltv)
999 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SetChannelInfo");
1012 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Called on local recorder");
This decrements the reference on destruction.
bool GetKeyframeDurations(int64_t start, int64_t end, frm_pos_map_t &map) const
bool IsReallyRecording(void)
Returns true if frontend can consider the recorder started.
bool GetChannelInfo(uint &chanid, uint &sourceid, QString &callsign, QString &channum, QString &channame, QString &xmltv) const
void RecordPending(const ProgramInfo *rcinfo, std::chrono::seconds secsleft, bool hasLater)
Tells TVRec "rcinfo" is the next pending recording.
void GetDiskSpace(QStringList &o_strlist)
Appends host's dir's total and used space in kilobytes.
QDateTime m_sleepStatusTime
QDateTime m_lastSleepTime
bool IsRecording(const ProgramInfo *rec)
Returns true if rec is scheduled for recording.
void RecordPending(int capturecardnum, const ProgramInfo *pginfo, std::chrono::seconds secsleft, bool hasLater)
float GetFramerate(void)
Returns the recording frame rate from TVRec. This only works on local recorders.
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
bool EncoderIsRecording(int capturecardnum, const ProgramInfo *pginfo)
QDateTime m_endRecordingTime
ChannelChangeDirection
ChannelChangeDirection is an enumeration of possible channel changing directions.
int64_t GetKeyframePosition(uint64_t desired)
Returns byte position in RingBuffer of a keyframe.
bool ShouldSwitchToAnotherInput(const QString &chanid) const
Checks if named channel exists on current tuner, or another tuner.
TVState GetState()
Returns the TVState of the recorder.
QString GetInput(void) const
Returns TVRec's recorders current input. This only works on local recorders.
bool IsLocal(void) const
Returns true for a local EncoderLink.
void SetNextLiveTVDir(const QString &dir)
Tells TVRec where to put the next LiveTV recording.
SleepStatus
SleepStatus is an enumeration of the awake/sleep status of a slave.
void StopLiveTV(void)
Tells TVRec to stop a "Live TV" recorder. This only works on local recorders.
bool IsBusy(InputInfo *busy_input=nullptr, std::chrono::seconds time_buffer=5s) const
Returns true if the recorder is busy, or will be within the next time_buffer seconds.
bool IsReallyRecording(void)
Checks if the RecorderBase held by TVRec is actually recording. This only works on local recorders.
void ToggleChannelFavorite(const QString &changroupname)
Toggles whether the current channel should be on our favorites list.
bool GoToSleep(void)
Tell a slave backend to go to sleep.
void PauseRecorder(void)
Tells TVRec to pause a recorder, used for channel and input changes. This only works on local recorde...
QString SetInput(QString input)
Tells TVRec's recorder to change to the specified input. This only works on local recorders.
bool AddChildInput(uint childid)
bool GetKeyframeDurations(int64_t start, int64_t end, frm_pos_map_t &map)
QString SetInput(QString input)
Changes to the specified input.
RecStatus::Type GetRecordingStatus(void)
void ChangeChannel(ChannelChangeDirection dir)
Changes to a channel in the 'dir' channel change direction.
bool CheckChannelPrefix(const QString &prefix, uint &complete_valid_channel_on_rec, bool &is_extra_char_useful, QString &needed_spacer)
Checks a prefix against the channels in the DB. This only works on local recorders.
void FrontendReady(void)
Tells TVRec that the frontend's TV class is ready for messages.
void StopRecording(bool killFile=false)
Changes from a recording state to kState_None.
int ChangePictureAttribute(PictureAdjustType type, PictureAttribute attr, bool direction)
Changes brightness/contrast/colour/hue of a recording. This only works on local recorders.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
long long GetFramesWritten(void)
Returns number of frames written to disk by recorder.
QString GetInput(void) const
Returns current input.
bool IsSameRecording(const ProgramInfo &other) const
bool CheckChannelPrefix(const QString &prefix, uint &complete_valid_channel_on_rec, bool &is_extra_char_useful, QString &needed_spacer) const
Checks a prefix against the channels in the DB.
bool IsBusy(InputInfo *busy_input=nullptr, std::chrono::seconds time_buffer=5s)
Returns true if the recorder is busy, or will be within the next time_buffer seconds.
QDateTime GetRecordingEndTime(void) const
Approximate time the recording should have ended, did end, or is intended to end.
QString GetChainID(void)
Get the chainid of the livetv instance.
void FrontendReady(void)
Tells TVRec that the frontend is ready for data. This only works on local recorders.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
void ToggleChannelFavorite(const QString &changroup)
Toggles whether the current channel should be on our favorites list.
VERBOSE_PREAMBLE Most true
@ kState_Error
Error State, if we ever try to enter this state errored is set.
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
long long GetFilePosition(void)
Returns total number of bytes written by RingBuffer.
@ kState_ChangingState
This is a placeholder state which we never actually enter, but is returned by GetState() when we are ...
@ kState_WatchingRecording
Watching Recording is the state for when we are watching an in progress recording,...
std::chrono::milliseconds SetSignalMonitoringRate(std::chrono::milliseconds rate, int notifyFrontend)
Sets the signal monitoring rate.
bool CheckFile(ProgramInfo *pginfo)
Checks if program is stored locally.
void SetPathname(const QString &pn)
void PauseRecorder(void)
Tells "recorder" to pause, used for channel and input changes.
long long GetMaxBitrate(void) const
Returns the maximum bits per second this recorder can produce.
bool CheckChannel(const QString &name)
Checks if named channel exists on current tuner. This only works on local recorders.
void SetSocket(PlaybackSock *lsock)
Used to set the socket for a non-local EncoderLink.
bool AddChildInput(uint childid)
Tells a slave to add a child input.
RecStatus::Type GetRecordingStatus(int capturecardnum)
void SpawnLiveTV(LiveTVChain *chain, bool pip, QString startchan)
Tells TVRec to Spawn a "Live TV" recorder. This only works on local recorders.
void FinishRecording(void)
Tells TVRec to finish the current recording as soon as possible.
bool CheckChannel(const QString &name) const
Checks if named channel exists on current tuner.
bool WouldConflict(const ProgramInfo *rec)
Checks a recording against any recording current or pending recordings on the recorder represented by...
void CancelNextRecording(int capturecardnum, bool cancel)
bool ShouldSwitchToAnotherInput(const QString &channelid)
Checks if named channel exists on current tuner, or another tuner. This only works on local recorders...
long long GetMaxBitrate(void)
Returns maximum bits per second this recorder might output.
void ChangeChannel(ChannelChangeDirection channeldirection)
Changes to the next or previous channel.
QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
bool CheckFile(ProgramInfo *pginfo)
QDateTime m_startRecordingTime
void GetDiskSpace(QStringList &o_strlist)
Appends total and used disk space in Kilobytes.
bool IsFallingAsleep(void) const
Returns true if the encoder is falling asleep.
bool HasSockAndIncrRef()
Atomicly checks if sock is not null and increases its refcount.
@ sStatus_Asleep
A slave is considered asleep when it is not awake and not undefined.
bool IsConnected(void) const
Returns true if the EncoderLink instance is usable.
int GetPictureAttribute(PictureAttribute attr)
void SetNextLiveTVDir(int capturecardnum, const QString &dir)
bool GetKeyframePositions(int64_t start, int64_t end, frm_pos_map_t &map) const
Returns byte position in RingBuffer of a keyframes according to recorder.
void GetNextProgram(BrowseDirection direction, QString &title, QString &subtitle, QString &desc, QString &category, QString &starttime, QString &endtime, QString &callsign, QString &iconpath, QString &channelname, uint &chanid, QString &seriesid, QString &programid)
Returns information about the program that would be seen if we changed the channel using ChangeChanne...
int GetEncoderState(int capturecardnum)
void SetNextLiveTVDir(QString dir)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
float GetFramerate(void)
Returns recordering frame rate from the recorder.
long long GetFilePosition(void)
Returns total number of bytes written by TVRec's RingBuffer. This only works on local recorders.
std::chrono::milliseconds SetSignalMonitoringRate(int capturecardnum, std::chrono::milliseconds rate, int notifyFrontend)
~EncoderLink()
Destructor does nothing for non-local EncoderLink instances, but deletes the TVRec for local EncoderL...
RecStatus::Type GetRecordingStatus(void) const
EncoderLink(int inputid, PlaybackSock *lsock, QString lhostname)
This is the EncoderLink constructor for non-local recorders.
RecStatus::Type StartRecording(int capturecardnum, ProgramInfo *pginfo)
bool GoToSleep(void)
Tells a slave to go to sleep.
ProgramInfo * GetRecording(void)
Allocates and returns a ProgramInfo for the current recording.
void SpawnLiveTV(LiveTVChain *newchain, bool pip, QString startchan)
Tells TVRec to spawn a "Live TV" recorder.
void CancelNextRecording(bool cancel)
Tells TVRec to cancel the upcoming recording.
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
bool SetChannelInfo(uint chanid, uint sourceid, const QString &oldchannum, const QString &callsign, const QString &channum, const QString &channame, const QString &xmltv)
void GetNextProgram(BrowseDirection direction, QString &title, QString &subtitle, QString &desc, QString &category, QString &starttime, QString &endtime, QString &callsign, QString &iconpath, QString &channum, uint &chanid, QString &seriesid, QString &programid)
void RecordPending(const ProgramInfo *rec, std::chrono::seconds secsleft, bool hasLater)
Tells TVRec there is a pending recording "rec" in "secsleft" seconds.
ProgramInfo * GetRecording(uint cardid)
Returns the ProgramInfo being used by any current recording.
int64_t GetKeyframePosition(uint64_t desired) const
Returns byte position in RingBuffer of a keyframe according to recorder.
void SetChannel(const QString &name)
Changes to a named channel on the current tuner. This only works on local recorders.
@ sStatus_Undefined
A slave's sleep status is undefined when it has never connected to the master backend or is not able ...
bool GetKeyframePositions(int64_t start, int64_t end, frm_pos_map_t &map)
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
RecStatus::Type StartRecording(ProgramInfo *rec)
Tells TVRec to Start recording the program "rec" as soon as possible.
uint GetFlags(void)
Returns the flag state of the recorder.
Holds information on recordings and videos.
bool GetChannelInfo(uint &chanid, uint &sourceid, QString &callsign, QString &channum, QString &channame, QString &xmltvid) const
TVState
TVState is an enumeration of the states used by TV and TVRec.
void CancelNextRecording(bool cancel)
Tells TVRec to cancel the next recording.
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
std::chrono::milliseconds SetSignalMonitoringRate(std::chrono::milliseconds rate, int notifyFrontend=1)
Sets the signal monitoring rate.
int GetPictureAttribute(PictureAttribute attr)
Changes brightness/contrast/colour/hue of a recording. This only works on local recorders.
This is the coordinating class of the Recorder Subsystem.
TVState GetState(void) const
Returns the TVState of the recorder.
@ kState_WatchingLiveTV
Watching LiveTV is the state for when we are watching a recording and the user has control over the c...
QString GetChainID(void)
Get the LiveTV chain id that's in use.
BrowseDirection
Used to request ProgramInfo for channel browsing.
uint GetFlags(void) const
void SetSleepStatus(SleepStatus newStatus)
Used to set the asleep status of an encoder.
ProgramInfo * GetRecording(void)
Returns TVRec's current recording.
void FinishRecording(void)
Tells TVRec to stop recording, but only after "overrecord" seconds. This only works on local recorder...
long long GetFramesWritten(void)
Returns number of frames written to disk by TVRec's RecorderBase instance. This only works on local r...
RecStatus::Type StartRecording(ProgramInfo *pginfo)
Tells TVRec to Start recording the program "rcinfo" as soon as possible.
bool SetChannelInfo(uint chanid, uint sourceid, const QString &oldchannum, const QString &callsign, const QString &channum, const QString &channame, const QString &xmltvid)
void SetLiveRecording(int recording)
Tells the Scheduler about changes to the recording status of the LiveTV recording.
int LockTuner(void)
Lock the tuner for exclusive use.
void StopRecording(bool killFile=false)
Tells TVRec to stop recording immediately. This only works on local recorders.
void SetChannel(const QString &name, uint requestType=kFlagDetect)
Changes to a named channel on the current tuner.
void StopLiveTV(void)
Tells TVRec to stop a "Live TV" recorder.
virtual int IncrRef(void)
Increments reference count.
bool MatchesRecording(const ProgramInfo *rec)
Returns true if rec is actually being recorded by TVRec.
void SetLiveRecording(int recording)
Tells TVRec to keep a LiveTV recording if 'recording' is 1. and to not keep a LiveTV recording if 're...
bool HasSockAndDecrRef()
Atomicly checks if sock is not null and decreases its refcount.
SleepStatus m_sleepStatus
int ChangePictureAttribute(PictureAdjustType type, PictureAttribute attr, bool direction)
Returns current value [0,100] if it succeeds, -1 otherwise.
@ sStatus_Awake
A slave is awake when it is connected to the master.
bool IsBusy(int capturecardnum, InputInfo *busy_input=nullptr, std::chrono::seconds time_buffer=5s)
@ kState_RecordingOnly
Recording Only is a TVRec only state for when we are recording a program, but there is no one current...
long long GetMaxBitrate(int capturecardnum)
bool IsBusyRecording(void)
Returns true if the TVRec state is in a recording state.
Keeps track of recordings in a current LiveTV instance.