remove DefaultMediaSourceFactory.Delegate

PiperOrigin-RevId: 299943596
This commit is contained in:
bachinger 2020-03-09 22:00:54 +00:00 committed by Oliver Woodman
parent fdf35776f8
commit 87405cb1c0
7 changed files with 33 additions and 36 deletions

View file

@ -93,21 +93,6 @@ import java.util.Map;
*/ */
public final class DefaultMediaSourceFactory implements MediaSourceFactory { public final class DefaultMediaSourceFactory implements MediaSourceFactory {
/**
* A media source factory to which calls to {@link #createMediaSource(MediaItem)} calls are
* delegated by the {@link DefaultMediaSourceFactory}.
*/
public interface Delegate extends MediaSourceFactory {
/**
* Sets an optional {@link LoadErrorHandlingPolicy}.
*
* @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}.
* @return This factory, for convenience.
*/
MediaSourceFactory setLoadErrorHandlingPolicy(
@Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy);
}
/** /**
* Creates a new instance with the given {@link Context}. * Creates a new instance with the given {@link Context}.
* *
@ -134,7 +119,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
return new DefaultMediaSourceFactory(context, dataSourceFactory); return new DefaultMediaSourceFactory(context, dataSourceFactory);
} }
private final SparseArray<Delegate> mediaSourceFactories; private final SparseArray<MediaSourceFactory> mediaSourceFactories;
@C.ContentType private final int[] supportedTypes; @C.ContentType private final int[] supportedTypes;
private final String userAgent; private final String userAgent;
@ -287,42 +272,43 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
return drmCallback; return drmCallback;
} }
private static SparseArray<Delegate> loadDelegates(DataSource.Factory dataSourceFactory) { private static SparseArray<MediaSourceFactory> loadDelegates(
SparseArray<Delegate> delegates = new SparseArray<>(); DataSource.Factory dataSourceFactory) {
SparseArray<MediaSourceFactory> factories = new SparseArray<>();
// LINT.IfChange // LINT.IfChange
try { try {
Class<? extends DefaultMediaSourceFactory.Delegate> factoryClazz = Class<? extends MediaSourceFactory> factoryClazz =
Class.forName("com.google.android.exoplayer2.source.dash.DashMediaSource$Factory") Class.forName("com.google.android.exoplayer2.source.dash.DashMediaSource$Factory")
.asSubclass(DefaultMediaSourceFactory.Delegate.class); .asSubclass(MediaSourceFactory.class);
delegates.put( factories.put(
C.TYPE_DASH, C.TYPE_DASH,
factoryClazz.getConstructor(DataSource.Factory.class).newInstance(dataSourceFactory)); factoryClazz.getConstructor(DataSource.Factory.class).newInstance(dataSourceFactory));
} catch (Exception e) { } catch (Exception e) {
// Expected if the app was built without the dash module. // Expected if the app was built without the dash module.
} }
try { try {
Class<? extends DefaultMediaSourceFactory.Delegate> factoryClazz = Class<? extends MediaSourceFactory> factoryClazz =
Class.forName( Class.forName(
"com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource$Factory") "com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource$Factory")
.asSubclass(DefaultMediaSourceFactory.Delegate.class); .asSubclass(MediaSourceFactory.class);
delegates.put( factories.put(
C.TYPE_SS, C.TYPE_SS,
factoryClazz.getConstructor(DataSource.Factory.class).newInstance(dataSourceFactory)); factoryClazz.getConstructor(DataSource.Factory.class).newInstance(dataSourceFactory));
} catch (Exception e) { } catch (Exception e) {
// Expected if the app was built without the smoothstreaming module. // Expected if the app was built without the smoothstreaming module.
} }
try { try {
Class<? extends DefaultMediaSourceFactory.Delegate> factoryClazz = Class<? extends MediaSourceFactory> factoryClazz =
Class.forName("com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory") Class.forName("com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory")
.asSubclass(DefaultMediaSourceFactory.Delegate.class); .asSubclass(MediaSourceFactory.class);
delegates.put( factories.put(
C.TYPE_HLS, C.TYPE_HLS,
factoryClazz.getConstructor(DataSource.Factory.class).newInstance(dataSourceFactory)); factoryClazz.getConstructor(DataSource.Factory.class).newInstance(dataSourceFactory));
} catch (Exception e) { } catch (Exception e) {
// Expected if the app was built without the hls module. // Expected if the app was built without the hls module.
} }
// LINT.ThenChange(../../../../../../../../proguard-rules.txt) // LINT.ThenChange(../../../../../../../../proguard-rules.txt)
delegates.put(C.TYPE_OTHER, new ProgressiveMediaSource.Factory(dataSourceFactory)); factories.put(C.TYPE_OTHER, new ProgressiveMediaSource.Factory(dataSourceFactory));
return delegates; return factories;
} }
} }

View file

@ -136,6 +136,7 @@ public final class ExtractorMediaSource extends CompositeMediaSource<Void> {
* @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}. * @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}.
* @return This factory, for convenience. * @return This factory, for convenience.
*/ */
@Override
public Factory setLoadErrorHandlingPolicy( public Factory setLoadErrorHandlingPolicy(
@Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy) { @Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
this.loadErrorHandlingPolicy = this.loadErrorHandlingPolicy =

View file

@ -22,6 +22,7 @@ import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.drm.DrmSession; import com.google.android.exoplayer2.drm.DrmSession;
import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.offline.StreamKey; import com.google.android.exoplayer2.offline.StreamKey;
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
import java.util.List; import java.util.List;
/** Factory for creating {@link MediaSource}s from URIs. */ /** Factory for creating {@link MediaSource}s from URIs. */
@ -41,6 +42,15 @@ public interface MediaSourceFactory {
*/ */
MediaSourceFactory setDrmSessionManager(@Nullable DrmSessionManager<?> drmSessionManager); MediaSourceFactory setDrmSessionManager(@Nullable DrmSessionManager<?> drmSessionManager);
/**
* Sets an optional {@link LoadErrorHandlingPolicy}.
*
* @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}.
* @return This factory, for convenience.
*/
MediaSourceFactory setLoadErrorHandlingPolicy(
@Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy);
/** /**
* Returns the {@link C.ContentType content types} supported by media sources created by this * Returns the {@link C.ContentType content types} supported by media sources created by this
* factory. * factory.

View file

@ -47,7 +47,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
implements ProgressiveMediaPeriod.Listener { implements ProgressiveMediaPeriod.Listener {
/** Factory for {@link ProgressiveMediaSource}s. */ /** Factory for {@link ProgressiveMediaSource}s. */
public static final class Factory implements DefaultMediaSourceFactory.Delegate { public static final class Factory implements MediaSourceFactory {
private final DataSource.Factory dataSourceFactory; private final DataSource.Factory dataSourceFactory;

View file

@ -33,11 +33,11 @@ import com.google.android.exoplayer2.offline.StreamKey;
import com.google.android.exoplayer2.source.BaseMediaSource; import com.google.android.exoplayer2.source.BaseMediaSource;
import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory; import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory;
import com.google.android.exoplayer2.source.DefaultCompositeSequenceableLoaderFactory; import com.google.android.exoplayer2.source.DefaultCompositeSequenceableLoaderFactory;
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
import com.google.android.exoplayer2.source.MediaPeriod; import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSourceEventListener; 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.MediaSourceFactory;
import com.google.android.exoplayer2.source.SequenceableLoader; import com.google.android.exoplayer2.source.SequenceableLoader;
import com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerEmsgCallback; import com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerEmsgCallback;
import com.google.android.exoplayer2.source.dash.manifest.AdaptationSet; import com.google.android.exoplayer2.source.dash.manifest.AdaptationSet;
@ -79,7 +79,7 @@ public final class DashMediaSource extends BaseMediaSource {
} }
/** Factory for {@link DashMediaSource}s. */ /** Factory for {@link DashMediaSource}s. */
public static final class Factory implements DefaultMediaSourceFactory.Delegate { public static final class Factory implements MediaSourceFactory {
private final DashChunkSource.Factory chunkSourceFactory; private final DashChunkSource.Factory chunkSourceFactory;
@Nullable private final DataSource.Factory manifestDataSourceFactory; @Nullable private final DataSource.Factory manifestDataSourceFactory;

View file

@ -31,11 +31,11 @@ import com.google.android.exoplayer2.offline.StreamKey;
import com.google.android.exoplayer2.source.BaseMediaSource; import com.google.android.exoplayer2.source.BaseMediaSource;
import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory; import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory;
import com.google.android.exoplayer2.source.DefaultCompositeSequenceableLoaderFactory; import com.google.android.exoplayer2.source.DefaultCompositeSequenceableLoaderFactory;
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
import com.google.android.exoplayer2.source.MediaPeriod; import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSourceEventListener; 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.MediaSourceFactory;
import com.google.android.exoplayer2.source.SequenceableLoader; import com.google.android.exoplayer2.source.SequenceableLoader;
import com.google.android.exoplayer2.source.SinglePeriodTimeline; import com.google.android.exoplayer2.source.SinglePeriodTimeline;
import com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistParserFactory; import com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistParserFactory;
@ -87,7 +87,7 @@ public final class HlsMediaSource extends BaseMediaSource
public static final int METADATA_TYPE_EMSG = 3; public static final int METADATA_TYPE_EMSG = 3;
/** Factory for {@link HlsMediaSource}s. */ /** Factory for {@link HlsMediaSource}s. */
public static final class Factory implements DefaultMediaSourceFactory.Delegate { public static final class Factory implements MediaSourceFactory {
private final HlsDataSourceFactory hlsDataSourceFactory; private final HlsDataSourceFactory hlsDataSourceFactory;

View file

@ -30,11 +30,11 @@ import com.google.android.exoplayer2.offline.StreamKey;
import com.google.android.exoplayer2.source.BaseMediaSource; import com.google.android.exoplayer2.source.BaseMediaSource;
import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory; import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory;
import com.google.android.exoplayer2.source.DefaultCompositeSequenceableLoaderFactory; import com.google.android.exoplayer2.source.DefaultCompositeSequenceableLoaderFactory;
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
import com.google.android.exoplayer2.source.MediaPeriod; import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSourceEventListener; 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.MediaSourceFactory;
import com.google.android.exoplayer2.source.SequenceableLoader; import com.google.android.exoplayer2.source.SequenceableLoader;
import com.google.android.exoplayer2.source.SinglePeriodTimeline; import com.google.android.exoplayer2.source.SinglePeriodTimeline;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest; import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
@ -66,7 +66,7 @@ public final class SsMediaSource extends BaseMediaSource
} }
/** Factory for {@link SsMediaSource}. */ /** Factory for {@link SsMediaSource}. */
public static final class Factory implements DefaultMediaSourceFactory.Delegate { public static final class Factory implements MediaSourceFactory {
private final SsChunkSource.Factory chunkSourceFactory; private final SsChunkSource.Factory chunkSourceFactory;
@Nullable private final DataSource.Factory manifestDataSourceFactory; @Nullable private final DataSource.Factory manifestDataSourceFactory;