com.brightcove.player.drm

## Class OfflineLicenseManager

- java.lang.Object
- - com.brightcove.player.drm.OfflineLicenseManager

- All Implemented Interfaces:
    BrightcoveDrmSession, DrmSession<com.google.android.exoplayer2.drm.ExoMediaCrypto>, LicenseManager

      public class OfflineLicenseManager
      extends java.lang.Object
      implements LicenseManager, DrmSession<com.google.android.exoplayer2.drm.ExoMediaCrypto>

  Offline license helper can be used to download, renew and release offline playback licenses.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `OfflineLicenseManager.Builder`

  - ### Field Summary

    - ### Fields inherited from interface com.brightcove.player.drm.LicenseManager

      `CR_TOKEN_HEADER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OfflineLicenseManager(com.google.android.exoplayer2.drm.ExoMediaDrm.Provider mediaDrm, com.google.android.exoplayer2.drm.MediaDrmCallback callback, java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters, com.google.android.exoplayer2.drm.DrmSessionEventListener.EventDispatcher drmSessionEventDispatcher)` Deprecated.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `downloadLicense(java.lang.String manifestUriString, CustomerRightsToken customerRightsToken)` Downloads an offline license.
    `DrmException` | `getDrmError()` Deprecated.
    `byte[]` | `getOfflineLicenseKeySetId()` Deprecated.
    `byte[]` | `getPropertyByteArray(java.lang.String propertyName)`
    `java.lang.String` | `getPropertyString(java.lang.String propertyName)` Gets the specified property.
    `android.util.Pair<java.lang.Long,java.lang.Long>` | `getRemainingLicenseDuration(byte[] licenseKeySetId)` Returns license and playback durations remaining in seconds of the given offline license.
    `java.util.Map<java.lang.String,java.lang.String>` | `queryKeyStatus()` Deprecated.
    `void` | `releaseLicense(byte[] licenseKeySetId)` Releases an offline license.
    `void` | `releaseResources()` Releases the used resources.
    `byte[]` | `renewLicense(byte[] licenseKeySetId)` Renews an offline license.
    `void` | `setPropertyByteArray(java.lang.String propertyName, byte[] value)`
    `void` | `setPropertyString(java.lang.String propertyName, java.lang.String value)` Sets the specified property.

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

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

