Skip to content

Commit

Permalink
Fix lint warnings in m3u8-parser.js in prep for TS conversion. (video…
Browse files Browse the repository at this point in the history
  • Loading branch information
itsjamie authored and johnBartos committed Jan 30, 2019
1 parent dcb3db6 commit a0c28c5
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/loader/m3u8-parser.js
Original file line number Diff line number Diff line change
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

0 comments on commit a0c28c5

Please sign in to comment.