Go to the documentation of this file.
16 #include <QCoreApplication>
19 #ifdef USING_OSX_FIREWIRE
22 #ifdef USING_LINUX_FIREWIRE
48 #define LOC QString("ChannelBase[%1]: ").arg(m_inputId)
70 QString msg1 = QString(
"Setting start channel '%1' failed ").arg(startchannel);
71 QString msg2 =
"and no suitable channel found.";
72 bool msg_error =
true;
77 if (
channel.m_chanNum == startchannel &&
80 LOG(VB_CHANNEL, LOG_INFO,
LOC +
81 QString(
"Found startchannel '%1'").
arg(startchannel));
86 uint mplexid_restriction = 0;
87 uint chanid_restriction = 0;
98 if ((chanid != 0U) && (cit !=
m_channels.end()))
102 ok =
IsTunable((mplexid_restriction || chanid_restriction)
103 ? (*cit).m_chanNum : startchannel);
110 startchannel = (*cit).m_chanNum;
111 msg2 = QString(
"selected '%1' instead.").arg(startchannel);
117 LOG(VB_GENERAL, ((msg_error) ? LOG_ERR : LOG_WARNING),
LOC + msg1 + msg2);
124 QString loc =
LOC + QString(
"IsTunable(%1)").arg(channum);
128 LOG(VB_GENERAL, LOG_ERR, loc +
" " +
129 QString(
"Requested non-existant input"));
134 uint mplexid_restriction = 0;
135 uint chanid_restriction = 0;
138 LOG(VB_GENERAL, LOG_ERR, loc +
" " +
139 QString(
"Requested channel is on input '%1' "
140 "which is in a busy input group")
153 uint64_t frequency = 0;
154 int mpeg_prog_num = 0;
161 bool commfree =
false;
164 tvformat, modulation, freqtable, freqid,
165 finetune, frequency, dtv_si_std,
166 mpeg_prog_num, atsc_major, atsc_minor,
167 tsid, netid, mplexid, commfree))
169 LOG(VB_GENERAL, LOG_ERR, loc +
" " +
170 QString(
"Failed to find channel in DB on input '%1' ")
176 if ((mplexid_restriction && (mplexid != mplexid_restriction)) ||
177 (!mplexid_restriction &&
178 chanid_restriction && (chanid != chanid_restriction)))
180 LOG(VB_GENERAL, LOG_ERR, loc +
" " +
181 QString(
"Channel is valid, but tuner is busy "
182 "on different multiplex/channel (%1 != %2) / (%3 != %4)")
183 .
arg(mplexid).
arg(mplexid_restriction)
184 .
arg(chanid).
arg(chanid_restriction));
202 uint mplexid_restriction = 0;
203 uint chanid_restriction = 0;
207 m_channels, chanid, mplexid_restriction, chanid_restriction,
221 uint &mplexid_restriction,
uint &chanid_restriction)
const
225 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"no m_inputId"));
231 mplexid_restriction = 0;
232 chanid_restriction = 0;
235 for (
uint inputid : inputids)
239 LOG(VB_CHANNEL, LOG_DEBUG,
LOC +
240 QString(
"Input %1 is busy on %2/%3")
245 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"Input is busy"));
253 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"Input is free on %1/%2")
254 .
arg(mplexid_restriction).
arg(chanid_restriction));
293 if (freqid.isEmpty())
295 LOG(VB_GENERAL, LOG_WARNING,
LOC +
296 "A channel changer is set, but the freqid field is empty."
297 "\n\t\t\tWe will return success to ease setup pains, "
298 "but no script is will actually run.");
320 LOG(VB_GENERAL, LOG_ERR,
LOC +
321 "Can not execute channel changer, previous call to script "
322 "is still running.");
333 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Can not execute internal channel "
347 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Can not execute channel changer.");
358 #ifdef USING_FIREWIRE
364 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Internal channel change to %1 "
365 "on inputid %2, GUID %3 (%4)").
arg(freqid).
arg(inputid)
366 .
arg(fwnode).
arg(fwmodel));
368 #ifdef USING_LINUX_FIREWIRE
371 #endif // USING_LINUX_FIREWIRE
373 #ifdef USING_OSX_FIREWIRE
375 #endif // USING_OSX_FIREWIRE
383 if (!device->
SetChannel(fwmodel, 0, freqid.toUInt()))
404 const QString &freqid)
409 if (changer.isEmpty() || freqid.isEmpty())
412 QString command = QString(
"%1 %2").arg(changer).arg(freqid);
413 LOG(VB_CHANNEL, LOG_INFO,
LOC +
414 QString(
"Running command: %1").
arg(command));
440 LOG(VB_CHANNEL, LOG_DEBUG,
LOC + QString(
"GetScriptStatus() %1")
458 LOG(VB_CHANNEL, LOG_DEBUG,
LOC + QString(
"GetScriptStatus() %1 -> %2")
474 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Channel change script succeeded.");
483 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Channel change script failed.");
498 "WHERE deleted IS NULL AND "
499 " channum = :CHANNUM AND "
500 " sourceid = :SOURCEID");
523 LOG(VB_GENERAL, LOG_INFO,
524 QString(
"No visible channel ids for %1 on sourceid %2")
530 LOG(VB_GENERAL, LOG_WARNING,
531 QString(
"Found multiple visible channel ids for %1 on sourceid %2")
535 return (visible >= 0 ? visible :
id);
553 LOG(VB_GENERAL, LOG_ERR,
554 "InitializeInput(): Programmer error, no parent.");
560 "SELECT sourceid, inputname, "
561 " startchan, externalcommand, "
564 "WHERE cardid = :INPUTID");
574 LOG(VB_GENERAL, LOG_ERR,
LOC +
575 QString(
"No capturecard record in database for input %1")
590 LOG(VB_GENERAL, LOG_ERR,
LOC +
591 QString(
"No video source defined for input %1")
603 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"External Channel changer is "
604 "set, but this device does not support it.");
609 LOG(VB_CHANNEL, LOG_INFO,
LOC +
610 QString(
"Input #%1: '%2' schan(%3) sourceid(%4)")
621 const QString &oldChanNum,
622 const QString &newChanNum)
624 bool skip = (
m_name.isEmpty() ||
648 "UPDATE capturecard "
649 "SET startchan = :STARTCHAN "
650 "WHERE cardid = :CARDINPUTID");
665 "SELECT channel.chanid "
666 "FROM channel, capturecard "
667 "WHERE channel.deleted IS NULL AND "
668 " channel.channum = :CHANNUM AND "
669 " channel.sourceid = capturecard.sourceid AND "
670 " capturecard.cardid = :INPUTID AND "
671 " capturecard.hostname = :HOSTNAME");
683 LOG(VB_CHANNEL, LOG_ERR,
LOC +
684 QString(
"Failed to find channel(%1) on input (%2).")
694 const QString &startchannel,
695 bool enter_power_save_mode,
707 if (dvbchannel !=
nullptr)
713 #ifdef USING_FIREWIRE
719 #ifdef USING_HDHOMERUN
734 genOpt.
m_videoDev.startsWith(
"file:", Qt::CaseInsensitive)))
791 QString msg = QString(
792 "%1 card configured on video device %2, \n"
793 "but MythTV was not compiled with %3 support. \n"
795 "Recompile MythTV with %4 support or remove the card \n"
796 "from the configuration and restart MythTV.")
799 LOG(VB_GENERAL, LOG_ERR,
"ChannelBase: CreateChannel() Error: \n" +
806 LOG(VB_GENERAL, LOG_ERR,
"ChannelBase: CreateChannel() Error: " +
812 QString channum = startchannel;
813 channel->Init(channum, setchan);
815 if (enter_power_save_mode)
843 LOG(VB_GENERAL, LOG_ERR,
LOC +
844 QString(
"IsExternalChannelChangeInUse: "
845 "non-existant input"));
bool isActive(void) const
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
virtual bool Init(QString &startchannel, bool setchan)
void bindValueNoNull(const QString &placeholder, const QVariant &val)
Add a single binding, taking care not to set a NULL value.
#define GENERIC_EXIT_OK
Exited with no error.
void Term(bool force=false)
ChannelChangeDirection
ChannelChangeDirection is an enumeration of possible channel changing directions.
virtual void HandleScriptEnd(bool ok)
static uint GetFirstInputID(const QString &videodevice)
Convenience function for GetInputIDs()
QVariant value(int i) const
arg(title).arg(filename).arg(doDelete))
static ChannelBase * CreateChannel(TVRec *tvrec, const GeneralDBOptions &genOpt, const DVBDBOptions &dvbOpt, const FireWireDBOptions &fwOpt, const QString &startchannel, bool enter_power_save_mode, QString &rbFileExt, bool setchan)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
virtual bool IsTunable(const QString &channum) const
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static uint64_t string_to_guid(const QString &guid)
static uint GetNextChannel(const ChannelInfoList &sorted, uint old_chanid, uint mplexid_restriction, uint chanid_restriction, ChannelChangeDirection direction, bool skip_non_visible=true, bool skip_same_channum_and_callsign=false, bool skip_other_sources=false)
virtual bool IsExternalChannelChangeSupported(void)
static QString GetFirewireChangerModel(uint inputid)
virtual void Renumber(uint sourceid, const QString &oldChanNum, const QString &newChanNum)
Changes a channum if we have it cached anywhere.
ChannelInfoList m_channels
channels across all inputs
static void SortChannels(ChannelInfoList &list, const QString &order, bool eliminate_duplicates=false)
virtual bool IsInputAvailable(uint &mplexid_restriction, uint &chanid_restriction) const
Switches to another input on hardware, and sets the channel is setstarting is true.
void HandleScript(const QString &freqid)
uint GetInputId(void) const
Returns the inputid.
static int GetChanID(int db_mplexid, int service_transport_id, int major_channel, int minor_channel, int program_number)
void SetSlowTuning(std::chrono::milliseconds how_slow)
Abstract class providing a generic interface to tuning hardware.
bool RemoteIsBusy(uint inputid, InputInfo &busy_input)
virtual void StoreInputChannels(void)
Saves current channel as the default channel for the current input.
FirewireChannel Copyright (c) 2005 by Jim Westfall and Dave Abrahams Distributed as part of MythTV un...
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
virtual bool IsExternalChannelChangeInUse(void)
uint Wait(std::chrono::seconds timeout=0s)
static ChannelInfoList GetChannels(uint sourceid, bool visible_only, const QString &group_by=QString(), uint channel_groupid=0)
bool isConnected(void) const
Only updated once during object creation.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
virtual bool EnterPowerSavingMode(void)
Enters power saving mode if the card supports it.
static bool IsV4L(const QString &rawtype)
static QString GetFirewireChangerNode(uint inputid)
@ kMSRunShell
run process through shell
@ kMSRunBackground
run child in the background
uint GetScriptStatus(bool holding_lock=false)
static bool GetChannelData(uint sourceid, uint &chanid, const QString &channum, QString &tvformat, QString &modulation, QString &freqtable, QString &freqid, int &finetune, uint64_t &frequency, QString &dtv_si_std, int &mpeg_prog_num, uint &atsc_major, uint &atsc_minor, uint &dvb_transportid, uint &dvb_networkid, uint &mplexid, bool &commfree)
Provides interface to the tuning hardware when using DVB drivers.
bool ChangeInternalChannel(const QString &freqid, uint cardinputid) const
virtual bool SetChannelByString(const QString &chan)=0
uint m_systemStatus
These get mapped from the GENERIC_EXIT_* to these values for use with the signalmonitor code.
bool CheckChannel(const QString &channum) const
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
This is the coordinating class of the Recorder Subsystem.
#define GENERIC_EXIT_START
MythSystemLegacy process starting.
std::chrono::milliseconds m_dvbTuningDelay
virtual QString GetDevice(void) const
Returns String representing device, useful for debugging.
bool ChangeExternalChannel(const QString &changer, const QString &freqid)
QString GetHostName(void)
virtual uint GetSourceID(void) const
void Run(std::chrono::seconds timeout=0s)
Runs a command inside the /bin/sh shell. Returns immediately.
Class providing a generic interface to digital tuning hardware.
virtual uint GetNextChannel(uint chanid, ChannelChangeDirection direction) const
#define GENERIC_EXIT_RUNNING
Process is running.
virtual bool SetChannel(const QString &panel_model, uint alt_method, uint channel)
MythSystemLegacy * m_system
static std::vector< uint > GetConflictingInputs(uint inputid)
virtual bool InitializeInput(void)
Fills in input map from DB.
Implements tuning for TV cards using the V4L driver API, both versions 1 and 2.
MSqlQuery query(MSqlQuery::InitCon())
virtual ~ChannelBase(void)
virtual bool ClosePort(void)=0
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
QString GetSetting(const QString &key, const QString &defaultval="")
QString m_externalChanger
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
virtual bool OpenPort(void)=0
virtual int GetChanID(void) const