2 #ifndef IPTV_TUNING_DATA_H
3 #define IPTV_TUNING_DATA_H
8 #include <QApplication>
10 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
11 #include <QStringConverter>
59 m_dataUrl(data_url), m_protocol(protocol)
66 const QString &fec_url0,
uint fec_bitrate0,
67 const QString &fec_url1,
uint fec_bitrate1) :
69 m_fecType(fec_type), m_fecUrl0(fec_url0), m_fecUrl1(fec_url1)
72 m_bitrate[0] = data_bitrate;
73 m_bitrate[1] = fec_bitrate0;
74 m_bitrate[2] = fec_bitrate1;
78 const QString &fec_type,
79 const QString &fec_url0,
uint fec_bitrate0,
80 const QString &fec_url1,
uint fec_bitrate1,
83 m_fecUrl0(fec_url0), m_fecUrl1(fec_url1),
86 m_bitrate[0] = data_bitrate;
87 m_bitrate[1] = fec_bitrate0;
88 m_bitrate[2] = fec_bitrate1;
89 if (fec_type.toLower() ==
"rfc2733")
91 else if (fec_type.toLower() ==
"rfc5109")
93 else if (fec_type.toLower() ==
"smpte2022")
94 m_fecType = kSMPTE2022;
104 const QUrl u = GetDataURL();
106 return QString(
"%1(%2)").arg(u.toString()).arg(GetBitrate(0));
107 if (IsHTTPTS() || IsRTSP())
108 return QString(
"%1").arg(u.toString());
109 return QString(
"%1:%2:%3")
110 .arg(u.host(),u.userInfo(),QString::number(u.port())).toLower();
115 return QString(
"[data]%1[fectype]%2[fec0]%3[fec1]%4%5")
120 GetBitrate(0) ? QString(
"-%1").arg(GetBitrate(0)) :
"");
162 case kNone:
return {};
163 case kRFC2733:
return QString(
"rfc2733-%1").arg(i);
164 case kRFC5109:
return QString(
"rfc5109-%1").arg(i);
165 case kSMPTE2022:
return QString(
"smpte2022-%1").arg(i);
174 bool ret = (m_dataUrl.isValid() && (IsUDP() || IsRTP() || IsRTSP() || IsHLS() || IsHTTPTS()));
176 LOG(VB_CHANNEL, LOG_DEBUG, QString(
"IPTVTuningdata (%1): IsValid = %2")
177 .arg(m_dataUrl.toString(),
178 ret ?
"true" :
"false"));
185 return (m_protocol == udp);
190 return (m_protocol == rtp);
195 return (m_protocol == rtsp);
200 return (m_protocol == http_hls);
205 return (m_protocol == http_ts);
210 if (!m_dataUrl.isValid())
212 else if (m_dataUrl.scheme() ==
"udp")
214 else if (m_dataUrl.scheme() ==
"rtp")
216 else if (m_dataUrl.scheme() ==
"rtsp")
218 else if (((m_dataUrl.scheme() ==
"http") || (m_dataUrl.scheme() ==
"https")) && IsHLSPlaylist())
220 else if ((m_dataUrl.scheme() ==
"http") || (m_dataUrl.scheme() ==
"https"))
234 if (QCoreApplication::instance() ==
nullptr)
236 LOG(VB_GENERAL, LOG_ERR, QString(
"IsHLSPlaylist - No QCoreApplication!!"));
240 QString url = m_dataUrl.toString();
241 auto path = m_dataUrl.path();
244 if(path.endsWith(
".m3u8", Qt::CaseInsensitive) ||
245 path.endsWith(
".m3u", Qt::CaseInsensitive))
247 LOG(VB_RECORD, LOG_INFO, QString(
"IsHLSPlaylist url ends with either .m3u8 or .m3u %1").arg(url));
252 LOG(VB_RECORD, LOG_INFO, QString(
"IsHLSPlaylist url does not end with either .m3u8 or .m3u %1").arg(url));
259 downloader.
DownloadURL(url, &buffer, 5s, 0, 10000);
260 if (buffer.isEmpty())
262 LOG(VB_GENERAL, LOG_ERR, QString(
"IsHLSPlaylist - Open Failed: %1\n\t\t\t%2")
267 QTextStream text(&buffer);
268 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
269 text.setCodec(
"UTF-8");
271 text.setEncoding(QStringConverter::Utf8);
281 std::array<uint,3> m_bitrate {};
285 #endif // IPTV_TUNING_DATA_H