Remove generic type parameter from TransferListener.

All known instances use DataSource as generic type and thus code can be simplified
by removing the generic type altogether.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205798542
This commit is contained in:
tonihei 2018-07-24 02:30:23 -07:00 committed by Oliver Woodman
parent 9d0ec37ead
commit ffdc17d0e0
61 changed files with 135 additions and 162 deletions

View File

@ -22,7 +22,6 @@ import android.util.Log;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.upstream.BaseDataSource; import com.google.android.exoplayer2.upstream.BaseDataSource;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSourceException; import com.google.android.exoplayer2.upstream.DataSourceException;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource;
@ -163,7 +162,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
CronetEngine cronetEngine, CronetEngine cronetEngine,
Executor executor, Executor executor,
Predicate<String> contentTypePredicate, Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> listener) { @Nullable TransferListener listener) {
this(cronetEngine, executor, contentTypePredicate, listener, DEFAULT_CONNECT_TIMEOUT_MILLIS, this(cronetEngine, executor, contentTypePredicate, listener, DEFAULT_CONNECT_TIMEOUT_MILLIS,
DEFAULT_READ_TIMEOUT_MILLIS, false, null, false); DEFAULT_READ_TIMEOUT_MILLIS, false, null, false);
} }
@ -188,7 +187,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
CronetEngine cronetEngine, CronetEngine cronetEngine,
Executor executor, Executor executor,
Predicate<String> contentTypePredicate, Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener,
int connectTimeoutMs, int connectTimeoutMs,
int readTimeoutMs, int readTimeoutMs,
boolean resetTimeoutOnRedirects, boolean resetTimeoutOnRedirects,
@ -219,7 +218,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
CronetEngine cronetEngine, CronetEngine cronetEngine,
Executor executor, Executor executor,
Predicate<String> contentTypePredicate, Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener,
int connectTimeoutMs, int connectTimeoutMs,
int readTimeoutMs, int readTimeoutMs,
boolean resetTimeoutOnRedirects, boolean resetTimeoutOnRedirects,
@ -234,7 +233,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
CronetEngine cronetEngine, CronetEngine cronetEngine,
Executor executor, Executor executor,
Predicate<String> contentTypePredicate, Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener,
int connectTimeoutMs, int connectTimeoutMs,
int readTimeoutMs, int readTimeoutMs,
boolean resetTimeoutOnRedirects, boolean resetTimeoutOnRedirects,

View File

