MythTV master
hdhrchannelfetcher.h
Go to the documentation of this file.
1#ifndef HDHRCHANNELFETCHER_H
2#define HDHRCHANNELFETCHER_H
3
4#include <utility>
5
6// Qt headers
7#include <QCoreApplication>
8#include <QMap>
9#include <QMutex>
10#include <QObject>
11#include <QRunnable>
12#include <QString>
13
14// MythTV headers
15#include "libmythbase/mthread.h"
17
18#include "channelscantypes.h"
19
20class ScanMonitor;
22
24{
25 Q_DECLARE_TR_FUNCTIONS(HDHRChannelInfo)
26
27 public:
28 HDHRChannelInfo() = default;
29 HDHRChannelInfo(QString name,
30 QString number,
31 const QString& url,
32 QString modulation,
33 QString videoCodec,
34 QString audioCodec,
35 uint frequency,
36 uint serviceID,
37 uint networkID,
38 uint transportID):
39 m_name(std::move(name)),
40 m_number(std::move(number)),
41 m_tuning(url, IPTVTuningData::http_ts),
42 m_modulation(std::move(modulation)),
43 m_videoCodec(std::move(videoCodec)),
44 m_audioCodec(std::move(audioCodec)),
45 m_frequency(frequency),
46 m_serviceID(serviceID),
47 m_networkID(networkID),
48 m_transportID(transportID)
49 {
50 // Determine channel type from presence of audio and video codecs
51 if (m_videoCodec.isEmpty())
52 {
53 if (m_audioCodec.isEmpty())
54 {
55 // No video, no audio, then it is Data
56 m_channelType = "Data";
57 }
58 else
59 {
60 // Only audio channel then it is Radio
61 m_channelType = "Radio";
62 }
63 }
64 else
65 {
66 // Video with or without audio is always TV
67 m_channelType = "TV";
68 }
69 }
70
71 bool IsValid(void) const
72 {
73 return !m_name.isEmpty() && m_tuning.IsValid();
74 }
75
76 public:
77 QString m_name;
78 QString m_number;
80 QString m_channelType; // TV/Radio/Data
81 QString m_modulation;
82 QString m_videoCodec;
83 QString m_audioCodec;
88 bool m_fta {true};
89};
90using hdhr_chan_map_t = QMap<QString,HDHRChannelInfo>;
91
92class HDHRChannelFetcher : public QRunnable
93{
95
96 public:
97 HDHRChannelFetcher(uint cardid, QString inputname, uint sourceid,
98 ServiceRequirements serviceType, ScanMonitor *monitor = nullptr);
99 ~HDHRChannelFetcher() override;
100
101 void Scan(void);
102 void Stop(void);
104
105 private:
106 void SetTotalNumChannels(uint val) { m_chanCnt = (val) ? val : 1; }
108
109 protected:
110 void run(void) override; // QRunnable
111
112 private:
115 QString m_inputName;
120 bool m_threadRunning {false};
121 bool m_stopNow {false};
122 MThread *m_thread {nullptr};
123 QMutex m_lock;
124};
125
126#endif // HDHRCHANNELFETCHER_H
ServiceRequirements
void run(void) override
void SetTotalNumChannels(uint val)
void SetNumChannelsInserted(uint val)
HDHRChannelFetcher(uint cardid, QString inputname, uint sourceid, ServiceRequirements serviceType, ScanMonitor *monitor=nullptr)
hdhr_chan_map_t * m_channels
Q_DECLARE_TR_FUNCTIONS(HDHRChannelFetcher)
void Stop(void)
Stops the scanning thread running.
hdhr_chan_map_t GetChannels(void)
ScanMonitor * m_scanMonitor
ServiceRequirements m_serviceType
bool IsValid(void) const
HDHRChannelInfo(QString name, QString number, const QString &url, QString modulation, QString videoCodec, QString audioCodec, uint frequency, uint serviceID, uint networkID, uint transportID)
IPTVTuningData m_tuning
HDHRChannelInfo()=default
bool IsValid(void) const
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
unsigned int uint
Definition: compat.h:68
QMap< QString, HDHRChannelInfo > hdhr_chan_map_t
STL namespace.