Skip to content
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

Merged
merged 3 commits into from
Jun 24, 2024

Conversation

el-gringo
Copy link

  • A zero-filled keyId makes all streams undecipherable.

fix #1458

- 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)
Copy link
Contributor

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.

Suggested change
return keyId.every(value => value !== 0)
return ! keyId.every(value => value == 0)

Copy link
Author

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.

Copy link
Collaborator

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

Copy link
Author

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.

Copy link
Collaborator

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.

@peaBerberian peaBerberian added this to the 4.1.0 milestone Jun 21, 2024
@peaBerberian peaBerberian added bug This is an RxPlayer issue (unexpected result when comparing to the API) DASH Relative to the DASH streaming protocol Priority: 1 (High) This issue or PR has a high priority. labels Jun 21, 2024
@peaBerberian peaBerberian merged commit a9c6b54 into canalplus:dev Jun 24, 2024
8 of 9 checks passed
@peaBerberian peaBerberian mentioned this pull request Jun 24, 2024
@peaBerberian peaBerberian mentioned this pull request Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is an RxPlayer issue (unexpected result when comparing to the API) DASH Relative to the DASH streaming protocol Priority: 1 (High) This issue or PR has a high priority.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DRM: Zero filled TENC KID cause a NO_PLAYABLE_REPRESENTATION error
4 participants