mirror of
https://github.com/androidx/media.git
synced 2025-05-03 21:57:46 +08:00
Expose timeout values in DefaultDataSourceFactory.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130522990
This commit is contained in:
parent
b35648eafb
commit
cdb0ef13c8
@ -55,14 +55,33 @@ public final class DefaultDataSource implements DataSource {
|
||||
* @param listener An optional listener.
|
||||
* @param userAgent The User-Agent string that should be used when requesting remote data.
|
||||
* @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
|
||||
* to HTTPS and vice versa) are enabled when fetching remote data..
|
||||
* to HTTPS and vice versa) are enabled when fetching remote data.
|
||||
*/
|
||||
public DefaultDataSource(Context context, TransferListener<? super DataSource> listener,
|
||||
String userAgent, boolean allowCrossProtocolRedirects) {
|
||||
this(context, listener, userAgent, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
|
||||
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, allowCrossProtocolRedirects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance, optionally configured to follow cross-protocol redirects.
|
||||
*
|
||||
* @param context A context.
|
||||
* @param listener An optional listener.
|
||||
* @param userAgent The User-Agent string that should be used when requesting remote data.
|
||||
* @param connectTimeoutMillis The connection timeout that should be used when requesting remote
|
||||
* data, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
|
||||
* @param readTimeoutMillis The read timeout that should be used when requesting remote data,
|
||||
* in milliseconds. A timeout of zero is interpreted as an infinite timeout.
|
||||
* @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
|
||||
* to HTTPS and vice versa) are enabled when fetching remote data.
|
||||
*/
|
||||
public DefaultDataSource(Context context, TransferListener<? super DataSource> listener,
|
||||
String userAgent, int connectTimeoutMillis, int readTimeoutMillis,
|
||||
boolean allowCrossProtocolRedirects) {
|
||||
this(context, listener,
|
||||
new DefaultHttpDataSource(userAgent, null, listener,
|
||||
DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
|
||||
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, allowCrossProtocolRedirects));
|
||||
new DefaultHttpDataSource(userAgent, null, listener, connectTimeoutMillis,
|
||||
readTimeoutMillis, allowCrossProtocolRedirects));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,9 +24,22 @@ import com.google.android.exoplayer2.upstream.DataSource.Factory;
|
||||
*/
|
||||
public final class DefaultDataSourceFactory implements Factory {
|
||||
|
||||
/**
|
||||
* The default connection timeout, in milliseconds.
|
||||
*/
|
||||
public static final int DEFAULT_CONNECT_TIMEOUT_MILLIS =
|
||||
DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS;
|
||||
/**
|
||||
* The default read timeout, in milliseconds.
|
||||
*/
|
||||
public static final int DEFAULT_READ_TIMEOUT_MILLIS =
|
||||
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS;
|
||||
|
||||
private final Context context;
|
||||
private final String userAgent;
|
||||
private final TransferListener<? super DataSource> listener;
|
||||
private final int connectTimeoutMillis;
|
||||
private final int readTimeoutMillis;
|
||||
private final boolean allowCrossProtocolRedirects;
|
||||
|
||||
/**
|
||||
@ -56,15 +69,36 @@ public final class DefaultDataSourceFactory implements Factory {
|
||||
*/
|
||||
public DefaultDataSourceFactory(Context context, String userAgent,
|
||||
TransferListener<? super DataSource> listener, boolean allowCrossProtocolRedirects) {
|
||||
this(context, userAgent, listener, DEFAULT_CONNECT_TIMEOUT_MILLIS,
|
||||
DEFAULT_CONNECT_TIMEOUT_MILLIS, allowCrossProtocolRedirects);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context A context.
|
||||
* @param userAgent The User-Agent string that should be used.
|
||||
* @param listener An optional listener.
|
||||
* @param connectTimeoutMillis The connection timeout that should be used when requesting remote
|
||||
* data, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
|
||||
* @param readTimeoutMillis The read timeout that should be used when requesting remote data,
|
||||
* in milliseconds. A timeout of zero is interpreted as an infinite timeout.
|
||||
* @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
|
||||
* to HTTPS and vice versa) are enabled.
|
||||
*/
|
||||
public DefaultDataSourceFactory(Context context, String userAgent,
|
||||
TransferListener<? super DataSource> listener, int connectTimeoutMillis,
|
||||
int readTimeoutMillis, boolean allowCrossProtocolRedirects) {
|
||||
this.context = context.getApplicationContext();
|
||||
this.userAgent = userAgent;
|
||||
this.listener = listener;
|
||||
this.connectTimeoutMillis = connectTimeoutMillis;
|
||||
this.readTimeoutMillis = readTimeoutMillis;
|
||||
this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultDataSource createDataSource() {
|
||||
return new DefaultDataSource(context, listener, userAgent, allowCrossProtocolRedirects);
|
||||
return new DefaultDataSource(context, listener, userAgent, connectTimeoutMillis,
|
||||
readTimeoutMillis, allowCrossProtocolRedirects);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user