MythTV  master
eitscanner.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 #ifndef EITSCANNER_H
3 #define EITSCANNER_H
4 
5 // Qt includes
6 #include <QWaitCondition>
7 #include <QStringList>
8 #include <QDateTime>
9 #include <QRunnable>
10 #include <QMutex>
11 
12 class TVRec;
13 class MThread;
14 class ChannelBase;
15 class DVBSIParser;
16 class EITHelper;
17 class ProgramMapTable;
18 
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 };
27 
28 class EITScanner : public QRunnable
29 {
30  public:
31  explicit EITScanner(uint cardnum);
32  ~EITScanner() override { TeardownAll(); }
33 
34  void StartEITEventProcessing(ChannelBase *channel, EITSource *eitSource);
35  void StopEITEventProcessing(void);
36 
37  void StartActiveScan(TVRec *rec, std::chrono::seconds max_seconds_per_source);
38  void StopActiveScan(void);
39 
40  protected:
41  void run(void) override; // QRunnable
42 
43  private:
44  void TeardownAll(void);
45  static void *SpawnEventLoop(void*);
46  void RescheduleRecordings(void);
47 
48  QMutex m_lock;
49  ChannelBase *m_channel {nullptr};
50  EITSource *m_eitSource {nullptr};
51 
52  EITHelper *m_eitHelper {nullptr};
53  MThread *m_eventThread {nullptr};
54  volatile bool m_exitThread {false};
55  QWaitCondition m_exitThreadCond; // protected by lock
56 
57  TVRec *m_rec {nullptr};
58  volatile bool m_activeScan {false}; // active scan true, passive scan false
59  volatile bool m_activeScanStopped {true}; // protected by lock
60  QWaitCondition m_activeScanCond; // protected by lock
62  std::chrono::seconds m_activeScanTrigTime {0s};
63  QStringList m_activeScanChannels;
64  QStringList::iterator m_activeScanNextChan;
66 
68 
69  static QMutex s_resched_lock;
70  static QDateTime s_resched_next_time;
71 
72 };
73 
74 #endif // EITSCANNER_H
EITScanner::RescheduleRecordings
void RescheduleRecordings(void)
Tells scheduler about programming changes.
Definition: eitscanner.cpp:174
EITScanner::StopEITEventProcessing
void StopEITEventProcessing(void)
Stops inserting Event Information Tables into DB.
Definition: eitscanner.cpp:215
EITScanner::m_cardnum
uint m_cardnum
Definition: eitscanner.h:67
EITScanner::m_exitThread
volatile bool m_exitThread
Definition: eitscanner.h:54
EITScanner::StartEITEventProcessing
void StartEITEventProcessing(ChannelBase *channel, EITSource *eitSource)
Start inserting Event Information Tables from the multiplex we happen to be tuned to into the databas...
Definition: eitscanner.cpp:183
EITScanner::m_activeScanNextTrig
QDateTime m_activeScanNextTrig
Definition: eitscanner.h:61
EITScanner::m_activeScanCond
QWaitCondition m_activeScanCond
Definition: eitscanner.h:60
EITScanner::m_eitSource
EITSource * m_eitSource
Definition: eitscanner.h:50
EITScanner::~EITScanner
~EITScanner() override
Definition: eitscanner.h:32
ProgramMapTable
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:694
EITScanner::EITScanner
EITScanner(uint cardnum)
Definition: eitscanner.cpp:35
EITScanner::m_rec
TVRec * m_rec
Definition: eitscanner.h:57
EITScanner::m_eitHelper
EITHelper * m_eitHelper
Definition: eitscanner.h:52
EITSource::SetEITRate
virtual void SetEITRate(float rate)=0
EITScanner::m_activeScanNextChanIndex
uint m_activeScanNextChanIndex
Definition: eitscanner.h:65
EITScanner::StopActiveScan
void StopActiveScan(void)
Definition: eitscanner.cpp:300
ChannelBase
Abstract class providing a generic interface to tuning hardware.
Definition: channelbase.h:31
EITSource::~EITSource
virtual ~EITSource()=default
EITScanner::m_eventThread
MThread * m_eventThread
Definition: eitscanner.h:53
EITSource::SetEITHelper
virtual void SetEITHelper(EITHelper *)=0
EITScanner::m_exitThreadCond
QWaitCondition m_exitThreadCond
Definition: eitscanner.h:55
EITScanner::SpawnEventLoop
static void * SpawnEventLoop(void *)
EITScanner::m_lock
QMutex m_lock
Definition: eitscanner.h:48
uint
unsigned int uint
Definition: compat.h:79
EITHelper
Definition: eithelper.h:93
EITScanner::m_activeScanTrigTime
std::chrono::seconds m_activeScanTrigTime
Definition: eitscanner.h:62
EITScanner::m_activeScan
volatile bool m_activeScan
Definition: eitscanner.h:58
EITScanner::m_activeScanNextChan
QStringList::iterator m_activeScanNextChan
Definition: eitscanner.h:64
EITScanner::m_channel
ChannelBase * m_channel
Definition: eitscanner.h:49
EITScanner::run
void run(void) override
This runs the event loop for EITScanner until 'exitThread' is true.
Definition: eitscanner.cpp:72
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:144
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
EITScanner::s_resched_next_time
static QDateTime s_resched_next_time
Definition: eitscanner.h:70
EITScanner::m_activeScanChannels
QStringList m_activeScanChannels
Definition: eitscanner.h:63
EITScanner::m_activeScanStopped
volatile bool m_activeScanStopped
Definition: eitscanner.h:59
EITScanner::s_resched_lock
static QMutex s_resched_lock
Definition: eitscanner.h:69
EITScanner
Acts as glue between ChannelBase, EITSource and EITHelper.
Definition: eitscanner.h:28
EITScanner::StartActiveScan
void StartActiveScan(TVRec *rec, std::chrono::seconds max_seconds_per_source)
Definition: eitscanner.cpp:234
EITScanner::TeardownAll
void TeardownAll(void)
Definition: eitscanner.cpp:48
EITSource
Definition: eitscanner.h:19