11 QByteArray ba = uri.toLatin1();
12 QUrl url = QUrl::fromEncoded(ba);
13 return url.toString();
16 QString
RelativeURI(
const QString& surl,
const QString& spath)
18 QUrl url = QUrl(surl);
19 QUrl path = QUrl(spath);
21 if (!path.isRelative())
24 return url.resolved(path).toString();
29 int p = line.indexOf(QLatin1String(
":"));
33 QStringList list = line.mid(
p + 1).split(
',');
34 for (
const auto & it : std::as_const(list))
36 QString arg = it.trimmed();
37 if (arg.startsWith(attr))
39 int pos = arg.indexOf(QLatin1String(
"="));
42 return arg.mid(pos+1);
54 int p = line.indexOf(QLatin1String(
":"));
58 while (++i < line.size() && line[i].isNumber());
61 target = line.mid(
p + 1, i -
p - 1).toInt();
71 int p = line.indexOf(QLatin1String(
":"));
75 while (++i < line.size() && line[i].isNumber());
78 target = line.mid(
p + 1, i -
p - 1).toInt();
98 LOG(VB_RECORD, LOG_ERR, loc +
99 "#EXT-X-VERSION: no protocol version found, should be version 1.");
104 if (version <= 0 || version > 3)
106 LOG(VB_RECORD, LOG_ERR, loc +
107 QString(
"#EXT-X-VERSION is %1, but we only understand 0 through 3")
118 int&
id, uint64_t& bandwidth)
120 LOG(VB_RECORD, LOG_INFO, loc +
121 QString(
"Parsing stream from %1").arg(url));
132 LOG(VB_RECORD, LOG_INFO, loc +
133 "#EXT-X-STREAM-INF: expected PROGRAM-ID=<value>, using -1");
144 LOG(VB_RECORD, LOG_ERR, loc +
145 "#EXT-X-STREAM-INF: expected BANDWIDTH=<value>");
148 bandwidth = attr.toInt();
152 LOG(VB_RECORD, LOG_ERR, loc +
153 "#EXT-X-STREAM-INF: bandwidth cannot be 0");
157 LOG(VB_RECORD, LOG_INFO, loc +
158 QString(
"bandwidth adaptation detected (program-id=%1, bandwidth=%2")
159 .arg(
id).arg(bandwidth));
176 LOG(VB_RECORD, LOG_ERR, loc +
"expected #EXT-X-TARGETDURATION:<s>");
184 uint& duration, QString& title,
196 int p = line.indexOf(QLatin1String(
":"));
199 LOG(VB_RECORD, LOG_ERR, loc +
200 QString(
"ParseSegmentInformation: Missing ':' in '%1'")
205 QStringList list = line.mid(
p + 1).split(
',');
210 LOG(VB_RECORD, LOG_ERR, loc +
211 QString(
"ParseSegmentInformation: Missing arguments in '%1'")
216 QString val = list[0];
221 duration = val.toInt(&ok);
225 LOG(VB_RECORD, LOG_ERR, loc +
226 QString(
"ParseSegmentInformation: invalid duration in '%1'")
233 double d = val.toDouble(&ok);
237 LOG(VB_RECORD, LOG_ERR, loc +
238 QString(
"ParseSegmentInformation: invalid duration in '%1'")
242 if ((
d) - ((
int)
d) >= 0.5)
243 duration = ((int)
d) + 1;
248 if (list.size() >= 2)
258 const QString& line,
const QString& loc)
271 LOG(VB_RECORD, LOG_ERR, loc +
"expected #EXT-X-MEDIA-SEQUENCE:<s>");
279 [[maybe_unused]]
bool& aesmsg,
280 const QString& loc, QString &path, QString &iv)
295 LOG(VB_RECORD, LOG_ERR, loc +
"#EXT-X-KEY: expected METHOD=<value>");
299 if (attr.startsWith(QLatin1String(
"NONE")))
304 LOG(VB_RECORD, LOG_ERR, loc +
"#EXT-X-KEY: URI not expected");
313 LOG(VB_RECORD, LOG_ERR, loc +
"#EXT-X-KEY: IV not expected");
318 #ifdef USING_LIBCRYPTO
319 else if (attr.startsWith(QLatin1String(
"AES-128")))
324 LOG(VB_RECORD, LOG_INFO, loc +
325 "playback of AES-128 encrypted HTTP Live media detected.");
331 LOG(VB_RECORD, LOG_ERR, loc +
"#EXT-X-KEY: URI not found for "
332 "encrypted HTTP Live media in AES-128");
337 path =
DecodedURI(uri.remove(QChar(QLatin1Char(
'"'))));
344 LOG(VB_RECORD, LOG_ERR, loc +
345 "invalid encryption type, only NONE "
346 #ifdef USING_LIBCRYPTO
347 "and AES-128 are supported"
367 LOG(VB_RECORD, LOG_DEBUG, loc +
368 QString(
"tag not supported: #EXT-X-PROGRAM-DATE-TIME %1")
385 int pos = line.indexOf(QLatin1String(
":"));
388 LOG(VB_RECORD, LOG_ERR, loc +
389 QString(
"ParseAllowCache: missing ':' in '%1'")
393 QString answer = line.mid(pos+1, 3);
394 if (answer.size() < 2)
396 LOG(VB_RECORD, LOG_ERR, loc +
"#EXT-X-ALLOW-CACHE, ignoring ...");
399 do_cache = (!answer.startsWith(QLatin1String(
"NO")));
407 LOG(VB_RECORD, LOG_DEBUG, loc + QString(
"#EXT-X-DISCONTINUITY %1")
420 LOG(VB_RECORD, LOG_INFO, loc +
"video on demand (vod) mode");