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, uint max_seconds_per_source);
43 
44  void StopActiveScan(void);
45 
46  protected:
47  void run(void) override; // QRunnable
48 
49  private:
50  void TeardownAll(void);
51  static void *SpawnEventLoop(void*);
52  void RescheduleRecordings(void);
53 
54  QMutex m_lock;
55  ChannelBase *m_channel {nullptr};
56  EITSource *m_eitSource {nullptr};
57 
58  EITHelper *m_eitHelper {nullptr};
59  MThread *m_eventThread {nullptr};
60  volatile bool m_exitThread {false};
61  QWaitCondition m_exitThreadCond; // protected by lock
62 
63  TVRec *m_rec {nullptr};
64  volatile bool m_activeScan {false};
65  volatile bool m_activeScanStopped {true}; // protected by lock
66  QWaitCondition m_activeScanCond; // protected by lock
69  QStringList m_activeScanChannels;
70  QStringList::iterator m_activeScanNextChan;
72 
74 
75  static QMutex s_resched_lock;
76  static QDateTime s_resched_next_time;
77 
80 };
81 
82 #endif // EITSCANNER_H
channel
QDomElement channel
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:498
EITScanner::RescheduleRecordings
void RescheduleRecordings(void)
Tells scheduler about programming changes.
Definition: eitscanner.cpp:186
EITScanner::m_cardnum
uint m_cardnum
Definition: eitscanner.h:73
EITScanner::m_exitThread
volatile bool m_exitThread
Definition: eitscanner.h:60
EITScanner::StopPassiveScan
void StopPassiveScan(void)
Stops inserting Event Information Tables into DB.
Definition: eitscanner.cpp:214
EITScanner::m_activeScanNextTrig
QDateTime m_activeScanNextTrig
Definition: eitscanner.h:67
EITScanner::m_activeScanCond
QWaitCondition m_activeScanCond
Definition: eitscanner.h:66
EITScanner::m_eitSource
EITSource * m_eitSource
Definition: eitscanner.h:56
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:685
EITScanner::StartActiveScan
void StartActiveScan(TVRec *_rec, uint max_seconds_per_source)
Definition: eitscanner.cpp:231
EITScanner::EITScanner
EITScanner(uint cardnum)
Definition: eitscanner.cpp:32
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:195
EITScanner::m_rec
TVRec * m_rec
Definition: eitscanner.h:63
EITScanner::m_eitHelper
EITHelper * m_eitHelper
Definition: eitscanner.h:58
EITSource::SetEITRate
virtual void SetEITRate(float rate)=0
EITScanner::m_activeScanNextChanIndex
uint m_activeScanNextChanIndex
Definition: eitscanner.h:71
EITScanner::StopActiveScan
void StopActiveScan(void)
Definition: eitscanner.cpp:296
ChannelBase
Abstract class providing a generic interface to tuning hardware.
Definition: channelbase.h:32
EITSource::~EITSource
virtual ~EITSource()=default
EITScanner::m_eventThread
MThread * m_eventThread
Definition: eitscanner.h:59
EITSource::SetEITHelper
virtual void SetEITHelper(EITHelper *)=0
EITScanner::m_exitThreadCond
QWaitCondition m_exitThreadCond
Definition: eitscanner.h:61
EITScanner::SpawnEventLoop
static void * SpawnEventLoop(void *)
EITScanner::m_lock
QMutex m_lock
Definition: eitscanner.h:54
uint
unsigned int uint
Definition: compat.h:140
EITHelper
Definition: eithelper.h:93
EITScanner::m_activeScan
volatile bool m_activeScan
Definition: eitscanner.h:64
EITScanner::m_activeScanNextChan
QStringList::iterator m_activeScanNextChan
Definition: eitscanner.h:70
MythRandom
MBASE_PUBLIC uint32_t MythRandom()
Definition: mythmiscutil.h:24
EITScanner::m_channel
ChannelBase * m_channel
Definition: eitscanner.h:55
mythmiscutil.h
EITScanner::m_activeScanTrigTime
uint m_activeScanTrigTime
Definition: eitscanner.h:68
EITScanner::kMinRescheduleInterval
static const uint kMinRescheduleInterval
Minumum number of seconds between reschedules.
Definition: eitscanner.h:79
EITScanner::run
void run(void) override
This runs the event loop for EITScanner until 'exitThread' is true.
Definition: eitscanner.cpp:66
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:143
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
EITScanner::s_resched_next_time
static QDateTime s_resched_next_time
Definition: eitscanner.h:76
EITScanner::m_activeScanChannels
QStringList m_activeScanChannels
Definition: eitscanner.h:69
EITScanner::m_activeScanStopped
volatile bool m_activeScanStopped
Definition: eitscanner.h:65
EITScanner::s_resched_lock
static QMutex s_resched_lock
Definition: eitscanner.h:75
EITScanner
Acts as glue between ChannelBase, EITSource, and EITHelper.
Definition: eitscanner.h:34
EITScanner::TeardownAll
void TeardownAll(void)
Definition: eitscanner.cpp:42
EITSource
Definition: eitscanner.h:23