Skip to content

Commit

Permalink
feat: add version parsing and remove totalduration (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored Jan 22, 2021
1 parent 4f4da3d commit 98f0421
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 27 deletions.
14 changes: 5 additions & 9 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ export default class Parser extends Stream {
tag() {
// switch based on the tag type
(({
version() {
if (entry.version) {
this.manifest.version = entry.version;
}
},
'allow-cache'() {
this.manifest.allowCache = entry.allowed;
if (!('allowed' in entry)) {
Expand Down Expand Up @@ -405,15 +410,6 @@ export default class Parser extends Stream {

setHoldBack.call(this, this.manifest);
},
totalduration() {
if (!isFinite(entry.duration) || entry.duration < 0) {
this.trigger('warn', {
message: 'ignoring invalid total duration: ' + entry.duration
});
return;
}
this.manifest.totalDuration = entry.duration;
},
start() {
if (!entry.attributes || isNaN(entry.attributes['TIME-OFFSET'])) {
this.trigger('warn', {
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/integration/allowCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@ module.exports = {
targetDuration: 10,
endList: true,
discontinuitySequence: 0,
discontinuityStarts: []
discontinuityStarts: [],
version: 4
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/allowCacheInvalid.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ module.exports = {
targetDuration: 10,
endList: true,
discontinuitySequence: 0,
discontinuityStarts: []
discontinuityStarts: [],
version: 4
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/byteRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,6 @@ module.exports = {
targetDuration: 10,
endList: true,
discontinuitySequence: 0,
discontinuityStarts: []
discontinuityStarts: [],
version: 3
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/disallowCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ module.exports = {
targetDuration: 10,
endList: true,
discontinuitySequence: 0,
discontinuityStarts: []
discontinuityStarts: [],
version: 4
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/disc-sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ module.exports = {
],
targetDuration: 19,
endList: true,
discontinuityStarts: [2]
discontinuityStarts: [2],
version: 3
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/discontinuity.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ module.exports = {
],
targetDuration: 19,
endList: true,
discontinuityStarts: [2, 4, 7]
discontinuityStarts: [2, 4, 7],
version: 3
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/emptyAllowCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ module.exports = {
targetDuration: 10,
endList: true,
discontinuitySequence: 0,
discontinuityStarts: []
discontinuityStarts: [],
version: 4
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/encrypted.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ module.exports = {
uri: 'http://media.example.com/fileSequence53-B.ts'
}
],
targetDuration: 15
targetDuration: 15,
version: 3
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/extinf.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@ module.exports = {
targetDuration: 10,
endList: true,
discontinuitySequence: 0,
discontinuityStarts: []
discontinuityStarts: [],
version: 3
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/fmp4.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ module.exports = {
}
}
],
endList: true
endList: true,
version: 7
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/invalidAllowCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ module.exports = {
targetDuration: 10,
endList: true,
discontinuitySequence: 0,
discontinuityStarts: []
discontinuityStarts: [],
version: 4
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/invalidTargetDuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,6 @@ module.exports = {
],
endList: true,
discontinuitySequence: 0,
discontinuityStarts: []
discontinuityStarts: [],
version: 4
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/llhls.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,6 @@ module.exports = {
'PART-HOLD-BACK': 1,
'HOLD-BACK': 12
},
targetDuration: 4
targetDuration: 4,
version: 6
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/llhlsDelta.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,6 @@ module.exports = {
'PART-HOLD-BACK': 1,
'HOLD-BACK': 12
},
targetDuration: 4
targetDuration: 4,
version: 9
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/master-fmp4.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,5 +460,6 @@ module.exports = {
timeline: 0,
uri: 'v1/prog_index.m3u8'
}],
segments: []
segments: [],
version: 6
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/missingExtinf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ module.exports = {
targetDuration: 10,
endList: true,
discontinuitySequence: 0,
discontinuityStarts: []
discontinuityStarts: [],
version: 3
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@ module.exports = {
targetDuration: 10,
endList: true,
discontinuitySequence: 0,
discontinuityStarts: []
discontinuityStarts: [],
version: 4
};
3 changes: 2 additions & 1 deletion test/fixtures/integration/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ module.exports = {
start: {
timeOffset: 10.3,
precise: false
}
},
version: 3
};

0 comments on commit 98f0421

Please sign in to comment.