ContentProtectionIntegration

@objc(THEOplayerContentProtectionIntegration)
public protocol ContentProtectionIntegration

This ContentProtectionIntegration defines some methods to alter license and certificate requests and responses.

  • Handler which will be called when an HTTP request for a new certificate is about to be sent.

    Remark

    Remark:

    • If a valid certificate was provided as part of the KeySystemConfiguration.certificate, this handler will not be called.
    • The handler must return either a request or a raw certificate. When a (possibly modified) request is returned, the player will send that request instead of the original request. When a raw certificate is returned, the request is skipped entirely and the certificate is used directly. If no handler is provided, the player sends the original request.
    • For example, an integration may want to “wrap” the request body in a different format (e.g. JSON or XML) for certain DRM vendors, or add additional authentication tokens to the request. Alternatively, an integration may want to send the HTTP request using its own network stack, and return the final certificate response to the player.

    Declaration

    Swift

    @objc
    optional func onCertificateRequest(request: CertificateRequest, callback: CertificateRequestCallback)

    Parameters

    request

    The CertificateRequest that is about to be sent.

    callback

    The CertificateRequestCallback that should be called with the modified CertificateRequest.

  • Handler which will be called when an HTTP request for a certificate returns a response.

    Remark

    Remark:

    • The completion handler callback will be called regardless of the HTTP status code on the response (i.e. also for unsuccessful statuses outside of the 200-299 range).
    • The completion handler callback must return the raw certificate, in a manner suitable for further processing by the CDM. If no completion handler is provided, the player uses the response body as raw certificate, but only if the response’s status indicates success.
    • For example, an integration may want to “unwrap” a wrapped JSON or XML response body, turning it into a raw certificate.

    Declaration

    Swift

    @objc
    optional func onCertificateResponse(response: CertificateResponse, callback: CertificateResponseCallback)

    Parameters

    response

    The CertificateResponse that was returned from the certificate request.

    callback

    The CertificateResponseCallback completion handler that should be called with the modified CertificateResponse.

  • Handler which will be called when an HTTP request for a new license is about to be sent.

    Remark

    Remark:

    • The completion handler callback must return either a request or a raw license. When a (possibly modified) request is returned, the player will send that request instead of the original request. When a raw license is returned, the request is skipped entirely and the license is used directly. If no handler is provided, the player sends the original request.
    • For example, an integration may want to “wrap” the request body in a different format (e.g. JSON or XML) for certain DRM vendors, or add additional authentication tokens to the request. Alternatively, an integration may want to send the HTTP request using its own network stack, and return the final license response to the player.

    Declaration

    Swift

    @objc
    optional func onLicenseRequest(request: LicenseRequest, callback: LicenseRequestCallback)

    Parameters

    request

    The LicenseRequest that is about to be sent.

    callback

    The LicenseRequestCallback that should be called with the modified LicenseRequest.

  • Handler which will be called when an HTTP request for a license returns an response.

    Remark

    Remark:

    • The completion handler callback will be called regardless of the HTTP status code on the response (i.e. also for unsuccessful statuses outside of the 200-299 range).
    • The completion handler callback must return the raw license, in a manner suitable for further processing by the CDM.
    • If no completion handler is provided, the player uses the response body as raw license, but only if the response’s status indicates success. For example, an integration may want to “unwrap” a wrapped JSON or XML response body, turning it into a raw license.

    Declaration

    Swift

    @objc
    optional func onLicenseResponse(response: LicenseResponse, callback: LicenseResponseCallback)

    Parameters

    response

    The LicenseResponse that was returned from the license request.

    callback

    The LicenseResponseCallback that should be called with the modified LicenseResponse.

  • A function to extract the Fairplay content ID from the key URI, as given by the URI attribute of the #EXT-X-KEY tag in the HLS playlist (m3u8).

    Since

    v5.4.1

    Remark

    Remark:

    • In order to start a Fairplay license request, the player must provide the initialization data, the content ID and the certificate to the CDM.
    • The content ID is usually contained in the key URI in some vendor-specific way, for example in the host name (e.g. skd://123456789) or in the URL query (e.g. skd://vendor?123456789). This function should extract this content ID from the key URI.
    • This method is required only for Fairplay integrations. It is ignored for other key systems.

    Declaration

    Swift

    @objc
    optional func onExtractFairplayContentId(skdUrl: String, callback: ExtractContentIdCallback)

    Parameters

    skdUrl

    The orignal key URI.

    callback

    The ExtractContentIdCallback completion handler that should be called with the modified content ID.