Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint warnings in m3u8-parser.js in prep for TS conversion. #2106

Merged
merged 1 commit into from Jan 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 20 additions & 16 deletions src/loader/m3u8-parser.js
Expand Up @@ -48,7 +48,8 @@ export default class M3U8Parser {
}

static convertAVC1ToAVCOTI (codec) {
let result, avcdata = codec.split('.');
let avcdata = codec.split('.');
let result;
if (avcdata.length > 2) {
result = avcdata.shift() + '.';
result += parseInt(avcdata.shift()).toString(16);
Expand All @@ -64,7 +65,7 @@ export default class M3U8Parser {
}

static parseMasterPlaylist (string, baseurl) {
let levels = [], result;
let levels = [];
MASTER_PLAYLIST_REGEX.lastIndex = 0;

function setCodecs (codecs, level) {
Expand All @@ -84,6 +85,7 @@ export default class M3U8Parser {
level.unknownCodecs = codecs;
}

let result;
while ((result = MASTER_PLAYLIST_REGEX.exec(string)) != null) {
const level = {};

Expand Down Expand Up @@ -206,7 +208,7 @@ export default class M3U8Parser {
} else {
result = result[0].match(LEVEL_PLAYLIST_REGEX_SLOW);
for (i = 1; i < result.length; i++) {
if (result[i] !== undefined) {
if (typeof result[i] !== 'undefined') {
break;
}
}
Expand Down Expand Up @@ -243,13 +245,14 @@ export default class M3U8Parser {
case 'DISCONTINUITY-SEQ':
cc = parseInt(value1);
break;
case 'KEY':
case 'KEY': {
// https://tools.ietf.org/html/draft-pantos-http-live-streaming-08#section-3.4.4
var decryptparams = value1;
var keyAttrs = new AttrList(decryptparams);
var decryptmethod = keyAttrs.enumeratedString('METHOD'),
decrypturi = keyAttrs.URI,
decryptiv = keyAttrs.hexadecimalInteger('IV');
const decryptparams = value1;
const keyAttrs = new AttrList(decryptparams);
const decryptmethod = keyAttrs.enumeratedString('METHOD');
const decrypturi = keyAttrs.URI;
const decryptiv = keyAttrs.hexadecimalInteger('IV');

if (decryptmethod) {
levelkey = new LevelKey();
if ((decrypturi) && (['AES-128', 'SAMPLE-AES', 'SAMPLE-AES-CENC'].indexOf(decryptmethod) >= 0)) {
Expand All @@ -263,18 +266,18 @@ export default class M3U8Parser {
}
}
break;
case 'START':
let startParams = value1;
let startAttrs = new AttrList(startParams);
let startTimeOffset = startAttrs.decimalFloatingPoint('TIME-OFFSET');
}
case 'START': {
const startAttrs = new AttrList(value1);
const startTimeOffset = startAttrs.decimalFloatingPoint('TIME-OFFSET');
// TIME-OFFSET can be 0
if (Number.isFinite(startTimeOffset)) {
level.startTimeOffset = startTimeOffset;
}

break;
case 'MAP':
let mapAttrs = new AttrList(value1);
}
case 'MAP': {
const mapAttrs = new AttrList(value1);
frag.relurl = mapAttrs.URI;
frag.rawByteRange = mapAttrs.BYTERANGE;
frag.baseurl = baseurl;
Expand All @@ -285,6 +288,7 @@ export default class M3U8Parser {
frag = new Fragment();
frag.rawProgramDateTime = level.initSegment.rawProgramDateTime;
break;
}
default:
logger.warn(`line parsed but not handled: ${result}`);
break;
Expand Down