Package com.castlabs.android.drm

# Class DrmConfiguration

java.lang.Object
com.castlabs.android.drm.DrmConfiguration

All Implemented Interfaces:
  `Parcelable`

Direct Known Subclasses:
  `DrmTodayConfiguration`

public class DrmConfiguration extends Object implements Parcelable
Basic DRM configuration that can be used to query keys from a widevine proxy. Please note that this is not sufficient in combination with DRMToday. To query keys from DRMToday, please use the `DrmTodayConfiguration` configuration instead.

See Also:
  - `DrmTodayConfiguration`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `DrmConfiguration.Builder`
  A builder implementation to create instances of `DrmConfiguration`s

  ## Nested classes/interfaces inherited from interface android.os.Parcelable

  `Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final Drm`
  `audioDrm`
  The DRM system used for audio tracks.
  `static final Parcelable.Creator<DrmConfiguration>`
  `CREATOR`
  Parcelable creator for DrmConfiguration
  `static final DrmConfiguration`
  `DEFAULT`
  Default DRM configuration instance
  `final Drm`
  `drm`
  The default DRM system.
  `final boolean`
  `forceWidevineL3`
  If set to true, Widevine L3 will be enforced.
  `final boolean`
  `keyRotation`
  Enforce Key-Rotation support also on older devices before Android M.
  `final Bundle`
  `mediaDrmProperties`
  This bundle contains key-value pairs as the properties of Widevine mediaDrm.
  `final String`
  `offlineId`
  This is used to identify this DRM Configuration and its asset when storing offline keys.
  `final boolean`
  `playClearSamplesWithoutKeys`
  If true, clear samples will be played while the key is fetched
  `final boolean`
  `preferManifestUrl`
  If true, then any non-empty DRM URL found in the manifest will be used instead of `url` Default is `PlayerSDK.DEFAULT_DRM_PREFER_MANIFEST_URL`
  `final long`
  `renewalThresholdMs`
  If set to non-zero and non-negative value then the Widevine license will be automatically renewed before `renewalThresholdMs` milliseconds of license expiration.
  `final Bundle`
  `requestParameters`
  Bundle that can be used to put additional request (header) parameters that will be send to the DRM backend during license requests.
  `final String`
  `url`
  The proxy URL

  ### Fields inherited from interface android.os.Parcelable

  `CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DrmConfiguration(String url, boolean playClearSamplesWithoutKeys)`
  Deprecated.
  Use `DrmConfiguration.Builder`
  `DrmConfiguration(String url, boolean playClearSamplesWithoutKeys, Drm drm)`
  Deprecated.
  Use `DrmConfiguration.Builder`
  `DrmConfiguration(String url, boolean playClearSamplesWithoutKeys, Drm drm, Drm audioDrm, String offlineId)`
  Deprecated.
  Use `DrmConfiguration.Builder`
  `DrmConfiguration(String url, boolean playClearSamplesWithoutKeys, Drm drm, Drm audioDrm, String offlineId, Bundle requestParameters)`
  Deprecated.
  Use `DrmConfiguration.Builder`
  `DrmConfiguration(String url, boolean playClearSamplesWithoutKeys, Drm drm, Drm audioDrm, String offlineId, Bundle requestParameters, boolean keyRotation, boolean forceWidevineL3)`
  Deprecated.
  Use `DrmConfiguration.Builder`
  `DrmConfiguration(String url, boolean playClearSamplesWithoutKeys, Drm drm, Drm audioDrm, String offlineId, Bundle requestParameters, boolean keyRotation, boolean forceWidevineL3, long renewalThresholdMs)`
  Deprecated.
  Use `DrmConfiguration.Builder`
  `DrmConfiguration(String url, boolean playClearSamplesWithoutKeys, Drm drm, Drm audioDrm, String offlineId, Bundle requestParameters, boolean keyRotation, boolean forceWidevineL3, long renewalThresholdMs, Bundle mediaDrmProperties, boolean preferManifestUrl)`
  Deprecated.
  The constructor will have access level protected, use `DrmConfiguration.Builder` if not extending
  `DrmConfiguration(String url, boolean playClearSamplesWithoutKeys, Drm drm, String offlineId)`
  Deprecated.
  Use `DrmConfiguration.Builder`
  `DrmConfiguration(String url, boolean playClearSamplesWithoutKeys, String offlineId)`
  Deprecated.
  Use `DrmConfiguration.Builder`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `describeContents()`
  `boolean`
  `equals(Object obj)`
  `SecurityLevel`
  `getSecurityLevel()`
  Gets the security level for the selected DRM on this device.
  `int`
  `hashCode()`
  `boolean`
  `renewalEnabled()`
  Checks if license renewal is enabled in the current configuration.
  `Drm`
  `resolvedAudioDrm()`
  The best available DRM if no explicit DRM was specified.
  `Drm`
  `resolvedDrm()`
  The best available DRM if no explicit DRM was specified
  `String`
  `toString()`
  `void`
  `writeToParcel(Parcel dest, int flags)`

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

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### CREATOR

    public static final Parcelable.Creator<DrmConfiguration> CREATOR
    Parcelable creator for DrmConfiguration

  - ### DEFAULT

    @NonNull public static final DrmConfiguration DEFAULT
    Default DRM configuration instance

  - ### url

    @Nullable public final String url
    The proxy URL

  - ### preferManifestUrl

    public final boolean preferManifestUrl
    If true, then any non-empty DRM URL found in the manifest will be used instead of `url` Default is `PlayerSDK.DEFAULT_DRM_PREFER_MANIFEST_URL`

  - ### playClearSamplesWithoutKeys

    public final boolean playClearSamplesWithoutKeys
    If true, clear samples will be played while the key is fetched

  - ### offlineId

    @Nullable public final String offlineId
    This is used to identify this DRM Configuration and its asset when storing offline keys. Offline key storage is disabled if this is `null`.

  - ### drm

    @NonNull public final Drm drm
    The default DRM system. This is the requested DRM. If BestAvailable, use `resolvedDrm()` to get the one used on the device.

  - ### audioDrm

    @NonNull public final Drm audioDrm
    The DRM system used for audio tracks. If this is null `drm` will be used for both video and audio. This is the requested DRM. If BestAvailable, use `resolvedAudioDrm()` to get the one used on the device.

  - ### requestParameters

    @NonNull public final Bundle requestParameters
    Bundle that can be used to put additional request (header) parameters that will be send to the DRM backend during license requests.

    Note that all values need to be of type String!

  - ### keyRotation

    public final boolean keyRotation
    Enforce Key-Rotation support also on older devices before Android M. This is primarily indented for live content with changing keys where we need to enable session sharing support on older devices to make sure we can rotate keys.

  - ### forceWidevineL3

    public final boolean forceWidevineL3
    If set to true, Widevine L3 will be enforced. Note that this will prevent playback of DRM content where the license requires L1 security.

    This flag can be set for certain devices that are known to have broken secure decoder implementation to allow Widevine protected content playback.

  - ### renewalThresholdMs

    public final long renewalThresholdMs
    If set to non-zero and non-negative value then the Widevine license will be automatically renewed before `renewalThresholdMs` milliseconds of license expiration. Set to `C.TIME_UNSET` to disable the license renewal (default).

    Note: `offlineId` has to be set to a non-null and non-empty value as well

  - ### mediaDrmProperties

    @NonNull public final Bundle mediaDrmProperties
    This bundle contains key-value pairs as the properties of Widevine mediaDrm. Only values which are instances of String or byte[] will be applied and other value types will be ignored.

