PSSH: Add support for Key IDs of lengths other than 16 bytes

This is required for cases like Google's testing DASH manifests, e.g., 'tears' MPD. It assumes the Key ID as a number, which can support up to 16 bytes in this fashion (therefore technically 15 in our scenario as 16 byte Key_IDs can load normally).

Fixes #13
This commit is contained in:
rlaphoenix 2022-09-28 06:21:28 +01:00
parent c5c620ea84
commit e90371922c
1 changed files with 5 additions and 1 deletions

View File

@ -199,7 +199,11 @@ class PSSH:
cenc_header.ParseFromString(self.init_data) cenc_header.ParseFromString(self.init_data)
return [ return [
# the key_ids value may or may not be hex underlying # the key_ids value may or may not be hex underlying
UUID(bytes=key_id) if len(key_id) == 16 else UUID(hex=key_id.decode()) (
UUID(bytes=key_id) if len(key_id) == 16 else # normal
UUID(hex=key_id.decode()) if len(key_id) == 32 else # stored as hex
UUID(int=int.from_bytes(key_id, "big")) # assuming as number
)
for key_id in cenc_header.key_ids for key_id in cenc_header.key_ids
] ]