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
21 #include "libmythbase/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  QString logo,
35  const QString &data_url,
36  uint data_bitrate,
37  const QString &fec_type,
38  const QString &fec_url0,
39  uint fec_bitrate0,
40  const QString &fec_url1,
41  uint fec_bitrate1,
42  uint programnumber) :
43  m_name(std::move(name)), m_xmltvid(std::move(xmltvid)), m_logo(std::move(logo)),
44  m_programNumber(programnumber),
45  m_tuning(data_url, data_bitrate,
46  fec_type, fec_url0, fec_bitrate0, fec_url1, fec_bitrate1,
47  IPTVTuningData::inValid)
48  {
49  }
50 
51  protected:
52  friend class TestIPTVRecorder;
53  bool IsValid(void) const
54  {
55  return !m_name.isEmpty() && m_tuning.IsValid();
56  }
57 
58  public:
59  QString m_name;
60  QString m_xmltvid;
61  QString m_logo;
64 };
65 using fbox_chan_map_t = QMap<QString,IPTVChannelInfo>;
66 
67 class IPTVChannelFetcher : public QRunnable
68 {
70 
71  public:
72  IPTVChannelFetcher(uint cardid, QString inputname, uint sourceid,
73  bool is_mpts, ScanMonitor *monitor = nullptr);
74  ~IPTVChannelFetcher() override;
75 
76  void Scan(void);
77  void Stop(void);
79 
80  static QString DownloadPlaylist(const QString &url);
82  const QString &rawdata, IPTVChannelFetcher *fetcher = nullptr);
83 
84  private:
85  void SetTotalNumChannels(uint val) { m_chanCnt = (val) ? val : 1; }
86  void SetNumChannelsParsed(uint val);
87  void SetNumChannelsInserted(uint val);
88  void SetMessage(const QString &status);
89 
90  protected:
91  void run(void) override; // QRunnable
92 
93  private:
96  QString m_inputName;
98  bool m_isMpts;
101  bool m_threadRunning {false};
102  bool m_stopNow {false};
103  MThread *m_thread {nullptr};
104  QMutex m_lock;
105 };
106 
107 #endif // IPTVCHANNELFETCHER_H
108 
109 /* vim: set expandtab tabstop=4 shiftwidth=4: */
IPTVChannelFetcher::m_sourceId
uint m_sourceId
Definition: iptvchannelfetcher.h:97
IPTVChannelFetcher::m_channels
fbox_chan_map_t m_channels
Definition: iptvchannelfetcher.h:99
IPTVChannelInfo::m_name
QString m_name
Definition: iptvchannelfetcher.h:59
IPTVChannelFetcher::m_cardId
uint m_cardId
Definition: iptvchannelfetcher.h:95
IPTVChannelFetcher::m_thread
MThread * m_thread
Definition: iptvchannelfetcher.h:103
IPTVChannelInfo::IPTVChannelInfo
IPTVChannelInfo(QString name, QString xmltvid, QString logo, 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)
Definition: iptvchannelfetcher.h:32
IPTVChannelFetcher::SetNumChannelsInserted
void SetNumChannelsInserted(uint val)
Definition: iptvchannelfetcher.cpp:303
IPTVChannelInfo::m_programNumber
uint m_programNumber
Definition: iptvchannelfetcher.h:62
IPTVChannelFetcher::SetMessage
void SetMessage(const QString &status)
Definition: iptvchannelfetcher.cpp:312
IPTVChannelFetcher::m_threadRunning
bool m_threadRunning
Definition: iptvchannelfetcher.h:101
IPTVChannelFetcher::Scan
void Scan(void)
Scans the given frequency list.
Definition: iptvchannelfetcher.cpp:86
IPTVChannelFetcher::IPTVChannelFetcher
IPTVChannelFetcher(uint cardid, QString inputname, uint sourceid, bool is_mpts, ScanMonitor *monitor=nullptr)
Definition: iptvchannelfetcher.cpp:36
IPTVChannelFetcher::run
void run(void) override
Definition: iptvchannelfetcher.cpp:140
IPTVChannelFetcher::Stop
void Stop(void)
Stops the scanning thread running.
Definition: iptvchannelfetcher.cpp:58
IPTVChannelFetcher::m_chanCnt
uint m_chanCnt
Definition: iptvchannelfetcher.h:100
IPTVChannelInfo
Definition: iptvchannelfetcher.h:26
IPTVChannelFetcher::m_inputName
QString m_inputName
Definition: iptvchannelfetcher.h:96
IPTVChannelInfo::m_logo
QString m_logo
Definition: iptvchannelfetcher.h:61
IPTVChannelFetcher
Definition: iptvchannelfetcher.h:67
IPTVTuningData
Definition: iptvtuningdata.h:21
iptvtuningdata.h
IPTVChannelInfo::m_xmltvid
QString m_xmltvid
Definition: iptvchannelfetcher.h:60
IPTVChannelFetcher::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(IPTVChannelFetcher)
IPTVChannelInfo::IsValid
bool IsValid(void) const
Definition: iptvchannelfetcher.h:53
IPTVChannelFetcher::m_lock
QMutex m_lock
Definition: iptvchannelfetcher.h:104
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
IPTVChannelFetcher::m_scanMonitor
ScanMonitor * m_scanMonitor
Definition: iptvchannelfetcher.h:94
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
mthread.h
IPTVChannelFetcher::m_isMpts
bool m_isMpts
Definition: iptvchannelfetcher.h:98
IPTVChannelFetcher::~IPTVChannelFetcher
~IPTVChannelFetcher() override
Definition: iptvchannelfetcher.cpp:48
IPTVTuningData::IsValid
bool IsValid(void) const
Definition: iptvtuningdata.h:172
IPTVChannelInfo::TestIPTVRecorder
friend class TestIPTVRecorder
Definition: iptvchannelfetcher.h:52
IPTVChannelFetcher::GetChannels
fbox_chan_map_t GetChannels(void)
Definition: iptvchannelfetcher.cpp:75
IPTVChannelFetcher::m_stopNow
bool m_stopNow
Definition: iptvchannelfetcher.h:102
IPTVChannelFetcher::DownloadPlaylist
static QString DownloadPlaylist(const QString &url)
Definition: iptvchannelfetcher.cpp:319
fbox_chan_map_t
QMap< QString, IPTVChannelInfo > fbox_chan_map_t
Definition: iptvchannelfetcher.h:65
IPTVChannelInfo::IPTVChannelInfo
IPTVChannelInfo()=default
IPTVChannelInfo::m_tuning
IPTVTuningData m_tuning
Definition: iptvchannelfetcher.h:63
ScanMonitor
Definition: scanmonitor.h:44
IPTVChannelFetcher::SetTotalNumChannels
void SetTotalNumChannels(uint val)
Definition: iptvchannelfetcher.h:85
IPTVChannelFetcher::SetNumChannelsParsed
void SetNumChannelsParsed(uint val)
Definition: iptvchannelfetcher.cpp:294
IPTVChannelFetcher::ParsePlaylist
static MTV_PUBLIC fbox_chan_map_t ParsePlaylist(const QString &rawdata, IPTVChannelFetcher *fetcher=nullptr)
Definition: iptvchannelfetcher.cpp:376
uint
unsigned int uint
Definition: freesurround.h:24