Skip to content

Commit

Permalink
Added support for showing all tags in fragment metrics
Browse files Browse the repository at this point in the history
Shows all fragment tags, including custom tags in frag object returned.
  • Loading branch information
corca committed May 18, 2016
1 parent 7efc352 commit 79c17b7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/loader/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ class PlaylistLoader extends EventHandler {
result,
regexp,
byteRangeEndOffset,
byteRangeStartOffset;
byteRangeStartOffset,
tagList = [];

regexp = /(?:#EXT-X-(MEDIA-SEQUENCE):(\d+))|(?:#EXT-X-(TARGETDURATION):(\d+))|(?:#EXT-X-(KEY):(.*)[\r\n]+([^#|\r\n]+)?)|(?:#EXT(INF):([\d\.]+)[^\r\n]*([\r\n]+[^#|\r\n]+)?)|(?:#EXT-X-(BYTERANGE):([\d]+[@[\d]*)]*[\r\n]+([^#|\r\n]+)?|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(PROGRAM-DATE-TIME):(.*))/g;
regexp = /(?:#EXT-X-(MEDIA-SEQUENCE):(\d+))|(?:#EXT-X-(TARGETDURATION):(\d+))|(?:#EXT-X-(KEY):(.*)[\r\n]+([^#|\r\n]+)?)|(?:#EXT(INF):([\d\.]+)[^\r\n]*([\r\n]+[^#|\r\n]+)?)|(?:#EXT-X-(BYTERANGE):([\d]+[@[\d]*)]*[\r\n]+([^#|\r\n]+)?|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(PROGRAM-DATE-TIME):(.*))|(?:#EXT-X-(VERSION):(.*))|(?:#(.*):(.*))|(?:#(.*))/g;
while ((result = regexp.exec(string)) !== null) {
result.shift();
result = result.filter(function(n) { return (n !== undefined); });
Expand All @@ -186,11 +187,14 @@ class PlaylistLoader extends EventHandler {
case 'TARGETDURATION':
level.targetduration = parseFloat(result[1]);
break;
case 'VERSION':
break;
case 'ENDLIST':
level.live = false;
break;
case 'DIS':
cc++;
tagList.push(result);
break;
case 'BYTERANGE':
var params = result[1].split('@');
Expand All @@ -204,6 +208,7 @@ class PlaylistLoader extends EventHandler {
frag.byteRangeStartOffset = byteRangeStartOffset;
frag.byteRangeEndOffset = byteRangeEndOffset;
frag.url = this.resolve(result[2], baseurl);
tagList.push(result);
}
break;
case 'INF':
Expand All @@ -212,11 +217,13 @@ class PlaylistLoader extends EventHandler {
var sn = currentSN++;
fragdecryptdata = this.fragmentDecryptdataFromLevelkey(levelkey, sn);
var url = result[2] ? this.resolve(result[2], baseurl) : null;
frag = {url: url, duration: duration, start: totalduration, sn: sn, level: id, cc: cc, byteRangeStartOffset: byteRangeStartOffset, byteRangeEndOffset: byteRangeEndOffset, decryptdata : fragdecryptdata, programDateTime: programDateTime};
tagList.push(result);
frag = {url: url, duration: duration, start: totalduration, sn: sn, level: id, cc: cc, byteRangeStartOffset: byteRangeStartOffset, byteRangeEndOffset: byteRangeEndOffset, decryptdata : fragdecryptdata, programDateTime: programDateTime, tagList: tagList};
level.fragments.push(frag);
totalduration += duration;
byteRangeStartOffset = null;
programDateTime = null;
tagList = [];
}
break;
case 'KEY':
Expand Down Expand Up @@ -245,12 +252,15 @@ class PlaylistLoader extends EventHandler {
//we have not moved onto another segment, we are still parsing one
fragdecryptdata = this.fragmentDecryptdataFromLevelkey(levelkey, currentSN - 1);
frag.decryptdata = fragdecryptdata;
tagList.push(result);
}
break;
case 'PROGRAM-DATE-TIME':
programDateTime = new Date(Date.parse(result[1]));
tagList.push(result);
break;
default:
tagList.push(result);
break;
}
}
Expand Down

0 comments on commit 79c17b7

Please sign in to comment.