Cdm: Return the service cert provider id instead of the cert

There's no need for the user to get back the verified DrmCertificate as they could easily get it themselves. Instead return the provider ID which may be more useful to get.
This commit is contained in:
rlaphoenix 2022-07-30 02:50:22 +01:00
parent d1974ad1fb
commit 0bfbbdccc3
1 changed files with 3 additions and 8 deletions

View File

@ -95,7 +95,7 @@ class Cdm:
self.service_certificate: Optional[DrmCertificate] = None self.service_certificate: Optional[DrmCertificate] = None
self.context: dict[bytes, tuple[bytes, bytes]] = {} self.context: dict[bytes, tuple[bytes, bytes]] = {}
def set_service_certificate(self, certificate: Union[bytes, str]) -> DrmCertificate: def set_service_certificate(self, certificate: Union[bytes, str]) -> str:
""" """
Set a Service Privacy Certificate for Privacy Mode. (optional but recommended) Set a Service Privacy Certificate for Privacy Mode. (optional but recommended)
@ -117,16 +117,11 @@ class Cdm:
nor a SignedMessage containing a SignedDrmCertificate. nor a SignedMessage containing a SignedDrmCertificate.
ValueError: If the SignedDrmCertificate signature is invalid. ValueError: If the SignedDrmCertificate signature is invalid.
Returns the parsed and verified DrmCertificate if successful. Returns the Service Provider ID of the verified DrmCertificate if successful.
""" """
if isinstance(certificate, str): if isinstance(certificate, str):
certificate = base64.b64decode(certificate) # assuming base64 certificate = base64.b64decode(certificate) # assuming base64
# All these 3 schemas can sort of parse each other in a minimal buggy way,
# so we have to parse down the full chain instead of relaying each step.
# We also parse fully down to the DrmCertificate before parsing signatures
# for the same reason. The data may not parse at a lower level.
signed_message = SignedMessage() signed_message = SignedMessage()
signed_drm_certificate = SignedDrmCertificate() signed_drm_certificate = SignedDrmCertificate()
@ -155,7 +150,7 @@ class Cdm:
drm_certificate = DrmCertificate() drm_certificate = DrmCertificate()
drm_certificate.ParseFromString(signed_drm_certificate.drm_certificate) drm_certificate.ParseFromString(signed_drm_certificate.drm_certificate)
self.service_certificate = drm_certificate self.service_certificate = drm_certificate
return self.service_certificate return self.service_certificate.provider_id
def get_license_challenge(self, type_: LicenseType = LicenseType.STREAMING, privacy_mode: bool = True) -> bytes: def get_license_challenge(self, type_: LicenseType = LicenseType.STREAMING, privacy_mode: bool = True) -> bytes:
""" """