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_
void SetNumChannelsInserted(uint val)
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
VBoxChannelInfo()=default
bool IsValid(void) const
VBoxChannelFetcher(uint cardid, QString inputname, uint sourceid, bool ftaOnly, ServiceRequirements serviceType, ScanMonitor *monitor=nullptr)
ScanMonitor * m_scanMonitor
vbox_chan_map_t GetChannels(void)
bool SupportedTransmission(const QString &transType)
bool IsValid(void) const
Q_DECLARE_TR_FUNCTIONS(VBoxChannelFetcher)
void run(void) override
QMap< QString, VBoxChannelInfo > vbox_chan_map_t
unsigned int uint
Definition: compat.h:140
vbox_chan_map_t * m_channels
ServiceRequirements
IPTVTuningData m_tuning
ServiceRequirements m_serviceType
void Stop(void)
Stops the scanning thread running.
VBoxChannelInfo(QString name, QString xmltvid, const QString &data_url, bool fta, QString chanType, QString transType, uint serviceID, uint networkID, uint transportID)
void SetTotalNumChannels(uint val)