Class ModifierDataSourceFactory

java.lang.Object
com.castlabs.android.network.ModifierDataSourceFactory
All Implemented Interfaces:
DataSourceFactory, com.castlabs.media3.datasource.DataSource.Factory

public class ModifierDataSourceFactory extends Object implements DataSourceFactory
Delegating data source factory that will trigger all RequestModifiers registered with the player controller.

Note that you usually do not have to use this class explicitly. The PlayerController will automatically create delegate instances for the different data request types.

Since:
4.1.2
  • Constructor Details

    • ModifierDataSourceFactory

      public ModifierDataSourceFactory(@NonNull DataSourceFactory delegate, int type, @NonNull List<RequestModifier> requestModifiers, @NonNull List<ResponseModifier> responseModifiers)
      Create a new instance of this data source factory
      Parameters:
      delegate - The delegate that this factory wraps around
      type - The request type that will be send to the request modifier plugin. Should be one of Request.DATA_TYPE_MANIFEST, Request.DATA_TYPE_SEGMENT, or Request.DATA_TYPE_OTHER
      requestModifiers - The list of request modifier plugins
      responseModifiers - The list of response modifier plugins
    • ModifierDataSourceFactory

      public ModifierDataSourceFactory(@NonNull DataSourceFactory delegate, int type, @NonNull List<RequestModifier> requestModifiers, @NonNull List<ResponseModifier> responseModifiers, @NonNull NetworkConfiguration networkConfiguration, @Nullable RequestModifier.Listener requestModifierListener)
      Create a new instance of this data source factory
      Parameters:
      delegate - The delegate that this factory wraps around
      type - The request type that will be send to the request modifier plugin. Should be one of Request.DATA_TYPE_MANIFEST, Request.DATA_TYPE_SEGMENT, or Request.DATA_TYPE_OTHER
      requestModifiers - The list of request modifier plugins
      responseModifiers - The list of response modifier plugins
      networkConfiguration - The network configuration to use for requests
      requestModifierListener - The listener for request modifier events
    • ModifierDataSourceFactory

      public ModifierDataSourceFactory(@NonNull DataSourceFactory delegate, int type, @NonNull List<RequestModifier> requestModifiers, @NonNull List<ResponseModifier> responseModifiers, @NonNull NetworkConfiguration networkConfiguration, @Nullable RequestModifier.Listener requestModifierListener, @NonNull PlayerConfig effectiveUrlConfig, @NonNull EffectiveUrlListener effectiveUrlListener)
      Create a new instance that reports the effective URL for one content source.
      Parameters:
      delegate - The delegate that this factory wraps around
      type - The request type that will be sent to request modifiers
      requestModifiers - The list of request modifier plugins
      responseModifiers - The list of response modifier plugins
      networkConfiguration - The network configuration to use for requests
      requestModifierListener - The listener for request modifier events
      effectiveUrlConfig - The configuration that owns this content source
      effectiveUrlListener - The listener for completed content URI modifications
  • Method Details

    • forceDataSourceWrap

      public void forceDataSourceWrap(boolean forceSourceWrap)
      Force the data source to be wrapped even if no request modifiers are present. This is useful when the request modifiers are added later.
      Parameters:
      forceSourceWrap - True if the data source should be wrapped even if no request modifiers are present
    • createDataSource

      public com.castlabs.media3.datasource.DataSource createDataSource()
      Specified by:
      createDataSource in interface com.castlabs.media3.datasource.DataSource.Factory
    • createDataSource

      public com.castlabs.media3.datasource.DataSource createDataSource(int requestType)
      Description copied from interface: DataSourceFactory
      Creates a data source for the given request type
      Specified by:
      createDataSource in interface DataSourceFactory
      Parameters:
      requestType - The request type
      Returns:
      dataSource the data source
    • addHeaderParameter

      public void addHeaderParameter(@NonNull String key, @NonNull String value)
      Description copied from interface: DataSourceFactory
      Adds a header parameter that will be added to each HTTP connection header that is generated with a DataSource created by this factory.

      Note that you will need to call this before a call to DataSource.Factory.createDataSource() in order to successfully add the parameter.

      Specified by:
      addHeaderParameter in interface DataSourceFactory
      Parameters:
      key - the key
      value - the value or null to remove any previously added endtry with the given key
    • clearHeaderParameters

      public void clearHeaderParameters()
      Description copied from interface: DataSourceFactory
      Removes all header parameters added previously with DataSourceFactory.addHeaderParameter(String, String).
      Specified by:
      clearHeaderParameters in interface DataSourceFactory
    • addQueryParameter

      public void addQueryParameter(@NonNull String key, @NonNull String value)
      Description copied from interface: DataSourceFactory
      Adds a query parameter that will be appended to each HTTP URL.

      Note that you will need to call this before a call to DataSource.Factory.createDataSource() in order to successfully add the parameter.

      Specified by:
      addQueryParameter in interface DataSourceFactory
      Parameters:
      key - the key
      value - the value or null to remove any previously added entry with the given key
    • clearQueryParameters

      public void clearQueryParameters()
      Description copied from interface: DataSourceFactory
      Removes all query parameters added previously with DataSourceFactory.addQueryParameter(String, String)
      Specified by:
      clearQueryParameters in interface DataSourceFactory
    • getHeaderParameter

      @NonNull public Map<String,String> getHeaderParameter()
      Description copied from interface: DataSourceFactory
      Returns a non-null map of all registered header parameters.
      Specified by:
      getHeaderParameter in interface DataSourceFactory
      Returns:
      A non-null map of all registered header parameter
    • getQueryParameter

      @NonNull public Map<String,String> getQueryParameter()
      Description copied from interface: DataSourceFactory
      Returns a non-null map of all registered query parameters.
      Specified by:
      getQueryParameter in interface DataSourceFactory
      Returns:
      A non-null map of all registered query parameter
    • setTag

      public void setTag(@Nullable Object tag)
      Set a tag that will be applied to the produced data sources so request and response modifiers can correlate callbacks.
      Parameters:
      tag - Marker object to associate with subsequent requests
    • getTag

      @Nullable public Object getTag()
      Get the tag that should be attached to generated requests.
      Returns:
      Marker object associated with requests