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