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 : qAsConst(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 const QString& loc, QString &path, QString &iv)
288 #ifndef USING_LIBCRYPTO
298 LOG(VB_RECORD, LOG_ERR, loc +
"#EXT-X-KEY: expected METHOD=<value>");
302 if (attr.startsWith(QLatin1String(
"NONE")))
307 LOG(VB_RECORD, LOG_ERR, loc +
"#EXT-X-KEY: URI not expected");
316 LOG(VB_RECORD, LOG_ERR, loc +
"#EXT-X-KEY: IV not expected");
321 #ifdef USING_LIBCRYPTO
322 else if (attr.startsWith(QLatin1String(
"AES-128")))
327 LOG(VB_RECORD, LOG_INFO, loc +
328 "playback of AES-128 encrypted HTTP Live media detected.");
334 LOG(VB_RECORD, LOG_ERR, loc +
"#EXT-X-KEY: URI not found for "
335 "encrypted HTTP Live media in AES-128");
340 path =
DecodedURI(uri.remove(QChar(QLatin1Char(
'"'))));
347 LOG(VB_RECORD, LOG_ERR, loc +
348 "invalid encryption type, only NONE "
349 #ifdef USING_LIBCRYPTO
350 "and AES-128 are supported"
370 LOG(VB_RECORD, LOG_DEBUG, loc +
371 QString(
"tag not supported: #EXT-X-PROGRAM-DATE-TIME %1")
388 int pos = line.indexOf(QLatin1String(
":"));
391 LOG(VB_RECORD, LOG_ERR, loc +
392 QString(
"ParseAllowCache: missing ':' in '%1'")
396 QString answer = line.mid(pos+1, 3);
397 if (answer.size() < 2)
399 LOG(VB_RECORD, LOG_ERR, loc +
"#EXT-X-ALLOW-CACHE, ignoring ...");
402 do_cache = (!answer.startsWith(QLatin1String(
"NO")));
410 LOG(VB_RECORD, LOG_DEBUG, loc + QString(
"#EXT-X-DISCONTINUITY %1")
423 LOG(VB_RECORD, LOG_INFO, loc +
"video on demand (vod) mode");