MythTV  master
iptvchannelfetcher.h
Go to the documentation of this file.
1 
6 #ifndef _IPTVCHANNELFETCHER_H_
7 #define _IPTVCHANNELFETCHER_H_
8 
9 // Qt headers
10 #include <QString>
11 #include <QRunnable>
12 #include <QObject>
13 #include <QMutex>
14 #include <QMap>
15 #include <QCoreApplication>
16 
17 // MythTV headers
18 #include "iptvtuningdata.h"
19 #include "mthread.h"
20 
21 class ScanMonitor;
22 class IPTVChannelFetcher;
23 
25 {
26  Q_DECLARE_TR_FUNCTIONS(IPTVChannelInfo)
27 
28  public:
29  IPTVChannelInfo() = default;
30  IPTVChannelInfo(const QString &name,
31  const QString &xmltvid,
32  const QString &data_url,
33  uint data_bitrate,
34  const QString &fec_type,
35  const QString &fec_url0,
36  uint fec_bitrate0,
37  const QString &fec_url1,
38  uint fec_bitrate1,
39  uint programnumber) :
40  m_name(name), m_xmltvid(xmltvid), m_programNumber(programnumber),
41  m_tuning(data_url, data_bitrate,
42  fec_type, fec_url0, fec_bitrate0, fec_url1, fec_bitrate1)
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;
56 };
57 typedef QMap<QString,IPTVChannelInfo> fbox_chan_map_t;
58 
59 class IPTVChannelFetcher : public QRunnable
60 {
62 
63  public:
64  IPTVChannelFetcher(uint cardid, const QString &inputname, uint sourceid,
65  bool is_mpts, ScanMonitor *monitor = nullptr);
67 
68  void Scan(void);
69  void Stop(void);
71 
72  static QString DownloadPlaylist(const QString &url);
74  const QString &rawdata, IPTVChannelFetcher *fetcher = nullptr);
75 
76  private:
77  void SetTotalNumChannels(uint val) { m_chan_cnt = (val) ? val : 1; }
80  void SetMessage(const QString &status);
81 
82  protected:
83  void run(void) override; // QRunnable
84 
85  private:
88  QString m_inputname;
90  bool m_is_mpts;
93  bool m_thread_running {false};
94  bool m_stop_now {false};
95  MThread *m_thread {nullptr};
96  QMutex m_lock;
97 };
98 
99 #endif // _IPTVCHANNELFETCHER_H_
100 
101 /* vim: set expandtab tabstop=4 shiftwidth=4: */
IPTVChannelInfo(const QString &name, const 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)
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
bool IsValid(void) const
IPTVChannelFetcher(uint cardid, const QString &inputname, uint sourceid, bool is_mpts, ScanMonitor *monitor=nullptr)
unsigned int uint
Definition: compat.h:140
IPTVChannelInfo()=default
QMap< QString, IPTVChannelInfo > fbox_chan_map_t
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)
const char * name
Definition: ParseText.cpp:328
void Scan(void)
Scans the given frequency list.
fbox_chan_map_t GetChannels(void)
IPTVTuningData m_tuning
ScanMonitor * m_scan_monitor
void run(void) override
fbox_chan_map_t m_channels
void Stop(void)
Stops the scanning thread running.
void SetMessage(const QString &status)