MythTV  master
dvbstreamhandler.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #ifndef DVBSTREAMHANDLER_H
4 #define DVBSTREAMHANDLER_H
5 
6 #include <vector>
7 
8 #include <QString>
9 #include <QMutex>
10 #include <QMap>
11 
12 #include "streamhandler.h"
13 
14 class QString;
15 class DVBStreamHandler;
16 class DTVSignalMonitor;
17 class DVBChannel;
18 class DeviceReadBuffer;
19 
20 //#define RETUNE_TIMEOUT 5000
21 
22 class DVBPIDInfo : public PIDInfo
23 {
24  public:
25  explicit DVBPIDInfo(uint pid) : PIDInfo(pid) {}
26  DVBPIDInfo(uint pid, uint stream_type, int pes_type) :
27  PIDInfo(pid, stream_type, pes_type) {}
28  bool Open(const QString &dvb_dev, bool use_section_reader) override; // PIDInfo
29  bool Close(const QString &dvb_dev) override; // PIDInfo
30 };
31 
33 {
34  public:
35  static DVBStreamHandler *Get(const QString &devname, int inputid);
36  static void Return(DVBStreamHandler * & ref, int inputid);
37 
38  // DVB specific
39 
40  void RetuneMonitor(void);
41 
42  bool IsRetuneAllowed(void) const { return m_allowRetune; }
43 
44  void SetRetuneAllowed(bool allow,
45  DTVSignalMonitor *sigmon,
46  DVBChannel *dvbchan);
47 
48  private:
49  explicit DVBStreamHandler(const QString &dvb_device, int inputid);
50 
51  void run(void) override; // MThread
52  void RunTS(void);
53  void RunSR(void);
54 
55  void CycleFiltersByPriority(void) override; // StreamHandler
56 
57  bool SupportsTSMonitoring(void);
58 
59  PIDInfo *CreatePIDInfo(uint pid, uint stream_type, int pes_type) override // StreamHandler
60  { return new DVBPIDInfo(pid, stream_type, pes_type); }
61 
62  private:
63  QString m_dvrDevPath;
64  volatile bool m_allowRetune { false };
65 
66  DTVSignalMonitor *m_sigMon { nullptr };
67  DVBChannel *m_dvbChannel { nullptr };
68  DeviceReadBuffer *m_drb { nullptr };
69 
70  // for caching TS monitoring supported value.
72  static QMap<QString,bool> s_recSupportsTsMonitoring;
73 
74  // for implementing Get & Return
75  static QMutex s_handlersLock;
76  static QMap<QString,DVBStreamHandler*> s_handlers;
77  static QMap<QString,uint> s_handlersRefCnt;
78 };
79 
80 #endif // DVBSTREAMHANDLER_H
DVBStreamHandler::m_sigMon
DTVSignalMonitor * m_sigMon
Definition: dvbstreamhandler.h:66
DVBStreamHandler::SetRetuneAllowed
void SetRetuneAllowed(bool allow, DTVSignalMonitor *sigmon, DVBChannel *dvbchan)
Definition: dvbstreamhandler.cpp:493
streamhandler.h
DVBStreamHandler::m_allowRetune
volatile bool m_allowRetune
Definition: dvbstreamhandler.h:64
StreamHandler
Definition: streamhandler.h:58
DVBStreamHandler::CreatePIDInfo
PIDInfo * CreatePIDInfo(uint pid, uint stream_type, int pes_type) override
Definition: dvbstreamhandler.h:59
DVBStreamHandler::s_recSupportsTsMonitoring
static QMap< QString, bool > s_recSupportsTsMonitoring
Definition: dvbstreamhandler.h:72
PIDInfo
Definition: streamhandler.h:29
DVBStreamHandler::s_rec_supportsTsMonitoringLock
static QMutex s_rec_supportsTsMonitoringLock
Definition: dvbstreamhandler.h:71
DVBStreamHandler::RetuneMonitor
void RetuneMonitor(void)
Definition: dvbstreamhandler.cpp:512
DeviceReadBuffer
Buffers reads from device files.
Definition: DeviceReadBuffer.h:35
DVBStreamHandler::m_dvrDevPath
QString m_dvrDevPath
Definition: dvbstreamhandler.h:63
DVBPIDInfo
Definition: dvbstreamhandler.h:22
DVBStreamHandler::Return
static void Return(DVBStreamHandler *&ref, int inputid)
Definition: dvbstreamhandler.cpp:74
DVBStreamHandler::Get
static DVBStreamHandler * Get(const QString &devname, int inputid)
Definition: dvbstreamhandler.cpp:44
DVBStreamHandler::DVBStreamHandler
DVBStreamHandler(const QString &dvb_device, int inputid)
Definition: dvbstreamhandler.cpp:111
DVBStreamHandler::IsRetuneAllowed
bool IsRetuneAllowed(void) const
Definition: dvbstreamhandler.h:42
DVBPIDInfo::DVBPIDInfo
DVBPIDInfo(uint pid, uint stream_type, int pes_type)
Definition: dvbstreamhandler.h:26
DVBStreamHandler::RunSR
void RunSR(void)
Uses "Section" reader to read a DVB device for tables.
Definition: dvbstreamhandler.cpp:306
DVBStreamHandler::s_handlers
static QMap< QString, DVBStreamHandler * > s_handlers
Definition: dvbstreamhandler.h:76
DVBStreamHandler::RunTS
void RunTS(void)
Uses TS filtering devices to read a DVB device for tables & data.
Definition: dvbstreamhandler.cpp:142
DVBStreamHandler::m_dvbChannel
DVBChannel * m_dvbChannel
Definition: dvbstreamhandler.h:67
uint
unsigned int uint
Definition: compat.h:79
DVBStreamHandler::m_drb
DeviceReadBuffer * m_drb
Definition: dvbstreamhandler.h:68
DVBStreamHandler
Definition: dvbstreamhandler.h:32
DVBChannel
Provides interface to the tuning hardware when using DVB drivers.
Definition: dvbchannel.h:31
DVBStreamHandler::CycleFiltersByPriority
void CycleFiltersByPriority(void) override
Definition: dvbstreamhandler.cpp:387
DVBStreamHandler::s_handlersRefCnt
static QMap< QString, uint > s_handlersRefCnt
Definition: dvbstreamhandler.h:77
DVBStreamHandler::run
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: dvbstreamhandler.cpp:118
DTVSignalMonitor
This class is intended to detect the presence of needed tables.
Definition: dtvsignalmonitor.h:14
DVBPIDInfo::DVBPIDInfo
DVBPIDInfo(uint pid)
Definition: dvbstreamhandler.h:25
DVBStreamHandler::s_handlersLock
static QMutex s_handlersLock
Definition: dvbstreamhandler.h:75
DVBPIDInfo::Open
bool Open(const QString &dvb_dev, bool use_section_reader) override
Definition: dvbstreamhandler.cpp:594
DVBStreamHandler::SupportsTSMonitoring
bool SupportsTSMonitoring(void)
Returns true if TS monitoring is supported.
Definition: dvbstreamhandler.cpp:554
DVBPIDInfo::Close
bool Close(const QString &dvb_dev) override
Definition: dvbstreamhandler.cpp:695