@ -16,7 +16,6 @@
package com.google.android.exoplayer2.ext.cronet; package com.google.android.exoplayer2.ext.cronet;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource.BaseFactory; import com.google.android.exoplayer2.upstream.HttpDataSource.BaseFactory;
@ -47,7 +46,7 @@ public final class CronetDataSourceFactory extends BaseFactory {
private final CronetEngineWrapper cronetEngineWrapper; private final CronetEngineWrapper cronetEngineWrapper;
private final Executor executor; private final Executor executor;
private final Predicate<String> contentTypePredicate; private final Predicate<String> contentTypePredicate;
private final @Nullable TransferListener<? super DataSource> transferListener; private final @Nullable TransferListener transferListener;
private final int connectTimeoutMs; private final int connectTimeoutMs;
private final int readTimeoutMs; private final int readTimeoutMs;
private final boolean resetTimeoutOnRedirects; private final boolean resetTimeoutOnRedirects;
@ -224,7 +223,7 @@ public final class CronetDataSourceFactory extends BaseFactory {
CronetEngineWrapper cronetEngineWrapper, CronetEngineWrapper cronetEngineWrapper,
Executor executor, Executor executor,
Predicate<String> contentTypePredicate, Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> transferListener, @Nullable TransferListener transferListener,
HttpDataSource.Factory fallbackFactory) { HttpDataSource.Factory fallbackFactory) {
this(cronetEngineWrapper, executor, contentTypePredicate, transferListener, this(cronetEngineWrapper, executor, contentTypePredicate, transferListener,
DEFAULT_CONNECT_TIMEOUT_MILLIS, DEFAULT_READ_TIMEOUT_MILLIS, false, fallbackFactory); DEFAULT_CONNECT_TIMEOUT_MILLIS, DEFAULT_READ_TIMEOUT_MILLIS, false, fallbackFactory);
@ -252,7 +251,7 @@ public final class CronetDataSourceFactory extends BaseFactory {
CronetEngineWrapper cronetEngineWrapper, CronetEngineWrapper cronetEngineWrapper,
Executor executor, Executor executor,
Predicate<String> contentTypePredicate, Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> transferListener, @Nullable TransferListener transferListener,
String userAgent) { String userAgent) {
this(cronetEngineWrapper, executor, contentTypePredicate, transferListener, this(cronetEngineWrapper, executor, contentTypePredicate, transferListener,
DEFAULT_CONNECT_TIMEOUT_MILLIS, DEFAULT_READ_TIMEOUT_MILLIS, false, DEFAULT_CONNECT_TIMEOUT_MILLIS, DEFAULT_READ_TIMEOUT_MILLIS, false,
@ -281,7 +280,7 @@ public final class CronetDataSourceFactory extends BaseFactory {
CronetEngineWrapper cronetEngineWrapper, CronetEngineWrapper cronetEngineWrapper,
Executor executor, Executor executor,
Predicate<String> contentTypePredicate, Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> transferListener, @Nullable TransferListener transferListener,
int connectTimeoutMs, int connectTimeoutMs,
int readTimeoutMs, int readTimeoutMs,
boolean resetTimeoutOnRedirects, boolean resetTimeoutOnRedirects,
@ -314,7 +313,7 @@ public final class CronetDataSourceFactory extends BaseFactory {
CronetEngineWrapper cronetEngineWrapper, CronetEngineWrapper cronetEngineWrapper,
Executor executor, Executor executor,
Predicate<String> contentTypePredicate, Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> transferListener, @Nullable TransferListener transferListener,
int connectTimeoutMs, int connectTimeoutMs,
int readTimeoutMs, int readTimeoutMs,
boolean resetTimeoutOnRedirects, boolean resetTimeoutOnRedirects,

View File

@ -32,7 +32,6 @@ import android.net.Uri;
import android.os.ConditionVariable; import android.os.ConditionVariable;
import android.os.SystemClock; import android.os.SystemClock;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource.HttpDataSourceException; import com.google.android.exoplayer2.upstream.HttpDataSource.HttpDataSourceException;
@ -87,7 +86,7 @@ public final class CronetDataSourceTest {
@Mock private UrlRequest.Builder mockUrlRequestBuilder; @Mock private UrlRequest.Builder mockUrlRequestBuilder;
@Mock private UrlRequest mockUrlRequest; @Mock private UrlRequest mockUrlRequest;
@Mock private Predicate<String> mockContentTypePredicate; @Mock private Predicate<String> mockContentTypePredicate;
@Mock private TransferListener<DataSource> mockTransferListener; @Mock private TransferListener mockTransferListener;
@Mock private Executor mockExecutor; @Mock private Executor mockExecutor;
@Mock private NetworkException mockNetworkException; @Mock private NetworkException mockNetworkException;
@Mock private CronetEngine mockCronetEngine; @Mock private CronetEngine mockCronetEngine;

View File

@ -80,7 +80,7 @@ public final class ImaAdsMediaSource extends BaseMediaSource implements SourceIn
public void prepareSourceInternal( public void prepareSourceInternal(
final ExoPlayer player, final ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
adsMediaSource.prepareSource( adsMediaSource.prepareSource(
player, isTopLevelSource, /* listener= */ this, mediaTransferListener); player, isTopLevelSource, /* listener= */ this, mediaTransferListener);
} }

View File

@ -21,7 +21,6 @@ import android.support.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.upstream.BaseDataSource; import com.google.android.exoplayer2.upstream.BaseDataSource;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSourceException; import com.google.android.exoplayer2.upstream.DataSourceException;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource;
@ -97,7 +96,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
@NonNull Call.Factory callFactory, @NonNull Call.Factory callFactory,
@Nullable String userAgent, @Nullable String userAgent,
@Nullable Predicate<String> contentTypePredicate, @Nullable Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> listener) { @Nullable TransferListener listener) {
this(callFactory, userAgent, contentTypePredicate, listener, null, null); this(callFactory, userAgent, contentTypePredicate, listener, null, null);
} }
@ -117,7 +116,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
@NonNull Call.Factory callFactory, @NonNull Call.Factory callFactory,
@Nullable String userAgent, @Nullable String userAgent,
@Nullable Predicate<String> contentTypePredicate, @Nullable Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener,
@Nullable CacheControl cacheControl, @Nullable CacheControl cacheControl,
@Nullable RequestProperties defaultRequestProperties) { @Nullable RequestProperties defaultRequestProperties) {
super(/* isNetwork= */ true); super(/* isNetwork= */ true);

View File

@ -17,7 +17,6 @@ package com.google.android.exoplayer2.ext.okhttp;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource.BaseFactory; import com.google.android.exoplayer2.upstream.HttpDataSource.BaseFactory;
import com.google.android.exoplayer2.upstream.HttpDataSource.Factory; import com.google.android.exoplayer2.upstream.HttpDataSource.Factory;
@ -32,7 +31,7 @@ public final class OkHttpDataSourceFactory extends BaseFactory {
@NonNull private final Call.Factory callFactory; @NonNull private final Call.Factory callFactory;
@Nullable private final String userAgent; @Nullable private final String userAgent;
@Nullable private final TransferListener<? super DataSource> listener; @Nullable private final TransferListener listener;
@Nullable private final CacheControl cacheControl; @Nullable private final CacheControl cacheControl;
/** /**
@ -63,8 +62,10 @@ public final class OkHttpDataSourceFactory extends BaseFactory {
* @param userAgent An optional User-Agent string. * @param userAgent An optional User-Agent string.
* @param listener An optional listener. * @param listener An optional listener.
*/ */
public OkHttpDataSourceFactory(@NonNull Call.Factory callFactory, @Nullable String userAgent, public OkHttpDataSourceFactory(
@Nullable TransferListener<? super DataSource> listener) { @NonNull Call.Factory callFactory,
@Nullable String userAgent,
@Nullable TransferListener listener) {
this(callFactory, userAgent, listener, /* cacheControl= */ null); this(callFactory, userAgent, listener, /* cacheControl= */ null);
} }
@ -75,8 +76,10 @@ public final class OkHttpDataSourceFactory extends BaseFactory {
* @param listener An optional listener. * @param listener An optional listener.
* @param cacheControl An optional {@link CacheControl} for setting the Cache-Control header. * @param cacheControl An optional {@link CacheControl} for setting the Cache-Control header.
*/ */
public OkHttpDataSourceFactory(@NonNull Call.Factory callFactory, @Nullable String userAgent, public OkHttpDataSourceFactory(
@Nullable TransferListener<? super DataSource> listener, @NonNull Call.Factory callFactory,
@Nullable String userAgent,
@Nullable TransferListener listener,
@Nullable CacheControl cacheControl) { @Nullable CacheControl cacheControl) {
this.callFactory = callFactory; this.callFactory = callFactory;
this.userAgent = userAgent; this.userAgent = userAgent;

View File

@ -42,7 +42,7 @@ public final class RtmpDataSource extends BaseDataSource {
} }
/** @param listener An optional listener. */ /** @param listener An optional listener. */
public RtmpDataSource(@Nullable TransferListener<? super DataSource> listener) { public RtmpDataSource(@Nullable TransferListener listener) {
super(/* isNetwork= */ true); super(/* isNetwork= */ true);
if (listener != null) { if (listener != null) {
addTransferListener(listener); addTransferListener(listener);

View File

@ -25,14 +25,14 @@ import com.google.android.exoplayer2.upstream.TransferListener;
*/ */
public final class RtmpDataSourceFactory implements DataSource.Factory { public final class RtmpDataSourceFactory implements DataSource.Factory {
private final @Nullable TransferListener<? super DataSource> listener; private final @Nullable TransferListener listener;
public RtmpDataSourceFactory() { public RtmpDataSourceFactory() {
this(null); this(null);
} }
/** @param listener An optional listener. */ /** @param listener An optional listener. */
public RtmpDataSourceFactory(@Nullable TransferListener<? super DataSource> listener) { public RtmpDataSourceFactory(@Nullable TransferListener listener) {
this.listener = listener; this.listener = listener;
} }

View File

@ -19,7 +19,6 @@ import android.os.Handler;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import java.util.ArrayList; import java.util.ArrayList;
@ -59,9 +58,7 @@ public abstract class BaseMediaSource implements MediaSource {
* manifests and other data. * manifests and other data.
*/ */
protected abstract void prepareSourceInternal( protected abstract void prepareSourceInternal(
ExoPlayer player, ExoPlayer player, boolean isTopLevelSource, @Nullable TransferListener mediaTransferListener);
boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener);
/** /**
* Releases the source. This method is called exactly once after each call to {@link * Releases the source. This method is called exactly once after each call to {@link
@ -147,7 +144,7 @@ public abstract class BaseMediaSource implements MediaSource {
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
SourceInfoRefreshListener listener, SourceInfoRefreshListener listener,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
Assertions.checkArgument(this.player == null || this.player == player); Assertions.checkArgument(this.player == null || this.player == player);
sourceInfoListeners.add(listener); sourceInfoListeners.add(listener);
if (this.player == null) { if (this.player == null) {

View File

@ -21,7 +21,6 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException; import java.io.IOException;
@ -216,7 +215,7 @@ public final class ClippingMediaSource extends CompositeMediaSource<Void> {
public void prepareSourceInternal( public void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener); super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
prepareChildSource(/* id= */ null, mediaSource); prepareChildSource(/* id= */ null, mediaSource);
} }

View File

@ -20,7 +20,6 @@ import android.support.annotation.CallSuper;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
@ -38,7 +37,7 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
private @Nullable ExoPlayer player; private @Nullable ExoPlayer player;
private @Nullable Handler eventHandler; private @Nullable Handler eventHandler;
private @Nullable TransferListener<? super DataSource> mediaTransferListener; private @Nullable TransferListener mediaTransferListener;
/** Create composite media source without child sources. */ /** Create composite media source without child sources. */
protected CompositeMediaSource() { protected CompositeMediaSource() {
@ -50,7 +49,7 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
public void prepareSourceInternal( public void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
this.player = player; this.player = player;
this.mediaTransferListener = mediaTransferListener; this.mediaTransferListener = mediaTransferListener;
eventHandler = new Handler(); eventHandler = new Handler();

View File

@ -26,7 +26,6 @@ import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.ConcatenatingMediaSource.MediaSourceHolder; import com.google.android.exoplayer2.source.ConcatenatingMediaSource.MediaSourceHolder;
import com.google.android.exoplayer2.source.ShuffleOrder.DefaultShuffleOrder; import com.google.android.exoplayer2.source.ShuffleOrder.DefaultShuffleOrder;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
@ -376,7 +375,7 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
public final synchronized void prepareSourceInternal( public final synchronized void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener); super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
this.player = player; this.player = player;
playerApplicationHandler = new Handler(player.getApplicationLooper()); playerApplicationHandler = new Handler(player.getApplicationLooper());

View File

@ -241,7 +241,7 @@ public final class ExtractorMediaSource extends BaseMediaSource
private long timelineDurationUs; private long timelineDurationUs;
private boolean timelineIsSeekable; private boolean timelineIsSeekable;
private @Nullable TransferListener<? super DataSource> transferListener; private @Nullable TransferListener transferListener;
/** /**
* @param uri The {@link Uri} of the media stream. * @param uri The {@link Uri} of the media stream.
@ -347,7 +347,7 @@ public final class ExtractorMediaSource extends BaseMediaSource
public void prepareSourceInternal( public void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
transferListener = mediaTransferListener; transferListener = mediaTransferListener;
notifySourceInfoRefreshed(timelineDurationUs, /* isSeekable= */ false); notifySourceInfoRefreshed(timelineDurationUs, /* isSeekable= */ false);
} }

View File

@ -22,7 +22,6 @@ import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.ShuffleOrder.UnshuffledShuffleOrder; import com.google.android.exoplayer2.source.ShuffleOrder.UnshuffledShuffleOrder;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
@ -65,7 +64,7 @@ public final class LoopingMediaSource extends CompositeMediaSource<Void> {
public void prepareSourceInternal( public void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener); super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
prepareChildSource(/* id= */ null, childSource); prepareChildSource(/* id= */ null, childSource);
} }

View File

@ -21,7 +21,6 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import java.io.IOException; import java.io.IOException;
@ -257,7 +256,7 @@ public interface MediaSource {
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
SourceInfoRefreshListener listener, SourceInfoRefreshListener listener,
@Nullable TransferListener<? super DataSource> mediaTransferListener); @Nullable TransferListener mediaTransferListener);
/** /**
* Throws any pending error encountered while loading or refreshing source information. * Throws any pending error encountered while loading or refreshing source information.

View File

@ -20,7 +20,6 @@ import android.support.annotation.Nullable;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@ -102,7 +101,7 @@ public final class MergingMediaSource extends CompositeMediaSource<Integer> {
public void prepareSourceInternal( public void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener); super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
for (int i = 0; i < mediaSources.length; i++) { for (int i = 0; i < mediaSources.length; i++) {
prepareChildSource(i, mediaSources[i]); prepareChildSource(i, mediaSources[i]);

View File

@ -49,7 +49,7 @@ import java.util.Arrays;
private final DataSpec dataSpec; private final DataSpec dataSpec;
private final DataSource.Factory dataSourceFactory; private final DataSource.Factory dataSourceFactory;
private final @Nullable TransferListener<? super DataSource> transferListener; private final @Nullable TransferListener transferListener;
private final int minLoadableRetryCount; private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final TrackGroupArray tracks; private final TrackGroupArray tracks;
@ -70,7 +70,7 @@ import java.util.Arrays;
public SingleSampleMediaPeriod( public SingleSampleMediaPeriod(
DataSpec dataSpec, DataSpec dataSpec,
DataSource.Factory dataSourceFactory, DataSource.Factory dataSourceFactory,
@Nullable TransferListener<? super DataSource> transferListener, @Nullable TransferListener transferListener,
Format format, Format format,
long durationUs, long durationUs,
int minLoadableRetryCount, int minLoadableRetryCount,

View File

@ -169,7 +169,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
private final boolean treatLoadErrorsAsEndOfStream; private final boolean treatLoadErrorsAsEndOfStream;
private final Timeline timeline; private final Timeline timeline;
private @Nullable TransferListener<? super DataSource> transferListener; private @Nullable TransferListener transferListener;
/** /**
* @param uri The {@link Uri} of the media stream. * @param uri The {@link Uri} of the media stream.
@ -274,7 +274,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
public void prepareSourceInternal( public void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
transferListener = mediaTransferListener; transferListener = mediaTransferListener;
refreshSourceInfo(timeline, /* manifest= */ null); refreshSourceInfo(timeline, /* manifest= */ null);
} }

View File

@ -309,7 +309,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
public void prepareSourceInternal( public void prepareSourceInternal(
final ExoPlayer player, final ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener); super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
Assertions.checkArgument(isTopLevelSource); Assertions.checkArgument(isTopLevelSource);
final ComponentListener componentListener = new ComponentListener(); final ComponentListener componentListener = new ComponentListener();

View File

@ -56,7 +56,7 @@ public final class AssetDataSource extends BaseDataSource {
* @param context A context. * @param context A context.
* @param listener An optional listener. * @param listener An optional listener.
*/ */
public AssetDataSource(Context context, @Nullable TransferListener<? super DataSource> listener) { public AssetDataSource(Context context, @Nullable TransferListener listener) {
super(/* isNetwork= */ false); super(/* isNetwork= */ false);
this.assetManager = context.getAssets(); this.assetManager = context.getAssets();
if (listener != null) { if (listener != null) {

View File

@ -49,7 +49,7 @@ public interface BandwidthMeter {
* from data transfers. May be null, if no transfer listener is used. * from data transfers. May be null, if no transfer listener is used.
*/ */
@Nullable @Nullable
TransferListener<? super DataSource> getTransferListener(); TransferListener getTransferListener();
/** /**
* Adds an {@link EventListener} to be informed of bandwidth samples. * Adds an {@link EventListener} to be informed of bandwidth samples.

View File

@ -29,7 +29,7 @@ import java.util.ArrayList;
public abstract class BaseDataSource implements DataSource { public abstract class BaseDataSource implements DataSource {
private final boolean isNetwork; private final boolean isNetwork;
private final ArrayList<TransferListener<? super DataSource>> listeners; private final ArrayList<TransferListener> listeners;
private @Nullable DataSpec dataSpec; private @Nullable DataSpec dataSpec;
@ -44,7 +44,7 @@ public abstract class BaseDataSource implements DataSource {
} }
@Override @Override
public final void addTransferListener(TransferListener<? super DataSource> transferListener) { public final void addTransferListener(TransferListener transferListener) {
listeners.add(transferListener); listeners.add(transferListener);
} }

View File

@ -60,8 +60,7 @@ public final class ContentDataSource extends BaseDataSource {
* @param context A context. * @param context A context.
* @param listener An optional listener. * @param listener An optional listener.
*/ */
public ContentDataSource( public ContentDataSource(Context context, @Nullable TransferListener listener) {
Context context, @Nullable TransferListener<? super DataSource> listener) {
super(/* isNetwork= */ false); super(/* isNetwork= */ false);
this.resolver = context.getContentResolver(); this.resolver = context.getContentResolver();
if (listener != null) { if (listener != null) {

View File

@ -44,7 +44,7 @@ public interface DataSource {
* *
* @param transferListener A {@link TransferListener}. * @param transferListener A {@link TransferListener}.
*/ */
default void addTransferListener(TransferListener<? super DataSource> transferListener) { default void addTransferListener(TransferListener transferListener) {
// TODO: Make non-default once all DataSources implement this method. // TODO: Make non-default once all DataSources implement this method.
} }

View File

@ -26,7 +26,7 @@ import com.google.android.exoplayer2.util.SlidingPercentile;
* Estimates bandwidth by listening to data transfers. The bandwidth estimate is calculated using a * Estimates bandwidth by listening to data transfers. The bandwidth estimate is calculated using a
* {@link SlidingPercentile} and is updated each time a transfer ends. * {@link SlidingPercentile} and is updated each time a transfer ends.
*/ */
public final class DefaultBandwidthMeter implements BandwidthMeter, TransferListener<Object> { public final class DefaultBandwidthMeter implements BandwidthMeter, TransferListener {
/** Default initial bitrate estimate in bits per second. */ /** Default initial bitrate estimate in bits per second. */
public static final long DEFAULT_INITIAL_BITRATE_ESTIMATE = 1_000_000; public static final long DEFAULT_INITIAL_BITRATE_ESTIMATE = 1_000_000;
@ -169,7 +169,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
} }
@Override @Override
public @Nullable TransferListener<? super DataSource> getTransferListener() { public @Nullable TransferListener getTransferListener() {
return this; return this;
} }
@ -184,12 +184,13 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
} }
@Override @Override
public void onTransferInitializing(Object source, DataSpec dataSpec, boolean isNetwork) { public void onTransferInitializing(DataSource source, DataSpec dataSpec, boolean isNetwork) {
// Do nothing. // Do nothing.
} }
@Override @Override
public synchronized void onTransferStart(Object source, DataSpec dataSpec, boolean isNetwork) { public synchronized void onTransferStart(
DataSource source, DataSpec dataSpec, boolean isNetwork) {
if (!isNetwork) { if (!isNetwork) {
return; return;
} }
@ -201,7 +202,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
@Override @Override
public synchronized void onBytesTransferred( public synchronized void onBytesTransferred(
Object source, DataSpec dataSpec, boolean isNetwork, int bytes) { DataSource source, DataSpec dataSpec, boolean isNetwork, int bytes) {
if (!isNetwork) { if (!isNetwork) {
return; return;
} }
@ -209,7 +210,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
} }
@Override @Override
public synchronized void onTransferEnd(Object source, DataSpec dataSpec, boolean isNetwork) { public synchronized void onTransferEnd(DataSource source, DataSpec dataSpec, boolean isNetwork) {
if (!isNetwork) { if (!isNetwork) {
return; return;
} }

View File

@ -57,7 +57,7 @@ public final class DefaultDataSource implements DataSource {
private static final String SCHEME_RAW = RawResourceDataSource.RAW_RESOURCE_SCHEME; private static final String SCHEME_RAW = RawResourceDataSource.RAW_RESOURCE_SCHEME;
private final Context context; private final Context context;
private final List<TransferListener<? super DataSource>> transferListeners; private final List<TransferListener> transferListeners;
private final DataSource baseDataSource; private final DataSource baseDataSource;
// Lazily initialized. // Lazily initialized.
@ -81,7 +81,7 @@ public final class DefaultDataSource implements DataSource {
*/ */
public DefaultDataSource( public DefaultDataSource(
Context context, Context context,
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener,
String userAgent, String userAgent,
boolean allowCrossProtocolRedirects) { boolean allowCrossProtocolRedirects) {
this(context, listener, userAgent, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, this(context, listener, userAgent, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
@ -103,7 +103,7 @@ public final class DefaultDataSource implements DataSource {
*/ */
public DefaultDataSource( public DefaultDataSource(
Context context, Context context,
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener,
String userAgent, String userAgent,
int connectTimeoutMillis, int connectTimeoutMillis,
int readTimeoutMillis, int readTimeoutMillis,
@ -123,9 +123,7 @@ public final class DefaultDataSource implements DataSource {
* content. This {@link DataSource} should normally support at least http(s). * content. This {@link DataSource} should normally support at least http(s).
*/ */
public DefaultDataSource( public DefaultDataSource(
Context context, Context context, @Nullable TransferListener listener, DataSource baseDataSource) {
@Nullable TransferListener<? super DataSource> listener,
DataSource baseDataSource) {
this.context = context.getApplicationContext(); this.context = context.getApplicationContext();
this.baseDataSource = Assertions.checkNotNull(baseDataSource); this.baseDataSource = Assertions.checkNotNull(baseDataSource);
transferListeners = new ArrayList<>(); transferListeners = new ArrayList<>();
@ -135,7 +133,7 @@ public final class DefaultDataSource implements DataSource {
} }
@Override @Override
public void addTransferListener(TransferListener<? super DataSource> transferListener) { public void addTransferListener(TransferListener transferListener) {
baseDataSource.addTransferListener(transferListener); baseDataSource.addTransferListener(transferListener);
transferListeners.add(transferListener); transferListeners.add(transferListener);
maybeAddListenerToDataSource(fileDataSource, transferListener); maybeAddListenerToDataSource(fileDataSource, transferListener);
@ -271,7 +269,7 @@ public final class DefaultDataSource implements DataSource {
} }
private void maybeAddListenerToDataSource( private void maybeAddListenerToDataSource(
@Nullable DataSource dataSource, TransferListener<? super DataSource> listener) { @Nullable DataSource dataSource, TransferListener listener) {
if (dataSource != null) { if (dataSource != null) {
dataSource.addTransferListener(listener); dataSource.addTransferListener(listener);
} }

View File

@ -26,7 +26,7 @@ import com.google.android.exoplayer2.upstream.DataSource.Factory;
public final class DefaultDataSourceFactory implements Factory { public final class DefaultDataSourceFactory implements Factory {
private final Context context; private final Context context;
private final @Nullable TransferListener<? super DataSource> listener; private final @Nullable TransferListener listener;
private final DataSource.Factory baseDataSourceFactory; private final DataSource.Factory baseDataSourceFactory;
/** /**
@ -43,7 +43,7 @@ public final class DefaultDataSourceFactory implements Factory {
* @param listener An optional listener. * @param listener An optional listener.
*/ */
public DefaultDataSourceFactory( public DefaultDataSourceFactory(
Context context, String userAgent, @Nullable TransferListener<? super DataSource> listener) { Context context, String userAgent, @Nullable TransferListener listener) {
this(context, listener, new DefaultHttpDataSourceFactory(userAgent, listener)); this(context, listener, new DefaultHttpDataSourceFactory(userAgent, listener));
} }
@ -66,7 +66,7 @@ public final class DefaultDataSourceFactory implements Factory {
*/ */
public DefaultDataSourceFactory( public DefaultDataSourceFactory(
Context context, Context context,
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener,
DataSource.Factory baseDataSourceFactory) { DataSource.Factory baseDataSourceFactory) {
this.context = context.getApplicationContext(); this.context = context.getApplicationContext();
this.listener = listener; this.listener = listener;

View File

@ -105,7 +105,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
public DefaultHttpDataSource( public DefaultHttpDataSource(
String userAgent, String userAgent,
@Nullable Predicate<String> contentTypePredicate, @Nullable Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> listener) { @Nullable TransferListener listener) {
this(userAgent, contentTypePredicate, listener, DEFAULT_CONNECT_TIMEOUT_MILLIS, this(userAgent, contentTypePredicate, listener, DEFAULT_CONNECT_TIMEOUT_MILLIS,
DEFAULT_READ_TIMEOUT_MILLIS); DEFAULT_READ_TIMEOUT_MILLIS);
} }
@ -124,7 +124,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
public DefaultHttpDataSource( public DefaultHttpDataSource(
String userAgent, String userAgent,
@Nullable Predicate<String> contentTypePredicate, @Nullable Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener,
int connectTimeoutMillis, int connectTimeoutMillis,
int readTimeoutMillis) { int readTimeoutMillis) {
this(userAgent, contentTypePredicate, listener, connectTimeoutMillis, readTimeoutMillis, false, this(userAgent, contentTypePredicate, listener, connectTimeoutMillis, readTimeoutMillis, false,
@ -150,7 +150,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
public DefaultHttpDataSource( public DefaultHttpDataSource(
String userAgent, String userAgent,
@Nullable Predicate<String> contentTypePredicate, @Nullable Predicate<String> contentTypePredicate,
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener,
int connectTimeoutMillis, int connectTimeoutMillis,
int readTimeoutMillis, int readTimeoutMillis,
boolean allowCrossProtocolRedirects, boolean allowCrossProtocolRedirects,

View File

@ -23,7 +23,7 @@ import com.google.android.exoplayer2.upstream.HttpDataSource.Factory;
public final class DefaultHttpDataSourceFactory extends BaseFactory { public final class DefaultHttpDataSourceFactory extends BaseFactory {
private final String userAgent; private final String userAgent;
private final @Nullable TransferListener<? super DataSource> listener; private final @Nullable TransferListener listener;
private final int connectTimeoutMillis; private final int connectTimeoutMillis;
private final int readTimeoutMillis; private final int readTimeoutMillis;
private final boolean allowCrossProtocolRedirects; private final boolean allowCrossProtocolRedirects;
@ -50,8 +50,7 @@ public final class DefaultHttpDataSourceFactory extends BaseFactory {
* @param listener An optional listener. * @param listener An optional listener.
* @see #DefaultHttpDataSourceFactory(String, TransferListener, int, int, boolean) * @see #DefaultHttpDataSourceFactory(String, TransferListener, int, int, boolean)
*/ */
public DefaultHttpDataSourceFactory( public DefaultHttpDataSourceFactory(String userAgent, @Nullable TransferListener listener) {
String userAgent, @Nullable TransferListener<? super DataSource> listener) {
this(userAgent, listener, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, this(userAgent, listener, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, false); DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, false);
} }
@ -90,7 +89,7 @@ public final class DefaultHttpDataSourceFactory extends BaseFactory {
*/ */
public DefaultHttpDataSourceFactory( public DefaultHttpDataSourceFactory(
String userAgent, String userAgent,
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener,
int connectTimeoutMillis, int connectTimeoutMillis,
int readTimeoutMillis, int readTimeoutMillis,
boolean allowCrossProtocolRedirects) { boolean allowCrossProtocolRedirects) {

View File

@ -46,7 +46,7 @@ public final class FileDataSource extends BaseDataSource {
} }
/** @param listener An optional listener. */ /** @param listener An optional listener. */
public FileDataSource(@Nullable TransferListener<? super DataSource> listener) { public FileDataSource(@Nullable TransferListener listener) {
super(/* isNetwork= */ false); super(/* isNetwork= */ false);
if (listener != null) { if (listener != null) {
addTransferListener(listener); addTransferListener(listener);

View File

@ -22,13 +22,13 @@ import android.support.annotation.Nullable;
*/ */
public final class FileDataSourceFactory implements DataSource.Factory { public final class FileDataSourceFactory implements DataSource.Factory {
private final @Nullable TransferListener<? super DataSource> listener; private final @Nullable TransferListener listener;
public FileDataSourceFactory() { public FileDataSourceFactory() {
this(null); this(null);
} }
public FileDataSourceFactory(@Nullable TransferListener<? super DataSource> listener) { public FileDataSourceFactory(@Nullable TransferListener listener) {
this.listener = listener; this.listener = listener;
} }

View File

@ -54,7 +54,7 @@ public final class PriorityDataSource implements DataSource {
} }
@Override @Override
public void addTransferListener(TransferListener<? super DataSource> transferListener) { public void addTransferListener(TransferListener transferListener) {
upstream.addTransferListener(transferListener); upstream.addTransferListener(transferListener);
} }

View File

@ -81,8 +81,7 @@ public final class RawResourceDataSource extends BaseDataSource {
* @param context A context. * @param context A context.
* @param listener An optional listener. * @param listener An optional listener.
*/ */
public RawResourceDataSource( public RawResourceDataSource(Context context, @Nullable TransferListener listener) {
Context context, @Nullable TransferListener<? super DataSource> listener) {
super(/* isNetwork= */ false); super(/* isNetwork= */ false);
this.resources = context.getResources(); this.resources = context.getResources();
if (listener != null) { if (listener != null) {

View File

@ -71,7 +71,7 @@ public final class StatsDataSource implements DataSource {
} }
@Override @Override
public void addTransferListener(TransferListener<? super DataSource> transferListener) { public void addTransferListener(TransferListener transferListener) {
dataSource.addTransferListener(transferListener); dataSource.addTransferListener(transferListener);
} }

View File

@ -44,7 +44,7 @@ public final class TeeDataSource implements DataSource {
} }
@Override @Override
public void addTransferListener(TransferListener<? super DataSource> transferListener) { public void addTransferListener(TransferListener transferListener) {
upstream.addTransferListener(transferListener); upstream.addTransferListener(transferListener);
} }

View File

@ -22,20 +22,20 @@ package com.google.android.exoplayer2.upstream;
* *
* <ol> * <ol>
* <li>Initializing the underlying resource (e.g. opening a HTTP connection). {@link * <li>Initializing the underlying resource (e.g. opening a HTTP connection). {@link
* #onTransferInitializing(Object, DataSpec, boolean)} is called before the initialization * #onTransferInitializing(DataSource, DataSpec, boolean)} is called before the initialization
* starts. * starts.
* <li>Starting the transfer after successfully initializing the resource. {@link * <li>Starting the transfer after successfully initializing the resource. {@link
* #onTransferStart(Object, DataSpec, boolean)} is called. Note that this only happens if the * #onTransferStart(DataSource, DataSpec, boolean)} is called. Note that this only happens if
* initialization was successful. * the initialization was successful.
* <li>Transferring data. {@link #onBytesTransferred(Object, DataSpec, boolean, int)} is called * <li>Transferring data. {@link #onBytesTransferred(DataSource, DataSpec, boolean, int)} is
* frequently during the transfer to indicate progress. * called frequently during the transfer to indicate progress.
* <li>Closing the transfer and the underlying resource. {@link #onTransferEnd(Object, DataSpec, * <li>Closing the transfer and the underlying resource. {@link #onTransferEnd(DataSource,
* boolean)} is called. Note that each {@link #onTransferStart(Object, DataSpec, boolean)} * DataSpec, boolean)} is called. Note that each {@link #onTransferStart(DataSource, DataSpec,
* will have exactly one corresponding call to {@link #onTransferEnd(Object, DataSpec, * boolean)} will have exactly one corresponding call to {@link #onTransferEnd(DataSource,
* boolean)}. * DataSpec, boolean)}.
* </ol> * </ol>
*/ */
public interface TransferListener<S> { public interface TransferListener {
/** /**
* Called when a transfer is being initialized. * Called when a transfer is being initialized.
@ -44,7 +44,7 @@ public interface TransferListener<S> {
* @param dataSpec Describes the data for which the transfer is initialized. * @param dataSpec Describes the data for which the transfer is initialized.
* @param isNetwork Whether the data is transferred through a network. * @param isNetwork Whether the data is transferred through a network.
*/ */
void onTransferInitializing(S source, DataSpec dataSpec, boolean isNetwork); void onTransferInitializing(DataSource source, DataSpec dataSpec, boolean isNetwork);
/** /**
* Called when a transfer starts. * Called when a transfer starts.
@ -53,7 +53,7 @@ public interface TransferListener<S> {
* @param dataSpec Describes the data being transferred. * @param dataSpec Describes the data being transferred.
* @param isNetwork Whether the data is transferred through a network. * @param isNetwork Whether the data is transferred through a network.
*/ */
void onTransferStart(S source, DataSpec dataSpec, boolean isNetwork); void onTransferStart(DataSource source, DataSpec dataSpec, boolean isNetwork);
/** /**
* Called incrementally during a transfer. * Called incrementally during a transfer.
@ -63,7 +63,8 @@ public interface TransferListener<S> {
* @param isNetwork Whether the data is transferred through a network. * @param isNetwork Whether the data is transferred through a network.
* @param bytesTransferred The number of bytes transferred since the previous call to this method * @param bytesTransferred The number of bytes transferred since the previous call to this method
*/ */
void onBytesTransferred(S source, DataSpec dataSpec, boolean isNetwork, int bytesTransferred); void onBytesTransferred(
DataSource source, DataSpec dataSpec, boolean isNetwork, int bytesTransferred);
/** /**
* Called when a transfer ends. * Called when a transfer ends.
@ -72,5 +73,5 @@ public interface TransferListener<S> {
* @param dataSpec Describes the data being transferred. * @param dataSpec Describes the data being transferred.
* @param isNetwork Whether the data is transferred through a network. * @param isNetwork Whether the data is transferred through a network.
*/ */
void onTransferEnd(S source, DataSpec dataSpec, boolean isNetwork); void onTransferEnd(DataSource source, DataSpec dataSpec, boolean isNetwork);
} }

View File

@ -64,7 +64,7 @@ public final class UdpDataSource extends BaseDataSource {
private int packetRemaining; private int packetRemaining;
/** @param listener An optional listener. */ /** @param listener An optional listener. */
public UdpDataSource(@Nullable TransferListener<? super DataSource> listener) { public UdpDataSource(@Nullable TransferListener listener) {
this(listener, DEFAULT_MAX_PACKET_SIZE); this(listener, DEFAULT_MAX_PACKET_SIZE);
} }
@ -72,7 +72,7 @@ public final class UdpDataSource extends BaseDataSource {
* @param listener An optional listener. * @param listener An optional listener.
* @param maxPacketSize The maximum datagram packet size, in bytes. * @param maxPacketSize The maximum datagram packet size, in bytes.
*/ */
public UdpDataSource(@Nullable TransferListener<? super DataSource> listener, int maxPacketSize) { public UdpDataSource(@Nullable TransferListener listener, int maxPacketSize) {
this(listener, maxPacketSize, DEAFULT_SOCKET_TIMEOUT_MILLIS); this(listener, maxPacketSize, DEAFULT_SOCKET_TIMEOUT_MILLIS);
} }
@ -83,9 +83,7 @@ public final class UdpDataSource extends BaseDataSource {
* as an infinite timeout. * as an infinite timeout.
*/ */
public UdpDataSource( public UdpDataSource(
@Nullable TransferListener<? super DataSource> listener, @Nullable TransferListener listener, int maxPacketSize, int socketTimeoutMillis) {
int maxPacketSize,
int socketTimeoutMillis) {
super(/* isNetwork= */ true); super(/* isNetwork= */ true);
this.socketTimeoutMillis = socketTimeoutMillis; this.socketTimeoutMillis = socketTimeoutMillis;
packetBuffer = new byte[maxPacketSize]; packetBuffer = new byte[maxPacketSize];

View File

@ -258,7 +258,7 @@ public final class CacheDataSource implements DataSource {
} }
@Override @Override
public void addTransferListener(TransferListener<? super DataSource> transferListener) { public void addTransferListener(TransferListener transferListener) {
cacheReadDataSource.addTransferListener(transferListener); cacheReadDataSource.addTransferListener(transferListener);
upstreamDataSource.addTransferListener(transferListener); upstreamDataSource.addTransferListener(transferListener);
} }

View File

@ -42,7 +42,7 @@ public final class AesCipherDataSource implements DataSource {
} }
@Override @Override
public void addTransferListener(TransferListener<? super DataSource> transferListener) { public void addTransferListener(TransferListener transferListener) {
upstream.addTransferListener(transferListener); upstream.addTransferListener(transferListener);
} }

View File

@ -45,7 +45,6 @@ import com.google.android.exoplayer2.testutil.FakeTrackSelection;
import com.google.android.exoplayer2.testutil.FakeTrackSelector; import com.google.android.exoplayer2.testutil.FakeTrackSelector;
import com.google.android.exoplayer2.testutil.RobolectricUtil; import com.google.android.exoplayer2.testutil.RobolectricUtil;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -234,7 +233,7 @@ public final class ExoPlayerTest {
public synchronized void prepareSourceInternal( public synchronized void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener); super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
// We've queued a source info refresh on the playback thread's event queue. Allow the // We've queued a source info refresh on the playback thread's event queue. Allow the
// test thread to prepare the player with the third source, and block this thread (the // test thread to prepare the player with the third source, and block this thread (the
@ -582,7 +581,7 @@ public final class ExoPlayerTest {
TrackGroupArray trackGroupArray, TrackGroupArray trackGroupArray,
Allocator allocator, Allocator allocator,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray, eventDispatcher); FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray, eventDispatcher);
mediaPeriod.setSeekToUsOffset(10); mediaPeriod.setSeekToUsOffset(10);
return mediaPeriod; return mediaPeriod;
@ -617,7 +616,7 @@ public final class ExoPlayerTest {
TrackGroupArray trackGroupArray, TrackGroupArray trackGroupArray,
Allocator allocator, Allocator allocator,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray, eventDispatcher); FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray, eventDispatcher);
mediaPeriod.setDiscontinuityPositionUs(10); mediaPeriod.setDiscontinuityPositionUs(10);
return mediaPeriod; return mediaPeriod;
@ -643,7 +642,7 @@ public final class ExoPlayerTest {
TrackGroupArray trackGroupArray, TrackGroupArray trackGroupArray,
Allocator allocator, Allocator allocator,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray, eventDispatcher); FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray, eventDispatcher);
mediaPeriod.setDiscontinuityPositionUs(0); mediaPeriod.setDiscontinuityPositionUs(0);
return mediaPeriod; return mediaPeriod;
@ -880,7 +879,7 @@ public final class ExoPlayerTest {
TrackGroupArray trackGroupArray, TrackGroupArray trackGroupArray,
Allocator allocator, Allocator allocator,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
// Defer completing preparation of the period until playback parameters have been set. // Defer completing preparation of the period until playback parameters have been set.
fakeMediaPeriodHolder[0] = fakeMediaPeriodHolder[0] =
new FakeMediaPeriod(trackGroupArray, eventDispatcher, /* deferOnPrepared= */ true); new FakeMediaPeriod(trackGroupArray, eventDispatcher, /* deferOnPrepared= */ true);

View File

@ -37,7 +37,6 @@ import com.google.android.exoplayer2.testutil.MediaSourceTestRunner;
import com.google.android.exoplayer2.testutil.RobolectricUtil; import com.google.android.exoplayer2.testutil.RobolectricUtil;
import com.google.android.exoplayer2.testutil.TimelineAsserts; import com.google.android.exoplayer2.testutil.TimelineAsserts;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import java.io.IOException; import java.io.IOException;
import org.junit.Before; import org.junit.Before;
@ -481,7 +480,7 @@ public final class ClippingMediaSourceTest {
TrackGroupArray trackGroupArray, TrackGroupArray trackGroupArray,
Allocator allocator, Allocator allocator,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
eventDispatcher.downstreamFormatChanged( eventDispatcher.downstreamFormatChanged(
new MediaLoadData( new MediaLoadData(
C.DATA_TYPE_MEDIA, C.DATA_TYPE_MEDIA,

View File

@ -117,7 +117,7 @@ public class BaseDataSourceTest {
} }
} }
private static final class TestTransferListener implements TransferListener<DataSource> { private static final class TestTransferListener implements TransferListener {
public Object lastTransferInitializingSource; public Object lastTransferInitializingSource;
public DataSpec lastTransferInitializingDataSpec; public DataSpec lastTransferInitializingDataSpec;

View File

@ -21,7 +21,6 @@ import com.google.android.exoplayer2.source.chunk.ChunkSource;
import com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler; import com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler;
import com.google.android.exoplayer2.source.dash.manifest.DashManifest; import com.google.android.exoplayer2.source.dash.manifest.DashManifest;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.LoaderErrorThrower; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
@ -61,7 +60,7 @@ public interface DashChunkSource extends ChunkSource {
boolean enableEventMessageTrack, boolean enableEventMessageTrack,
boolean enableCea608Track, boolean enableCea608Track,
@Nullable PlayerTrackEmsgHandler playerEmsgHandler, @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
@Nullable TransferListener<? super DataSource> transferListener); @Nullable TransferListener transferListener);
} }
/** /**

View File

@ -42,7 +42,6 @@ import com.google.android.exoplayer2.source.dash.manifest.Period;
import com.google.android.exoplayer2.source.dash.manifest.Representation; import com.google.android.exoplayer2.source.dash.manifest.Representation;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.LoaderErrorThrower; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
@ -62,7 +61,7 @@ import java.util.List;
/* package */ final int id; /* package */ final int id;
private final DashChunkSource.Factory chunkSourceFactory; private final DashChunkSource.Factory chunkSourceFactory;
private final @Nullable TransferListener<? super DataSource> transferListener; private final @Nullable TransferListener transferListener;
private final int minLoadableRetryCount; private final int minLoadableRetryCount;
private final long elapsedRealtimeOffset; private final long elapsedRealtimeOffset;
private final LoaderErrorThrower manifestLoaderErrorThrower; private final LoaderErrorThrower manifestLoaderErrorThrower;
@ -89,7 +88,7 @@ import java.util.List;
DashManifest manifest, DashManifest manifest,
int periodIndex, int periodIndex,
DashChunkSource.Factory chunkSourceFactory, DashChunkSource.Factory chunkSourceFactory,
@Nullable TransferListener<? super DataSource> transferListener, @Nullable TransferListener transferListener,
int minLoadableRetryCount, int minLoadableRetryCount,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,
long elapsedRealtimeOffset, long elapsedRealtimeOffset,

View File

@ -344,7 +344,7 @@ public final class DashMediaSource extends BaseMediaSource {
private DataSource dataSource; private DataSource dataSource;
private Loader loader; private Loader loader;
private @Nullable TransferListener<? super DataSource> mediaTransferListener; private @Nullable TransferListener mediaTransferListener;
private IOException manifestFatalError; private IOException manifestFatalError;
private Handler handler; private Handler handler;
@ -596,7 +596,7 @@ public final class DashMediaSource extends BaseMediaSource {
public void prepareSourceInternal( public void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
this.mediaTransferListener = mediaTransferListener; this.mediaTransferListener = mediaTransferListener;
if (sideloadedManifest) { if (sideloadedManifest) {
processManifest(false); processManifest(false);

View File

@ -89,7 +89,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
boolean enableEventMessageTrack, boolean enableEventMessageTrack,
boolean enableCea608Track, boolean enableCea608Track,
@Nullable PlayerTrackEmsgHandler playerEmsgHandler, @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
DataSource dataSource = dataSourceFactory.createDataSource(); DataSource dataSource = dataSourceFactory.createDataSource();
if (transferListener != null) { if (transferListener != null) {
dataSource.addTransferListener(transferListener); dataSource.addTransferListener(transferListener);

View File

@ -65,7 +65,7 @@ import javax.crypto.spec.SecretKeySpec;
} }
@Override @Override
public void addTransferListener(TransferListener<? super DataSource> transferListener) { public void addTransferListener(TransferListener transferListener) {
upstream.addTransferListener(transferListener); upstream.addTransferListener(transferListener);
} }

View File

@ -129,7 +129,7 @@ import java.util.List;
HlsPlaylistTracker playlistTracker, HlsPlaylistTracker playlistTracker,
HlsUrl[] variants, HlsUrl[] variants,
HlsDataSourceFactory dataSourceFactory, HlsDataSourceFactory dataSourceFactory,
@Nullable TransferListener<? super DataSource> mediaTransferListener, @Nullable TransferListener mediaTransferListener,
TimestampAdjusterProvider timestampAdjusterProvider, TimestampAdjusterProvider timestampAdjusterProvider,
List<Format> muxedCaptionFormats) { List<Format> muxedCaptionFormats) {
this.extractorFactory = extractorFactory; this.extractorFactory = extractorFactory;

View File

@ -55,7 +55,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
private final HlsExtractorFactory extractorFactory; private final HlsExtractorFactory extractorFactory;
private final HlsPlaylistTracker playlistTracker; private final HlsPlaylistTracker playlistTracker;
private final HlsDataSourceFactory dataSourceFactory; private final HlsDataSourceFactory dataSourceFactory;
private final @Nullable TransferListener<? super DataSource> mediaTransferListener; private final @Nullable TransferListener mediaTransferListener;
private final LoadErrorHandlingPolicy<Chunk> chunkLoadErrorHandlingPolicy; private final LoadErrorHandlingPolicy<Chunk> chunkLoadErrorHandlingPolicy;
private final int minLoadableRetryCount; private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
@ -94,7 +94,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
HlsExtractorFactory extractorFactory, HlsExtractorFactory extractorFactory,
HlsPlaylistTracker playlistTracker, HlsPlaylistTracker playlistTracker,
HlsDataSourceFactory dataSourceFactory, HlsDataSourceFactory dataSourceFactory,
@Nullable TransferListener<? super DataSource> mediaTransferListener, @Nullable TransferListener mediaTransferListener,
LoadErrorHandlingPolicy<Chunk> chunkLoadErrorHandlingPolicy, LoadErrorHandlingPolicy<Chunk> chunkLoadErrorHandlingPolicy,
int minLoadableRetryCount, int minLoadableRetryCount,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,

View File

@ -287,7 +287,7 @@ public final class HlsMediaSource extends BaseMediaSource
private final HlsPlaylistTracker playlistTracker; private final HlsPlaylistTracker playlistTracker;
private final @Nullable Object tag; private final @Nullable Object tag;
private @Nullable TransferListener<? super DataSource> mediaTransferListener; private @Nullable TransferListener mediaTransferListener;
/** /**
* @param manifestUri The {@link Uri} of the HLS manifest. * @param manifestUri The {@link Uri} of the HLS manifest.
@ -402,7 +402,7 @@ public final class HlsMediaSource extends BaseMediaSource
public void prepareSourceInternal( public void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
this.mediaTransferListener = mediaTransferListener; this.mediaTransferListener = mediaTransferListener;
EventDispatcher eventDispatcher = createEventDispatcher(/* mediaPeriodId= */ null); EventDispatcher eventDispatcher = createEventDispatcher(/* mediaPeriodId= */ null);
playlistTracker.start(manifestUri, eventDispatcher, /* listener= */ this); playlistTracker.start(manifestUri, eventDispatcher, /* listener= */ this);

View File

@ -61,7 +61,7 @@ public class DefaultSsChunkSource implements SsChunkSource {
int elementIndex, int elementIndex,
TrackSelection trackSelection, TrackSelection trackSelection,
TrackEncryptionBox[] trackEncryptionBoxes, TrackEncryptionBox[] trackEncryptionBoxes,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
DataSource dataSource = dataSourceFactory.createDataSource(); DataSource dataSource = dataSourceFactory.createDataSource();
if (transferListener != null) { if (transferListener != null) {
dataSource.addTransferListener(transferListener); dataSource.addTransferListener(transferListener);

View File

@ -20,7 +20,6 @@ import com.google.android.exoplayer2.extractor.mp4.TrackEncryptionBox;
import com.google.android.exoplayer2.source.chunk.ChunkSource; import com.google.android.exoplayer2.source.chunk.ChunkSource;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest; import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.LoaderErrorThrower; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
@ -50,7 +49,7 @@ public interface SsChunkSource extends ChunkSource {
int streamElementIndex, int streamElementIndex,
TrackSelection trackSelection, TrackSelection trackSelection,
TrackEncryptionBox[] trackEncryptionBoxes, TrackEncryptionBox[] trackEncryptionBoxes,
@Nullable TransferListener<? super DataSource> transferListener); @Nullable TransferListener transferListener);
} }
/** /**

View File

@ -32,7 +32,6 @@ import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.ProtectionElement; import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.ProtectionElement;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.LoaderErrorThrower; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import java.io.IOException; import java.io.IOException;
@ -47,7 +46,7 @@ import java.util.ArrayList;
private static final int INITIALIZATION_VECTOR_SIZE = 8; private static final int INITIALIZATION_VECTOR_SIZE = 8;
private final SsChunkSource.Factory chunkSourceFactory; private final SsChunkSource.Factory chunkSourceFactory;
private final @Nullable TransferListener<? super DataSource> transferListener; private final @Nullable TransferListener transferListener;
private final LoaderErrorThrower manifestLoaderErrorThrower; private final LoaderErrorThrower manifestLoaderErrorThrower;
private final int minLoadableRetryCount; private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
@ -65,7 +64,7 @@ import java.util.ArrayList;
public SsMediaPeriod( public SsMediaPeriod(
SsManifest manifest, SsManifest manifest,
SsChunkSource.Factory chunkSourceFactory, SsChunkSource.Factory chunkSourceFactory,
@Nullable TransferListener<? super DataSource> transferListener, @Nullable TransferListener transferListener,
CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory, CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
int minLoadableRetryCount, int minLoadableRetryCount,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,

View File

@ -295,7 +295,7 @@ public final class SsMediaSource extends BaseMediaSource
private DataSource manifestDataSource; private DataSource manifestDataSource;
private Loader manifestLoader; private Loader manifestLoader;
private LoaderErrorThrower manifestLoaderErrorThrower; private LoaderErrorThrower manifestLoaderErrorThrower;
private @Nullable TransferListener<? super DataSource> mediaTransferListener; private @Nullable TransferListener mediaTransferListener;
private long manifestLoadStartTimestamp; private long manifestLoadStartTimestamp;
private SsManifest manifest; private SsManifest manifest;
@ -477,7 +477,7 @@ public final class SsMediaSource extends BaseMediaSource
public void prepareSourceInternal( public void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
this.mediaTransferListener = mediaTransferListener; this.mediaTransferListener = mediaTransferListener;
if (sideloadedManifest) { if (sideloadedManifest) {
manifestLoaderErrorThrower = new LoaderErrorThrower.Dummy(); manifestLoaderErrorThrower = new LoaderErrorThrower.Dummy();

View File

@ -307,8 +307,8 @@ public final class DashTestRunner {
} }
@Override @Override
protected MediaSource buildSource(HostActivity host, String userAgent, protected MediaSource buildSource(
TransferListener<? super DataSource> mediaTransferListener) { HostActivity host, String userAgent, TransferListener mediaTransferListener) {
DataSource.Factory manifestDataSourceFactory = dataSourceFactory != null DataSource.Factory manifestDataSourceFactory = dataSourceFactory != null
? dataSourceFactory : new DefaultDataSourceFactory(host, userAgent); ? dataSourceFactory : new DefaultDataSourceFactory(host, userAgent);
DataSource.Factory mediaDataSourceFactory = dataSourceFactory != null DataSource.Factory mediaDataSourceFactory = dataSourceFactory != null

View File

@ -41,7 +41,6 @@ import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
import com.google.android.exoplayer2.upstream.BandwidthMeter; import com.google.android.exoplayer2.upstream.BandwidthMeter;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.Clock;
@ -377,8 +376,8 @@ public abstract class ExoHostedTest
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
protected abstract MediaSource buildSource(HostActivity host, String userAgent, protected abstract MediaSource buildSource(
TransferListener<? super DataSource> mediaTransferListener); HostActivity host, String userAgent, TransferListener mediaTransferListener);
@SuppressWarnings("unused") @SuppressWarnings("unused")
protected void onPlayerErrorInternal(ExoPlaybackException error) { protected void onPlayerErrorInternal(ExoPlaybackException error) {

View File

@ -25,7 +25,6 @@ import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.source.chunk.ChunkSampleStream; import com.google.android.exoplayer2.source.chunk.ChunkSampleStream;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import java.util.ArrayList; import java.util.ArrayList;
@ -40,7 +39,7 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
private final Allocator allocator; private final Allocator allocator;
private final FakeChunkSource.Factory chunkSourceFactory; private final FakeChunkSource.Factory chunkSourceFactory;
private final @Nullable TransferListener<? super DataSource> transferListener; private final @Nullable TransferListener transferListener;
private final long durationUs; private final long durationUs;
private Callback callback; private Callback callback;
@ -53,7 +52,7 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
Allocator allocator, Allocator allocator,
FakeChunkSource.Factory chunkSourceFactory, FakeChunkSource.Factory chunkSourceFactory,
long durationUs, long durationUs,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
super(trackGroupArray, eventDispatcher); super(trackGroupArray, eventDispatcher);
this.allocator = allocator; this.allocator = allocator;
this.chunkSourceFactory = chunkSourceFactory; this.chunkSourceFactory = chunkSourceFactory;

View File

@ -24,7 +24,6 @@ import com.google.android.exoplayer2.source.MediaSourceEventListener;
import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher; import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
/** /**
@ -53,7 +52,7 @@ public class FakeAdaptiveMediaSource extends FakeMediaSource {
TrackGroupArray trackGroupArray, TrackGroupArray trackGroupArray,
Allocator allocator, Allocator allocator,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
Period period = timeline.getPeriod(id.periodIndex, new Period()); Period period = timeline.getPeriod(id.periodIndex, new Period());
return new FakeAdaptiveMediaPeriod( return new FakeAdaptiveMediaPeriod(
trackGroupArray, trackGroupArray,

View File

@ -57,7 +57,7 @@ public final class FakeChunkSource implements ChunkSource {
public FakeChunkSource createChunkSource( public FakeChunkSource createChunkSource(
TrackSelection trackSelection, TrackSelection trackSelection,
long durationUs, long durationUs,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
FakeAdaptiveDataSet dataSet = FakeAdaptiveDataSet dataSet =
dataSetFactory.createDataSet(trackSelection.getTrackGroup(), durationUs); dataSetFactory.createDataSet(trackSelection.getTrackGroup(), durationUs);
dataSourceFactory.setFakeDataSet(dataSet); dataSourceFactory.setFakeDataSet(dataSet);

View File

@ -40,11 +40,11 @@ public class FakeDataSource extends BaseDataSource {
*/ */
public static class Factory implements DataSource.Factory { public static class Factory implements DataSource.Factory {
protected final TransferListener<? super DataSource> transferListener; protected final TransferListener transferListener;
protected FakeDataSet fakeDataSet; protected FakeDataSet fakeDataSet;
protected boolean isNetwork; protected boolean isNetwork;
public Factory(@Nullable TransferListener<? super DataSource> transferListener) { public Factory(@Nullable TransferListener transferListener) {
this.transferListener = transferListener; this.transferListener = transferListener;
} }
@ -83,9 +83,7 @@ public class FakeDataSource extends BaseDataSource {
} }
public FakeDataSource( public FakeDataSource(
FakeDataSet fakeDataSet, FakeDataSet fakeDataSet, @Nullable TransferListener transferListener, boolean isNetwork) {
@Nullable TransferListener<? super DataSource> transferListener,
boolean isNetwork) {
super(isNetwork); super(isNetwork);
Assertions.checkNotNull(fakeDataSet); Assertions.checkNotNull(fakeDataSet);
this.fakeDataSet = fakeDataSet; this.fakeDataSet = fakeDataSet;

View File

@ -35,7 +35,6 @@ import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadDa
import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
@ -61,7 +60,7 @@ public class FakeMediaSource extends BaseMediaSource {
private boolean preparedSource; private boolean preparedSource;
private boolean releasedSource; private boolean releasedSource;
private Handler sourceInfoRefreshHandler; private Handler sourceInfoRefreshHandler;
private @Nullable TransferListener<? super DataSource> transferListener; private @Nullable TransferListener transferListener;
/** /**
* Creates a {@link FakeMediaSource}. This media source creates {@link FakeMediaPeriod}s with a * Creates a {@link FakeMediaSource}. This media source creates {@link FakeMediaPeriod}s with a
@ -92,7 +91,7 @@ public class FakeMediaSource extends BaseMediaSource {
public synchronized void prepareSourceInternal( public synchronized void prepareSourceInternal(
ExoPlayer player, ExoPlayer player,
boolean isTopLevelSource, boolean isTopLevelSource,
@Nullable TransferListener<? super DataSource> mediaTransferListener) { @Nullable TransferListener mediaTransferListener) {
assertThat(preparedSource).isFalse(); assertThat(preparedSource).isFalse();
transferListener = mediaTransferListener; transferListener = mediaTransferListener;
preparedSource = true; preparedSource = true;
@ -206,7 +205,7 @@ public class FakeMediaSource extends BaseMediaSource {
TrackGroupArray trackGroupArray, TrackGroupArray trackGroupArray,
Allocator allocator, Allocator allocator,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,
@Nullable TransferListener<? super DataSource> transferListener) { @Nullable TransferListener transferListener) {
return new FakeMediaPeriod(trackGroupArray, eventDispatcher); return new FakeMediaPeriod(trackGroupArray, eventDispatcher);
} }