28#define LOC QString("EITScanner[%1]: ").arg(m_cardnum)
37 m_eventThread(new
MThread(
"EIT", this)),
39 m_sourceid(
CardUtil::GetSourceID(cardnum))
45 LOG(VB_EIT, LOG_INFO,
LOC +
46 QString(
"Start EIT scanner thread for source %1 '%2'")
103 LOG(VB_EIT, LOG_INFO,
LOC +
104 QString(
"Added %1 EIT events in passive scan ").arg(
m_eitCount) +
113 const std::chrono::seconds eventTimeout = 60s;
118 if (noEvents && !scanTimeUp)
120 LOG(VB_EIT, LOG_INFO,
LOC +
121 QString(
"No new EIT events received in last %1 seconds ").arg(eventTimeout.count()) +
123 QString(
"on multiplex %4, move to next multiplex").arg(
m_mplexid));
131 if (!(*m_activeScanNextChan).isEmpty())
139 LOG(VB_EIT, LOG_DEBUG,
LOC +
140 QString(
"Next EIT active scan source %1 '%2' multiplex %3 chanid %4 channel %5")
191 QMutexLocker locker(&
m_lock);
205 LOG(VB_EIT, LOG_INFO,
LOC +
206 QString(
"Start EIT %1 scan source %2 '%3' multiplex %4 chanid %5 channel %6")
208 .arg(
m_mplexid).arg(chanid).arg(channum));
212 LOG(VB_EIT, LOG_INFO,
LOC +
213 QString(
"Failed to start EIT scan, invalid chanid %1 channum %2")
214 .arg(chanid).arg(channum));
223 QMutexLocker locker(&
m_lock);
228 LOG(VB_EIT, LOG_INFO,
LOC +
229 QString(
"Stop EIT scan source %1 '%2', added %3 EIT events")
255 QMutexLocker locker(&
m_lock);
267 "SELECT channum, MIN(chanid) "
268 "FROM channel, capturecard, videosource "
269 "WHERE capturecard.sourceid = channel.sourceid AND "
270 " videosource.sourceid = channel.sourceid AND "
271 " channel.deleted IS NULL AND "
272 " channel.mplexid IS NOT NULL AND "
273 " channel.visible > 0 AND "
274 " channel.useonairguide = 1 AND "
275 " channel.channum != '' AND "
276 " videosource.useeit = 1 AND "
277 " capturecard.cardid = :CARDID "
279 "ORDER BY capturecard.sourceid, mplexid, "
280 " atsc_major_chan, atsc_minor_chan ");
306 LOG(VB_EIT, LOG_INFO,
LOC +
307 QString(
"EIT scan channel table for source %1 '%2' with %3 multiplexes")
324 LOG(VB_EIT, LOG_INFO,
LOC +
325 QString(
"Start EIT active scan on source %1 '%2'")
335 QMutexLocker locker(&
m_lock);
345 LOG(VB_EIT, LOG_INFO,
LOC +
346 QString(
"Stop EIT active scan on source %1 '%2'")
Collection of helper utilities for input DB use.
Abstract class providing a generic interface to tuning hardware.
virtual QString GetChannelName(void) const
virtual int GetChanID(void) const
static uint GetMplexID(uint sourceid, const QString &channum)
static int GetChanID(int db_mplexid, int service_transport_id, int major_channel, int minor_channel, int program_number)
void SetSourceID(uint sourceid)
static void PruneEITCache(uint timestamp)
uint GetListSize(void) const
uint ProcessEvents(void)
Get events from queue and insert into DB after processing.
void SetLanguagePreferences(const QStringList &langPref)
void RescheduleRecordings(void)
Tells scheduler about programming changes.
static void WriteEITCache(void)
void SetChannelID(uint channelid)
void TeardownAll(void)
Stop active scan, delete thread and delete eithelper.
void StopEITEventProcessing(void)
Stops inserting Event Information Tables into DB.
void run(void) override
This runs the event loop for EITScanner until 'm_exitThread' is true.
QWaitCondition m_activeScanCond
QDateTime m_activeScanNextTrig
void RescheduleRecordings(void)
Tells scheduler about programming changes.
QWaitCondition m_exitThreadCond
void StartEITEventProcessing(ChannelBase *channel, EITSource *eitSource)
Start inserting Event Information Tables from the multiplex we happen to be tuned to into the databas...
void StartActiveScan(TVRec *rec, std::chrono::seconds max_seconds_per_multiplex)
Start active EIT scan.
volatile bool m_activeScan
std::chrono::seconds m_activeScanTrigTime
QStringList::iterator m_activeScanNextChan
QStringList m_activeScanChannels
volatile bool m_exitThread
volatile bool m_activeScanStopped
void StopActiveScan(void)
Stop active EIT scan.
virtual void SetEITHelper(EITHelper *)=0
virtual void SetEITRate(float rate)=0
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
QVariant value(int i) const
bool isActive(void) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
This is a wrapper around QThread that does several additional things.
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
static void DBError(const QString &where, const MSqlQuery &query)
A QElapsedTimer based timer to replace use of QTime as a timer.
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
bool isRunning(void) const
Returns true if start() or restart() has been called at least once since construction and since any c...
void start(void)
starts measuring elapsed time.
static QString GetSourceName(uint sourceid)
This is the coordinating class of the Recorder Subsystem.
bool QueueEITChannelChange(const QString &name)
Queues up a channel change for the EITScanner.
uint GetInputId(void) const
Returns the inputid.
uint GetSourceID(void) const
Returns current source id.
QStringList iso639_get_language_list(void)
Returns list of three character ISO-639 language descriptors, starting with the most preferred.
ISO 639-1 and ISO 639-2 support functions.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Convenience inline random number generator functions.
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
uint32_t MythRandom()
generate 32 random bits