Go to the documentation of this file.
10 #include <QTextStream>
22 #define LOC QString("ExternRecChanFetch: ")
28 : m_scanMonitor(monitor)
30 , m_inputName(
std::move(inputname))
31 , m_sourceId(sourceid)
32 , m_thread(new
MThread(
"ExternRecChannelScanner", this))
34 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"Has ScanMonitor %1")
35 .arg(monitor ?
"true" :
"false"));
85 LOG(VB_CHANNEL, LOG_INFO,
LOC +
"Invalid external command");
86 QMutexLocker locker(&
m_lock);
92 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"External Command: '%1'").arg(cmd));
106 LOG(VB_CHANNEL, LOG_ERR,
LOC +
"Failed to load channels");
107 QMutexLocker locker(&
m_lock);
114 std::vector<uint>::iterator Iold;
127 if (!fetch.
FirstChannel(channum, name, callsign, xmltvid, icon))
129 LOG(VB_CHANNEL, LOG_WARNING,
LOC +
"No channels found.");
130 QMutexLocker locker(&
m_lock);
142 QString msg = tr(
"Channel #%1 : %2").arg(channum, name);
144 LOG(VB_CHANNEL, LOG_INFO, QString(
"Handling channel %1 %2")
145 .arg(channum, name));
161 icon,
"Default", xmltvid);
171 icon,
"Default", xmltvid);
176 if ((Iold =
std::find(existing.begin(), existing.end(), chanid)) !=
179 existing.erase(Iold);
183 fetch.
NextChannel(channum, name, callsign, xmltvid, icon);
189 for (Iold = existing.begin(); Iold != existing.end(); ++Iold)
195 (tr(
"Removing unused Channel #%1").arg(channum));
201 LOG(VB_CHANNEL, LOG_INFO,
LOC + QString(
"Found %1 channels").arg(cnt));
204 (tr(
"Found %1 channels.").arg(cnt));
214 QMutexLocker locker(&
m_lock);
222 uint range = 70 - minval;
231 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_)
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)
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 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 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)
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)