mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 01:22:33 -06:00
203 lines
11 KiB
Java
203 lines
11 KiB
Java
package com.google.android.exoplayer2.source;
|
|
|
|
import android.os.Looper;
|
|
import com.google.android.exoplayer2.MediaItem;
|
|
import com.google.android.exoplayer2.Timeline;
|
|
import com.google.android.exoplayer2.analytics.PlayerId;
|
|
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
|
import com.google.android.exoplayer2.drm.DrmSessionManagerProvider;
|
|
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
|
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
|
import com.google.android.exoplayer2.source.MediaSource;
|
|
import com.google.android.exoplayer2.source.ProgressiveMediaExtractor;
|
|
import com.google.android.exoplayer2.source.ProgressiveMediaPeriod;
|
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
|
import com.google.android.exoplayer2.upstream.Allocator;
|
|
import com.google.android.exoplayer2.upstream.DataSource;
|
|
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
|
|
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
|
|
import com.google.android.exoplayer2.upstream.TransferListener;
|
|
import com.google.android.exoplayer2.util.Assertions;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class ProgressiveMediaSource extends BaseMediaSource implements ProgressiveMediaPeriod.Listener {
|
|
public static final int DEFAULT_LOADING_CHECK_INTERVAL_BYTES = 1048576;
|
|
private final int continueLoadingCheckIntervalBytes;
|
|
private final DataSource.Factory dataSourceFactory;
|
|
private final DrmSessionManager drmSessionManager;
|
|
private final LoadErrorHandlingPolicy loadableLoadErrorHandlingPolicy;
|
|
private final MediaItem.LocalConfiguration localConfiguration;
|
|
private final MediaItem mediaItem;
|
|
private final ProgressiveMediaExtractor.Factory progressiveMediaExtractorFactory;
|
|
private long timelineDurationUs;
|
|
private boolean timelineIsLive;
|
|
private boolean timelineIsPlaceholder;
|
|
private boolean timelineIsSeekable;
|
|
private TransferListener transferListener;
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSource
|
|
public MediaItem getMediaItem() {
|
|
return this.mediaItem;
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSource
|
|
public void maybeThrowSourceInfoRefreshError() {
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static final class Factory implements MediaSourceFactory {
|
|
private int continueLoadingCheckIntervalBytes;
|
|
private String customCacheKey;
|
|
private final DataSource.Factory dataSourceFactory;
|
|
private DrmSessionManagerProvider drmSessionManagerProvider;
|
|
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
|
private ProgressiveMediaExtractor.Factory progressiveMediaExtractorFactory;
|
|
private Object tag;
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSource.Factory
|
|
public int[] getSupportedTypes() {
|
|
return new int[]{4};
|
|
}
|
|
|
|
public Factory setContinueLoadingCheckIntervalBytes(int i) {
|
|
this.continueLoadingCheckIntervalBytes = i;
|
|
return this;
|
|
}
|
|
|
|
public Factory(DataSource.Factory factory) {
|
|
this(factory, new DefaultExtractorsFactory());
|
|
}
|
|
|
|
public Factory(DataSource.Factory factory, final ExtractorsFactory extractorsFactory) {
|
|
this(factory, new ProgressiveMediaExtractor.Factory() { // from class: com.google.android.exoplayer2.source.ProgressiveMediaSource$Factory$$ExternalSyntheticLambda0
|
|
@Override // com.google.android.exoplayer2.source.ProgressiveMediaExtractor.Factory
|
|
public final ProgressiveMediaExtractor createProgressiveMediaExtractor(PlayerId playerId) {
|
|
return ProgressiveMediaSource.Factory.lambda$new$0(ExtractorsFactory.this, playerId);
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static /* synthetic */ ProgressiveMediaExtractor lambda$new$0(ExtractorsFactory extractorsFactory, PlayerId playerId) {
|
|
return new BundledExtractorsAdapter(extractorsFactory);
|
|
}
|
|
|
|
public Factory(DataSource.Factory factory, ProgressiveMediaExtractor.Factory factory2) {
|
|
this(factory, factory2, new DefaultDrmSessionManagerProvider(), new DefaultLoadErrorHandlingPolicy(), 1048576);
|
|
}
|
|
|
|
public Factory(DataSource.Factory factory, ProgressiveMediaExtractor.Factory factory2, DrmSessionManagerProvider drmSessionManagerProvider, LoadErrorHandlingPolicy loadErrorHandlingPolicy, int i) {
|
|
this.dataSourceFactory = factory;
|
|
this.progressiveMediaExtractorFactory = factory2;
|
|
this.drmSessionManagerProvider = drmSessionManagerProvider;
|
|
this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
|
|
this.continueLoadingCheckIntervalBytes = i;
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSource.Factory
|
|
public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
|
|
this.loadErrorHandlingPolicy = (LoadErrorHandlingPolicy) Assertions.checkNotNull(loadErrorHandlingPolicy, "MediaSource.Factory#setLoadErrorHandlingPolicy no longer handles null by instantiating a new DefaultLoadErrorHandlingPolicy. Explicitly construct and pass an instance in order to retain the old behavior.");
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSource.Factory
|
|
public Factory setDrmSessionManagerProvider(DrmSessionManagerProvider drmSessionManagerProvider) {
|
|
this.drmSessionManagerProvider = (DrmSessionManagerProvider) Assertions.checkNotNull(drmSessionManagerProvider, "MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior.");
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSource.Factory
|
|
public ProgressiveMediaSource createMediaSource(MediaItem mediaItem) {
|
|
Assertions.checkNotNull(mediaItem.localConfiguration);
|
|
boolean z = mediaItem.localConfiguration.tag == null && this.tag != null;
|
|
boolean z2 = mediaItem.localConfiguration.customCacheKey == null && this.customCacheKey != null;
|
|
if (z && z2) {
|
|
mediaItem = mediaItem.buildUpon().setTag(this.tag).setCustomCacheKey(this.customCacheKey).build();
|
|
} else if (z) {
|
|
mediaItem = mediaItem.buildUpon().setTag(this.tag).build();
|
|
} else if (z2) {
|
|
mediaItem = mediaItem.buildUpon().setCustomCacheKey(this.customCacheKey).build();
|
|
}
|
|
MediaItem mediaItem2 = mediaItem;
|
|
return new ProgressiveMediaSource(mediaItem2, this.dataSourceFactory, this.progressiveMediaExtractorFactory, this.drmSessionManagerProvider.get(mediaItem2), this.loadErrorHandlingPolicy, this.continueLoadingCheckIntervalBytes);
|
|
}
|
|
}
|
|
|
|
private ProgressiveMediaSource(MediaItem mediaItem, DataSource.Factory factory, ProgressiveMediaExtractor.Factory factory2, DrmSessionManager drmSessionManager, LoadErrorHandlingPolicy loadErrorHandlingPolicy, int i) {
|
|
this.localConfiguration = (MediaItem.LocalConfiguration) Assertions.checkNotNull(mediaItem.localConfiguration);
|
|
this.mediaItem = mediaItem;
|
|
this.dataSourceFactory = factory;
|
|
this.progressiveMediaExtractorFactory = factory2;
|
|
this.drmSessionManager = drmSessionManager;
|
|
this.loadableLoadErrorHandlingPolicy = loadErrorHandlingPolicy;
|
|
this.continueLoadingCheckIntervalBytes = i;
|
|
this.timelineIsPlaceholder = true;
|
|
this.timelineDurationUs = -9223372036854775807L;
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.BaseMediaSource
|
|
protected void prepareSourceInternal(TransferListener transferListener) {
|
|
this.transferListener = transferListener;
|
|
this.drmSessionManager.setPlayer((Looper) Assertions.checkNotNull(Looper.myLooper()), getPlayerId());
|
|
this.drmSessionManager.prepare();
|
|
notifySourceInfoRefreshed();
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSource
|
|
public MediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator, long j) {
|
|
DataSource createDataSource = this.dataSourceFactory.createDataSource();
|
|
TransferListener transferListener = this.transferListener;
|
|
if (transferListener != null) {
|
|
createDataSource.addTransferListener(transferListener);
|
|
}
|
|
return new ProgressiveMediaPeriod(this.localConfiguration.uri, createDataSource, this.progressiveMediaExtractorFactory.createProgressiveMediaExtractor(getPlayerId()), this.drmSessionManager, createDrmEventDispatcher(mediaPeriodId), this.loadableLoadErrorHandlingPolicy, createEventDispatcher(mediaPeriodId), this, allocator, this.localConfiguration.customCacheKey, this.continueLoadingCheckIntervalBytes);
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSource
|
|
public void releasePeriod(MediaPeriod mediaPeriod) {
|
|
((ProgressiveMediaPeriod) mediaPeriod).release();
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.BaseMediaSource
|
|
protected void releaseSourceInternal() {
|
|
this.drmSessionManager.release();
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.ProgressiveMediaPeriod.Listener
|
|
public void onSourceInfoRefreshed(long j, boolean z, boolean z2) {
|
|
if (j == -9223372036854775807L) {
|
|
j = this.timelineDurationUs;
|
|
}
|
|
if (!this.timelineIsPlaceholder && this.timelineDurationUs == j && this.timelineIsSeekable == z && this.timelineIsLive == z2) {
|
|
return;
|
|
}
|
|
this.timelineDurationUs = j;
|
|
this.timelineIsSeekable = z;
|
|
this.timelineIsLive = z2;
|
|
this.timelineIsPlaceholder = false;
|
|
notifySourceInfoRefreshed();
|
|
}
|
|
|
|
private void notifySourceInfoRefreshed() {
|
|
Timeline singlePeriodTimeline = new SinglePeriodTimeline(this.timelineDurationUs, this.timelineIsSeekable, false, this.timelineIsLive, (Object) null, this.mediaItem);
|
|
if (this.timelineIsPlaceholder) {
|
|
singlePeriodTimeline = new ForwardingTimeline(this, singlePeriodTimeline) { // from class: com.google.android.exoplayer2.source.ProgressiveMediaSource.1
|
|
@Override // com.google.android.exoplayer2.source.ForwardingTimeline, com.google.android.exoplayer2.Timeline
|
|
public Timeline.Window getWindow(int i, Timeline.Window window, long j) {
|
|
super.getWindow(i, window, j);
|
|
window.isPlaceholder = true;
|
|
return window;
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.ForwardingTimeline, com.google.android.exoplayer2.Timeline
|
|
public Timeline.Period getPeriod(int i, Timeline.Period period, boolean z) {
|
|
super.getPeriod(i, period, z);
|
|
period.isPlaceholder = true;
|
|
return period;
|
|
}
|
|
};
|
|
}
|
|
refreshSourceInfo(singlePeriodTimeline);
|
|
}
|
|
}
|