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 // MythTV
13 #include "mythmiscutil.h"
14 
15 class TVRec;
16 class MThread;
17 class ChannelBase;
18 class DVBSIParser;
19 class EITHelper;
20 class ProgramMapTable;
21 
22 class EITSource
23 {
24  protected:
25  virtual ~EITSource() = default;
26  public:
27  virtual void SetEITHelper(EITHelper*) = 0;
28  virtual void SetEITRate(float rate) = 0;
29 };
30 
31 class EITScanner;
32 
33 class EITScanner : public QRunnable
34 {
35  public:
36  explicit EITScanner(uint cardnum);
37  ~EITScanner() override { TeardownAll(); }
38 
39  void StartPassiveScan(ChannelBase *channel, EITSource *eitSource);
40  void StopPassiveScan(void);
41 
42  void StartActiveScan(TVRec *rec, std::chrono::seconds max_seconds_per_source);
43  void StopActiveScan(void);
44 
45  protected:
46  void run(void) override; // QRunnable
47 
48  private:
49  void TeardownAll(void);
50  static void *SpawnEventLoop(void*);
51  void RescheduleRecordings(void);
52 
53  QMutex m_lock;
54  ChannelBase *m_channel {nullptr};
55  EITSource *m_eitSource {nullptr};
56 
57  EITHelper *m_eitHelper {nullptr};
58  MThread *m_eventThread {nullptr};
59  volatile bool m_exitThread {false};
60  QWaitCondition m_exitThreadCond; // protected by lock
61 
62  TVRec *m_rec {nullptr};
63  volatile bool m_activeScan {false};
64  volatile bool m_activeScanStopped {true}; // protected by lock
65  QWaitCondition m_activeScanCond; // protected by lock
67  std::chrono::seconds m_activeScanTrigTime {0s};
68  QStringList m_activeScanChannels;
69  QStringList::iterator m_activeScanNextChan;
71 
73 
74  static QMutex s_resched_lock;
75  static QDateTime s_resched_next_time;
76 
77 };
78 
79 #endif // EITSCANNER_H
EITScanner::RescheduleRecordings
void RescheduleRecordings(void)
Tells scheduler about programming changes.
Definition: eitscanner.cpp:171
EITScanner::m_cardnum
uint m_cardnum
Definition: eitscanner.h:72
EITScanner::m_exitThread
volatile bool m_exitThread
Definition: eitscanner.h:59
EITScanner::StopPassiveScan
void StopPassiveScan(void)
Stops inserting Event Information Tables into DB.
Definition: eitscanner.cpp:212
EITScanner::m_activeScanNextTrig
QDateTime m_activeScanNextTrig
Definition: eitscanner.h:66
EITScanner::m_activeScanCond
QWaitCondition m_activeScanCond
Definition: eitscanner.h:65
EITScanner::m_eitSource
EITSource * m_eitSource
Definition: eitscanner.h:55
EITScanner::~EITScanner
~EITScanner() override
Definition: eitscanner.h:37
ProgramMapTable
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:692
EITScanner::EITScanner
EITScanner(uint cardnum)
Definition: eitscanner.cpp:33
EITScanner::StartPassiveScan
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:180
EITScanner::m_rec
TVRec * m_rec
Definition: eitscanner.h:62
EITScanner::m_eitHelper
EITHelper * m_eitHelper
Definition: eitscanner.h:57
EITSource::SetEITRate
virtual void SetEITRate(float rate)=0
EITScanner::m_activeScanNextChanIndex
uint m_activeScanNextChanIndex
Definition: eitscanner.h:70
EITScanner::StopActiveScan
void StopActiveScan(void)
Definition: eitscanner.cpp:296
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:58
EITSource::SetEITHelper
virtual void SetEITHelper(EITHelper *)=0
EITScanner::m_exitThreadCond
QWaitCondition m_exitThreadCond
Definition: eitscanner.h:60
EITScanner::SpawnEventLoop
static void * SpawnEventLoop(void *)
EITScanner::m_lock
QMutex m_lock
Definition: eitscanner.h:53
uint
unsigned int uint
Definition: compat.h:140
EITHelper
Definition: eithelper.h:93
EITScanner::m_activeScanTrigTime
std::chrono::seconds m_activeScanTrigTime
Definition: eitscanner.h:67
EITScanner::m_activeScan
volatile bool m_activeScan
Definition: eitscanner.h:63
EITScanner::m_activeScanNextChan
QStringList::iterator m_activeScanNextChan
Definition: eitscanner.h:69
MythRandom
MBASE_PUBLIC uint32_t MythRandom()
Definition: mythmiscutil.h:21
EITScanner::m_channel
ChannelBase * m_channel
Definition: eitscanner.h:54
mythmiscutil.h
EITScanner::run
void run(void) override
This runs the event loop for EITScanner until 'exitThread' is true.
Definition: eitscanner.cpp:69
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:145
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:75
EITScanner::m_activeScanChannels
QStringList m_activeScanChannels
Definition: eitscanner.h:68
EITScanner::m_activeScanStopped
volatile bool m_activeScanStopped
Definition: eitscanner.h:64
EITScanner::s_resched_lock
static QMutex s_resched_lock
Definition: eitscanner.h:74
EITScanner
Acts as glue between ChannelBase, EITSource and EITHelper.
Definition: eitscanner.h:33
EITScanner::StartActiveScan
void StartActiveScan(TVRec *rec, std::chrono::seconds max_seconds_per_source)
Definition: eitscanner.cpp:231
EITScanner::TeardownAll
void TeardownAll(void)
Definition: eitscanner.cpp:45
EITSource
Definition: eitscanner.h:22