Interface ExoMediaDrm

  • All Known Implementing Classes:
    DummyExoMediaDrm, FakeExoMediaDrm, FrameworkMediaDrm

    public interface ExoMediaDrm
    Used to obtain keys for decrypting protected media streams.

    Reference counting

    Access to an instance is managed by reference counting, where acquire() increments the reference count and release() decrements it. When the reference count drops to 0 underlying resources are released, and the instance cannot be re-used.

    Each new instance has an initial reference count of 1. Hence application code that creates a new instance does not normally need to call acquire(), and must call release() when the instance is no longer required.

    See Also:
    MediaDrm
    • Field Detail

      • EVENT_KEY_REQUIRED

        static final int EVENT_KEY_REQUIRED
        Event indicating that keys need to be requested from the license server.
        See Also:
        Constant Field Values
      • EVENT_KEY_EXPIRED

        static final int EVENT_KEY_EXPIRED
        Event indicating that keys have expired, and are no longer usable.
        See Also:
        Constant Field Values
      • EVENT_PROVISION_REQUIRED

        static final int EVENT_PROVISION_REQUIRED
        Event indicating that a certificate needs to be requested from the provisioning server.
        See Also:
        Constant Field Values
      • KEY_TYPE_STREAMING

        static final int KEY_TYPE_STREAMING
        Key request type for keys that will be used for online use. Streaming keys will not be saved to the device for subsequent use when the device is not connected to a network.
        See Also:
        Constant Field Values
      • KEY_TYPE_OFFLINE

        static final int KEY_TYPE_OFFLINE
        Key request type for keys that will be used for offline use. They will be saved to the device for subsequent use when the device is not connected to a network.
        See Also:
        Constant Field Values
      • KEY_TYPE_RELEASE

        static final int KEY_TYPE_RELEASE
        Key request type indicating that saved offline keys should be released.
        See Also:
        Constant Field Values
    • Method Detail

      • closeSession

        void closeSession​(byte[] sessionId)
        Closes a DRM session.
        Parameters:
        sessionId - The ID of the session to close.
      • setPlayerIdForSession

        default void setPlayerIdForSession​(byte[] sessionId,
                                           PlayerId playerId)
        Sets the PlayerId of the player using a session.
        Parameters:
        sessionId - The ID of the session.
        playerId - The PlayerId of the player using the session.
      • getProvisionRequest

        ExoMediaDrm.ProvisionRequest getProvisionRequest()
        Generates a provisioning request.
        Returns:
        The generated provisioning request.
      • provideProvisionResponse

        void provideProvisionResponse​(byte[] response)
                               throws DeniedByServerException
        Provides a provisioning response for the last request to be generated using getProvisionRequest().
        Parameters:
        response - The response data from the server.
        Throws:
        DeniedByServerException - If the response indicates that the server rejected the request.
      • queryKeyStatus

        Map<String,​String> queryKeyStatus​(byte[] sessionId)
        Returns the key status for a given session, as {name, value} pairs. Since DRM license policies vary by vendor, the returned entries depend on the DRM plugin being used. Refer to your DRM provider's documentation for more information.
        Parameters:
        sessionId - The ID of the session being queried.
        Returns:
        The key status for the session.
      • requiresSecureDecoder

        boolean requiresSecureDecoder​(byte[] sessionId,
                                      String mimeType)
        Returns whether the given session requires use of a secure decoder for the given MIME type. Assumes a license policy that requires the highest level of security supported by the session.
        Parameters:
        sessionId - The ID of the session.
        mimeType - The content MIME type to query.
      • acquire

        void acquire()
        Increments the reference count. When the caller no longer needs to use the instance, it must call release() to decrement the reference count.

        A new instance will have an initial reference count of 1, and therefore it is not normally necessary for application code to call this method.

      • release

        void release()
        Decrements the reference count. If the reference count drops to 0 underlying resources are released, and the instance cannot be re-used.
      • restoreKeys

        void restoreKeys​(byte[] sessionId,
                         byte[] keySetId)
        Restores persisted offline keys into a session.
        Parameters:
        sessionId - The ID of the session into which the keys will be restored.
        keySetId - The keySetId of the keys to restore, as provided by the call to provideKeyResponse(byte[], byte[]) that persisted them.
      • getMetrics

        @Nullable
        PersistableBundle getMetrics()
        Returns metrics data for this ExoMediaDrm instance, or null if metrics are unavailable.
      • setPropertyString

        void setPropertyString​(String propertyName,
                               String value)
        Sets the value of a string property.
        Parameters:
        propertyName - The property name.
        value - The value.
        Throws:
        IllegalArgumentException - If the underlying DRM plugin does not support the property.
      • setPropertyByteArray

        void setPropertyByteArray​(String propertyName,
                                  byte[] value)
        Sets the value of a byte array property.
        Parameters:
        propertyName - The property name.
        value - The value.
        Throws:
        IllegalArgumentException - If the underlying DRM plugin does not support the property.