-
Notifications
You must be signed in to change notification settings - Fork 131
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
fix(isobmff): exclude zero-filled keyId from the init segment parsing #1466
fix(isobmff): exclude zero-filled keyId from the init segment parsing #1466
Conversation
ebd2c68
to
6e984d1
Compare
- A zero-filled keyId makes all streams undecipherable.
return tenc.subarray(8, 24); | ||
const keyId = tenc.subarray(8, 24);!keyId.every(value => value === 0) | ||
// Zero-filled keyId should only be valid for unencrypted content | ||
return keyId.every(value => value !== 0) |
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.
It seems this code returns the keyId
value only if all its bytes are non-zero, which is wrong.
return keyId.every(value => value !== 0) | |
return ! keyId.every(value => value == 0) |
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.
right !
Thanks, I changed my code last minute.
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.
Cool thanks!
Very small nitpick but I find that here:
return keyId.every(...) ? null : keyId
easier to reason about than potentially having to think about what the negative of every
means like here (or at least going through a supplementary step):
return !keyId.every(...) ? keyId : null;
But other than that, LGTM
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.
alright. I test the build then push the update.
By the way. what would trigger the ISOBMFF parsing ? For testing the fix, I have to seek randomly in the stream until it triggers the error, so I know the issue happens at that specific time in the stream, then I apply the patch and seek at that time to check if there is any change in representations.
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.
By the way. what would trigger the ISOBMFF parsing ?
We do it as soon as we have loaded the corresponding initialization segment (this code is called by our DASH "segment parser" - which extracts metadata from a segment - and which is called just after our DASH "segment loader" - which just performs the segment request - succeeds). And we only do that request when we start to buffer the related media.
Here I don't know if the corresponding init segment is linked to a different DASH <Period>
(e.g. like it could be for an ad or a specific live program for example) or if it's another Representation (quality). Because you wrote that it happens at specific times, the most probable is that it's linked to a Period.
Then the logic is that as the init segment contains all the encryption metadata we need anyway, we can parse it to handle cases where the MPD did not have all the information (which is not just theoretical, we worked with partners that did not put the key id in their MPD).
So if we detect supplementary encryption metadata in there, we update the Representation
and signals through our "segment parser"'s return that we did so (through a protectionData
property). This then triggers some checks in our central logic to be sure the added encryption metadata is properly handled.
6e984d1
to
c170d48
Compare
fix #1458