-
Notifications
You must be signed in to change notification settings - Fork 793
attach attributes property to playlist objects in cases the m3u8-pars… #1214
Conversation
src/playlist-loader.js
Outdated
@@ -510,6 +508,12 @@ const PlaylistLoader = function(srcUrl, hls, withCredentials) { | |||
playlist = loader.master.playlists[i]; | |||
loader.master.playlists[playlist.uri] = playlist; | |||
playlist.resolvedUri = resolveUrl(loader.master.uri, playlist.uri); | |||
// Although the spec states an #EXT-X-STREAM-INF tag MUST have a | |||
// BANDWIDTH attribute, we can play the stream without it. This means a poorly | |||
// formated master playlist may not have an attribute list. An attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatted
src/playlist-loader.js
Outdated
// formated master playlist may not have an attribute list. An attributes | ||
// property is added here to prevent undefined references when we encounter | ||
// this scenario. | ||
playlist.attributes = playlist.attributes || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to at least have a warning log here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would also be good to have a test for the warning log
src/playlist-loader.js
Outdated
// this scenario. | ||
playlist.attributes = {}; | ||
|
||
log.warn('Invalid playlist STREAM-INF detected. Missing attribute list.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since BANDWIDTH
is the only required attribute, maybe it makes sense to just write something like "Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute."
src/rendition-mixin.js
Outdated
let attributes = playlist.attributes; | ||
// some playlist attributes are optional | ||
if (playlist.attributes.RESOLUTION) { | ||
let resolution = playlist.attributes.RESOLUTION; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of a nitpick, by why let and not const? If statement is the scope and the value doesn't seem to change.
test/playlist-loader.test.js
Outdated
'video2/media.m3u8\n'); | ||
|
||
assert.ok(loader.master, 'infers a master playlist'); | ||
assert.ok(loader.master.playlists[0], 'parsed invalid stream'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, I think the second one is the one that is invalid, but it may be worth checking both.
test/playlist-loader.test.js
Outdated
assert.ok(loader.master, 'infers a master playlist'); | ||
assert.ok(loader.master.playlists[0], 'parsed invalid stream'); | ||
assert.ok(loader.master.playlists[0].attributes, 'attached attributes property'); | ||
assert.equal(this.env.log.warn.calls, 1, 'logged a warning'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also check the warning text.
…er does not
Description
The m3u8-parser does not attach
attributes
property to the playlist object when it is parsing a media playlist or a master manifest that has anEXT-X-STREAM-INF
tag without an attribute list. This has caused someundefined
reference errors asattributes
is not always checked first.Specific Changes proposed
This change attaches
attributes
property to any playlist object returned from the parser that does not have it.addresses #1205