12#define LOC QString("DTVChan[%1](%2): ").arg(m_inputId).arg(GetDevice())
35 uint mpeg_tsid,
int mpeg_pnum)
65 bool useQuickTuning = ((quickTuning != 0U) && is_live_tv) || (quickTuning > 1);
81 std::vector<DTVTunerType> tts;
129 (*mit).removeAll(
this);
130 if (mit.key() == key)
145 return (*mit).front();
159 QString loc =
LOC + QString(
"SetChannelByString(%1): ").arg(channum);
160 LOG(VB_CHANNEL, LOG_INFO, loc);
166 LOG(VB_GENERAL, LOG_ERR, loc +
"Channel object "
167 "will not open, can not change channels.");
175 uint mplexid_restriction = 0;
176 uint chanid_restriction = 0;
179 LOG(VB_GENERAL, LOG_INFO, loc +
180 QString(
"Requested channel '%1' is on input '%2' "
181 "which is in a busy input group")
196 uint64_t frequency = 0;
197 int mpeg_prog_num = 0;
207 tvformat, modulation, freqtable, freqid,
209 si_std, mpeg_prog_num, atsc_major, atsc_minor, tsid, netid,
212 LOG(VB_GENERAL, LOG_ERR, loc +
"Unable to find channel in database.");
217 if ((mplexid_restriction && (mplexid != mplexid_restriction)) ||
218 (!mplexid_restriction &&
219 chanid_restriction && (chanid != chanid_restriction)))
221 LOG(VB_GENERAL, LOG_ERR, loc +
222 QString(
"Requested channel '%1' is not available because "
223 "the tuner is currently in use on another transport.")
232 frequency = (freqid.toULongLong() + finetune) * 1000;
235 bool isFrequency = (frequency > 10000000);
241 if (!isFrequency || hasTuneToChan)
267 if (!
Tune(tuning,
false))
269 LOG(VB_GENERAL, LOG_ERR, loc +
"Tuning to IPTV URL");
274 else if (
m_name.contains(
"composite", Qt::CaseInsensitive) ||
275 m_name.contains(
"component", Qt::CaseInsensitive) ||
276 m_name.contains(
"s-video", Qt::CaseInsensitive))
278 LOG(VB_GENERAL, LOG_WARNING, loc +
"You have not set "
279 "an external channel changing"
280 "\n\t\t\tscript for a component|composite|s-video "
281 "input. Channel changing will do nothing.");
283 else if (isFrequency &&
Tune(frequency))
286 else if (isFrequency)
292 LOG(VB_GENERAL, LOG_ERR, loc +
293 "Failed to initialize multiplex options");
298 LOG(VB_GENERAL, LOG_DEBUG, loc +
299 QString(
"Initialize multiplex options m_tunerType:%1 mplexid:%2")
308 LOG(VB_GENERAL, LOG_ERR, loc +
"Tuning to frequency.");
318 ok = freqid.isEmpty() && finetune == 0 ?
319 Tune(channum) :
Tune(freqid, finetune);
323 LOG(VB_CHANNEL, LOG_INFO, loc + ((ok) ?
"success" :
"failure"));
328 if (atsc_minor || (mpeg_prog_num>=0))
331 SetDTVInfo(atsc_major, atsc_minor, netid, tsid, mpeg_prog_num);
339 if (pid_cache.empty())
341 LOG(VB_GENERAL, LOG_ERR, loc +
"PID cache is empty");
346 std::vector<uint> pnum; pnum.push_back(1);
347 std::vector<uint> pid; pid.push_back(9999);
351 std::vector<uint> pids;
352 std::vector<uint>
types;
353 for (
auto & pit : pid_cache)
355 if (!pit.GetStreamID())
357 pids.push_back(pit.GetPID());
358 types.push_back(pit.GetStreamID());
360 pcrpid = pit.GetPID();
362 pcrpid = pit.GetPID();
365 pcrpid = pid_cache[0].GetPID();
std::vector< pid_cache_item_t > pid_cache_t
static uint GetQuickTuning(uint inputid, const QString &input_name)
virtual QString GetInputName(void) const
void HandleScript(const QString &freqid)
virtual uint GetSourceID(void) const
virtual bool Open(void)=0
Opens the channel changing hardware for use.
virtual bool IsInputAvailable(uint &mplexid_restriction, uint &chanid_restriction) const
Switches to another input on hardware, and sets the channel is setstarting is true.
virtual bool IsOpen(void) const =0
Reports whether channel is already open.
virtual bool IsExternalChannelChangeInUse(void)
virtual int GetChanID(void) const
virtual bool InitPictureAttributes(void)
virtual int SetFreqTable(const QString &)
static int GetChanID(int db_mplexid, int service_transport_id, int major_channel, int minor_channel, int program_number)
static bool GetCachedPids(uint chanid, pid_cache_t &pid_cache)
Returns cached MPEG PIDs when given a Channel ID.
static bool SaveCachedPids(uint chanid, const pid_cache_t &_pid_cache, bool delete_all=false)
Saves PIDs for PSIP tables to database.
static bool GetChannelData(uint sourceid, uint &chanid, const QString &channum, QString &name, QString &callsign, 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)
static IPTVTuningData GetIPTVTuningData(uint chanid)
Class providing a generic interface to digital tuning hardware.
uint m_currentTransportID
QString m_sistandard
PSIP table standard: MPEG, DVB, ATSC, OpenCable.
static void ReturnMasterLock(DTVChannelP &chan)
void DeregisterForMaster(const QString &key)
ProgramAssociationTable * m_genPAT
This is a generated PAT for RAW pid tuning.
bool SetChannelByString(const QString &chan) override
void SaveCachedPids(const pid_cache_t &pid_cache) const
Saves MPEG PIDs to cache to database.
QString GetTuningMode(void) const
Returns tuning mode last set by SetTuningMode().
virtual bool Tune(const DTVMultiplex &tuning)=0
This performs the actual frequency tuning and in some cases input switching.
void SetSIStandard(const QString &si_std)
Sets PSIP table standard: MPEG, DVB, ATSC, or OpenCable.
virtual std::vector< DTVTunerType > GetTunerTypes(void) const
Returns a vector of supported tuning types.
QString GetSIStandard(void) const
Returns PSIP table standard: MPEG, DVB, ATSC, or OpenCable.
void SetDTVInfo(uint atsc_major, uint atsc_minor, uint dvb_orig_netid, uint mpeg_tsid, int mpeg_pnum)
void SetTuningMode(const QString &tuning_mode)
Sets tuning mode: "mpeg", "dvb", "atsc", etc.
virtual bool IsPIDTuningSupported(void) const
uint m_currentOriginalNetworkID
static DTVChannel * GetMasterLock(const QString &key)
void HandleScriptEnd(bool ok) override
void SetFormat(const QString &format) override
void GetCachedPids(pid_cache_t &pid_cache) const
Returns cached MPEG PIDs for last tuned channel.
QString GetSuggestedTuningMode(bool is_live_tv) const
Returns suggested tuning mode: "mpeg", "dvb", or "atsc".
virtual void CheckOptions(DTVMultiplex &) const
Checks tuning for problems, and tries to fix them.
ProgramMapTable * m_genPMT
This is a generated PMT for RAW pid tuning.
virtual bool TuneMultiplex(uint mplexid, const QString &inputname)
To be used by the channel scanner and possibly the EIT scanner.
virtual bool IsIPTV(void) const
static MasterMap s_master_map
static QReadWriteLock s_master_map_lock
uint m_currentATSCMinorChannel
uint m_currentATSCMajorChannel
void RegisterForMaster(const QString &key)
virtual bool FillFromDB(DTVTunerType type, uint mplexid)
static const int kTunerTypeUnknown
static ProgramAssociationTable * Create(uint tsid, uint version, const std::vector< uint > &pnum, const std::vector< uint > &pid)
static ProgramMapTable * Create(uint programNumber, uint basepid, uint pcrpid, uint version, std::vector< uint > pids, std::vector< uint > types)
static bool IsVideo(uint type)
Returns true iff video is an MPEG1/2/3, H264 or open cable video stream.
bool SetVideoFiltersForChannel(uint sourceid, const QString &channum)
QMap< QString, QList< DTVChannel * > > MasterMap
static const struct wl_interface * types[]
#define LOG(_MASK_, _LEVEL_, _QSTRING_)