mirror of
https://github.com/samsonjs/media.git
synced 2026-03-30 10:15:48 +00:00
remove DefaultMediaSourceFactory.Delegate
PiperOrigin-RevId: 299943596
This commit is contained in:
parent
fdf35776f8
commit
87405cb1c0
7 changed files with 33 additions and 36 deletions
|
|
@ -93,21 +93,6 @@ import java.util.Map;
|
|||
*/
|
||||
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}.
|
||||
*
|
||||
|
|
@ -134,7 +119,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||
return new DefaultMediaSourceFactory(context, dataSourceFactory);
|
||||
}
|
||||
|
||||
private final SparseArray<Delegate> mediaSourceFactories;
|
||||
private final SparseArray<MediaSourceFactory> mediaSourceFactories;
|
||||
@C.ContentType private final int[] supportedTypes;
|
||||
private final String userAgent;
|
||||
|
||||
|
|
@ -287,42 +272,43 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||
return drmCallback;
|
||||
}
|
||||
|
||||
private static SparseArray<Delegate> loadDelegates(DataSource.Factory dataSourceFactory) {
|
||||
SparseArray<Delegate> delegates = new SparseArray<>();
|
||||
private static SparseArray<MediaSourceFactory> loadDelegates(
|
||||
DataSource.Factory dataSourceFactory) {
|
||||
SparseArray<MediaSourceFactory> factories = new SparseArray<>();
|
||||
// LINT.IfChange
|
||||
try {
|
||||
Class<? extends DefaultMediaSourceFactory.Delegate> factoryClazz =
|
||||
Class<? extends MediaSourceFactory> factoryClazz =
|
||||
Class.forName("com.google.android.exoplayer2.source.dash.DashMediaSource$Factory")
|
||||
.asSubclass(DefaultMediaSourceFactory.Delegate.class);
|
||||
delegates.put(
|
||||
.asSubclass(MediaSourceFactory.class);
|
||||
factories.put(
|
||||
C.TYPE_DASH,
|
||||
factoryClazz.getConstructor(DataSource.Factory.class).newInstance(dataSourceFactory));
|
||||
} catch (Exception e) {
|
||||
// Expected if the app was built without the dash module.
|
||||
}
|
||||
try {
|
||||
Class<? extends DefaultMediaSourceFactory.Delegate> factoryClazz =
|
||||
Class<? extends MediaSourceFactory> factoryClazz =
|
||||
Class.forName(
|
||||
"com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource$Factory")
|
||||
.asSubclass(DefaultMediaSourceFactory.Delegate.class);
|
||||
delegates.put(
|
||||
.asSubclass(MediaSourceFactory.class);
|
||||
factories.put(
|
||||
C.TYPE_SS,
|
||||
factoryClazz.getConstructor(DataSource.Factory.class).newInstance(dataSourceFactory));
|
||||
} catch (Exception e) {
|
||||
// Expected if the app was built without the smoothstreaming module.
|
||||
}
|
||||
try {
|
||||
Class<? extends DefaultMediaSourceFactory.Delegate> factoryClazz =
|
||||
Class<? extends MediaSourceFactory> factoryClazz =
|
||||
Class.forName("com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory")
|
||||
.asSubclass(DefaultMediaSourceFactory.Delegate.class);
|
||||
delegates.put(
|
||||
.asSubclass(MediaSourceFactory.class);
|
||||
factories.put(
|
||||
C.TYPE_HLS,
|
||||
factoryClazz.getConstructor(DataSource.Factory.class).newInstance(dataSourceFactory));
|
||||
} catch (Exception e) {
|
||||
// Expected if the app was built without the hls module.
|
||||
}
|
||||
// LINT.ThenChange(../../../../../../../../proguard-rules.txt)
|
||||
delegates.put(C.TYPE_OTHER, new ProgressiveMediaSource.Factory(dataSourceFactory));
|
||||
return delegates;
|
||||
factories.put(C.TYPE_OTHER, new ProgressiveMediaSource.Factory(dataSourceFactory));
|
||||
return factories;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ public final class ExtractorMediaSource extends CompositeMediaSource<Void> {
|
|||
* @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}.
|
||||
* @return This factory, for convenience.
|
||||
*/
|
||||
@Override
|
||||
public Factory setLoadErrorHandlingPolicy(
|
||||
@Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
|
||||
this.loadErrorHandlingPolicy =
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.google.android.exoplayer2.MediaItem;
|
|||
import com.google.android.exoplayer2.drm.DrmSession;
|
||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||
import com.google.android.exoplayer2.offline.StreamKey;
|
||||
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
|
||||
import java.util.List;
|
||||
|
||||
/** Factory for creating {@link MediaSource}s from URIs. */
|
||||
|
|
@ -41,6 +42,15 @@ public interface MediaSourceFactory {
|
|||
*/
|
||||
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
|
||||
* factory.
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
|||
implements ProgressiveMediaPeriod.Listener {
|
||||
|
||||
/** 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ import com.google.android.exoplayer2.offline.StreamKey;
|
|||
import com.google.android.exoplayer2.source.BaseMediaSource;
|
||||
import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory;
|
||||
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.MediaSource;
|
||||
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
||||
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.dash.PlayerEmsgHandler.PlayerEmsgCallback;
|
||||
import com.google.android.exoplayer2.source.dash.manifest.AdaptationSet;
|
||||
|
|
@ -79,7 +79,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||
}
|
||||
|
||||
/** 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;
|
||||
@Nullable private final DataSource.Factory manifestDataSourceFactory;
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ import com.google.android.exoplayer2.offline.StreamKey;
|
|||
import com.google.android.exoplayer2.source.BaseMediaSource;
|
||||
import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory;
|
||||
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.MediaSource;
|
||||
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
||||
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.SinglePeriodTimeline;
|
||||
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;
|
||||
|
||||
/** Factory for {@link HlsMediaSource}s. */
|
||||
public static final class Factory implements DefaultMediaSourceFactory.Delegate {
|
||||
public static final class Factory implements MediaSourceFactory {
|
||||
|
||||
private final HlsDataSourceFactory hlsDataSourceFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ import com.google.android.exoplayer2.offline.StreamKey;
|
|||
import com.google.android.exoplayer2.source.BaseMediaSource;
|
||||
import com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory;
|
||||
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.MediaSource;
|
||||
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
||||
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.SinglePeriodTimeline;
|
||||
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
|
||||
|
|
@ -66,7 +66,7 @@ public final class SsMediaSource extends BaseMediaSource
|
|||
}
|
||||
|
||||
/** Factory for {@link SsMediaSource}. */
|
||||
public static final class Factory implements DefaultMediaSourceFactory.Delegate {
|
||||
public static final class Factory implements MediaSourceFactory {
|
||||
|
||||
private final SsChunkSource.Factory chunkSourceFactory;
|
||||
@Nullable private final DataSource.Factory manifestDataSourceFactory;
|
||||
|
|
|
|||
Loading…
Reference in a new issue