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,
438 LOG(VB_GENERAL, LOG_ERR,
439 QString(
"Wanted to start recording on recorder %1,\n\t\t\t"
440 "but the backend is not there anymore\n")
469 LOG(VB_GENERAL, LOG_ERR,
470 QString(
"Wanted to get status on recorder %1,\n\t\t\t"
471 "but the backend is not there anymore\n")
551 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: IsReallyRecording");
567 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetFramerate");
583 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetFramesWritten");
598 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetFilePosition");
613 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetKeyframePosition");
622 LOG(VB_GENERAL, LOG_ERR,
623 "Should be local only query: GetKeyframePositions");
635 LOG(VB_GENERAL, LOG_ERR,
636 "Should be local only query: GetKeyframeDurations");
653 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: FrontendReady");
691 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SpawnLiveTV");
702 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SpawnLiveTV");
716 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: StopLiveTV");
730 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: PauseRecorder");
743 LOG(VB_GENERAL, LOG_ERR,
744 "Should be local only query: SetLiveRecording");
772 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetInput");
791 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SetInput");
805 LOG(VB_GENERAL, LOG_ERR,
806 "Should be local only query: ToggleChannelFavorite");
820 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: ChangeChannel");
835 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SetChannel");
850 LOG(VB_GENERAL, LOG_ERR,
851 "Should be local only query: GetPictureAttribute");
872 LOG(VB_GENERAL, LOG_ERR,
873 "Should be local only query: ChangePictureAttribute");
894 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: CheckChannel");
912 LOG(VB_GENERAL, LOG_ERR,
913 "Should be local only query: ShouldSwitchToAnotherInput");
926 uint &complete_valid_channel_on_rec,
927 bool &is_extra_char_useful,
928 QString &needed_spacer)
933 prefix, complete_valid_channel_on_rec,
934 is_extra_char_useful, needed_spacer);
937 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: CheckChannelPrefix");
938 complete_valid_channel_on_rec = 0;
939 is_extra_char_useful =
false;
950 QString &title, QString &subtitle,
951 QString &desc, QString &category,
952 QString &starttime, QString &endtime,
953 QString &callsign, QString &iconpath,
954 QString &channelname,
uint &_chanid,
955 QString &seriesid, QString &programid)
960 title, subtitle, desc, category, starttime,
961 endtime, callsign, iconpath, channelname,
962 _chanid, seriesid, programid);
966 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetNextProgram");
971 QString &callsign, QString &channum,
972 QString &channame, QString &xmltv)
const
976 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: GetChannelInfo");
981 callsign, channum, channame, xmltv);
985 const QString& oldchannum,
986 const QString& callsign,
const QString& channum,
987 const QString& channame,
const QString& xmltv)
991 LOG(VB_GENERAL, LOG_ERR,
"Should be local only query: SetChannelInfo");
1004 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Called on local recorder");
void FinishRecording(void)
Tells TVRec to stop recording, but only after "overrecord" seconds.
void CancelNextRecording(bool cancel)
Tells TVRec to cancel the next recording.
bool ShouldSwitchToAnotherInput(const QString &channelid)
Checks if named channel exists on current tuner, or another tuner.
bool SetChannelInfo(uint chanid, uint sourceid, const QString &oldchannum, const QString &callsign, const QString &channum, const QString &channame, const QString &xmltv)
void SetNextLiveTVDir(const QString &dir)
Tells TVRec where to put the next LiveTV recording.
RecStatus::Type StartRecording(ProgramInfo *rec)
Tells TVRec to Start recording the program "rec" as soon as possible.
bool IsConnected(void) const
Returns true if the EncoderLink instance is usable.
RecStatus::Type GetRecordingStatus(void)
QString SetInput(QString input)
Tells TVRec's recorder to change to the specified input.
bool AddChildInput(uint childid)
bool IsBusyRecording(void)
Returns true if the TVRec state is in a recording state.
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...
void ToggleChannelFavorite(const QString &changroup)
Toggles whether the current channel should be on our favorites list.
ProgramInfo * GetRecording(void)
Returns TVRec's current recording.
float GetFramerate(void)
Returns the recording frame rate from TVRec.
~EncoderLink()
Destructor does nothing for non-local EncoderLink instances, but deletes the TVRec for local EncoderL...
QString GetInput(void) const
Returns TVRec's recorders current input.
void SetSocket(PlaybackSock *lsock)
Used to set the socket for a non-local EncoderLink.
long long GetMaxBitrate(void)
Returns maximum bits per second this recorder might output.
int LockTuner(void)
Lock the tuner for exclusive use.
bool CheckFile(ProgramInfo *pginfo)
Checks if program is stored locally.
bool IsLocal(void) const
Returns true for a local EncoderLink.
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.
bool GoToSleep(void)
Tell a slave backend to go to sleep.
bool MatchesRecording(const ProgramInfo *rec)
Returns true if rec is actually being recorded by TVRec.
void ChangeChannel(ChannelChangeDirection channeldirection)
Changes to the next or previous channel.
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 m_sleepStatusTime
uint GetFlags(void)
Returns the flag state of the recorder.
QDateTime m_startRecordingTime
void StopLiveTV(void)
Tells TVRec to stop a "Live TV" recorder.
bool GetKeyframePositions(int64_t start, int64_t end, frm_pos_map_t &map)
TVState GetState()
Returns the TVState of the recorder.
void PauseRecorder(void)
Tells TVRec to pause a recorder, used for channel and input changes.
int GetPictureAttribute(PictureAttribute attr)
Changes brightness/contrast/colour/hue of a recording.
bool IsFallingAsleep(void) const
Returns true if the encoder is falling asleep.
void FrontendReady(void)
Tells TVRec that the frontend is ready for data.
QDateTime m_lastSleepTime
void RecordPending(const ProgramInfo *rec, std::chrono::seconds secsleft, bool hasLater)
Tells TVRec there is a pending recording "rec" in "secsleft" seconds.
bool CheckChannel(const QString &name)
Checks if named channel exists on current tuner.
int ChangePictureAttribute(PictureAdjustType type, PictureAttribute attr, bool direction)
Changes brightness/contrast/colour/hue of a recording.
void SetLiveRecording(int recording)
Tells TVRec to keep a LiveTV recording if 'recording' is 1.
void SetChannel(const QString &name)
Changes to a named channel on the current tuner.
SleepStatus m_sleepStatus
bool HasSockAndDecrRef()
Atomicly checks if sock is not null and decreases its refcount.
void SetSleepStatus(SleepStatus newStatus)
Used to set the asleep status of an encoder.
void SpawnLiveTV(LiveTVChain *chain, bool pip, QString startchan)
Tells TVRec to Spawn a "Live TV" recorder.
void StopRecording(bool killFile=false)
Tells TVRec to stop recording immediately.
bool IsRecording(const ProgramInfo *rec)
Returns true if rec is scheduled for recording.
QDateTime m_endRecordingTime
long long GetFramesWritten(void)
Returns number of frames written to disk by TVRec's RecorderBase instance.
bool HasSockAndIncrRef()
Atomicly checks if sock is not null and increases its refcount.
bool GetChannelInfo(uint &chanid, uint &sourceid, QString &callsign, QString &channum, QString &channame, QString &xmltv) const
int64_t GetKeyframePosition(uint64_t desired)
Returns byte position in RingBuffer of a keyframe.
bool GetKeyframeDurations(int64_t start, int64_t end, frm_pos_map_t &map)
bool WouldConflict(const ProgramInfo *rec)
Checks a recording against any recording current or pending recordings on the recorder represented by...
std::chrono::milliseconds SetSignalMonitoringRate(std::chrono::milliseconds rate, int notifyFrontend)
Sets the signal monitoring rate.
QString GetChainID(void)
Get the LiveTV chain id that's in use.
long long GetFilePosition(void)
Returns total number of bytes written by TVRec's RingBuffer.
bool IsReallyRecording(void)
Checks if the RecorderBase held by TVRec is actually recording.
EncoderLink(int inputid, PlaybackSock *lsock, QString lhostname)
This is the EncoderLink constructor for non-local recorders.
Keeps track of recordings in a current LiveTV instance.
QString GetSettingOnHost(const QString &key, const QString &host, const QString &defaultval="")
bool IsBusy(int capturecardnum, InputInfo *busy_input=nullptr, std::chrono::seconds time_buffer=5s)
void CancelNextRecording(int capturecardnum, bool cancel)
RecStatus::Type GetRecordingStatus(int capturecardnum)
bool GoToSleep(void)
Tells a slave to go to sleep.
long long GetMaxBitrate(int capturecardnum)
bool CheckFile(ProgramInfo *pginfo)
ProgramInfo * GetRecording(uint cardid)
Returns the ProgramInfo being used by any current recording.
std::chrono::milliseconds SetSignalMonitoringRate(int capturecardnum, std::chrono::milliseconds rate, int notifyFrontend)
bool EncoderIsRecording(int capturecardnum, const ProgramInfo *pginfo)
void RecordPending(int capturecardnum, const ProgramInfo *pginfo, std::chrono::seconds secsleft, bool hasLater)
int GetEncoderState(int capturecardnum)
Returns the maximum bits per second the recorder can produce.
RecStatus::Type StartRecording(int capturecardnum, ProgramInfo *pginfo)
void SetNextLiveTVDir(int capturecardnum, const QString &dir)
bool AddChildInput(uint childid)
Tells a slave to add a child input.
Holds information on recordings and videos.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
bool IsSameRecording(const ProgramInfo &other) const
QDateTime GetRecordingEndTime(void) const
Approximate time the recording should have ended, did end, or is intended to end.
void SetPathname(const QString &pn)
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
virtual int IncrRef(void)
Increments reference count.
This decrements the reference on destruction.
This is the coordinating class of the Recorder Subsystem.
bool ShouldSwitchToAnotherInput(const QString &chanid) const
Checks if named channel exists on current tuner, or another tuner.
bool GetChannelInfo(uint &chanid, uint &sourceid, QString &callsign, QString &channum, QString &channame, QString &xmltvid) const
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 PauseRecorder(void)
Tells "recorder" to pause, used for channel and input changes.
uint GetFlags(void) const
void FrontendReady(void)
Tells TVRec that the frontend's TV class is ready for messages.
bool SetChannelInfo(uint chanid, uint sourceid, const QString &oldchannum, const QString &callsign, const QString &channum, const QString &channame, const QString &xmltvid)
QString GetChainID(void)
Get the chainid of the livetv instance.
void SetChannel(const QString &name, uint requestType=kFlagDetect)
Changes to a named channel on the current tuner.
ProgramInfo * GetRecording(void)
Allocates and returns a ProgramInfo for the current recording.
void SetNextLiveTVDir(QString dir)
RecStatus::Type GetRecordingStatus(void) const
void FinishRecording(void)
Tells TVRec to finish the current recording as soon as possible.
long long GetMaxBitrate(void) const
Returns the maximum bits per second this recorder can produce.
RecStatus::Type StartRecording(ProgramInfo *pginfo)
Tells TVRec to Start recording the program "rcinfo" as soon as possible.
void ToggleChannelFavorite(const QString &changroupname)
Toggles whether the current channel should be on our favorites list.
int ChangePictureAttribute(PictureAdjustType type, PictureAttribute attr, bool direction)
Returns current value [0,100] if it succeeds, -1 otherwise.
long long GetFramesWritten(void)
Returns number of frames written to disk by recorder.
void RecordPending(const ProgramInfo *rcinfo, std::chrono::seconds secsleft, bool hasLater)
Tells TVRec "rcinfo" is the next pending recording.
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.
void StopLiveTV(void)
Tells TVRec to stop a "Live TV" recorder.
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)
long long GetFilePosition(void)
Returns total number of bytes written by RingBuffer.
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.
void CancelNextRecording(bool cancel)
Tells TVRec to cancel the upcoming recording.
void ChangeChannel(ChannelChangeDirection dir)
Changes to a channel in the 'dir' channel change direction.
QString GetInput(void) const
Returns current input.
void SetLiveRecording(int recording)
Tells the Scheduler about changes to the recording status of the LiveTV recording.
TVState GetState(void) const
Returns the TVState of the recorder.
int GetPictureAttribute(PictureAttribute attr)
void SpawnLiveTV(LiveTVChain *newchain, bool pip, QString startchan)
Tells TVRec to spawn a "Live TV" recorder.
void StopRecording(bool killFile=false)
Changes from a recording state to kState_None.
std::chrono::milliseconds SetSignalMonitoringRate(std::chrono::milliseconds rate, int notifyFrontend=1)
Sets the signal monitoring rate.
bool IsReallyRecording(void)
Returns true if frontend can consider the recorder started.
int64_t GetKeyframePosition(uint64_t desired) const
Returns byte position in RingBuffer of a keyframe according to recorder.
bool CheckChannel(const QString &name) const
Checks if named channel exists on current tuner.
bool GetKeyframeDurations(int64_t start, int64_t end, frm_pos_map_t &map) const
float GetFramerate(void)
Returns recordering frame rate from the recorder.
QString SetInput(QString input)
Changes to the specified input.
QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
SleepStatus
SleepStatus is an enumeration of the awake/sleep status of a slave.
@ sStatus_Asleep
A slave is considered asleep when it is not awake and not undefined.
@ sStatus_Awake
A slave is awake when it is connected to the master.
@ sStatus_Undefined
A slave's sleep status is undefined when it has never connected to the master backend or is not able ...
BrowseDirection
Used to request ProgramInfo for channel browsing.
ChannelChangeDirection
ChannelChangeDirection is an enumeration of possible channel changing directions.
TVState
TVState is an enumeration of the states used by TV and TVRec.
@ kState_RecordingOnly
Recording Only is a TVRec only state for when we are recording a program, but there is no one current...
@ kState_WatchingLiveTV
Watching LiveTV is the state for when we are watching a recording and the user has control over the c...
@ kState_Error
Error State, if we ever try to enter this state errored is set.
@ kState_WatchingRecording
Watching Recording is the state for when we are watching an in progress recording,...
@ kState_ChangingState
This is a placeholder state which we never actually enter, but is returned by GetState() when we are ...
VERBOSE_PREAMBLE Most true