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  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: */
IPTVChannelFetcher::m_sourceId
uint m_sourceId
Definition: iptvchannelfetcher.h:94
IPTVChannelFetcher::m_channels
fbox_chan_map_t m_channels
Definition: iptvchannelfetcher.h:96
IPTVChannelInfo::m_name
QString m_name
Definition: iptvchannelfetcher.h:57
IPTVChannelFetcher::m_cardId
uint m_cardId
Definition: iptvchannelfetcher.h:92
IPTVChannelFetcher::m_thread
MThread * m_thread
Definition: iptvchannelfetcher.h:100
IPTVChannelFetcher::SetNumChannelsInserted
void SetNumChannelsInserted(uint val)
Definition: iptvchannelfetcher.cpp:224
IPTVChannelInfo::m_programNumber
uint m_programNumber
Definition: iptvchannelfetcher.h:59
IPTVChannelFetcher::SetMessage
void SetMessage(const QString &status)
Definition: iptvchannelfetcher.cpp:233
IPTVChannelFetcher::m_threadRunning
bool m_threadRunning
Definition: iptvchannelfetcher.h:98
IPTVChannelInfo::IPTVChannelInfo
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)
Definition: iptvchannelfetcher.h:32
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:93
IPTVChannelFetcher::Stop
void Stop(void)
Stops the scanning thread running.
Definition: iptvchannelfetcher.cpp:58
IPTVChannelFetcher::m_chanCnt
uint m_chanCnt
Definition: iptvchannelfetcher.h:97
IPTVChannelInfo
Definition: iptvchannelfetcher.h:26
IPTVChannelFetcher::m_inputName
QString m_inputName
Definition: iptvchannelfetcher.h:93
IPTVChannelFetcher
Definition: iptvchannelfetcher.h:64
IPTVTuningData
Definition: iptvtuningdata.h:21
iptvtuningdata.h
IPTVChannelInfo::m_xmltvid
QString m_xmltvid
Definition: iptvchannelfetcher.h:58
uint
unsigned int uint
Definition: compat.h:81
IPTVChannelFetcher::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(IPTVChannelFetcher)
IPTVChannelInfo::IsValid
bool IsValid(void) const
Definition: iptvchannelfetcher.h:51
IPTVChannelFetcher::m_lock
QMutex m_lock
Definition: iptvchannelfetcher.h:101
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
IPTVChannelFetcher::m_scanMonitor
ScanMonitor * m_scanMonitor
Definition: iptvchannelfetcher.h:91
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:95
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:50
IPTVChannelFetcher::GetChannels
fbox_chan_map_t GetChannels(void)
Definition: iptvchannelfetcher.cpp:75
IPTVChannelFetcher::m_stopNow
bool m_stopNow
Definition: iptvchannelfetcher.h:99
IPTVChannelFetcher::DownloadPlaylist
static QString DownloadPlaylist(const QString &url)
Definition: iptvchannelfetcher.cpp:240
fbox_chan_map_t
QMap< QString, IPTVChannelInfo > fbox_chan_map_t
Definition: iptvchannelfetcher.h:62
IPTVChannelInfo::IPTVChannelInfo
IPTVChannelInfo()=default
IPTVChannelInfo::m_tuning
IPTVTuningData m_tuning
Definition: iptvchannelfetcher.h:60
ScanMonitor
Definition: scanmonitor.h:44
IPTVChannelFetcher::SetTotalNumChannels
void SetTotalNumChannels(uint val)
Definition: iptvchannelfetcher.h:82
IPTVChannelFetcher::SetNumChannelsParsed
void SetNumChannelsParsed(uint val)
Definition: iptvchannelfetcher.cpp:215
IPTVChannelFetcher::ParsePlaylist
static MTV_PUBLIC fbox_chan_map_t ParsePlaylist(const QString &rawdata, IPTVChannelFetcher *fetcher=nullptr)
Definition: iptvchannelfetcher.cpp:296