Package com.castlabs.android.network
Class ModifierDataSourceFactory
java.lang.Object
com.castlabs.android.network.ModifierDataSourceFactory
- All Implemented Interfaces:
DataSourceFactory,com.google.android.exoplayer2.upstream.DataSource.Factory
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 Summary
ConstructorsConstructorDescriptionModifierDataSourceFactory(DataSourceFactory delegate, int type, List<RequestModifier> requestModifiers, List<ResponseModifier> responseListeners) Create a new instance of this data source factoryModifierDataSourceFactory(DataSourceFactory delegate, int type, List<RequestModifier> requestModifiers, List<ResponseModifier> responseListeners, NetworkConfiguration networkConfiguration) Create a new instance of this data source factory -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHeaderParameter(String key, String value) Adds a header parameter that will be added to each HTTP connection header that is generated with aDataSourcecreated by this factory.voidaddQueryParameter(String key, String value) Adds a query parameter that will be appended to each HTTP URL.voidRemoves all header parameters added previously withDataSourceFactory.addHeaderParameter(String, String).voidRemoves all query parameters added previously withDataSourceFactory.addQueryParameter(String, String)com.google.android.exoplayer2.upstream.DataSourcecom.google.android.exoplayer2.upstream.DataSourcecreateDataSource(int requestType) Creates a data source for the given request type
-
Constructor Details
-
ModifierDataSourceFactory
public ModifierDataSourceFactory(@NonNull DataSourceFactory delegate, int type, @NonNull List<RequestModifier> requestModifiers, @NonNull List<ResponseModifier> responseListeners) Create a new instance of this data source factory- Parameters:
delegate- The delegate that this factory wraps aroundtype- The request type that will be send to the request modifier plugin. Should be one ofRequest.DATA_TYPE_MANIFEST,Request.DATA_TYPE_SEGMENT, orRequest.DATA_TYPE_OTHERrequestModifiers- The list of request modifier plugins
-
ModifierDataSourceFactory
public ModifierDataSourceFactory(@NonNull DataSourceFactory delegate, int type, @NonNull List<RequestModifier> requestModifiers, @NonNull List<ResponseModifier> responseListeners, @NonNull NetworkConfiguration networkConfiguration) Create a new instance of this data source factory- Parameters:
delegate- The delegate that this factory wraps aroundtype- The request type that will be send to the request modifier plugin. Should be one ofRequest.DATA_TYPE_MANIFEST,Request.DATA_TYPE_SEGMENT, orRequest.DATA_TYPE_OTHERrequestModifiers- The list of request modifier plugins
-
-
Method Details
-
createDataSource
public com.google.android.exoplayer2.upstream.DataSource createDataSource()- Specified by:
createDataSourcein interfacecom.google.android.exoplayer2.upstream.DataSource.Factory
-
createDataSource
public com.google.android.exoplayer2.upstream.DataSource createDataSource(int requestType) Description copied from interface:DataSourceFactoryCreates a data source for the given request type- Specified by:
createDataSourcein interfaceDataSourceFactory- Parameters:
requestType- The request type- Returns:
- dataSource the data source
-
addHeaderParameter
Description copied from interface:DataSourceFactoryAdds a header parameter that will be added to each HTTP connection header that is generated with aDataSourcecreated by this factory. Note that you will need to call this before a call toDataSource.Factory.createDataSource()in order to successfully add the parameter.- Specified by:
addHeaderParameterin interfaceDataSourceFactory- Parameters:
key- the keyvalue- the value or null to remove any previously added endtry with the given key
-
clearHeaderParameters
public void clearHeaderParameters()Description copied from interface:DataSourceFactoryRemoves all header parameters added previously withDataSourceFactory.addHeaderParameter(String, String).- Specified by:
clearHeaderParametersin interfaceDataSourceFactory
-
addQueryParameter
Description copied from interface:DataSourceFactoryAdds a query parameter that will be appended to each HTTP URL. Note that you will need to call this before a call toDataSource.Factory.createDataSource()in order to successfully add the parameter.- Specified by:
addQueryParameterin interfaceDataSourceFactory- Parameters:
key- the keyvalue- the value or null to remove any previously added entry with the given key
-
clearQueryParameters
public void clearQueryParameters()Description copied from interface:DataSourceFactoryRemoves all query parameters added previously withDataSourceFactory.addQueryParameter(String, String)- Specified by:
clearQueryParametersin interfaceDataSourceFactory
-
getHeaderParameter
- Specified by:
getHeaderParameterin interfaceDataSourceFactory- Returns:
- A non-null map of all registered header parameter
-
getQueryParameter
- Specified by:
getQueryParameterin interfaceDataSourceFactory- Returns:
- A non-null map of all registered query parameter
-