- - ### Constructor Detail

    - #### OfflineLicenseManager

          @Deprecated
          public OfflineLicenseManager(com.google.android.exoplayer2.drm.ExoMediaDrm.Provider mediaDrm,
                                                   com.google.android.exoplayer2.drm.MediaDrmCallback callback,
                                                   java.util.HashMap<java.lang.String,java.lang.String> optionalKeyRequestParameters,
                                                   com.google.android.exoplayer2.drm.DrmSessionEventListener.EventDispatcher drmSessionEventDispatcher)

      Deprecated.
      Deprecated.
      Parameters:
        `mediaDrm` - An underlying `ExoMediaDrm.Provider` for use by the manager.
        `callback` - Performs key and provisioning requests.
        `optionalKeyRequestParameters` - An optional map of parameters to pass as the last argument to `MediaDrm.getKeyRequest(byte[], byte[], String, int, HashMap)`. May be null.
        `drmSessionEventDispatcher` - A `DrmSessionEventListener.EventDispatcher` used to distribute DRM-related events.

  - ### Method Detail

    - #### releaseResources

          public void releaseResources()

      Description copied from interface: `LicenseManager`
      Releases the used resources.
      Specified by:
        `releaseResources` in interface `LicenseManager`

    - #### downloadLicense

          @Nullable
          public byte[] downloadLicense(java.lang.String manifestUriString,
                                                  @NonNull
                                                  CustomerRightsToken customerRightsToken)
                                           throws java.io.IOException,
                                                  DrmException

      Description copied from interface: `LicenseManager`
      Downloads an offline license.
      Specified by:
        `downloadLicense` in interface `LicenseManager`
      Parameters:
        `manifestUriString` - the URL to the DASH manifest file.
        `customerRightsToken` - the customer rights token that describes the license type and limitations.
      Returns:
        The downloaded offline license key set id.
      Throws:
        `java.io.IOException` - If an error occurs while attempt to read the manifest from the stream.
        `DrmException` - Thrown when there is an error during DRM session.

    - #### renewLicense

          @Nullable
          public byte[] renewLicense(byte[] licenseKeySetId)
                                        throws DrmException

      Description copied from interface: `LicenseManager`
      Renews an offline license.
      Specified by:
        `renewLicense` in interface `LicenseManager`
      Parameters:
        `licenseKeySetId` - The key set id of the license to be renewed.
      Returns:
        Renewed offline license key set id.
      Throws:
        `DrmException` - Thrown when there is an error during DRM session.

    - #### releaseLicense

          public void releaseLicense(@Nullable
                                     byte[] licenseKeySetId)
                              throws DrmException

      Description copied from interface: `LicenseManager`
      Releases an offline license.
      Specified by:
        `releaseLicense` in interface `LicenseManager`
      Parameters:
        `licenseKeySetId` - The key set id of the license to be released.
      Throws:
        `DrmException` - Thrown when there is an error during DRM session.

    - #### getRemainingLicenseDuration

          @Nullable
          public android.util.Pair<java.lang.Long,java.lang.Long> getRemainingLicenseDuration(byte[] licenseKeySetId)
                                                                                                 throws DrmException

      Description copied from interface: `LicenseManager`
      Returns license and playback durations remaining in seconds of the given offline license. The `Pair.first` value in the result will provide the remaining license duration as total number of seconds, while `Pair.second` value will provide the remain play duration as total number of seconds.
      Specified by:
        `getRemainingLicenseDuration` in interface `LicenseManager`
      Parameters:
        `licenseKeySetId` - The key set id of the license.
      Throws:
        `DrmException`

    - #### getDrmError

          @Deprecated
          public DrmException getDrmError()

      Deprecated.
      Specified by:
        `getDrmError` in interface `BrightcoveDrmSession`

    - #### queryKeyStatus

          @Deprecated
          public java.util.Map<java.lang.String,java.lang.String> queryKeyStatus()

      Deprecated.
      Specified by:
        `queryKeyStatus` in interface `BrightcoveDrmSession`

    - #### getOfflineLicenseKeySetId

          @Deprecated
          public byte[] getOfflineLicenseKeySetId()

      Deprecated.
      Specified by:
        `getOfflineLicenseKeySetId` in interface `BrightcoveDrmSession`

    - #### getPropertyString

          public java.lang.String getPropertyString(java.lang.String propertyName)

      Description copied from interface: `LicenseManager`
      Gets the specified property.
      Specified by:
        `getPropertyString` in interface `BrightcoveDrmSession`
      Specified by:
        `getPropertyString` in interface `LicenseManager`
      See Also:
        `MediaDrm.getPropertyString(String)`

    - #### getPropertyByteArray

          public byte[] getPropertyByteArray(java.lang.String propertyName)

      Specified by:
        `getPropertyByteArray` in interface `BrightcoveDrmSession`
      See Also:
        `MediaDrm.getPropertyByteArray(String)`

    - #### setPropertyString

          public void setPropertyString(java.lang.String propertyName,
                                        java.lang.String value)

      Description copied from interface: `LicenseManager`
      Sets the specified property.
      Specified by:
        `setPropertyString` in interface `BrightcoveDrmSession`
      Specified by:
        `setPropertyString` in interface `LicenseManager`
      See Also:
        `MediaDrm.setPropertyString(String, String)`

    - #### setPropertyByteArray

          public void setPropertyByteArray(java.lang.String propertyName,
                                           byte[] value)

      Specified by:
        `setPropertyByteArray` in interface `BrightcoveDrmSession`
      See Also:
        `MediaDrm.setPropertyByteArray(String, byte[])`