MythTV  master
vboxchannelfetcher.h
Go to the documentation of this file.
1 #ifndef VBOXCHANNELFETCHER_H
2 #define VBOXCHANNELFETCHER_H
3 
4 #include <utility>
5 
6 // Qt headers
7 #include <QCoreApplication>
8 #include <QMap>
9 #include <QMutex>
10 #include <QObject>
11 #include <QRunnable>
12 #include <QString>
13 
14 // MythTV headers
15 #include "iptvtuningdata.h"
16 #include "mthread.h"
17 #include "channelscantypes.h"
18 
19 class ScanMonitor;
20 class VBoxChannelFetcher;
21 
23 {
24  Q_DECLARE_TR_FUNCTIONS(VBoxChannelInfo)
25 
26  public:
27  VBoxChannelInfo() = default;
28  VBoxChannelInfo(QString name,
29  QString xmltvid,
30  const QString &data_url,
31  bool fta,
32  QString chanType,
33  QString transType,
34  uint serviceID,
35  uint networkID,
36  uint transportID):
37  m_name(std::move(name)), m_xmltvid(std::move(xmltvid)),
38  m_serviceID(serviceID), m_fta(fta), m_channelType(std::move(chanType)),
39  m_transType(std::move(transType)),
40  m_tuning(data_url, IPTVTuningData::http_ts), m_networkID(networkID),
41  m_transportID(transportID)
42  {
43  }
44 
45  bool IsValid(void) const
46  {
47  return !m_name.isEmpty() && m_tuning.IsValid();
48  }
49 
50  public:
51  QString m_name;
52  QString m_xmltvid;
54  bool m_fta {false};
55  QString m_channelType; // TV/Radio
56  QString m_transType; // T/T2/S/S2/C/A
58  uint m_networkID {0}; // Network ID from triplet
59  uint m_transportID {0}; // Transport ID from triplet
60 };
61 using vbox_chan_map_t = QMap<QString,VBoxChannelInfo>;
62 
63 class VBoxChannelFetcher : public QRunnable
64 {
66 
67  public:
68  VBoxChannelFetcher(uint cardid, QString inputname, uint sourceid,
69  bool ftaOnly, ServiceRequirements serviceType,
70  ScanMonitor *monitor = nullptr);
71  ~VBoxChannelFetcher() override;
72 
73  void Scan(void);
74  void Stop(void);
76 
77  private:
78  void SetTotalNumChannels(uint val) { m_chanCnt = (val) ? val : 1; }
79  void SetNumChannelsInserted(uint val);
80  bool SupportedTransmission(const QString &transType);
81 
82  protected:
83  void run(void) override; // QRunnable
84 
85  private:
88  QString m_inputName;
90  bool m_ftaOnly;
92  QString m_transType {"UNKNOWN"};
95  bool m_threadRunning {false};
96  bool m_stopNow {false};
97  MThread *m_thread {nullptr};
98  QMutex m_lock;
99 };
100 
101 #endif // VBOXCHANNELFETCHER_H
VBoxChannelFetcher::m_cardId
uint m_cardId
Definition: vboxchannelfetcher.h:87
VBoxChannelFetcher::m_transType
QString m_transType
Definition: vboxchannelfetcher.h:92
VBoxChannelFetcher::m_sourceId
uint m_sourceId
Definition: vboxchannelfetcher.h:89
VBoxChannelInfo::m_tuning
IPTVTuningData m_tuning
Definition: vboxchannelfetcher.h:57
vbox_chan_map_t
QMap< QString, VBoxChannelInfo > vbox_chan_map_t
Definition: vboxchannelfetcher.h:61
VBoxChannelFetcher::~VBoxChannelFetcher
~VBoxChannelFetcher() override
Definition: vboxchannelfetcher.cpp:58
VBoxChannelFetcher::m_threadRunning
bool m_threadRunning
Definition: vboxchannelfetcher.h:95
VBoxChannelFetcher::m_stopNow
bool m_stopNow
Definition: vboxchannelfetcher.h:96
VBoxChannelFetcher
Definition: vboxchannelfetcher.h:64
VBoxChannelInfo::VBoxChannelInfo
VBoxChannelInfo(QString name, QString xmltvid, const QString &data_url, bool fta, QString chanType, QString transType, uint serviceID, uint networkID, uint transportID)
Definition: vboxchannelfetcher.h:28
VBoxChannelFetcher::m_thread
MThread * m_thread
Definition: vboxchannelfetcher.h:97
VBoxChannelFetcher::m_lock
QMutex m_lock
Definition: vboxchannelfetcher.h:98
VBoxChannelInfo::IsValid
bool IsValid(void) const
Definition: vboxchannelfetcher.h:45
VBoxChannelFetcher::Stop
void Stop(void)
Stops the scanning thread running.
Definition: vboxchannelfetcher.cpp:70
VBoxChannelInfo::m_transportID
uint m_transportID
Definition: vboxchannelfetcher.h:59
VBoxChannelFetcher::m_scanMonitor
ScanMonitor * m_scanMonitor
Definition: vboxchannelfetcher.h:86
VBoxChannelFetcher::SupportedTransmission
bool SupportedTransmission(const QString &transType)
Definition: vboxchannelfetcher.cpp:284
VBoxChannelInfo::m_transType
QString m_transType
Definition: vboxchannelfetcher.h:56
VBoxChannelInfo::m_name
QString m_name
Definition: vboxchannelfetcher.h:51
VBoxChannelFetcher::m_channels
vbox_chan_map_t * m_channels
Definition: vboxchannelfetcher.h:93
channelscantypes.h
IPTVTuningData
Definition: iptvtuningdata.h:17
VBoxChannelInfo::m_serviceID
uint m_serviceID
Definition: vboxchannelfetcher.h:53
VBoxChannelFetcher::m_ftaOnly
bool m_ftaOnly
Definition: vboxchannelfetcher.h:90
iptvtuningdata.h
VBoxChannelFetcher::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(VBoxChannelFetcher)
VBoxChannelFetcher::GetChannels
vbox_chan_map_t GetChannels(void)
Definition: vboxchannelfetcher.cpp:87
VBoxChannelFetcher::Scan
void Scan(void)
Definition: vboxchannelfetcher.cpp:97
uint
unsigned int uint
Definition: compat.h:140
VBoxChannelInfo::m_channelType
QString m_channelType
Definition: vboxchannelfetcher.h:55
VBoxChannelFetcher::m_inputName
QString m_inputName
Definition: vboxchannelfetcher.h:88
VBoxChannelInfo::VBoxChannelInfo
VBoxChannelInfo()=default
VBoxChannelInfo::m_xmltvid
QString m_xmltvid
Definition: vboxchannelfetcher.h:52
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
VBoxChannelInfo::m_fta
bool m_fta
Definition: vboxchannelfetcher.h:54
mthread.h
VBoxChannelFetcher::m_serviceType
ServiceRequirements m_serviceType
Definition: vboxchannelfetcher.h:91
VBoxChannelFetcher::VBoxChannelFetcher
VBoxChannelFetcher(uint cardid, QString inputname, uint sourceid, bool ftaOnly, ServiceRequirements serviceType, ScanMonitor *monitor=nullptr)
Definition: vboxchannelfetcher.cpp:22
IPTVTuningData::IsValid
bool IsValid(void) const
Definition: iptvtuningdata.h:167
VBoxChannelFetcher::m_chanCnt
uint m_chanCnt
Definition: vboxchannelfetcher.h:94
VBoxChannelFetcher::run
void run(void) override
Definition: vboxchannelfetcher.cpp:104
VBoxChannelFetcher::SetNumChannelsInserted
void SetNumChannelsInserted(uint val)
Definition: vboxchannelfetcher.cpp:275
VBoxChannelFetcher::SetTotalNumChannels
void SetTotalNumChannels(uint val)
Definition: vboxchannelfetcher.h:78
ServiceRequirements
ServiceRequirements
Definition: channelscantypes.h:5
VBoxChannelInfo::m_networkID
uint m_networkID
Definition: vboxchannelfetcher.h:58
ScanMonitor
Definition: scanmonitor.h:47
VBoxChannelInfo
Definition: vboxchannelfetcher.h:23