/
iptvchannelfetcher.h
91 lines (76 loc) · 2.22 KB
/
iptvchannelfetcher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/** -*- Mode: c++ -*-
* IPTVChannelInfo
* Distributed as part of MythTV under GPL v2 and later.
*/
#ifndef _IPTVCHANNELFETCHER_H_
#define _IPTVCHANNELFETCHER_H_
// Qt headers
#include <QString>
#include <QRunnable>
#include <QObject>
#include <QMutex>
#include <QMap>
// MythTV headers
#include "iptvtuningdata.h"
#include "mthread.h"
class ScanMonitor;
class IPTVChannelFetcher;
class IPTVChannelInfo
{
public:
IPTVChannelInfo() {}
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) :
m_name(name), m_xmltvid(xmltvid),
m_tuning(data_url, data_bitrate,
fec_type, fec_url0, fec_bitrate0, fec_url1, fec_bitrate1)
{
}
bool IsValid(void) const
{
return !m_name.isEmpty() && !m_tuning.IsValid();
}
public:
QString m_name;
QString m_xmltvid;
IPTVTuningData m_tuning;
};
typedef QMap<QString,IPTVChannelInfo> fbox_chan_map_t;
class IPTVChannelFetcher : public QRunnable
{
public:
IPTVChannelFetcher(uint cardid, const QString &inputname, uint sourceid,
ScanMonitor *monitor = NULL);
~IPTVChannelFetcher();
void Scan(void);
void Stop(void);
static QString DownloadPlaylist(const QString &url, bool inQtThread);
static fbox_chan_map_t ParsePlaylist(
const QString &rawdata, IPTVChannelFetcher *fetcher = NULL);
private:
void SetTotalNumChannels(uint val) { _chan_cnt = (val) ? val : 1; }
void SetNumChannelsParsed(uint);
void SetNumChannelsInserted(uint);
void SetMessage(const QString &status);
protected:
virtual void run(void); // QRunnable
private:
ScanMonitor *_scan_monitor;
uint _cardid;
QString _inputname;
uint _sourceid;
uint _chan_cnt;
bool _thread_running;
bool _stop_now;
MThread *_thread;
QMutex _lock;
};
#endif // _IPTVCHANNELFETCHER_H_
/* vim: set expandtab tabstop=4 shiftwidth=4: */