MythTV  master
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 #ifndef EITSCANNER_H
3 #define EITSCANNER_H
5 // Qt includes
6 #include <QWaitCondition>
7 #include <QStringList>
8 #include <QDateTime>
9 #include <QRunnable>
10 #include <QMutex>
12 class TVRec;
13 class MThread;
14 class ChannelBase;
15 class DVBSIParser;
16 class EITHelper;
17 class ProgramMapTable;
19 class EITSource
20 {
21  protected:
22  virtual ~EITSource() = default;
23  public:
24  virtual void SetEITHelper(EITHelper*) = 0;
25  virtual void SetEITRate(float rate) = 0;
26 };
28 class EITScanner;
30 class EITScanner : public QRunnable
31 {
32  public:
33  explicit EITScanner(uint cardnum);
34  ~EITScanner() override { TeardownAll(); }
36  void StartPassiveScan(ChannelBase *channel, EITSource *eitSource);
37  void StopPassiveScan(void);
39  void StartActiveScan(TVRec *_rec, uint max_seconds_per_source);
41  void StopActiveScan(void);
43  protected:
44  void run(void) override; // QRunnable
46  private:
47  void TeardownAll(void);
48  static void *SpawnEventLoop(void*);
49  void RescheduleRecordings(void);
51  QMutex m_lock;
52  ChannelBase *m_channel {nullptr};
53  EITSource *m_eitSource {nullptr};
55  EITHelper *m_eitHelper {nullptr};
56  MThread *m_eventThread {nullptr};
57  volatile bool m_exitThread {false};
58  QWaitCondition m_exitThreadCond; // protected by lock
60  TVRec *m_rec {nullptr};
61  volatile bool m_activeScan {false};
62  volatile bool m_activeScanStopped {true}; // protected by lock
63  QWaitCondition m_activeScanCond; // protected by lock
66  QStringList m_activeScanChannels;
67  QStringList::iterator m_activeScanNextChan;
72  static QMutex s_resched_lock;
73  static QDateTime s_resched_next_time;
77 };
79 #endif // EITSCANNER_H
ChannelBase * m_channel
Definition: eitscanner.h:52
static QDateTime s_resched_next_time
Definition: eitscanner.h:73
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
virtual ~EITSource()=default
uint m_activeScanNextChanIndex
Definition: eitscanner.h:68
void run(void) override
This runs the event loop for EITScanner until 'exitThread' is true.
Definition: eitscanner.cpp:66
virtual void SetEITHelper(EITHelper *)=0
QStringList m_activeScanChannels
Definition: eitscanner.h:66
MThread * m_eventThread
Definition: eitscanner.h:56
void TeardownAll(void)
Definition: eitscanner.cpp:42
QMutex m_lock
Definition: eitscanner.h:51
QWaitCondition m_exitThreadCond
Definition: eitscanner.h:58
void StopPassiveScan(void)
Stops inserting Event Information Tables into DB.
Definition: eitscanner.cpp:218
void RescheduleRecordings(void)
Tells scheduler about programming changes.
Definition: eitscanner.cpp:190
QDateTime m_activeScanNextTrig
Definition: eitscanner.h:64
QStringList::iterator m_activeScanNextChan
Definition: eitscanner.h:67
static const uint kMinRescheduleInterval
Minumum number of seconds between reschedules.
Definition: eitscanner.h:76
~EITScanner() override
Definition: eitscanner.h:34
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:142
void StartPassiveScan(ChannelBase *channel, EITSource *eitSource)
Start inserting Event Information Tables from the multiplex we happen to be tuned to into the databas...
Definition: eitscanner.cpp:199
Acts as glue between ChannelBase, EITSource, and EITHelper.
Definition: eitscanner.h:30
volatile bool m_activeScanStopped
Definition: eitscanner.h:62
static QMutex s_resched_lock
Definition: eitscanner.h:72
TVRec * m_rec
Definition: eitscanner.h:60
unsigned int uint
Definition: compat.h:140
EITHelper * m_eitHelper
Definition: eitscanner.h:55
virtual void SetEITRate(float rate)=0
Abstract class providing a generic interface to tuning hardware.
Definition: channelbase.h:31
volatile bool m_exitThread
Definition: eitscanner.h:57
QWaitCondition m_activeScanCond
Definition: eitscanner.h:63
uint m_cardnum
Definition: eitscanner.h:70
void StartActiveScan(TVRec *_rec, uint max_seconds_per_source)
Definition: eitscanner.cpp:235
static long int random(void)
Definition: compat.h:149
volatile bool m_activeScan
Definition: eitscanner.h:61
static void * SpawnEventLoop(void *)
EITSource * m_eitSource
Definition: eitscanner.h:53
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:666
EITScanner(uint cardnum)
Definition: eitscanner.cpp:32
void StopActiveScan(void)
Definition: eitscanner.cpp:300
uint m_activeScanTrigTime
Definition: eitscanner.h:65