-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add variable substitution support to HLS parser #2509
Add variable substitution support to HLS parser #2509
Conversation
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.
Looks great for the most part. Thanks!
lib/hls/hls_parser.js
Outdated
if (replaceValue) { | ||
newUri = newUri.replace(variable, replaceValue); | ||
} else { | ||
shaka.log.error(uriVariables, variableName); |
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.
Could you add some text to this log? Without context, it's a bid odd.
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.
I have added more information to the log.
lib/util/error.js
Outdated
@@ -650,6 +650,11 @@ shaka.util.Error.Code = { | |||
*/ | |||
'INCONSISTENT_DRM_ACROSS_PERIODS': 4038, | |||
|
|||
/** | |||
* The HLS manifest requires undeclared variables. |
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.
How about "refers to" instead of "requires". I think that might be clearer.
It might also be good to add the variable name to the error using the "data" array. Just add additional parameters to the new shaka.util.Error()
call and document them 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.
I have added that when the error is launched also include the missing varibale.
test/hls/hls_parser_unit.js
Outdated
goog.asserts.assert( | ||
audioPosition != null, 'Cannot find first audio segment'); | ||
|
||
const videoReference = video.segmentIndex.get(videoPosition); |
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 we refactored the manifest in #1339, SegmentIndex now implements Iterable, so you can now do things like this:
const videoReference = Array.from(video.segmentIndex)[0]
And not worry about positions and null checks.
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.
I have updated the tests to use this new mechanism. Thank you!
test/hls/hls_parser_unit.js
Outdated
expect(videoReference).not.toBe(null); | ||
expect(audioReference).not.toBe(null); | ||
if (videoReference) { | ||
expect(videoReference.getUris()) |
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.
I'm not sure why you check the URIs of the segments, when the test only has variables in the playlist URIs. Could you add comments?
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.
I have added a comment that explains the need for this.
I will review all your comments tomorrow. Thank you! |
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.
Looks good! Thanks!
All tests passed! |
Resolves #1561