Go to the documentation of this file.
12 #define LOC QString("DTVChan[%1](%2): ").arg(m_inputId).arg(GetDevice())
15 using MasterMap = QMap<QString,QList<DTVChannel*> >;
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")
194 uint64_t frequency = 0;
195 int mpeg_prog_num = 0;
205 tvformat, modulation, freqtable, freqid,
207 si_std, mpeg_prog_num, atsc_major, atsc_minor, tsid, netid,
210 LOG(VB_GENERAL, LOG_ERR, loc +
"Unable to find channel in database.");
215 if ((mplexid_restriction && (mplexid != mplexid_restriction)) ||
216 (!mplexid_restriction &&
217 chanid_restriction && (chanid != chanid_restriction)))
219 LOG(VB_GENERAL, LOG_ERR, loc +
220 QString(
"Requested channel '%1' is not available because "
221 "the tuner is currently in use on another transport.")
230 frequency = (freqid.toULongLong() + finetune) * 1000;
233 bool isFrequency = (frequency > 10000000);
239 if (!isFrequency || hasTuneToChan)
265 if (!
Tune(tuning,
false))
267 LOG(VB_GENERAL, LOG_ERR, loc +
"Tuning to IPTV URL");
272 else if (
m_name.contains(
"composite", Qt::CaseInsensitive) ||
273 m_name.contains(
"component", Qt::CaseInsensitive) ||
274 m_name.contains(
"s-video", Qt::CaseInsensitive))
276 LOG(VB_GENERAL, LOG_WARNING, loc +
"You have not set "
277 "an external channel changing"
278 "\n\t\t\tscript for a component|composite|s-video "
279 "input. Channel changing will do nothing.");
281 else if (isFrequency &&
Tune(frequency))
284 else if (isFrequency)
290 LOG(VB_GENERAL, LOG_ERR, loc +
291 "Failed to initialize multiplex options");
296 LOG(VB_GENERAL, LOG_DEBUG, loc +
297 QString(
"Initialize multiplex options m_tunerType:%1 mplexid:%2")
306 LOG(VB_GENERAL, LOG_ERR, loc +
"Tuning to frequency.");
316 ok = freqid.isEmpty() && finetune == 0 ?
317 Tune(channum) :
Tune(freqid, finetune);
321 LOG(VB_CHANNEL, LOG_INFO, loc + ((ok) ?
"success" :
"failure"));
326 if (atsc_minor || (mpeg_prog_num>=0))
329 SetDTVInfo(atsc_major, atsc_minor, netid, tsid, mpeg_prog_num);
337 if (pid_cache.empty())
339 LOG(VB_GENERAL, LOG_ERR, loc +
"PID cache is empty");
344 std::vector<uint> pnum; pnum.push_back(1);
345 std::vector<uint> pid; pid.push_back(9999);
349 std::vector<uint> pids;
350 std::vector<uint>
types;
351 for (
auto & pit : pid_cache)
353 if (!pit.GetStreamID())
355 pids.push_back(pit.GetPID());
356 types.push_back(pit.GetStreamID());
358 pcrpid = pit.GetPID();
360 pcrpid = pit.GetPID();
363 pcrpid = pid_cache[0].GetPID();
virtual std::vector< DTVTunerType > GetTunerTypes(void) const
Returns a vector of supported tuning types.
QMap< QString, QList< DTVChannel * > > MasterMap
virtual void CheckOptions(DTVMultiplex &) const
Checks tuning for problems, and tries to fix them.
void RegisterForMaster(const QString &key)
static void ReturnMasterLock(DTVChannelP &chan)
uint m_currentTransportID
static MasterMap s_master_map
virtual bool Open(void)=0
Opens the channel changing hardware for use.
virtual QString GetInputName(void) const
virtual bool IsIPTV(void) const
virtual bool IsOpen(void) const =0
Reports whether channel is already open.
virtual bool IsPIDTuningSupported(void) const
static const struct wl_interface * types[]
static bool GetCachedPids(uint chanid, pid_cache_t &pid_cache)
Returns cached MPEG PIDs when given a Channel ID.
bool SetChannelByString(const QString &chan) override
void DeregisterForMaster(const QString &key)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static DTVChannel * GetMasterLock(const QString &key)
static IPTVTuningData GetIPTVTuningData(uint chanid)
virtual bool Tune(const DTVMultiplex &tuning)=0
This performs the actual frequency tuning and in some cases input switching.
virtual bool FillFromDB(DTVTunerType type, uint mplexid)
static bool IsVideo(uint type)
Returns true iff video is an MPEG1/2/3, H264 or open cable video stream.
QString GetTuningMode(void) const
Returns tuning mode last set by SetTuningMode().
virtual bool IsInputAvailable(uint &mplexid_restriction, uint &chanid_restriction) const
Switches to another input on hardware, and sets the channel is setstarting is true.
uint m_currentOriginalNetworkID
void HandleScript(const QString &freqid)
virtual bool InitPictureAttributes(void)
static int GetChanID(int db_mplexid, int service_transport_id, int major_channel, int minor_channel, int program_number)
ProgramMapTable * m_genPMT
This is a generated PMT for RAW pid tuning.
void SaveCachedPids(const pid_cache_t &pid_cache) const
Saves MPEG PIDs to cache to database.
static const int kTunerTypeUnknown
void SetSIStandard(const QString &si_std)
Sets PSIP table standard: MPEG, DVB, ATSC, or OpenCable.
std::vector< pid_cache_item_t > pid_cache_t
virtual bool IsExternalChannelChangeInUse(void)
void SetFormat(const QString &format) override
static ProgramMapTable * Create(uint programNumber, uint basepid, uint pcrpid, uint version, std::vector< uint > pids, std::vector< uint > types)
QString m_sistandard
PSIP table standard: MPEG, DVB, ATSC, OpenCable.
QString GetSIStandard(void) const
Returns PSIP table standard: MPEG, DVB, ATSC, or OpenCable.
static uint GetQuickTuning(uint inputid, const QString &input_name)
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)
void HandleScriptEnd(bool ok) override
static QReadWriteLock s_master_map_lock
virtual bool TuneMultiplex(uint mplexid, const QString &inputname)
To be used by the channel scanner and possibly the EIT scanner.
virtual int SetFreqTable(const QString &)
ProgramAssociationTable * m_genPAT
This is a generated PAT for RAW pid tuning.
void SetTuningMode(const QString &tuning_mode)
Sets tuning mode: "mpeg", "dvb", "atsc", etc.
static ProgramAssociationTable * Create(uint tsid, uint version, const std::vector< uint > &pnum, const std::vector< uint > &pid)
void SetDTVInfo(uint atsc_major, uint atsc_minor, uint dvb_orig_netid, uint mpeg_tsid, int mpeg_pnum)
virtual uint GetSourceID(void) const
Class providing a generic interface to digital tuning hardware.
static bool SaveCachedPids(uint chanid, const pid_cache_t &_pid_cache, bool delete_all=false)
Saves PIDs for PSIP tables to database.
void GetCachedPids(pid_cache_t &pid_cache) const
Returns cached MPEG PIDs for last tuned channel.
bool SetVideoFiltersForChannel(uint sourceid, const QString &channum)
QString GetSuggestedTuningMode(bool is_live_tv) const
Returns suggested tuning mode: "mpeg", "dvb", or "atsc".
uint m_currentATSCMinorChannel
uint m_currentATSCMajorChannel
virtual int GetChanID(void) const