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 create
DataSource
s to fetch
remote data.
The implementation should allow to customize both header and query parameters for generated
data sources.
Please use the PlayerSDK.HTTP_DATASOURCE_BUILDER
as the source
for any HttpDataSource
instances.- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Removes all header parameters added previously withaddHeaderParameter(String, String)
.void
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 typeMethods inherited from interface com.google.android.exoplayer2.upstream.DataSource.Factory
createDataSource
-
Method Details
-
addHeaderParameter
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
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
- Returns:
- A non-null map of all registered header parameter
-
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
-