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)
211 LOG(VB_GENERAL, LOG_ERR, QString(
"Broken for input: %1")
238 LOG(VB_GENERAL, LOG_ERR,
LOC +
"GetFlags failed");
271 std::this_thread::sleep_for(100us);
303 std::chrono::seconds secsleft,
452 LOG(VB_GENERAL, LOG_ERR,
453 QString(
"Wanted to start recording on recorder %1,\n\t\t\t"
454 "but the backend is not there anymore\n")
483 LOG(VB_GENERAL, LOG_ERR,
484 QString(
"Wanted to get status on recorder %1,\n\t\t\t"
485 "but the backend is not there anymore\n")
565 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: IsReallyRecording");
581 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetFramerate");
597 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetFramesWritten");
612 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetFilePosition");
627 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetKeyframePosition");
636 LOG(VB_GENERAL, LOG_ERR,
637 "Should be local only query: GetKeyframePositions");
649 LOG(VB_GENERAL, LOG_ERR,
650 "Should be local only query: GetKeyframeDurations");
667 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: FrontendReady");
705 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SpawnLiveTV");
716 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SpawnLiveTV");
730 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: StopLiveTV");
744 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: PauseRecorder");
757 LOG(VB_GENERAL, LOG_ERR,
758 "Should be local only query: SetLiveRecording");
786 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetInput");
805 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SetInput");
819 LOG(VB_GENERAL, LOG_ERR,
820 "Should be local only query: ToggleChannelFavorite");
834 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: ChangeChannel");
849 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SetChannel");
864 LOG(VB_GENERAL, LOG_ERR,
865 "Should be local only query: GetPictureAttribute");
886 LOG(VB_GENERAL, LOG_ERR,
887 "Should be local only query: ChangePictureAttribute");
908 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: CheckChannel");
926 LOG(VB_GENERAL, LOG_ERR,
927 "Should be local only query: ShouldSwitchToAnotherInput");
940 uint &complete_valid_channel_on_rec,
941 bool &is_extra_char_useful,
942 QString &needed_spacer)
947 prefix, complete_valid_channel_on_rec,
948 is_extra_char_useful, needed_spacer);
951 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: CheckChannelPrefix");
952 complete_valid_channel_on_rec = 0;
953 is_extra_char_useful =
false;
964 QString &title, QString &subtitle,
965 QString &desc, QString &category,
966 QString &starttime, QString &endtime,
967 QString &callsign, QString &iconpath,
968 QString &channelname,
uint &_chanid,
969 QString &seriesid, QString &programid)
974 title, subtitle, desc, category, starttime,
975 endtime, callsign, iconpath, channelname,
976 _chanid, seriesid, programid);
980 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetNextProgram");
985 QString &callsign, QString &channum,
986 QString &channame, QString &xmltv)
const
990 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetChannelInfo");
995 callsign, channum, channame, xmltv);
999 const QString& oldchannum,
1000 const QString& callsign,
const QString& channum,
1001 const QString& channame,
const QString& xmltv)
1005 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SetChannelInfo");
1018 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Called on local recorder");
This decrements the reference on destruction.
BrowseDirection
Used to request ProgramInfo for channel browsing.
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
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.
@ sStatus_Undefined
A slave's sleep status is undefined when it has never connected to the master backend or is not able ...
void StopLiveTV(void)
Tells TVRec to stop a "Live TV" recorder. This only works on local recorders.
ChannelChangeDirection
ChannelChangeDirection is an enumeration of possible channel changing directions.
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)
SleepStatus
SleepStatus is an enumeration of the awake/sleep status of a slave.
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
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
long long GetFilePosition(void)
Returns total number of bytes written by RingBuffer.
std::chrono::milliseconds SetSignalMonitoringRate(std::chrono::milliseconds rate, int notifyFrontend)
Sets the signal monitoring rate.
@ sStatus_Awake
A slave is awake when it is connected to the master.
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.
@ sStatus_Asleep
A slave is considered asleep when it is not awake and not undefined.
bool HasSockAndIncrRef()
Atomicly checks if sock is not null and increases its refcount.
bool IsConnected(void) const
Returns true if the EncoderLink instance is usable.
@ kState_Error
Error State, if we ever try to enter this state errored is set.
@ kState_WatchingLiveTV
Watching LiveTV is the state for when we are watching a recording and the user has control over the c...
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.
@ kState_ChangingState
This is a placeholder state which we never actually enter, but is returned by GetState() when we are ...
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.
@ kState_WatchingRecording
Watching Recording is the state for when we are watching an in progress recording,...
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.
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
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
TVState is an enumeration of the states used by TV and TVRec.
TVState GetState(void) const
Returns the TVState of the recorder.
@ kState_RecordingOnly
Recording Only is a TVRec only state for when we are recording a program, but there is no one current...
QString GetChainID(void)
Get the LiveTV chain id that's in use.
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.
bool IsBusy(int capturecardnum, InputInfo *busy_input=nullptr, std::chrono::seconds time_buffer=5s)
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.