Package com.castlabs.sdk.base.subtitles.utilities

# Class DrmInitData

java.lang.Object
com.castlabs.sdk.base.subtitles.utilities.DrmInitData

All Implemented Interfaces:
  `Parcelable`, `Comparator<DrmInitData.SchemeData>`

public final class DrmInitData extends Object implements Comparator<DrmInitData.SchemeData>, Parcelable
Initialization data for one or more DRM schemes.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `DrmInitData.SchemeData`
  Scheme initialization data.

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

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

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Parcelable.Creator<DrmInitData>`
  `CREATOR`
  `final int`
  `schemeDataCount`
  Number of `DrmInitData.SchemeData`s.
  `final String`
  `schemeType`
  The protection scheme type, or null if not applicable or unknown.

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

  `CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DrmInitData(DrmInitData.SchemeData... schemeDatas)`
  `DrmInitData(String schemeType, DrmInitData.SchemeData... schemeDatas)`
  `DrmInitData(String schemeType, List<DrmInitData.SchemeData> schemeDatas)`
  `DrmInitData(List<DrmInitData.SchemeData> schemeDatas)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compare(DrmInitData.SchemeData first, DrmInitData.SchemeData second)`
  `DrmInitData`
  `copyWithSchemeType(String schemeType)`
  Returns a copy with the specified protection scheme type.
  `static DrmInitData`
  `createSessionCreationData(DrmInitData manifestData, DrmInitData mediaData)`
  Merges `DrmInitData` obtained from a media manifest and a media stream.
  `int`
  `describeContents()`
  `boolean`
  `equals(Object obj)`
  `DrmInitData.SchemeData`
  `get(int index)`
  Retrieves the `DrmInitData.SchemeData` at a given index.
  `DrmInitData.SchemeData`
  `get(UUID uuid)`
  Deprecated.
  Use `get(int)` and `DrmInitData.SchemeData.matches(UUID)` instead.
  `boolean`
  `hasEqualSchemeDatas(DrmInitData other)`
  Returns whether the DrmInitData has equal `DrmInitData.SchemeData`s to the one provided.
  `int`
  `hashCode()`
  `boolean`
  `hasMatchingSchemeData(DrmInitData other)`
  Returns whether the DrmInitData has at least one equal `DrmInitData.SchemeData` to the one provided.
  `DrmInitData`
  `merge(DrmInitData drmInitData)`
  Returns an instance containing the `schemeDatas` from both this and `other`.
  `void`
  `writeToParcel(Parcel dest, int flags)`

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

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

  ### Methods inherited from interface java.util.Comparator

  `reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- ## Field Details

  - ### schemeType

    @Nullable public final String schemeType
    The protection scheme type, or null if not applicable or unknown.

  - ### schemeDataCount

    public final int schemeDataCount
    Number of `DrmInitData.SchemeData`s.

  - ### CREATOR

    public static final Parcelable.Creator<DrmInitData> CREATOR

- ## Constructor Details

  - ### DrmInitData

    public DrmInitData(List<DrmInitData.SchemeData> schemeDatas)
    Parameters:
      `schemeDatas` - Scheme initialization data for possibly multiple DRM schemes.

  - ### DrmInitData

    public DrmInitData(@Nullable String schemeType, List<DrmInitData.SchemeData> schemeDatas)
    Parameters:
      `schemeType` - See `schemeType`.
      `schemeDatas` - Scheme initialization data for possibly multiple DRM schemes.

  - ### DrmInitData

    public DrmInitData(DrmInitData.SchemeData... schemeDatas)
    Parameters:
      `schemeDatas` - Scheme initialization data for possibly multiple DRM schemes.

  - ### DrmInitData

    public DrmInitData(@Nullable String schemeType, DrmInitData.SchemeData... schemeDatas)
    Parameters:
      `schemeType` - See `schemeType`.
      `schemeDatas` - Scheme initialization data for possibly multiple DRM schemes.

- ## Method Details

  - ### createSessionCreationData

    @Nullable public static DrmInitData createSessionCreationData(@Nullable DrmInitData manifestData, @Nullable DrmInitData mediaData)
    Merges `DrmInitData` obtained from a media manifest and a media stream.

    The result is generated as follows.

    1. Include all `DrmInitData.SchemeData`s from `manifestData` where `DrmInitData.SchemeData.hasData()` is true.
    2. Include all `DrmInitData.SchemeData`s in `mediaData` where `DrmInitData.SchemeData.hasData()` is true and for which we did not include an entry from the manifest targeting the same UUID.
    3. If available, the scheme type from the manifest is used. If not, the scheme type from the media is used.
    Parameters:
      `manifestData` - DRM session acquisition data obtained from the manifest.
      `mediaData` - DRM session acquisition data obtained from the media.
    Returns:
      A `DrmInitData` obtained from merging a media manifest and a media stream.

  - ### get

    @Deprecated @Nullable public DrmInitData.SchemeData get(UUID uuid)
    Deprecated.
    Use `get(int)` and `DrmInitData.SchemeData.matches(UUID)` instead.
    Retrieves data for a given DRM scheme, specified by its UUID.
    Parameters:
      `uuid` - The DRM scheme's UUID.
    Returns:
      The initialization data for the scheme, or null if the scheme is not supported.

  - ### get

    public DrmInitData.SchemeData get(int index)
    Retrieves the `DrmInitData.SchemeData` at a given index.
    Parameters:
      `index` - The index of the scheme to return. Must not exceed `schemeDataCount`.
    Returns:
      The `DrmInitData.SchemeData` at the specified index.

  - ### copyWithSchemeType

    public DrmInitData copyWithSchemeType(@Nullable String schemeType)
    Returns a copy with the specified protection scheme type.
    Parameters:
      `schemeType` - A protection scheme type. May be null.
    Returns:
      A copy with the specified protection scheme type.

  - ### merge

    public DrmInitData merge(DrmInitData drmInitData)
    Returns an instance containing the `schemeDatas` from both this and `other`. The `schemeType` of the instances being merged must either match, or at least one scheme type must be `null`.
    Parameters:
      `drmInitData` - The instance to merge.
    Returns:
      The merged result.

  - ### hashCode

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

  - ### equals

    public boolean equals(@Nullable Object obj)
    Specified by:
      `equals` in interface `Comparator<DrmInitData.SchemeData>`
    Overrides:
      `equals` in class `Object`

  - ### hasEqualSchemeDatas

    public boolean hasEqualSchemeDatas(@NonNull DrmInitData other)
    Returns whether the DrmInitData has equal `DrmInitData.SchemeData`s to the one provided.
    Parameters:
      `other` - other DrmInitData which to compare the schemeDatas to
    Returns:
      true if the underlying schemeDatas are equal

  - ### hasMatchingSchemeData

    public boolean hasMatchingSchemeData(@NonNull DrmInitData other)
    Returns whether the DrmInitData has at least one equal `DrmInitData.SchemeData` to the one provided.
    Parameters:
      `other` - other DrmInitData which to compare the schemeDatas to
    Returns:
      true if at least one of the underlying schemeDatas are equal

  - ### compare

    public int compare(DrmInitData.SchemeData first, DrmInitData.SchemeData second)
    Specified by:
      `compare` in interface `Comparator<DrmInitData.SchemeData>`

  - ### describeContents

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

  - ### writeToParcel

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