Package com.castlabs.android.drm

## Class CastlabsMediaDrm

- java.lang.Object
- - com.castlabs.android.drm.CastlabsMediaDrm

-     public class CastlabsMediaDrm
      extends Object

  Wrapper of the `FrameworkMediaDrm` allowing asynchronously close the DRM session.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `CastlabsMediaDrm.CastlabsMediaDrmException` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `closeSession​(byte[] sessionId)` | Asynchronously close the session with the given ID
    `void` | `closeSessionSync​(byte[] sessionId)` | Syncroniously close the session with the given ID
    `com.google.android.exoplayer2.drm.FrameworkMediaCrypto` | `createMediaCrypto​(byte[] initData)` |
    `com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest` | `getKeyRequest​(byte[] scope, List<com.google.android.exoplayer2.drm.DrmInitData.SchemeData> schemeDatas, int keyType, HashMap<String,​String> optionalParameters)` |
    `byte[]` | `getPropertyByteArray​(String propertyName)` |
    `String` | `getPropertyString​(String propertyName)` |
    `com.google.android.exoplayer2.drm.ExoMediaDrm.ProvisionRequest` | `getProvisionRequest()` |
    `static CastlabsMediaDrm` | `newInstance​(UUID uuid)` |
    `byte[]` | `openSession()` |
    `byte[]` | `provideKeyResponse​(byte[] scope, byte[] response)` |
    `void` | `provideProvisionResponse​(byte[] response)` |
    `Map<String,​String>` | `queryKeyStatus​(byte[] sessionId)` |
    `void` | `release()` |
    `void` | `releaseAsync()` |
    `void` | `restoreKeys​(byte[] sessionId, byte[] keySetId)` |
    `void` | `setOnEventListener​(com.google.android.exoplayer2.drm.ExoMediaDrm.OnEventListener<? super com.google.android.exoplayer2.drm.FrameworkMediaCrypto> listener)` |
    `void` | `setOnKeyStatusChangeListener​(com.google.android.exoplayer2.drm.ExoMediaDrm.OnKeyStatusChangeListener<? super com.google.android.exoplayer2.drm.FrameworkMediaCrypto> listener)` |
    `void` | `setPropertyByteArray​(String propertyName, byte[] value)` |
    `void` | `setPropertyString​(String propertyName, String value)` |

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### newInstance

          public static CastlabsMediaDrm newInstance​(UUID uuid)
                                              throws com.google.android.exoplayer2.drm.UnsupportedDrmException

      Throws:
        `com.google.android.exoplayer2.drm.UnsupportedDrmException`

    - #### setOnEventListener

          public void setOnEventListener​(com.google.android.exoplayer2.drm.ExoMediaDrm.OnEventListener<? super com.google.android.exoplayer2.drm.FrameworkMediaCrypto> listener)

    - #### setOnKeyStatusChangeListener

          public void setOnKeyStatusChangeListener​(com.google.android.exoplayer2.drm.ExoMediaDrm.OnKeyStatusChangeListener<? super com.google.android.exoplayer2.drm.FrameworkMediaCrypto> listener)

    - #### openSession

          public byte[] openSession()
                             throws NotProvisionedException,
                                    ResourceBusyException,
                                    MediaDrmException

      Throws:
        `NotProvisionedException`
        `ResourceBusyException`
        `MediaDrmException`

    - #### closeSession

          public void closeSession​(byte[] sessionId)

      Asynchronously close the session with the given ID
      Parameters:
        `sessionId` - The session ID

    - #### closeSessionSync

          public void closeSessionSync​(byte[] sessionId)

      Syncroniously close the session with the given ID
      Parameters:
        `sessionId` - The session ID

    - #### getKeyRequest

          public com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest getKeyRequest​(byte[] scope,
                                                                                        @Nullable
                                                                                        List<com.google.android.exoplayer2.drm.DrmInitData.SchemeData> schemeDatas,
                                                                                        int keyType,
                                                                                        HashMap<String,​String> optionalParameters)
                                                                                 throws NotProvisionedException

      Throws:
        `NotProvisionedException`

    - #### provideKeyResponse

          public byte[] provideKeyResponse​(byte[] scope,
                                           byte[] response)
                                    throws NotProvisionedException,
                                           DeniedByServerException

      Throws:
        `NotProvisionedException`
        `DeniedByServerException`

    - #### getProvisionRequest

          public com.google.android.exoplayer2.drm.ExoMediaDrm.ProvisionRequest getProvisionRequest()

    - #### provideProvisionResponse

          public void provideProvisionResponse​(byte[] response)
                                        throws DeniedByServerException

      Throws:
        `DeniedByServerException`

    - #### queryKeyStatus

          public Map<String,​String> queryKeyStatus​(byte[] sessionId)

    - #### release

          public void release()

    - #### releaseAsync

          public void releaseAsync()

    - #### restoreKeys

          public void restoreKeys​(byte[] sessionId,
                                  byte[] keySetId)

    - #### getPropertyString

          public String getPropertyString​(String propertyName)

    - #### getPropertyByteArray

          public byte[] getPropertyByteArray​(String propertyName)

    - #### setPropertyString

          public void setPropertyString​(String propertyName,
                                        String value)

    - #### setPropertyByteArray

          public void setPropertyByteArray​(String propertyName,
                                           byte[] value)

    - #### createMediaCrypto

          public com.google.android.exoplayer2.drm.FrameworkMediaCrypto createMediaCrypto​(byte[] initData)
                                                                                   throws MediaCryptoException

      Throws:
        `MediaCryptoException`