- ## Constructor Details

  - ### DrmConfiguration

    @Deprecated public DrmConfiguration(@Nullable String url, boolean playClearSamplesWithoutKeys)
    Deprecated.
    Use `DrmConfiguration.Builder`
    Create a new configuration with an empty offline id
    Parameters:
      `url` - The license server URL
      `playClearSamplesWithoutKeys` - True if clear sample will be played while fetching the key

  - ### DrmConfiguration

    @Deprecated public DrmConfiguration(@Nullable String url, boolean playClearSamplesWithoutKeys, @Nullable String offlineId)
    Deprecated.
    Use `DrmConfiguration.Builder`
    Create a new configuration using the best available DRM on the device
    Parameters:
      `url` - The license server URL
      `playClearSamplesWithoutKeys` - True if clear sample will be played while fetching the key
      `offlineId` - The ID used to identify this asset when storing offline keys

  - ### DrmConfiguration

    @Deprecated public DrmConfiguration(@Nullable String url, boolean playClearSamplesWithoutKeys, @Nullable Drm drm)
    Deprecated.
    Use `DrmConfiguration.Builder`
    Create a new configuration using the best available DRM on the device
    Parameters:
      `url` - The license server URL
      `playClearSamplesWithoutKeys` - True if clear sample will be played while fetching the key
      `drm` - The DRM system

  - ### DrmConfiguration

    @Deprecated public DrmConfiguration(@Nullable String url, boolean playClearSamplesWithoutKeys, @Nullable Drm drm, @Nullable String offlineId)
    Deprecated.
    Use `DrmConfiguration.Builder`
    Create a new configuration
    Parameters:
      `url` - The license server URL
      `playClearSamplesWithoutKeys` - True if clear sample will be played while fetching the key
      `drm` - The DRM system
      `offlineId` - The ID used to identify this asset when storing offline keys

  - ### DrmConfiguration

    @Deprecated public DrmConfiguration(@Nullable String url, boolean playClearSamplesWithoutKeys, @Nullable Drm drm, @Nullable Drm audioDrm, @Nullable String offlineId)
    Deprecated.
    Use `DrmConfiguration.Builder`
    Create a new configuration
    Parameters:
      `url` - The license server URL
      `playClearSamplesWithoutKeys` - True if clear sample will be played while fetching the key
      `drm` - The DRM system
      `audioDrm` - The DRM system used for audio tracks. If this is null, the main drm system will be used also for audio tracks
      `offlineId` - The ID used to identify this asset when storing offline keys

  - ### DrmConfiguration

    @Deprecated public DrmConfiguration(@Nullable String url, boolean playClearSamplesWithoutKeys, @Nullable Drm drm, @Nullable Drm audioDrm, @Nullable String offlineId, @NonNull Bundle requestParameters)
    Deprecated.
    Use `DrmConfiguration.Builder`
    Create a new configuration
    Parameters:
      `url` - The license server URL
      `playClearSamplesWithoutKeys` - True if clear sample will be played while fetching the key
      `drm` - The DRM system
      `audioDrm` - The DRM system used for audio tracks. If this is null, the main drm system will be used also for audio tracks
      `offlineId` - The ID used to identify this asset when storing offline keys
      `requestParameters` - The bundle with additional request parameters

  - ### DrmConfiguration

    @Deprecated public DrmConfiguration(@Nullable String url, boolean playClearSamplesWithoutKeys, @Nullable Drm drm, @Nullable Drm audioDrm, @Nullable String offlineId, @NonNull Bundle requestParameters, boolean keyRotation, boolean forceWidevineL3)
    Deprecated.
    Use `DrmConfiguration.Builder`
    Create a new configuration
    Parameters:
      `url` - The license server URL
      `playClearSamplesWithoutKeys` - True if clear sample will be played while fetching the key
      `drm` - The DRM system
      `audioDrm` - The DRM system used for audio tracks. If this is null, the main drm system will be used also for audio tracks
      `offlineId` - The ID used to identify this asset when storing offline keys
      `requestParameters` - The bundle with additional request parameters
      `keyRotation` - Enable key rotation also on older devices
      `forceWidevineL3` - Force Widevine L3

  - ### DrmConfiguration

    @Deprecated public DrmConfiguration(@Nullable String url, boolean playClearSamplesWithoutKeys, @Nullable Drm drm, @Nullable Drm audioDrm, @Nullable String offlineId, @NonNull Bundle requestParameters, boolean keyRotation, boolean forceWidevineL3, long renewalThresholdMs)
    Deprecated.
    Use `DrmConfiguration.Builder`
    Create a new configuration
    Parameters:
      `url` - The license server URL
      `playClearSamplesWithoutKeys` - True if clear sample will be played while fetching the key
      `drm` - The DRM system
      `audioDrm` - The DRM system used for audio tracks. If this is null, the main drm system will be used also for audio tracks
      `offlineId` - The ID used to identify this asset when storing offline keys
      `requestParameters` - The bundle with additional request parameters
      `keyRotation` - Enable key rotation also on older devices
      `forceWidevineL3` - Force Widevine L3
      `renewalThresholdMs` - License renewal threshold in milliseconds or `C.TIME_UNSET` to disable renewals, see `renewalThresholdMs`

  - ### DrmConfiguration

    @Deprecated public DrmConfiguration(@Nullable String url, boolean playClearSamplesWithoutKeys, @Nullable Drm drm, @Nullable Drm audioDrm, @Nullable String offlineId, @NonNull Bundle requestParameters, boolean keyRotation, boolean forceWidevineL3, long renewalThresholdMs, @NonNull Bundle mediaDrmProperties, boolean preferManifestUrl)
    Deprecated.
    The constructor will have access level protected, use `DrmConfiguration.Builder` if not extending
    Create a new configuration
    Parameters:
      `url` - The license server URL
      `playClearSamplesWithoutKeys` - True if clear sample will be played while fetching the key
      `drm` - The DRM system
      `audioDrm` - The DRM system used for audio tracks. If this is null, the main drm system will be used also for audio tracks
      `offlineId` - The ID used to identify this asset when storing offline keys
      `requestParameters` - The bundle with additional request parameters
      `keyRotation` - Enable key rotation also on older devices
      `forceWidevineL3` - Force Widevine L3
      `renewalThresholdMs` - License renewal threshold in milliseconds or `C.TIME_UNSET` to disable renewals, see `renewalThresholdMs`
      `mediaDrmProperties` - The properties of mediaDrm
      `preferManifestUrl` - True, then any non-empty DRM URL found in the manifest will be used instead of `url`

- ## Method Details

  - ### resolvedDrm

    @Nullable public Drm resolvedDrm()
    The best available DRM if no explicit DRM was specified
    Returns:
      The source DRM or the best available DRM if the source selection is `Drm.BestAvailable` or `null` if no supported DRM was found

  - ### resolvedAudioDrm

    @Nullable public Drm resolvedAudioDrm()
    The best available DRM if no explicit DRM was specified.
    Returns:
      Selects the audio drm system based on the given selection and the device

  - ### getSecurityLevel

    @NonNull public SecurityLevel getSecurityLevel()
    Gets the security level for the selected DRM on this device.
    Returns:
      the security level for the selected DRM on this device or `SecurityLevel.SOFTWARE` if the selected DRM is not supported by the devices and the security level can not be determined.

  - ### renewalEnabled

    public boolean renewalEnabled()
    Checks if license renewal is enabled in the current configuration.
    Returns:
      `true` if the renewal is enabled in the current configuration, otherwise `false`. See `renewalThresholdMs`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### describeContents

    public int describeContents()
    Specified by:
      `describeContents` in interface `Parcelable`

  - ### writeToParcel

    public void writeToParcel(Parcel dest, int flags)
    Specified by:
      `writeToParcel` in interface `Parcelable`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`