MythTV  master
iptvchannelfetcher.h
Go to the documentation of this file.
1 
6 #ifndef _IPTVCHANNELFETCHER_H_
7 #define _IPTVCHANNELFETCHER_H_
8 
9 #include <utility>
10 
11 // Qt headers
12 #include <QCoreApplication>
13 #include <QMap>
14 #include <QMutex>
15 #include <QObject>
16 #include <QRunnable>
17 #include <QString>
18 
19 // MythTV headers
20 #include "iptvtuningdata.h"
21 #include "mthread.h"
22 
23 class ScanMonitor;
24 class IPTVChannelFetcher;
25 
27 {
28  Q_DECLARE_TR_FUNCTIONS(IPTVChannelInfo)
29 
30  public:
31  IPTVChannelInfo() = default;
32  IPTVChannelInfo(QString name,
33  QString xmltvid,
34  const QString &data_url,
35  uint data_bitrate,
36  const QString &fec_type,
37  const QString &fec_url0,
38  uint fec_bitrate0,
39  const QString &fec_url1,
40  uint fec_bitrate1,
41  uint programnumber) :
42  m_name(std::move(name)), m_xmltvid(std::move(xmltvid)), m_programNumber(programnumber),
43  m_tuning(data_url, data_bitrate,
44  fec_type, fec_url0, fec_bitrate0, fec_url1, fec_bitrate1,
45  IPTVTuningData::inValid)
46  {
47  }
48 
49  protected:
50  friend class TestIPTVRecorder;
51  bool IsValid(void) const
52  {
53  return !m_name.isEmpty() && m_tuning.IsValid();
54  }
55 
56  public:
57  QString m_name;
58  QString m_xmltvid;
61 };
62 using fbox_chan_map_t = QMap<QString,IPTVChannelInfo>;
63 
64 class IPTVChannelFetcher : public QRunnable
65 {
67 
68  public:
69  IPTVChannelFetcher(uint cardid, QString inputname, uint sourceid,
70  bool is_mpts, ScanMonitor *monitor = nullptr);
71  ~IPTVChannelFetcher() override;
72 
73  void Scan(void);
74  void Stop(void);
76 
77  static QString DownloadPlaylist(const QString &url);
79  const QString &rawdata, IPTVChannelFetcher *fetcher = nullptr);
80 
81  private:
82  void SetTotalNumChannels(uint val) { m_chanCnt = (val) ? val : 1; }
83  void SetNumChannelsParsed(uint val);
84  void SetNumChannelsInserted(uint val);
85  void SetMessage(const QString &status);
86 
87  protected:
88  void run(void) override; // QRunnable
89 
90  private:
93  QString m_inputName;
95  bool m_isMpts;
98  bool m_threadRunning {false};
99  bool m_stopNow {false};
100  MThread *m_thread {nullptr};
101  QMutex m_lock;
102 };
103 
104 #endif // _IPTVCHANNELFETCHER_H_
105 
106 /* vim: set expandtab tabstop=4 shiftwidth=4: */
void SetNumChannelsParsed(uint val)
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
ScanMonitor * m_scanMonitor
bool IsValid(void) const
friend class TestIPTVRecorder
IPTVChannelInfo()=default
void SetNumChannelsInserted(uint val)
static fbox_chan_map_t ParsePlaylist(const QString &rawdata, IPTVChannelFetcher *fetcher=nullptr)
bool IsValid(void) const
static QString DownloadPlaylist(const QString &url)
void SetTotalNumChannels(uint val)
Q_DECLARE_TR_FUNCTIONS(IPTVChannelFetcher)
IPTVChannelInfo(QString name, QString xmltvid, const QString &data_url, uint data_bitrate, const QString &fec_type, const QString &fec_url0, uint fec_bitrate0, const QString &fec_url1, uint fec_bitrate1, uint programnumber)
unsigned int uint
Definition: compat.h:140
void Scan(void)
Scans the given frequency list.
fbox_chan_map_t GetChannels(void)
IPTVTuningData m_tuning
IPTVChannelFetcher(uint cardid, QString inputname, uint sourceid, bool is_mpts, ScanMonitor *monitor=nullptr)
void run(void) override
fbox_chan_map_t m_channels
void Stop(void)
Stops the scanning thread running.
void SetMessage(const QString &status)
QMap< QString, IPTVChannelInfo > fbox_chan_map_t