mirror of
https://github.com/devine-dl/pywidevine.git
synced 2024-10-30 13:39:18 +00:00
PSSH: Allow crafting v0 boxes with just Key IDs
This is actually possible and in some cases necessary. While v0 boxes do not use key_IDs field of the PSSH Box, we can store the provided key_ids in the init data. E.g., Apple Music.
This commit is contained in:
parent
27a701aaea
commit
26d81a7bef
@ -126,11 +126,9 @@ class PSSH:
|
|||||||
if flags < 0:
|
if flags < 0:
|
||||||
raise ValueError(f"Invalid flags, cannot be less than 0.")
|
raise ValueError(f"Invalid flags, cannot be less than 0.")
|
||||||
|
|
||||||
if version == 0:
|
if version == 0 and key_ids is not None and init_data is not None:
|
||||||
if key_ids is not None:
|
# v0 boxes use only init_data in the pssh field, but we can use the key_ids within the init_data
|
||||||
raise ValueError("Version 0 PSSH boxes must use init_data only, not key_ids.")
|
raise ValueError("Version 0 PSSH boxes must use only init_data, not init_data and key_ids.")
|
||||||
if init_data is None:
|
|
||||||
raise ValueError("Version 0 PSSH boxes must use init_data but it wasn't provided.")
|
|
||||||
elif version == 1:
|
elif version == 1:
|
||||||
# TODO: I cannot tell if they need either init_data or key_ids exclusively, or both is fine
|
# TODO: I cannot tell if they need either init_data or key_ids exclusively, or both is fine
|
||||||
# So for now I will just make sure at least one is supplied
|
# So for now I will just make sure at least one is supplied
|
||||||
@ -177,6 +175,9 @@ class PSSH:
|
|||||||
init_data=[init_data, b""][init_data is None]
|
init_data=[init_data, b""][init_data is None]
|
||||||
)))
|
)))
|
||||||
|
|
||||||
|
if key_ids and version == 0:
|
||||||
|
PSSH.overwrite_key_ids(box, [UUID(bytes=x) for x in key_ids])
|
||||||
|
|
||||||
return cls(box)
|
return cls(box)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user