Package com.castlabs.android.player

## Class DrmLicenseLoader.Builder

- java.lang.Object
- - com.castlabs.android.player.DrmLicenseLoader.Builder

- Enclosing class:
    DrmLicenseLoader

      public static class DrmLicenseLoader.Builder
      extends Object

  Use this builder class to generate new instances of the `DrmLicenseLoader`.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Builder​(Context context, PlayerConfig playerConfig, DrmLicenseLoader.Callback callback)` | Create a new builder to generate a license loader instance using the given PlayerConfig data.
    `Builder​(Context context, String contentUrl, DrmConfiguration drmConfiguration, DrmLicenseLoader.Callback callback)` | Create a new builder to generate a license loader instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `DrmLicenseLoader.Builder` | `contentType​(int contentType)` | Explicitly set the content type.
    `DrmLicenseLoader.Builder` | `dataSourceFactory​(DataSourceFactory dataSourceFactory)` | Set the data source factory that is used to generate content requests.
    `DrmLicenseLoader` | `get()` | Creates the license loader.
    `DrmLicenseLoader.Builder` | `headerParameter​(String key, String value)` | Add a header parameter to each content data request
    `DrmLicenseLoader.Builder` | `manifestModifier​(ManifestModifier manifestModifier)` | Add a `ManifestModifier` to optionally trim tracks out of it.
    `DrmLicenseLoader.Builder` | `mergeVideoTracks​(boolean mergeVideoTracks)` | Explicitly set the merge video tracks flag.
    `DrmLicenseLoader.Builder` | `queryParameter​(String key, String value)` | Add a query parameter to each content data request
    `DrmLicenseLoader.Builder` | `sourceSelectorFactory​(com.google.android.exoplayer2.upstream.InternalSourceSelector.Factory sourceSelectorFactory)` | Set the source selector factory that is used to pick up a base url from the manifest

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

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

- - ### Constructor Detail

    - #### Builder

          public Builder​(@NonNull
                         Context context,
                         @Nullable
                         String contentUrl,
                         @NonNull
                         DrmConfiguration drmConfiguration,
                         @NonNull
                         DrmLicenseLoader.Callback callback)

      Create a new builder to generate a license loader instance. A valid content URL shall be specified for license loading. When using for license removal, the content URL can be null but then the content type shall be specified explicitly with `contentType(int)`
      Parameters:
        `context` - The context
        `contentUrl` - The URL to the content or null if unknown and removing license
        `drmConfiguration` - The DRM configuration
        `callback` - The callback

    - #### Builder

          public Builder​(@NonNull
                         Context context,
                         @NonNull
                         PlayerConfig playerConfig,
                         @NonNull
                         DrmLicenseLoader.Callback callback)

      Create a new builder to generate a license loader instance using the given PlayerConfig data.

      The builder will read the following values specified from the configuration:
      - `PlayerConfig.contentUrl` - (mandatory) The source URL to the content
      - `PlayerConfig.drmConfiguration` - (mandatory) The DRM configuration
      - `PlayerConfig.contentParameters` - Bundle with additional header parameters for manifests
      - `PlayerConfig.contentQueryParameters` - Bundle with additional query parameters for manifests
      - `PlayerConfig.segmentParameters` - Bundle with additional header parameters for segments
      - `PlayerConfig.segmentQueryParameters` - Bundle with additional query parameters for segments
      - `PlayerConfig.contentType`
      - `PlayerConfig.mergeVideoTracks`
      Parameters:
        `context` - The context
        `playerConfig` - The bundle data
        `callback` - The callback

  - ### Method Detail

    - #### contentType

          @NonNull
          public DrmLicenseLoader.Builder contentType​(int contentType)

      Explicitly set the content type. Accepted value are `SdkConsts.CONTENT_TYPE_DASH`, `SdkConsts.CONTENT_TYPE_SMOOTHSTREAMING`, `SdkConsts.CONTENT_TYPE_HLS`, or `SdkConsts.CONTENT_TYPE_MP4`.
      Parameters:
        `contentType` - The content type
      Returns:
        The builder

    - #### mergeVideoTracks

          @NonNull
          public DrmLicenseLoader.Builder mergeVideoTracks​(boolean mergeVideoTracks)

      Explicitly set the merge video tracks flag.
      Parameters:
        `mergeVideoTracks` - The merge video tracks flag
      Returns:
        The builder

    - #### dataSourceFactory

          @NonNull
          public DrmLicenseLoader.Builder dataSourceFactory​(@Nullable
                                                            DataSourceFactory dataSourceFactory)

      Set the data source factory that is used to generate content requests. Note that this will reset any query and request parameters.
      Parameters:
        `dataSourceFactory` - The data source factory
      Returns:
        The builder

    - #### queryParameter

          @NonNull
          public DrmLicenseLoader.Builder queryParameter​(@NonNull
                                                         String key,
                                                         @NonNull
                                                         String value)

      Add a query parameter to each content data request
      Parameters:
        `key` - the key
        `value` - the value
      Returns:
        The builder

    - #### headerParameter

          @NonNull
          public DrmLicenseLoader.Builder headerParameter​(@NonNull
                                                          String key,
                                                          @NonNull
                                                          String value)

      Add a header parameter to each content data request
      Parameters:
        `key` - the key
        `value` - the value
      Returns:
        The builder

    - #### manifestModifier

          @NonNull
          public DrmLicenseLoader.Builder manifestModifier​(@Nullable
                                                           ManifestModifier manifestModifier)

      Add a `ManifestModifier` to optionally trim tracks out of it. In the offline use case, non-downloaded tracks need to be removed from the Manifest, so the loader will properly fetch one of the downloaded tracks in order to acquire the PSSH data.
      Parameters:
        `manifestModifier` - the modifier
      Returns:
        The Builder

    - #### sourceSelectorFactory

          @NonNull
          public DrmLicenseLoader.Builder sourceSelectorFactory​(@Nullable
                                                                com.google.android.exoplayer2.upstream.InternalSourceSelector.Factory sourceSelectorFactory)

      Set the source selector factory that is used to pick up a base url from the manifest
      Parameters:
        `sourceSelectorFactory` - The source selector factory
      Returns:
        The builder

    - #### get

          @NonNull
          public DrmLicenseLoader get()
                               throws IllegalArgumentException,
                                      NullPointerException

      Creates the license loader.
      Returns:
        The license loader
      Throws:
        `IllegalArgumentException` - in case no plugin was found that can handle the content or no offline ID is specified in the DRM configuration
        `NullPointerException` - if mandatory data are not specified