PSSH: Add dump and dumps methods

This commit is contained in:
rlaphoenix 2022-08-05 08:04:54 +01:00
parent 76c7a402eb
commit 2a87d55e20
1 changed files with 15 additions and 0 deletions

View File

@ -213,6 +213,21 @@ class PSSH:
return cls(box) return cls(box)
def dump(self) -> bytes:
"""Export the PSSH object as a full PSSH box in bytes form."""
return Box.build(dict(
type=b"pssh",
version=self.version,
flags=self.flags,
system_ID=self.system_id,
key_IDs=self.key_ids,
init_data=self.init_data
))
def dumps(self) -> str:
"""Export the PSSH object as a full PSSH box in base64 form."""
return base64.b64encode(self.dump()).decode()
@staticmethod @staticmethod
def get_key_ids(box: Container) -> list[UUID]: def get_key_ids(box: Container) -> list[UUID]:
""" """