Go to the documentation of this file.
10 #include <QRegularExpression>
11 #include <QTextStream>
23 #define LOC QString("ExternRecChanFetch: ")
29 : m_scanMonitor(monitor)
31 , m_inputName(std::move(inputname))
32 , m_sourceId(sourceid)
33 , m_thread(new
MThread(
"ExternRecChannelScanner", this))
35 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"Has ScanMonitor %1")
36 .arg(monitor ?
"true" :
"false"));
86 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Invalid external command");
87 QMutexLocker locker(&
m_lock);
93 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"External Command: '%1'").arg(cmd));
108 LOG(VB_CHANNEL, LOG_ERR,
LOC +
"Failed to load channels");
109 QMutexLocker locker(&
m_lock);
116 std::vector<uint>::iterator Iold;
131 if (!fetch.
FirstChannel(channum, name, callsign, xmltvid, icon))
133 LOG(VB_CHANNEL, LOG_WARNING,
LOC +
"No channels found.");
134 QMutexLocker locker(&
m_lock);
146 static const QRegularExpression digitRE {
"\\D+" };
147 QString msg = tr(
"Channel #%1 : %2").arg(channum, name);
148 QStringList digits = channum.split(digitRE);
150 if (digits.size() > 1)
152 atsc_major = digits.at(0).toInt();
153 atsc_minor = digits.at(1).toInt();
154 LOG(VB_CHANNEL, LOG_DEBUG,
LOC +
155 QString(
"ATSC: %1.%2").arg(atsc_major).arg(atsc_minor));
159 atsc_major = atsc_minor = 0;
162 LOG(VB_CHANNEL, LOG_INFO, QString(
"Handling channel %1 %2")
163 .arg(channum, name));
177 channum, 1, atsc_major, atsc_minor,
179 icon,
"Default", xmltvid);
187 channum, 1, atsc_major, atsc_minor,
189 icon,
"Default", xmltvid);
194 Iold =
std::find(existing.begin(), existing.end(), chanid);
195 if (Iold != existing.end())
197 existing.erase(Iold);
201 fetch.
NextChannel(channum, name, callsign, xmltvid, icon);
207 for (Iold = existing.begin(); Iold != existing.end(); ++Iold)
213 (tr(
"Removing unused Channel #%1").arg(channum));
219 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"Found %1 channels").arg(cnt));
222 (tr(
"Found %1 channels.").arg(cnt));
232 QMutexLocker locker(&
m_lock);
240 uint range = 70 - minval;
249 uint range = 100 - minval;
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
~ExternRecChannelScanner() override
void Stop(void)
Stops the scanning thread running.
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
static bool DeleteChannel(uint channel_id)
void ScanPercentComplete(int pct)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
ScanMonitor * m_scanMonitor
static int GetChanID(int db_mplexid, int service_transport_id, int major_channel, int minor_channel, int program_number)
void SetNumChannelsParsed(uint val)
static bool UpdateChannel(uint db_mplexid, uint source_id, uint channel_id, const QString &callsign, const QString &service_name, const QString &chan_num, uint service_id, uint atsc_major_channel, uint atsc_minor_channel, bool use_on_air_guide, ChannelVisibleType visible, const QString &freqid=QString(), const QString &icon=QString(), QString format=QString(), const QString &xmltvid=QString(), const QString &default_authority=QString(), uint service_type=0, int recpriority=INT_MIN, int tmOffset=INT_MIN, int commMethod=INT_MIN)
static int CreateChanID(uint sourceid, const QString &chan_num)
Creates a unique channel ID for database use.
ExternRecChannelScanner(uint cardid, QString inputname, uint sourceid, ScanMonitor *monitor=nullptr)
void Scan(void)
Scans the list.
void ScanAppendTextToLog(const QString &status)
static bool CreateChannel(uint db_mplexid, uint db_sourceid, uint new_channel_id, const QString &callsign, const QString &service_name, const QString &chan_num, uint service_id, uint atsc_major_channel, uint atsc_minor_channel, bool use_on_air_guide, ChannelVisibleType visible, const QString &freqid, const QString &icon=QString(), QString format="Default", const QString &xmltvid=QString(), const QString &default_authority=QString(), uint service_type=0, int recpriority=0, int tmOffset=0, int commMethod=-1)
void SetMessage(const QString &status)
bool NextChannel(QString &channum, QString &name, QString &callsign, QString &xmltvid, QString &icon)
bool FirstChannel(QString &channum, QString &name, QString &callsign, QString &xmltvid, QString &icon)
This is a wrapper around QThread that does several additional things.
void SetNumChannelsInserted(uint val)
static QString GetChanNum(int chan_id)
Returns the channel-number string of the given channel.
static std::vector< uint > GetChanIDs(int sourceid=-1, bool onlyVisible=false)
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)
static QString GetVideoDevice(uint inputid)