Package com.castlabs.android.network
Interface DataSourceFactory
-
- All Superinterfaces:
com.google.android.exoplayer2.upstream.DataSource.Factory
- All Known Implementing Classes:
DefaultDataSourceFactory
,ModifierDataSourceFactory
public interface DataSourceFactory extends com.google.android.exoplayer2.upstream.DataSource.Factory
Implementations of this interface are used to createDataSource
s to fetch remote data. The implementation should allow to customize both header and query parameters for generated data sources. Please use thePlayerSDK.HTTP_DATASOURCE_BUILDER
as the source for anyHttpDataSource
instances.- Since:
- 3.0.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addHeaderParameter(String key, String value)
Adds a header parameter that will be added to each HTTP connection header that is generated with aDataSource
created by this factory.void
addQueryParameter(String key, String value)
Adds a query parameter that will be appended to each HTTP URL.void
clearHeaderParameters()
Removes all header parameters added previously withaddHeaderParameter(String, String)
.void
clearQueryParameters()
Removes all query parameters added previously withaddQueryParameter(String, String)
com.google.android.exoplayer2.upstream.DataSource
createDataSource(int requestType)
Creates a data source for the given request typeMap<String,String>
getHeaderParameter()
Map<String,String>
getQueryParameter()
-
-
-
Method Detail
-
addHeaderParameter
void addHeaderParameter(@NonNull String key, @NonNull String value)
Adds a header parameter that will be added to each HTTP connection header that is generated with aDataSource
created by this factory. Note that you will need to call this before a call toDataSource.Factory.createDataSource()
in order to successfully add the parameter.- Parameters:
key
- the keyvalue
- the value or null to remove any previously added endtry with the given key
-
clearHeaderParameters
void clearHeaderParameters()
Removes all header parameters added previously withaddHeaderParameter(String, String)
.
-
addQueryParameter
void addQueryParameter(@NonNull String key, @NonNull String value)
Adds 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.- Parameters:
key
- the keyvalue
- the value or null to remove any previously added entry with the given key
-
clearQueryParameters
void clearQueryParameters()
Removes all query parameters added previously withaddQueryParameter(String, String)
-
getHeaderParameter
@NonNull Map<String,String> getHeaderParameter()
- Returns:
- A non-null map of all registered header parameter
-
getQueryParameter
@NonNull Map<String,String> getQueryParameter()
- Returns:
- A non-null map of all registered query parameter
-
createDataSource
com.google.android.exoplayer2.upstream.DataSource createDataSource(int requestType)
Creates a data source for the given request type- Parameters:
requestType
- The request type- Returns:
- dataSource the data source
-
-