Add Discord community version (64-bit only)

- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
This commit is contained in:
2026-02-18 15:48:36 -08:00
parent c19eb3d7ff
commit c080f0d97f
26930 changed files with 2529574 additions and 0 deletions

View File

@@ -0,0 +1,181 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.util.Pair;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
/* loaded from: classes4.dex */
abstract class AbstractConcatenatedTimeline extends Timeline {
private final int childCount;
private final boolean isAtomic;
private final ShuffleOrder shuffleOrder;
public abstract int getChildIndexByChildUid(Object obj);
public abstract int getChildIndexByPeriodIndex(int i);
public abstract int getChildIndexByWindowIndex(int i);
public abstract Object getChildUidByChildIndex(int i);
public abstract int getFirstPeriodIndexByChildIndex(int i);
public abstract int getFirstWindowIndexByChildIndex(int i);
public abstract Timeline getTimelineByChildIndex(int i);
public AbstractConcatenatedTimeline(boolean z, ShuffleOrder shuffleOrder) {
this.isAtomic = z;
this.shuffleOrder = shuffleOrder;
this.childCount = shuffleOrder.getLength();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getNextWindowIndex(int i, int i2, boolean z) {
if (this.isAtomic) {
if (i2 == 1) {
i2 = 2;
}
z = false;
}
int childIndexByWindowIndex = getChildIndexByWindowIndex(i);
int firstWindowIndexByChildIndex = getFirstWindowIndexByChildIndex(childIndexByWindowIndex);
int nextWindowIndex = getTimelineByChildIndex(childIndexByWindowIndex).getNextWindowIndex(i - firstWindowIndexByChildIndex, i2 != 2 ? i2 : 0, z);
if (nextWindowIndex != -1) {
return firstWindowIndexByChildIndex + nextWindowIndex;
}
int nextChildIndex = getNextChildIndex(childIndexByWindowIndex, z);
while (nextChildIndex != -1 && getTimelineByChildIndex(nextChildIndex).isEmpty()) {
nextChildIndex = getNextChildIndex(nextChildIndex, z);
}
if (nextChildIndex != -1) {
return getFirstWindowIndexByChildIndex(nextChildIndex) + getTimelineByChildIndex(nextChildIndex).getFirstWindowIndex(z);
}
if (i2 == 2) {
return getFirstWindowIndex(z);
}
return -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getPreviousWindowIndex(int i, int i2, boolean z) {
if (this.isAtomic) {
if (i2 == 1) {
i2 = 2;
}
z = false;
}
int childIndexByWindowIndex = getChildIndexByWindowIndex(i);
int firstWindowIndexByChildIndex = getFirstWindowIndexByChildIndex(childIndexByWindowIndex);
int previousWindowIndex = getTimelineByChildIndex(childIndexByWindowIndex).getPreviousWindowIndex(i - firstWindowIndexByChildIndex, i2 != 2 ? i2 : 0, z);
if (previousWindowIndex != -1) {
return firstWindowIndexByChildIndex + previousWindowIndex;
}
int previousChildIndex = getPreviousChildIndex(childIndexByWindowIndex, z);
while (previousChildIndex != -1 && getTimelineByChildIndex(previousChildIndex).isEmpty()) {
previousChildIndex = getPreviousChildIndex(previousChildIndex, z);
}
if (previousChildIndex != -1) {
return getFirstWindowIndexByChildIndex(previousChildIndex) + getTimelineByChildIndex(previousChildIndex).getLastWindowIndex(z);
}
if (i2 == 2) {
return getLastWindowIndex(z);
}
return -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getLastWindowIndex(boolean z) {
int i = this.childCount;
if (i == 0) {
return -1;
}
if (this.isAtomic) {
z = false;
}
int lastIndex = z ? this.shuffleOrder.getLastIndex() : i - 1;
while (getTimelineByChildIndex(lastIndex).isEmpty()) {
lastIndex = getPreviousChildIndex(lastIndex, z);
if (lastIndex == -1) {
return -1;
}
}
return getFirstWindowIndexByChildIndex(lastIndex) + getTimelineByChildIndex(lastIndex).getLastWindowIndex(z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getFirstWindowIndex(boolean z) {
if (this.childCount == 0) {
return -1;
}
if (this.isAtomic) {
z = false;
}
int firstIndex = z ? this.shuffleOrder.getFirstIndex() : 0;
while (getTimelineByChildIndex(firstIndex).isEmpty()) {
firstIndex = getNextChildIndex(firstIndex, z);
if (firstIndex == -1) {
return -1;
}
}
return getFirstWindowIndexByChildIndex(firstIndex) + getTimelineByChildIndex(firstIndex).getFirstWindowIndex(z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final Timeline.Window getWindow(int i, Timeline.Window window, boolean z, long j) {
int childIndexByWindowIndex = getChildIndexByWindowIndex(i);
int firstWindowIndexByChildIndex = getFirstWindowIndexByChildIndex(childIndexByWindowIndex);
int firstPeriodIndexByChildIndex = getFirstPeriodIndexByChildIndex(childIndexByWindowIndex);
getTimelineByChildIndex(childIndexByWindowIndex).getWindow(i - firstWindowIndexByChildIndex, window, z, j);
window.firstPeriodIndex += firstPeriodIndexByChildIndex;
window.lastPeriodIndex += firstPeriodIndexByChildIndex;
return window;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final Timeline.Period getPeriod(int i, Timeline.Period period, boolean z) {
int childIndexByPeriodIndex = getChildIndexByPeriodIndex(i);
int firstWindowIndexByChildIndex = getFirstWindowIndexByChildIndex(childIndexByPeriodIndex);
getTimelineByChildIndex(childIndexByPeriodIndex).getPeriod(i - getFirstPeriodIndexByChildIndex(childIndexByPeriodIndex), period, z);
period.windowIndex += firstWindowIndexByChildIndex;
if (z) {
period.uid = Pair.create(getChildUidByChildIndex(childIndexByPeriodIndex), period.uid);
}
return period;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getIndexOfPeriod(Object obj) {
int indexOfPeriod;
if (!(obj instanceof Pair)) {
return -1;
}
Pair pair = (Pair) obj;
Object obj2 = pair.first;
Object obj3 = pair.second;
int childIndexByChildUid = getChildIndexByChildUid(obj2);
if (childIndexByChildUid == -1 || (indexOfPeriod = getTimelineByChildIndex(childIndexByChildUid).getIndexOfPeriod(obj3)) == -1) {
return -1;
}
return getFirstPeriodIndexByChildIndex(childIndexByChildUid) + indexOfPeriod;
}
private int getNextChildIndex(int i, boolean z) {
if (z) {
return this.shuffleOrder.getNextIndex(i);
}
if (i < this.childCount - 1) {
return i + 1;
}
return -1;
}
private int getPreviousChildIndex(int i, boolean z) {
if (z) {
return this.shuffleOrder.getPreviousIndex(i);
}
if (i > 0) {
return i - 1;
}
return -1;
}
}

View File

@@ -0,0 +1,6 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
@Deprecated
/* loaded from: classes4.dex */
public interface AdaptiveMediaSourceEventListener extends MediaSourceEventListener {
}

View File

@@ -0,0 +1,83 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.os.Handler;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.util.ArrayList;
import java.util.Iterator;
/* loaded from: classes4.dex */
public abstract class BaseMediaSource implements MediaSource {
private Object manifest;
private ExoPlayer player;
private Timeline timeline;
private final ArrayList<MediaSource.SourceInfoRefreshListener> sourceInfoListeners = new ArrayList<>(1);
private final MediaSourceEventListener.EventDispatcher eventDispatcher = new MediaSourceEventListener.EventDispatcher();
public abstract void prepareSourceInternal(ExoPlayer exoPlayer, boolean z);
public abstract void releaseSourceInternal();
public final void refreshSourceInfo(Timeline timeline, @Nullable Object obj) {
this.timeline = timeline;
this.manifest = obj;
Iterator<MediaSource.SourceInfoRefreshListener> it = this.sourceInfoListeners.iterator();
while (it.hasNext()) {
it.next().onSourceInfoRefreshed(this, timeline, obj);
}
}
public final MediaSourceEventListener.EventDispatcher createEventDispatcher(@Nullable MediaSource.MediaPeriodId mediaPeriodId) {
return this.eventDispatcher.withParameters(0, mediaPeriodId, 0L);
}
public final MediaSourceEventListener.EventDispatcher createEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId, long j) {
Assertions.checkArgument(mediaPeriodId != null);
return this.eventDispatcher.withParameters(0, mediaPeriodId, j);
}
public final MediaSourceEventListener.EventDispatcher createEventDispatcher(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, long j) {
return this.eventDispatcher.withParameters(i, mediaPeriodId, j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void addEventListener(Handler handler, MediaSourceEventListener mediaSourceEventListener) {
this.eventDispatcher.addEventListener(handler, mediaSourceEventListener);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void removeEventListener(MediaSourceEventListener mediaSourceEventListener) {
this.eventDispatcher.removeEventListener(mediaSourceEventListener);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void prepareSource(ExoPlayer exoPlayer, boolean z, MediaSource.SourceInfoRefreshListener sourceInfoRefreshListener) {
ExoPlayer exoPlayer2 = this.player;
Assertions.checkArgument(exoPlayer2 == null || exoPlayer2 == exoPlayer);
this.sourceInfoListeners.add(sourceInfoRefreshListener);
if (this.player == null) {
this.player = exoPlayer;
prepareSourceInternal(exoPlayer, z);
} else {
Timeline timeline = this.timeline;
if (timeline != null) {
sourceInfoRefreshListener.onSourceInfoRefreshed(this, timeline, this.manifest);
}
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void releaseSource(MediaSource.SourceInfoRefreshListener sourceInfoRefreshListener) {
this.sourceInfoListeners.remove(sourceInfoRefreshListener);
if (this.sourceInfoListeners.isEmpty()) {
this.player = null;
this.timeline = null;
this.manifest = null;
releaseSourceInternal();
}
}
}

View File

@@ -0,0 +1,7 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class BehindLiveWindowException extends IOException {
}

View File

@@ -0,0 +1,373 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.FormatHolder;
import com.mbridge.msdk.playercommon.exoplayer2.SeekParameters;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderInputBuffer;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod;
import com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class ClippingMediaPeriod implements MediaPeriod, MediaPeriod.Callback {
private MediaPeriod.Callback callback;
long endUs;
public final MediaPeriod mediaPeriod;
private long pendingInitialDiscontinuityPositionUs;
private ClippingSampleStream[] sampleStreams = new ClippingSampleStream[0];
long startUs;
public final boolean isPendingInitialDiscontinuity() {
return this.pendingInitialDiscontinuityPositionUs != C.TIME_UNSET;
}
public final void updateClipping(long j, long j2) {
this.startUs = j;
this.endUs = j2;
}
public ClippingMediaPeriod(MediaPeriod mediaPeriod, boolean z, long j, long j2) {
this.mediaPeriod = mediaPeriod;
this.pendingInitialDiscontinuityPositionUs = z ? j : C.TIME_UNSET;
this.startUs = j;
this.endUs = j2;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void prepare(MediaPeriod.Callback callback, long j) {
this.callback = callback;
this.mediaPeriod.prepare(this, j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void maybeThrowPrepareError() throws IOException {
this.mediaPeriod.maybeThrowPrepareError();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final TrackGroupArray getTrackGroups() {
return this.mediaPeriod.getTrackGroups();
}
/* JADX WARN: Code restructure failed: missing block: B:25:0x005e, code lost:
if (r2 > r4) goto L26;
*/
/* JADX WARN: Removed duplicated region for block: B:20:0x004e */
/* JADX WARN: Removed duplicated region for block: B:30:0x006a */
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final long selectTracks(com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection[] r13, boolean[] r14, com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream[] r15, boolean[] r16, long r17) {
/*
r12 = this;
r0 = r12
r1 = r15
int r2 = r1.length
com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod$ClippingSampleStream[] r2 = new com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod.ClippingSampleStream[r2]
r0.sampleStreams = r2
int r2 = r1.length
com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream[] r9 = new com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream[r2]
r10 = 0
r2 = r10
Lc:
int r3 = r1.length
r11 = 0
if (r2 >= r3) goto L21
com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod$ClippingSampleStream[] r3 = r0.sampleStreams
r4 = r1[r2]
com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod$ClippingSampleStream r4 = (com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod.ClippingSampleStream) r4
r3[r2] = r4
if (r4 == 0) goto L1c
com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream r11 = r4.childStream
L1c:
r9[r2] = r11
int r2 = r2 + 1
goto Lc
L21:
com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod r2 = r0.mediaPeriod
r3 = r13
r4 = r14
r5 = r9
r6 = r16
r7 = r17
long r2 = r2.selectTracks(r3, r4, r5, r6, r7)
boolean r4 = r12.isPendingInitialDiscontinuity()
if (r4 == 0) goto L43
long r4 = r0.startUs
int r6 = (r17 > r4 ? 1 : (r17 == r4 ? 0 : -1))
if (r6 != 0) goto L43
r6 = r13
boolean r4 = shouldKeepInitialDiscontinuity(r4, r13)
if (r4 == 0) goto L43
r4 = r2
goto L48
L43:
r4 = -9223372036854775807(0x8000000000000001, double:-4.9E-324)
L48:
r0.pendingInitialDiscontinuityPositionUs = r4
int r4 = (r2 > r17 ? 1 : (r2 == r17 ? 0 : -1))
if (r4 == 0) goto L63
long r4 = r0.startUs
int r4 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1))
if (r4 < 0) goto L61
long r4 = r0.endUs
r6 = -9223372036854775808
int r6 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1))
if (r6 == 0) goto L63
int r4 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1))
if (r4 > 0) goto L61
goto L63
L61:
r4 = r10
goto L64
L63:
r4 = 1
L64:
com.mbridge.msdk.playercommon.exoplayer2.util.Assertions.checkState(r4)
L67:
int r4 = r1.length
if (r10 >= r4) goto L91
r4 = r9[r10]
if (r4 != 0) goto L73
com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod$ClippingSampleStream[] r4 = r0.sampleStreams
r4[r10] = r11
goto L88
L73:
r5 = r1[r10]
if (r5 == 0) goto L7f
com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod$ClippingSampleStream[] r5 = r0.sampleStreams
r5 = r5[r10]
com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream r5 = r5.childStream
if (r5 == r4) goto L88
L7f:
com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod$ClippingSampleStream[] r5 = r0.sampleStreams
com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod$ClippingSampleStream r6 = new com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod$ClippingSampleStream
r6.<init>(r4)
r5[r10] = r6
L88:
com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod$ClippingSampleStream[] r4 = r0.sampleStreams
r4 = r4[r10]
r1[r10] = r4
int r10 = r10 + 1
goto L67
L91:
return r2
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod.selectTracks(com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection[], boolean[], com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream[], boolean[], long):long");
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void discardBuffer(long j, boolean z) {
this.mediaPeriod.discardBuffer(j, z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final void reevaluateBuffer(long j) {
this.mediaPeriod.reevaluateBuffer(j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long readDiscontinuity() {
if (isPendingInitialDiscontinuity()) {
long j = this.pendingInitialDiscontinuityPositionUs;
this.pendingInitialDiscontinuityPositionUs = C.TIME_UNSET;
long readDiscontinuity = readDiscontinuity();
return readDiscontinuity != C.TIME_UNSET ? readDiscontinuity : j;
}
long readDiscontinuity2 = this.mediaPeriod.readDiscontinuity();
if (readDiscontinuity2 == C.TIME_UNSET) {
return C.TIME_UNSET;
}
Assertions.checkState(readDiscontinuity2 >= this.startUs);
long j2 = this.endUs;
Assertions.checkState(j2 == Long.MIN_VALUE || readDiscontinuity2 <= j2);
return readDiscontinuity2;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getBufferedPositionUs() {
long bufferedPositionUs = this.mediaPeriod.getBufferedPositionUs();
if (bufferedPositionUs != Long.MIN_VALUE) {
long j = this.endUs;
if (j == Long.MIN_VALUE || bufferedPositionUs < j) {
return bufferedPositionUs;
}
}
return Long.MIN_VALUE;
}
/* JADX WARN: Code restructure failed: missing block: B:17:0x0032, code lost:
if (r0 > r6) goto L17;
*/
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final long seekToUs(long r6) {
/*
r5 = this;
r0 = -9223372036854775807(0x8000000000000001, double:-4.9E-324)
r5.pendingInitialDiscontinuityPositionUs = r0
com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod$ClippingSampleStream[] r0 = r5.sampleStreams
int r1 = r0.length
r2 = 0
r3 = r2
Lc:
if (r3 >= r1) goto L18
r4 = r0[r3]
if (r4 == 0) goto L15
r4.clearSentEos()
L15:
int r3 = r3 + 1
goto Lc
L18:
com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod r0 = r5.mediaPeriod
long r0 = r0.seekToUs(r6)
int r6 = (r0 > r6 ? 1 : (r0 == r6 ? 0 : -1))
if (r6 == 0) goto L34
long r6 = r5.startUs
int r6 = (r0 > r6 ? 1 : (r0 == r6 ? 0 : -1))
if (r6 < 0) goto L35
long r6 = r5.endUs
r3 = -9223372036854775808
int r3 = (r6 > r3 ? 1 : (r6 == r3 ? 0 : -1))
if (r3 == 0) goto L34
int r6 = (r0 > r6 ? 1 : (r0 == r6 ? 0 : -1))
if (r6 > 0) goto L35
L34:
r2 = 1
L35:
com.mbridge.msdk.playercommon.exoplayer2.util.Assertions.checkState(r2)
return r0
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.source.ClippingMediaPeriod.seekToUs(long):long");
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long getAdjustedSeekPositionUs(long j, SeekParameters seekParameters) {
long j2 = this.startUs;
if (j == j2) {
return j2;
}
return this.mediaPeriod.getAdjustedSeekPositionUs(j, clipSeekParameters(j, seekParameters));
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getNextLoadPositionUs() {
long nextLoadPositionUs = this.mediaPeriod.getNextLoadPositionUs();
if (nextLoadPositionUs != Long.MIN_VALUE) {
long j = this.endUs;
if (j == Long.MIN_VALUE || nextLoadPositionUs < j) {
return nextLoadPositionUs;
}
}
return Long.MIN_VALUE;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final boolean continueLoading(long j) {
return this.mediaPeriod.continueLoading(j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod.Callback
public final void onPrepared(MediaPeriod mediaPeriod) {
this.callback.onPrepared(this);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader.Callback
public final void onContinueLoadingRequested(MediaPeriod mediaPeriod) {
this.callback.onContinueLoadingRequested(this);
}
private SeekParameters clipSeekParameters(long j, SeekParameters seekParameters) {
long constrainValue = Util.constrainValue(seekParameters.toleranceBeforeUs, 0L, j - this.startUs);
long j2 = seekParameters.toleranceAfterUs;
long j3 = this.endUs;
long constrainValue2 = Util.constrainValue(j2, 0L, j3 == Long.MIN_VALUE ? Long.MAX_VALUE : j3 - j);
return (constrainValue == seekParameters.toleranceBeforeUs && constrainValue2 == seekParameters.toleranceAfterUs) ? seekParameters : new SeekParameters(constrainValue, constrainValue2);
}
private static boolean shouldKeepInitialDiscontinuity(long j, TrackSelection[] trackSelectionArr) {
if (j != 0) {
for (TrackSelection trackSelection : trackSelectionArr) {
if (trackSelection != null && !MimeTypes.isAudio(trackSelection.getSelectedFormat().sampleMimeType)) {
return true;
}
}
}
return false;
}
public final class ClippingSampleStream implements SampleStream {
public final SampleStream childStream;
private boolean sentEos;
public final void clearSentEos() {
this.sentEos = false;
}
public ClippingSampleStream(SampleStream sampleStream) {
this.childStream = sampleStream;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final boolean isReady() {
return !ClippingMediaPeriod.this.isPendingInitialDiscontinuity() && this.childStream.isReady();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final void maybeThrowError() throws IOException {
this.childStream.maybeThrowError();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final int readData(FormatHolder formatHolder, DecoderInputBuffer decoderInputBuffer, boolean z) {
if (ClippingMediaPeriod.this.isPendingInitialDiscontinuity()) {
return -3;
}
if (this.sentEos) {
decoderInputBuffer.setFlags(4);
return -4;
}
int readData = this.childStream.readData(formatHolder, decoderInputBuffer, z);
if (readData == -5) {
Format format = formatHolder.format;
int i = format.encoderDelay;
if (i != 0 || format.encoderPadding != 0) {
ClippingMediaPeriod clippingMediaPeriod = ClippingMediaPeriod.this;
if (clippingMediaPeriod.startUs != 0) {
i = 0;
}
formatHolder.format = format.copyWithGaplessInfo(i, clippingMediaPeriod.endUs == Long.MIN_VALUE ? format.encoderPadding : 0);
}
return -5;
}
ClippingMediaPeriod clippingMediaPeriod2 = ClippingMediaPeriod.this;
long j = clippingMediaPeriod2.endUs;
if (j == Long.MIN_VALUE || ((readData != -4 || decoderInputBuffer.timeUs < j) && !(readData == -3 && clippingMediaPeriod2.getBufferedPositionUs() == Long.MIN_VALUE))) {
return readData;
}
decoderInputBuffer.clear();
decoderInputBuffer.setFlags(4);
this.sentEos = true;
return -4;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final int skipData(long j) {
if (ClippingMediaPeriod.this.isPendingInitialDiscontinuity()) {
return -3;
}
return this.childStream.skipData(j);
}
}
}

View File

@@ -0,0 +1,244 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
/* loaded from: classes4.dex */
public final class ClippingMediaSource extends CompositeMediaSource<Void> {
private final boolean allowDynamicClippingUpdates;
private IllegalClippingException clippingError;
private ClippingTimeline clippingTimeline;
private final boolean enableInitialDiscontinuity;
private final long endUs;
@Nullable
private Object manifest;
private final ArrayList<ClippingMediaPeriod> mediaPeriods;
private final MediaSource mediaSource;
private long periodEndUs;
private long periodStartUs;
private final boolean relativeToDefaultPosition;
private final long startUs;
private final Timeline.Window window;
public static final class IllegalClippingException extends IOException {
public static final int REASON_INVALID_PERIOD_COUNT = 0;
public static final int REASON_NOT_SEEKABLE_TO_START = 1;
public static final int REASON_START_EXCEEDS_END = 2;
public final int reason;
@Retention(RetentionPolicy.SOURCE)
public @interface Reason {
}
private static String getReasonDescription(int i) {
return i != 0 ? i != 1 ? i != 2 ? "unknown" : "start exceeds end" : "not seekable to start" : "invalid period count";
}
public IllegalClippingException(int i) {
super("Illegal clipping: " + getReasonDescription(i));
this.reason = i;
}
}
public ClippingMediaSource(MediaSource mediaSource, long j, long j2) {
this(mediaSource, j, j2, true, false, false);
}
@Deprecated
public ClippingMediaSource(MediaSource mediaSource, long j, long j2, boolean z) {
this(mediaSource, j, j2, z, false, false);
}
public ClippingMediaSource(MediaSource mediaSource, long j) {
this(mediaSource, 0L, j, true, false, true);
}
public ClippingMediaSource(MediaSource mediaSource, long j, long j2, boolean z, boolean z2, boolean z3) {
Assertions.checkArgument(j >= 0);
this.mediaSource = (MediaSource) Assertions.checkNotNull(mediaSource);
this.startUs = j;
this.endUs = j2;
this.enableInitialDiscontinuity = z;
this.allowDynamicClippingUpdates = z2;
this.relativeToDefaultPosition = z3;
this.mediaPeriods = new ArrayList<>();
this.window = new Timeline.Window();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void prepareSourceInternal(ExoPlayer exoPlayer, boolean z) {
super.prepareSourceInternal(exoPlayer, z);
prepareChildSource(null, this.mediaSource);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void maybeThrowSourceInfoRefreshError() throws IOException {
IllegalClippingException illegalClippingException = this.clippingError;
if (illegalClippingException != null) {
throw illegalClippingException;
}
super.maybeThrowSourceInfoRefreshError();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final MediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator) {
ClippingMediaPeriod clippingMediaPeriod = new ClippingMediaPeriod(this.mediaSource.createPeriod(mediaPeriodId, allocator), this.enableInitialDiscontinuity, this.periodStartUs, this.periodEndUs);
this.mediaPeriods.add(clippingMediaPeriod);
return clippingMediaPeriod;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void releasePeriod(MediaPeriod mediaPeriod) {
Assertions.checkState(this.mediaPeriods.remove(mediaPeriod));
this.mediaSource.releasePeriod(((ClippingMediaPeriod) mediaPeriod).mediaPeriod);
if (!this.mediaPeriods.isEmpty() || this.allowDynamicClippingUpdates) {
return;
}
refreshClippedTimeline(this.clippingTimeline.timeline);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void releaseSourceInternal() {
super.releaseSourceInternal();
this.clippingError = null;
this.clippingTimeline = null;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource
public final void onChildSourceInfoRefreshed(Void r1, MediaSource mediaSource, Timeline timeline, @Nullable Object obj) {
if (this.clippingError != null) {
return;
}
this.manifest = obj;
refreshClippedTimeline(timeline);
}
private void refreshClippedTimeline(Timeline timeline) {
long j;
long j2;
timeline.getWindow(0, this.window);
long positionInFirstPeriodUs = this.window.getPositionInFirstPeriodUs();
if (this.clippingTimeline == null || this.mediaPeriods.isEmpty() || this.allowDynamicClippingUpdates) {
long j3 = this.startUs;
long j4 = this.endUs;
if (this.relativeToDefaultPosition) {
long defaultPositionUs = this.window.getDefaultPositionUs();
j3 += defaultPositionUs;
j4 += defaultPositionUs;
}
this.periodStartUs = positionInFirstPeriodUs + j3;
this.periodEndUs = this.endUs != Long.MIN_VALUE ? positionInFirstPeriodUs + j4 : Long.MIN_VALUE;
int size = this.mediaPeriods.size();
for (int i = 0; i < size; i++) {
this.mediaPeriods.get(i).updateClipping(this.periodStartUs, this.periodEndUs);
}
j = j3;
j2 = j4;
} else {
long j5 = this.periodStartUs - positionInFirstPeriodUs;
j2 = this.endUs != Long.MIN_VALUE ? this.periodEndUs - positionInFirstPeriodUs : Long.MIN_VALUE;
j = j5;
}
try {
ClippingTimeline clippingTimeline = new ClippingTimeline(timeline, j, j2);
this.clippingTimeline = clippingTimeline;
refreshSourceInfo(clippingTimeline, this.manifest);
} catch (IllegalClippingException e) {
this.clippingError = e;
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource
public final long getMediaTimeForChildMediaTime(Void r7, long j) {
if (j == C.TIME_UNSET) {
return C.TIME_UNSET;
}
long usToMs = C.usToMs(this.startUs);
long max = Math.max(0L, j - usToMs);
long j2 = this.endUs;
return j2 != Long.MIN_VALUE ? Math.min(C.usToMs(j2) - usToMs, max) : max;
}
public static final class ClippingTimeline extends ForwardingTimeline {
private final long durationUs;
private final long endUs;
private final boolean isDynamic;
private final long startUs;
public ClippingTimeline(Timeline timeline, long j, long j2) throws IllegalClippingException {
super(timeline);
boolean z = false;
if (timeline.getPeriodCount() != 1) {
throw new IllegalClippingException(0);
}
Timeline.Window window = timeline.getWindow(0, new Timeline.Window(), false);
long max = Math.max(0L, j);
long max2 = j2 == Long.MIN_VALUE ? window.durationUs : Math.max(0L, j2);
long j3 = window.durationUs;
if (j3 != C.TIME_UNSET) {
max2 = max2 > j3 ? j3 : max2;
if (max != 0 && !window.isSeekable) {
throw new IllegalClippingException(1);
}
if (max > max2) {
throw new IllegalClippingException(2);
}
}
this.startUs = max;
this.endUs = max2;
this.durationUs = max2 == C.TIME_UNSET ? -9223372036854775807L : max2 - max;
if (window.isDynamic && (max2 == C.TIME_UNSET || (j3 != C.TIME_UNSET && max2 == j3))) {
z = true;
}
this.isDynamic = z;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ForwardingTimeline, com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final Timeline.Window getWindow(int i, Timeline.Window window, boolean z, long j) {
this.timeline.getWindow(0, window, z, 0L);
long j2 = window.positionInFirstPeriodUs;
long j3 = this.startUs;
window.positionInFirstPeriodUs = j2 + j3;
window.durationUs = this.durationUs;
window.isDynamic = this.isDynamic;
long j4 = window.defaultPositionUs;
if (j4 != C.TIME_UNSET) {
long max = Math.max(j4, j3);
window.defaultPositionUs = max;
long j5 = this.endUs;
if (j5 != C.TIME_UNSET) {
max = Math.min(max, j5);
}
window.defaultPositionUs = max - this.startUs;
}
long usToMs = C.usToMs(this.startUs);
long j6 = window.presentationStartTimeMs;
if (j6 != C.TIME_UNSET) {
window.presentationStartTimeMs = j6 + usToMs;
}
long j7 = window.windowStartTimeMs;
if (j7 != C.TIME_UNSET) {
window.windowStartTimeMs = j7 + usToMs;
}
return window;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ForwardingTimeline, com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final Timeline.Period getPeriod(int i, Timeline.Period period, boolean z) {
this.timeline.getPeriod(0, period, z);
long positionInWindowUs = period.getPositionInWindowUs() - this.startUs;
long j = this.durationUs;
return period.set(period.id, period.uid, 0, j == C.TIME_UNSET ? -9223372036854775807L : j - positionInWindowUs, positionInWindowUs);
}
}
}

View File

@@ -0,0 +1,196 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.os.Handler;
import androidx.annotation.CallSuper;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
/* loaded from: classes4.dex */
public abstract class CompositeMediaSource<T> extends BaseMediaSource {
private final HashMap<T, MediaSourceAndListener> childSources = new HashMap<>();
private Handler eventHandler;
private ExoPlayer player;
@Nullable
public MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(@Nullable T t, MediaSource.MediaPeriodId mediaPeriodId) {
return mediaPeriodId;
}
public long getMediaTimeForChildMediaTime(@Nullable T t, long j) {
return j;
}
public int getWindowIndexForChildWindowIndex(@Nullable T t, int i) {
return i;
}
public abstract void onChildSourceInfoRefreshed(@Nullable T t, MediaSource mediaSource, Timeline timeline, @Nullable Object obj);
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
@CallSuper
public void prepareSourceInternal(ExoPlayer exoPlayer, boolean z) {
this.player = exoPlayer;
this.eventHandler = new Handler();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
@CallSuper
public void maybeThrowSourceInfoRefreshError() throws IOException {
Iterator<MediaSourceAndListener> it = this.childSources.values().iterator();
while (it.hasNext()) {
it.next().mediaSource.maybeThrowSourceInfoRefreshError();
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
@CallSuper
public void releaseSourceInternal() {
for (MediaSourceAndListener mediaSourceAndListener : this.childSources.values()) {
mediaSourceAndListener.mediaSource.releaseSource(mediaSourceAndListener.listener);
mediaSourceAndListener.mediaSource.removeEventListener(mediaSourceAndListener.eventListener);
}
this.childSources.clear();
this.player = null;
}
public final void prepareChildSource(@Nullable final T t, MediaSource mediaSource) {
Assertions.checkArgument(!this.childSources.containsKey(t));
MediaSource.SourceInfoRefreshListener sourceInfoRefreshListener = new MediaSource.SourceInfoRefreshListener() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource.1
/* JADX WARN: Multi-variable type inference failed */
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource.SourceInfoRefreshListener
public void onSourceInfoRefreshed(MediaSource mediaSource2, Timeline timeline, @Nullable Object obj) {
CompositeMediaSource.this.onChildSourceInfoRefreshed(t, mediaSource2, timeline, obj);
}
};
ForwardingEventListener forwardingEventListener = new ForwardingEventListener(t);
this.childSources.put(t, new MediaSourceAndListener(mediaSource, sourceInfoRefreshListener, forwardingEventListener));
mediaSource.addEventListener(this.eventHandler, forwardingEventListener);
mediaSource.prepareSource(this.player, false, sourceInfoRefreshListener);
}
public final void releaseChildSource(@Nullable T t) {
MediaSourceAndListener remove = this.childSources.remove(t);
remove.mediaSource.releaseSource(remove.listener);
remove.mediaSource.removeEventListener(remove.eventListener);
}
public static final class MediaSourceAndListener {
public final MediaSourceEventListener eventListener;
public final MediaSource.SourceInfoRefreshListener listener;
public final MediaSource mediaSource;
public MediaSourceAndListener(MediaSource mediaSource, MediaSource.SourceInfoRefreshListener sourceInfoRefreshListener, MediaSourceEventListener mediaSourceEventListener) {
this.mediaSource = mediaSource;
this.listener = sourceInfoRefreshListener;
this.eventListener = mediaSourceEventListener;
}
}
public final class ForwardingEventListener implements MediaSourceEventListener {
private MediaSourceEventListener.EventDispatcher eventDispatcher;
@Nullable
private final T id;
public ForwardingEventListener(T t) {
this.eventDispatcher = CompositeMediaSource.this.createEventDispatcher(null);
this.id = t;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onMediaPeriodCreated(int i, MediaSource.MediaPeriodId mediaPeriodId) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.mediaPeriodCreated();
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onMediaPeriodReleased(int i, MediaSource.MediaPeriodId mediaPeriodId) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.mediaPeriodReleased();
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onLoadStarted(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.loadStarted(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData));
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onLoadCompleted(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.loadCompleted(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData));
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onLoadCanceled(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.loadCanceled(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData));
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onLoadError(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData, IOException iOException, boolean z) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.loadError(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData), iOException, z);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onReadingStarted(int i, MediaSource.MediaPeriodId mediaPeriodId) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.readingStarted();
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onUpstreamDiscarded(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.MediaLoadData mediaLoadData) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.upstreamDiscarded(maybeUpdateMediaLoadData(mediaLoadData));
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onDownstreamFormatChanged(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.MediaLoadData mediaLoadData) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.downstreamFormatChanged(maybeUpdateMediaLoadData(mediaLoadData));
}
}
private boolean maybeUpdateEventDispatcher(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId) {
MediaSource.MediaPeriodId mediaPeriodId2;
if (mediaPeriodId != null) {
mediaPeriodId2 = CompositeMediaSource.this.getMediaPeriodIdForChildMediaPeriodId(this.id, mediaPeriodId);
if (mediaPeriodId2 == null) {
return false;
}
} else {
mediaPeriodId2 = null;
}
int windowIndexForChildWindowIndex = CompositeMediaSource.this.getWindowIndexForChildWindowIndex(this.id, i);
MediaSourceEventListener.EventDispatcher eventDispatcher = this.eventDispatcher;
if (eventDispatcher.windowIndex == windowIndexForChildWindowIndex && Util.areEqual(eventDispatcher.mediaPeriodId, mediaPeriodId2)) {
return true;
}
this.eventDispatcher = CompositeMediaSource.this.createEventDispatcher(windowIndexForChildWindowIndex, mediaPeriodId2, 0L);
return true;
}
private MediaSourceEventListener.MediaLoadData maybeUpdateMediaLoadData(MediaSourceEventListener.MediaLoadData mediaLoadData) {
long mediaTimeForChildMediaTime = CompositeMediaSource.this.getMediaTimeForChildMediaTime(this.id, mediaLoadData.mediaStartTimeMs);
long mediaTimeForChildMediaTime2 = CompositeMediaSource.this.getMediaTimeForChildMediaTime(this.id, mediaLoadData.mediaEndTimeMs);
return (mediaTimeForChildMediaTime == mediaLoadData.mediaStartTimeMs && mediaTimeForChildMediaTime2 == mediaLoadData.mediaEndTimeMs) ? mediaLoadData : new MediaSourceEventListener.MediaLoadData(mediaLoadData.dataType, mediaLoadData.trackType, mediaLoadData.trackFormat, mediaLoadData.trackSelectionReason, mediaLoadData.trackSelectionData, mediaTimeForChildMediaTime, mediaTimeForChildMediaTime2);
}
}
}

View File

@@ -0,0 +1,69 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
/* loaded from: classes4.dex */
public class CompositeSequenceableLoader implements SequenceableLoader {
protected final SequenceableLoader[] loaders;
public CompositeSequenceableLoader(SequenceableLoader[] sequenceableLoaderArr) {
this.loaders = sequenceableLoaderArr;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getBufferedPositionUs() {
long j = Long.MAX_VALUE;
for (SequenceableLoader sequenceableLoader : this.loaders) {
long bufferedPositionUs = sequenceableLoader.getBufferedPositionUs();
if (bufferedPositionUs != Long.MIN_VALUE) {
j = Math.min(j, bufferedPositionUs);
}
}
if (j == Long.MAX_VALUE) {
return Long.MIN_VALUE;
}
return j;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getNextLoadPositionUs() {
long j = Long.MAX_VALUE;
for (SequenceableLoader sequenceableLoader : this.loaders) {
long nextLoadPositionUs = sequenceableLoader.getNextLoadPositionUs();
if (nextLoadPositionUs != Long.MIN_VALUE) {
j = Math.min(j, nextLoadPositionUs);
}
}
if (j == Long.MAX_VALUE) {
return Long.MIN_VALUE;
}
return j;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final void reevaluateBuffer(long j) {
for (SequenceableLoader sequenceableLoader : this.loaders) {
sequenceableLoader.reevaluateBuffer(j);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public boolean continueLoading(long j) {
boolean z;
boolean z2 = false;
do {
long nextLoadPositionUs = getNextLoadPositionUs();
if (nextLoadPositionUs == Long.MIN_VALUE) {
break;
}
z = false;
for (SequenceableLoader sequenceableLoader : this.loaders) {
long nextLoadPositionUs2 = sequenceableLoader.getNextLoadPositionUs();
boolean z3 = nextLoadPositionUs2 != Long.MIN_VALUE && nextLoadPositionUs2 <= j;
if (nextLoadPositionUs2 == nextLoadPositionUs || z3) {
z |= sequenceableLoader.continueLoading(j);
}
}
z2 |= z;
} while (z);
return z2;
}
}

View File

@@ -0,0 +1,6 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
/* loaded from: classes4.dex */
public interface CompositeSequenceableLoaderFactory {
SequenceableLoader createCompositeSequenceableLoader(SequenceableLoader... sequenceableLoaderArr);
}

View File

@@ -0,0 +1,675 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlaybackException;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.PlayerMessage;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/* loaded from: classes4.dex */
public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHolder> implements PlayerMessage.Target {
private static final int MSG_ADD = 0;
private static final int MSG_ADD_MULTIPLE = 1;
private static final int MSG_CLEAR = 4;
private static final int MSG_MOVE = 3;
private static final int MSG_NOTIFY_LISTENER = 5;
private static final int MSG_ON_COMPLETION = 6;
private static final int MSG_REMOVE = 2;
private final boolean isAtomic;
private boolean listenerNotificationScheduled;
private final Map<MediaPeriod, MediaSourceHolder> mediaSourceByMediaPeriod;
private final List<MediaSourceHolder> mediaSourceHolders;
private final List<MediaSourceHolder> mediaSourcesPublic;
private final List<EventDispatcher> pendingOnCompletionActions;
private int periodCount;
private ExoPlayer player;
private final MediaSourceHolder query;
private ShuffleOrder shuffleOrder;
private final Timeline.Window window;
private int windowCount;
public ConcatenatingMediaSource() {
this(false, (ShuffleOrder) new ShuffleOrder.DefaultShuffleOrder(0));
}
public ConcatenatingMediaSource(boolean z) {
this(z, new ShuffleOrder.DefaultShuffleOrder(0));
}
public ConcatenatingMediaSource(boolean z, ShuffleOrder shuffleOrder) {
this(z, shuffleOrder, new MediaSource[0]);
}
public ConcatenatingMediaSource(MediaSource... mediaSourceArr) {
this(false, mediaSourceArr);
}
public ConcatenatingMediaSource(boolean z, MediaSource... mediaSourceArr) {
this(z, new ShuffleOrder.DefaultShuffleOrder(0), mediaSourceArr);
}
public ConcatenatingMediaSource(boolean z, ShuffleOrder shuffleOrder, MediaSource... mediaSourceArr) {
for (MediaSource mediaSource : mediaSourceArr) {
Assertions.checkNotNull(mediaSource);
}
this.shuffleOrder = shuffleOrder.getLength() > 0 ? shuffleOrder.cloneAndClear() : shuffleOrder;
this.mediaSourceByMediaPeriod = new IdentityHashMap();
this.mediaSourcesPublic = new ArrayList();
this.mediaSourceHolders = new ArrayList();
this.pendingOnCompletionActions = new ArrayList();
this.query = new MediaSourceHolder(null);
this.isAtomic = z;
this.window = new Timeline.Window();
addMediaSources(Arrays.asList(mediaSourceArr));
}
public final synchronized void addMediaSource(MediaSource mediaSource) {
addMediaSource(this.mediaSourcesPublic.size(), mediaSource, null);
}
public final synchronized void addMediaSource(MediaSource mediaSource, @Nullable Runnable runnable) {
addMediaSource(this.mediaSourcesPublic.size(), mediaSource, runnable);
}
public final synchronized void addMediaSource(int i, MediaSource mediaSource) {
addMediaSource(i, mediaSource, null);
}
public final synchronized void addMediaSource(int i, MediaSource mediaSource, @Nullable Runnable runnable) {
try {
Assertions.checkNotNull(mediaSource);
MediaSourceHolder mediaSourceHolder = new MediaSourceHolder(mediaSource);
this.mediaSourcesPublic.add(i, mediaSourceHolder);
ExoPlayer exoPlayer = this.player;
if (exoPlayer != null) {
exoPlayer.createMessage(this).setType(0).setPayload(new MessageData(i, mediaSourceHolder, runnable)).send();
} else if (runnable != null) {
runnable.run();
}
} catch (Throwable th) {
throw th;
}
}
public final synchronized void addMediaSources(Collection<MediaSource> collection) {
addMediaSources(this.mediaSourcesPublic.size(), collection, null);
}
public final synchronized void addMediaSources(Collection<MediaSource> collection, @Nullable Runnable runnable) {
addMediaSources(this.mediaSourcesPublic.size(), collection, runnable);
}
public final synchronized void addMediaSources(int i, Collection<MediaSource> collection) {
addMediaSources(i, collection, null);
}
public final synchronized void addMediaSources(int i, Collection<MediaSource> collection, @Nullable Runnable runnable) {
try {
Iterator<MediaSource> it = collection.iterator();
while (it.hasNext()) {
Assertions.checkNotNull(it.next());
}
ArrayList arrayList = new ArrayList(collection.size());
Iterator<MediaSource> it2 = collection.iterator();
while (it2.hasNext()) {
arrayList.add(new MediaSourceHolder(it2.next()));
}
this.mediaSourcesPublic.addAll(i, arrayList);
if (this.player != null && !collection.isEmpty()) {
this.player.createMessage(this).setType(1).setPayload(new MessageData(i, arrayList, runnable)).send();
} else if (runnable != null) {
runnable.run();
}
} catch (Throwable th) {
throw th;
}
}
public final synchronized void removeMediaSource(int i) {
removeMediaSource(i, null);
}
public final synchronized void removeMediaSource(int i, @Nullable Runnable runnable) {
try {
this.mediaSourcesPublic.remove(i);
ExoPlayer exoPlayer = this.player;
if (exoPlayer != null) {
exoPlayer.createMessage(this).setType(2).setPayload(new MessageData(i, null, runnable)).send();
} else if (runnable != null) {
runnable.run();
}
} catch (Throwable th) {
throw th;
}
}
public final synchronized void moveMediaSource(int i, int i2) {
moveMediaSource(i, i2, null);
}
public final synchronized void moveMediaSource(int i, int i2, @Nullable Runnable runnable) {
if (i == i2) {
return;
}
try {
List<MediaSourceHolder> list = this.mediaSourcesPublic;
list.add(i2, list.remove(i));
ExoPlayer exoPlayer = this.player;
if (exoPlayer != null) {
exoPlayer.createMessage(this).setType(3).setPayload(new MessageData(i, Integer.valueOf(i2), runnable)).send();
} else if (runnable != null) {
runnable.run();
}
} catch (Throwable th) {
throw th;
}
}
public final synchronized void clear() {
clear(null);
}
public final synchronized void clear(@Nullable Runnable runnable) {
try {
this.mediaSourcesPublic.clear();
ExoPlayer exoPlayer = this.player;
if (exoPlayer != null) {
exoPlayer.createMessage(this).setType(4).setPayload(runnable != null ? new EventDispatcher(runnable) : null).send();
} else if (runnable != null) {
runnable.run();
}
} catch (Throwable th) {
throw th;
}
}
public final synchronized int getSize() {
return this.mediaSourcesPublic.size();
}
public final synchronized MediaSource getMediaSource(int i) {
return this.mediaSourcesPublic.get(i).mediaSource;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final synchronized void prepareSourceInternal(ExoPlayer exoPlayer, boolean z) {
try {
super.prepareSourceInternal(exoPlayer, z);
this.player = exoPlayer;
if (this.mediaSourcesPublic.isEmpty()) {
notifyListener();
} else {
this.shuffleOrder = this.shuffleOrder.cloneAndInsert(0, this.mediaSourcesPublic.size());
addMediaSourcesInternal(0, this.mediaSourcesPublic);
scheduleListenerNotification(null);
}
} catch (Throwable th) {
throw th;
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final MediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator) {
MediaSourceHolder mediaSourceHolder = this.mediaSourceHolders.get(findMediaSourceHolderByPeriodIndex(mediaPeriodId.periodIndex));
DeferredMediaPeriod deferredMediaPeriod = new DeferredMediaPeriod(mediaSourceHolder.mediaSource, mediaPeriodId.copyWithPeriodIndex(mediaPeriodId.periodIndex - mediaSourceHolder.firstPeriodIndexInChild), allocator);
this.mediaSourceByMediaPeriod.put(deferredMediaPeriod, mediaSourceHolder);
mediaSourceHolder.activeMediaPeriods.add(deferredMediaPeriod);
if (mediaSourceHolder.isPrepared) {
deferredMediaPeriod.createPeriod();
}
return deferredMediaPeriod;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void releasePeriod(MediaPeriod mediaPeriod) {
MediaSourceHolder remove = this.mediaSourceByMediaPeriod.remove(mediaPeriod);
((DeferredMediaPeriod) mediaPeriod).releasePeriod();
remove.activeMediaPeriods.remove(mediaPeriod);
if (remove.activeMediaPeriods.isEmpty() && remove.isRemoved) {
releaseChildSource(remove);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void releaseSourceInternal() {
super.releaseSourceInternal();
this.mediaSourceHolders.clear();
this.player = null;
this.shuffleOrder = this.shuffleOrder.cloneAndClear();
this.windowCount = 0;
this.periodCount = 0;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource
public final void onChildSourceInfoRefreshed(MediaSourceHolder mediaSourceHolder, MediaSource mediaSource, Timeline timeline, @Nullable Object obj) {
updateMediaSourceInternal(mediaSourceHolder, timeline);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource
@Nullable
public MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(MediaSourceHolder mediaSourceHolder, MediaSource.MediaPeriodId mediaPeriodId) {
for (int i = 0; i < mediaSourceHolder.activeMediaPeriods.size(); i++) {
if (mediaSourceHolder.activeMediaPeriods.get(i).id.windowSequenceNumber == mediaPeriodId.windowSequenceNumber) {
return mediaPeriodId.copyWithPeriodIndex(mediaPeriodId.periodIndex + mediaSourceHolder.firstPeriodIndexInChild);
}
}
return null;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource
public int getWindowIndexForChildWindowIndex(MediaSourceHolder mediaSourceHolder, int i) {
return i + mediaSourceHolder.firstWindowIndexInChild;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.mbridge.msdk.playercommon.exoplayer2.PlayerMessage.Target
public final void handleMessage(int i, Object obj) throws ExoPlaybackException {
switch (i) {
case 0:
MessageData messageData = (MessageData) obj;
this.shuffleOrder = this.shuffleOrder.cloneAndInsert(messageData.index, 1);
addMediaSourceInternal(messageData.index, (MediaSourceHolder) messageData.customData);
scheduleListenerNotification(messageData.actionOnCompletion);
return;
case 1:
MessageData messageData2 = (MessageData) obj;
this.shuffleOrder = this.shuffleOrder.cloneAndInsert(messageData2.index, ((Collection) messageData2.customData).size());
addMediaSourcesInternal(messageData2.index, (Collection) messageData2.customData);
scheduleListenerNotification(messageData2.actionOnCompletion);
return;
case 2:
MessageData messageData3 = (MessageData) obj;
this.shuffleOrder = this.shuffleOrder.cloneAndRemove(messageData3.index);
removeMediaSourceInternal(messageData3.index);
scheduleListenerNotification(messageData3.actionOnCompletion);
return;
case 3:
MessageData messageData4 = (MessageData) obj;
ShuffleOrder cloneAndRemove = this.shuffleOrder.cloneAndRemove(messageData4.index);
this.shuffleOrder = cloneAndRemove;
this.shuffleOrder = cloneAndRemove.cloneAndInsert(((Integer) messageData4.customData).intValue(), 1);
moveMediaSourceInternal(messageData4.index, ((Integer) messageData4.customData).intValue());
scheduleListenerNotification(messageData4.actionOnCompletion);
return;
case 4:
clearInternal();
scheduleListenerNotification((EventDispatcher) obj);
return;
case 5:
notifyListener();
return;
case 6:
List list = (List) obj;
for (int i2 = 0; i2 < list.size(); i2++) {
((EventDispatcher) list.get(i2)).dispatchEvent();
}
return;
default:
throw new IllegalStateException();
}
}
private void scheduleListenerNotification(@Nullable EventDispatcher eventDispatcher) {
if (!this.listenerNotificationScheduled) {
this.player.createMessage(this).setType(5).send();
this.listenerNotificationScheduled = true;
}
if (eventDispatcher != null) {
this.pendingOnCompletionActions.add(eventDispatcher);
}
}
private void notifyListener() {
List arrayList;
this.listenerNotificationScheduled = false;
if (this.pendingOnCompletionActions.isEmpty()) {
arrayList = Collections.emptyList();
} else {
arrayList = new ArrayList(this.pendingOnCompletionActions);
}
this.pendingOnCompletionActions.clear();
refreshSourceInfo(new ConcatenatedTimeline(this.mediaSourceHolders, this.windowCount, this.periodCount, this.shuffleOrder, this.isAtomic), null);
if (arrayList.isEmpty()) {
return;
}
this.player.createMessage(this).setType(6).setPayload(arrayList).send();
}
private void addMediaSourceInternal(int i, MediaSourceHolder mediaSourceHolder) {
if (i > 0) {
MediaSourceHolder mediaSourceHolder2 = this.mediaSourceHolders.get(i - 1);
mediaSourceHolder.reset(i, mediaSourceHolder2.firstWindowIndexInChild + mediaSourceHolder2.timeline.getWindowCount(), mediaSourceHolder2.firstPeriodIndexInChild + mediaSourceHolder2.timeline.getPeriodCount());
} else {
mediaSourceHolder.reset(i, 0, 0);
}
correctOffsets(i, 1, mediaSourceHolder.timeline.getWindowCount(), mediaSourceHolder.timeline.getPeriodCount());
this.mediaSourceHolders.add(i, mediaSourceHolder);
prepareChildSource(mediaSourceHolder, mediaSourceHolder.mediaSource);
}
private void addMediaSourcesInternal(int i, Collection<MediaSourceHolder> collection) {
Iterator<MediaSourceHolder> it = collection.iterator();
while (it.hasNext()) {
addMediaSourceInternal(i, it.next());
i++;
}
}
private void updateMediaSourceInternal(MediaSourceHolder mediaSourceHolder, Timeline timeline) {
if (mediaSourceHolder == null) {
throw new IllegalArgumentException();
}
DeferredTimeline deferredTimeline = mediaSourceHolder.timeline;
if (deferredTimeline.getTimeline() == timeline) {
return;
}
int windowCount = timeline.getWindowCount() - deferredTimeline.getWindowCount();
int periodCount = timeline.getPeriodCount() - deferredTimeline.getPeriodCount();
if (windowCount != 0 || periodCount != 0) {
correctOffsets(mediaSourceHolder.childIndex + 1, 0, windowCount, periodCount);
}
mediaSourceHolder.timeline = deferredTimeline.cloneWithNewTimeline(timeline);
if (!mediaSourceHolder.isPrepared && !timeline.isEmpty()) {
timeline.getWindow(0, this.window);
long positionInFirstPeriodUs = this.window.getPositionInFirstPeriodUs() + this.window.getDefaultPositionUs();
for (int i = 0; i < mediaSourceHolder.activeMediaPeriods.size(); i++) {
DeferredMediaPeriod deferredMediaPeriod = mediaSourceHolder.activeMediaPeriods.get(i);
deferredMediaPeriod.setDefaultPreparePositionUs(positionInFirstPeriodUs);
deferredMediaPeriod.createPeriod();
}
mediaSourceHolder.isPrepared = true;
}
scheduleListenerNotification(null);
}
private void clearInternal() {
for (int size = this.mediaSourceHolders.size() - 1; size >= 0; size--) {
removeMediaSourceInternal(size);
}
}
private void removeMediaSourceInternal(int i) {
MediaSourceHolder remove = this.mediaSourceHolders.remove(i);
DeferredTimeline deferredTimeline = remove.timeline;
correctOffsets(i, -1, -deferredTimeline.getWindowCount(), -deferredTimeline.getPeriodCount());
remove.isRemoved = true;
if (remove.activeMediaPeriods.isEmpty()) {
releaseChildSource(remove);
}
}
private void moveMediaSourceInternal(int i, int i2) {
int min = Math.min(i, i2);
int max = Math.max(i, i2);
int i3 = this.mediaSourceHolders.get(min).firstWindowIndexInChild;
int i4 = this.mediaSourceHolders.get(min).firstPeriodIndexInChild;
List<MediaSourceHolder> list = this.mediaSourceHolders;
list.add(i2, list.remove(i));
while (min <= max) {
MediaSourceHolder mediaSourceHolder = this.mediaSourceHolders.get(min);
mediaSourceHolder.firstWindowIndexInChild = i3;
mediaSourceHolder.firstPeriodIndexInChild = i4;
i3 += mediaSourceHolder.timeline.getWindowCount();
i4 += mediaSourceHolder.timeline.getPeriodCount();
min++;
}
}
private void correctOffsets(int i, int i2, int i3, int i4) {
this.windowCount += i3;
this.periodCount += i4;
while (i < this.mediaSourceHolders.size()) {
this.mediaSourceHolders.get(i).childIndex += i2;
this.mediaSourceHolders.get(i).firstWindowIndexInChild += i3;
this.mediaSourceHolders.get(i).firstPeriodIndexInChild += i4;
i++;
}
}
private int findMediaSourceHolderByPeriodIndex(int i) {
MediaSourceHolder mediaSourceHolder = this.query;
mediaSourceHolder.firstPeriodIndexInChild = i;
int binarySearch = Collections.binarySearch(this.mediaSourceHolders, mediaSourceHolder);
if (binarySearch < 0) {
return (-binarySearch) - 2;
}
while (binarySearch < this.mediaSourceHolders.size() - 1) {
int i2 = binarySearch + 1;
if (this.mediaSourceHolders.get(i2).firstPeriodIndexInChild != i) {
break;
}
binarySearch = i2;
}
return binarySearch;
}
public static final class MediaSourceHolder implements Comparable<MediaSourceHolder> {
public int childIndex;
public int firstPeriodIndexInChild;
public int firstWindowIndexInChild;
public boolean isPrepared;
public boolean isRemoved;
public final MediaSource mediaSource;
public DeferredTimeline timeline = new DeferredTimeline();
public List<DeferredMediaPeriod> activeMediaPeriods = new ArrayList();
public final Object uid = new Object();
public MediaSourceHolder(MediaSource mediaSource) {
this.mediaSource = mediaSource;
}
public final void reset(int i, int i2, int i3) {
this.childIndex = i;
this.firstWindowIndexInChild = i2;
this.firstPeriodIndexInChild = i3;
this.isPrepared = false;
this.isRemoved = false;
this.activeMediaPeriods.clear();
}
@Override // java.lang.Comparable
public final int compareTo(@NonNull MediaSourceHolder mediaSourceHolder) {
return this.firstPeriodIndexInChild - mediaSourceHolder.firstPeriodIndexInChild;
}
}
public static final class EventDispatcher {
public final Handler eventHandler;
public final Runnable runnable;
public EventDispatcher(Runnable runnable) {
this.runnable = runnable;
this.eventHandler = new Handler(Looper.myLooper() != null ? Looper.myLooper() : Looper.getMainLooper());
}
public final void dispatchEvent() {
this.eventHandler.post(this.runnable);
}
}
public static final class MessageData<T> {
@Nullable
public final EventDispatcher actionOnCompletion;
public final T customData;
public final int index;
public MessageData(int i, T t, @Nullable Runnable runnable) {
this.index = i;
this.actionOnCompletion = runnable != null ? new EventDispatcher(runnable) : null;
this.customData = t;
}
}
public static final class ConcatenatedTimeline extends AbstractConcatenatedTimeline {
private final HashMap<Object, Integer> childIndexByUid;
private final int[] firstPeriodInChildIndices;
private final int[] firstWindowInChildIndices;
private final int periodCount;
private final Timeline[] timelines;
private final Object[] uids;
private final int windowCount;
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getPeriodCount() {
return this.periodCount;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getWindowCount() {
return this.windowCount;
}
public ConcatenatedTimeline(Collection<MediaSourceHolder> collection, int i, int i2, ShuffleOrder shuffleOrder, boolean z) {
super(z, shuffleOrder);
this.windowCount = i;
this.periodCount = i2;
int size = collection.size();
this.firstPeriodInChildIndices = new int[size];
this.firstWindowInChildIndices = new int[size];
this.timelines = new Timeline[size];
this.uids = new Object[size];
this.childIndexByUid = new HashMap<>();
int i3 = 0;
for (MediaSourceHolder mediaSourceHolder : collection) {
this.timelines[i3] = mediaSourceHolder.timeline;
this.firstPeriodInChildIndices[i3] = mediaSourceHolder.firstPeriodIndexInChild;
this.firstWindowInChildIndices[i3] = mediaSourceHolder.firstWindowIndexInChild;
Object[] objArr = this.uids;
Object obj = mediaSourceHolder.uid;
objArr[i3] = obj;
this.childIndexByUid.put(obj, Integer.valueOf(i3));
i3++;
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final int getChildIndexByPeriodIndex(int i) {
return Util.binarySearchFloor(this.firstPeriodInChildIndices, i + 1, false, false);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final int getChildIndexByWindowIndex(int i) {
return Util.binarySearchFloor(this.firstWindowInChildIndices, i + 1, false, false);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final int getChildIndexByChildUid(Object obj) {
Integer num = this.childIndexByUid.get(obj);
if (num == null) {
return -1;
}
return num.intValue();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final Timeline getTimelineByChildIndex(int i) {
return this.timelines[i];
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final int getFirstPeriodIndexByChildIndex(int i) {
return this.firstPeriodInChildIndices[i];
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final int getFirstWindowIndexByChildIndex(int i) {
return this.firstWindowInChildIndices[i];
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final Object getChildUidByChildIndex(int i) {
return this.uids[i];
}
}
public static final class DeferredTimeline extends ForwardingTimeline {
private final Object replacedId;
private static final Object DUMMY_ID = new Object();
private static final Timeline.Period period = new Timeline.Period();
private static final DummyTimeline dummyTimeline = new DummyTimeline();
public final Timeline getTimeline() {
return this.timeline;
}
public DeferredTimeline() {
this(dummyTimeline, null);
}
private DeferredTimeline(Timeline timeline, Object obj) {
super(timeline);
this.replacedId = obj;
}
public final DeferredTimeline cloneWithNewTimeline(Timeline timeline) {
return new DeferredTimeline(timeline, (this.replacedId != null || timeline.getPeriodCount() <= 0) ? this.replacedId : timeline.getPeriod(0, period, true).uid);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ForwardingTimeline, com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final Timeline.Period getPeriod(int i, Timeline.Period period2, boolean z) {
this.timeline.getPeriod(i, period2, z);
if (Util.areEqual(period2.uid, this.replacedId)) {
period2.uid = DUMMY_ID;
}
return period2;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ForwardingTimeline, com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getIndexOfPeriod(Object obj) {
Timeline timeline = this.timeline;
if (DUMMY_ID.equals(obj)) {
obj = this.replacedId;
}
return timeline.getIndexOfPeriod(obj);
}
}
public static final class DummyTimeline extends Timeline {
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getIndexOfPeriod(Object obj) {
return obj == null ? 0 : -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getPeriodCount() {
return 1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getWindowCount() {
return 1;
}
private DummyTimeline() {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final Timeline.Window getWindow(int i, Timeline.Window window, boolean z, long j) {
return window.set(null, C.TIME_UNSET, C.TIME_UNSET, false, true, j > 0 ? C.TIME_UNSET : 0L, C.TIME_UNSET, 0, 0, 0L);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final Timeline.Period getPeriod(int i, Timeline.Period period, boolean z) {
return period.set(null, null, 0, C.TIME_UNSET, 0L);
}
}
}

View File

@@ -0,0 +1,9 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
/* loaded from: classes4.dex */
public final class DefaultCompositeSequenceableLoaderFactory implements CompositeSequenceableLoaderFactory {
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeSequenceableLoaderFactory
public final SequenceableLoader createCompositeSequenceableLoader(SequenceableLoader... sequenceableLoaderArr) {
return new CompositeSequenceableLoader(sequenceableLoaderArr);
}
}

View File

@@ -0,0 +1,45 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener;
import java.io.IOException;
/* loaded from: classes4.dex */
public abstract class DefaultMediaSourceEventListener implements MediaSourceEventListener {
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public void onDownstreamFormatChanged(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.MediaLoadData mediaLoadData) {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public void onLoadCanceled(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public void onLoadCompleted(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public void onLoadError(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData, IOException iOException, boolean z) {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public void onLoadStarted(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public void onMediaPeriodCreated(int i, MediaSource.MediaPeriodId mediaPeriodId) {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public void onMediaPeriodReleased(int i, MediaSource.MediaPeriodId mediaPeriodId) {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public void onReadingStarted(int i, MediaSource.MediaPeriodId mediaPeriodId) {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public void onUpstreamDiscarded(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.MediaLoadData mediaLoadData) {
}
}

View File

@@ -0,0 +1,163 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.SeekParameters;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class DeferredMediaPeriod implements MediaPeriod, MediaPeriod.Callback {
private final Allocator allocator;
private MediaPeriod.Callback callback;
public final MediaSource.MediaPeriodId id;
@Nullable
private PrepareErrorListener listener;
private MediaPeriod mediaPeriod;
public final MediaSource mediaSource;
private boolean notifiedPrepareError;
private long preparePositionOverrideUs = C.TIME_UNSET;
private long preparePositionUs;
public interface PrepareErrorListener {
void onPrepareError(MediaSource.MediaPeriodId mediaPeriodId, IOException iOException);
}
public final void setDefaultPreparePositionUs(long j) {
if (this.preparePositionUs != 0 || j == 0) {
return;
}
this.preparePositionOverrideUs = j;
this.preparePositionUs = j;
}
public final void setPrepareErrorListener(PrepareErrorListener prepareErrorListener) {
this.listener = prepareErrorListener;
}
public DeferredMediaPeriod(MediaSource mediaSource, MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator) {
this.id = mediaPeriodId;
this.allocator = allocator;
this.mediaSource = mediaSource;
}
public final void createPeriod() {
MediaPeriod createPeriod = this.mediaSource.createPeriod(this.id, this.allocator);
this.mediaPeriod = createPeriod;
if (this.callback != null) {
createPeriod.prepare(this, this.preparePositionUs);
}
}
public final void releasePeriod() {
MediaPeriod mediaPeriod = this.mediaPeriod;
if (mediaPeriod != null) {
this.mediaSource.releasePeriod(mediaPeriod);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void prepare(MediaPeriod.Callback callback, long j) {
this.callback = callback;
this.preparePositionUs = j;
MediaPeriod mediaPeriod = this.mediaPeriod;
if (mediaPeriod != null) {
mediaPeriod.prepare(this, j);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void maybeThrowPrepareError() throws IOException {
try {
MediaPeriod mediaPeriod = this.mediaPeriod;
if (mediaPeriod != null) {
mediaPeriod.maybeThrowPrepareError();
} else {
this.mediaSource.maybeThrowSourceInfoRefreshError();
}
} catch (IOException e) {
PrepareErrorListener prepareErrorListener = this.listener;
if (prepareErrorListener == null) {
throw e;
}
if (this.notifiedPrepareError) {
return;
}
this.notifiedPrepareError = true;
prepareErrorListener.onPrepareError(this.id, e);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final TrackGroupArray getTrackGroups() {
return this.mediaPeriod.getTrackGroups();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long selectTracks(TrackSelection[] trackSelectionArr, boolean[] zArr, SampleStream[] sampleStreamArr, boolean[] zArr2, long j) {
long j2;
long j3 = this.preparePositionOverrideUs;
if (j3 == C.TIME_UNSET || j != 0) {
j2 = j;
} else {
this.preparePositionOverrideUs = C.TIME_UNSET;
j2 = j3;
}
return this.mediaPeriod.selectTracks(trackSelectionArr, zArr, sampleStreamArr, zArr2, j2);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void discardBuffer(long j, boolean z) {
this.mediaPeriod.discardBuffer(j, z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long readDiscontinuity() {
return this.mediaPeriod.readDiscontinuity();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getBufferedPositionUs() {
return this.mediaPeriod.getBufferedPositionUs();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long seekToUs(long j) {
return this.mediaPeriod.seekToUs(j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long getAdjustedSeekPositionUs(long j, SeekParameters seekParameters) {
return this.mediaPeriod.getAdjustedSeekPositionUs(j, seekParameters);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getNextLoadPositionUs() {
return this.mediaPeriod.getNextLoadPositionUs();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final void reevaluateBuffer(long j) {
this.mediaPeriod.reevaluateBuffer(j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final boolean continueLoading(long j) {
MediaPeriod mediaPeriod = this.mediaPeriod;
return mediaPeriod != null && mediaPeriod.continueLoading(j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader.Callback
public final void onContinueLoadingRequested(MediaPeriod mediaPeriod) {
this.callback.onContinueLoadingRequested(this);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod.Callback
public final void onPrepared(MediaPeriod mediaPeriod) {
this.callback.onPrepared(this);
}
}

View File

@@ -0,0 +1,19 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
@Deprecated
/* loaded from: classes4.dex */
public final class DynamicConcatenatingMediaSource extends ConcatenatingMediaSource {
@Deprecated
public DynamicConcatenatingMediaSource() {
}
@Deprecated
public DynamicConcatenatingMediaSource(boolean z) {
super(z);
}
@Deprecated
public DynamicConcatenatingMediaSource(boolean z, ShuffleOrder shuffleOrder) {
super(z, shuffleOrder);
}
}

View File

@@ -0,0 +1,28 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import com.mbridge.msdk.playercommon.exoplayer2.FormatHolder;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderInputBuffer;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class EmptySampleStream implements SampleStream {
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final boolean isReady() {
return true;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final void maybeThrowError() throws IOException {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final int skipData(long j) {
return 0;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final int readData(FormatHolder formatHolder, DecoderInputBuffer decoderInputBuffer, boolean z) {
decoderInputBuffer.setFlags(4);
return -4;
}
}

View File

@@ -0,0 +1,772 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.net.Uri;
import android.os.Handler;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.FormatHolder;
import com.mbridge.msdk.playercommon.exoplayer2.SeekParameters;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderInputBuffer;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.DefaultExtractorInput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.Extractor;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorInput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorOutput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.PositionHolder;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.SeekMap;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener;
import com.mbridge.msdk.playercommon.exoplayer2.source.SampleQueue;
import com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.ConditionVariable;
import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.io.EOFException;
import java.io.IOException;
import java.util.Arrays;
/* loaded from: classes4.dex */
final class ExtractorMediaPeriod implements ExtractorOutput, MediaPeriod, SampleQueue.UpstreamFormatChangedListener, Loader.Callback<ExtractingLoadable>, Loader.ReleaseCallback {
private static final long DEFAULT_LAST_SAMPLE_DURATION_US = 10000;
private int actualMinLoadableRetryCount;
private final Allocator allocator;
@Nullable
private MediaPeriod.Callback callback;
private final long continueLoadingCheckIntervalBytes;
@Nullable
private final String customCacheKey;
private final DataSource dataSource;
private int enabledTrackCount;
private final MediaSourceEventListener.EventDispatcher eventDispatcher;
private int extractedSamplesCountAtStartOfLoad;
private final ExtractorHolder extractorHolder;
private boolean haveAudioVideoTracks;
private long lastSeekPositionUs;
private final Listener listener;
private boolean loadingFinished;
private final int minLoadableRetryCount;
private boolean notifiedReadingStarted;
private boolean notifyDiscontinuity;
private boolean pendingDeferredRetry;
private boolean prepared;
private boolean released;
private boolean sampleQueuesBuilt;
private SeekMap seekMap;
private boolean seenFirstTrackSelection;
private boolean[] trackEnabledStates;
private boolean[] trackFormatNotificationSent;
private boolean[] trackIsAudioVideoFlags;
private TrackGroupArray tracks;
private final Uri uri;
private final Loader loader = new Loader("Loader:ExtractorMediaPeriod");
private final ConditionVariable loadCondition = new ConditionVariable();
private final Runnable maybeFinishPrepareRunnable = new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.ExtractorMediaPeriod.1
@Override // java.lang.Runnable
public void run() {
ExtractorMediaPeriod.this.maybeFinishPrepare();
}
};
private final Runnable onContinueLoadingRequestedRunnable = new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.ExtractorMediaPeriod.2
@Override // java.lang.Runnable
public void run() {
if (ExtractorMediaPeriod.this.released) {
return;
}
ExtractorMediaPeriod.this.callback.onContinueLoadingRequested(ExtractorMediaPeriod.this);
}
};
private final Handler handler = new Handler();
private int[] sampleQueueTrackIds = new int[0];
private SampleQueue[] sampleQueues = new SampleQueue[0];
private long pendingResetPositionUs = C.TIME_UNSET;
private long length = -1;
private long durationUs = C.TIME_UNSET;
public interface Listener {
void onSourceInfoRefreshed(long j, boolean z);
}
private boolean isPendingReset() {
return this.pendingResetPositionUs != C.TIME_UNSET;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final TrackGroupArray getTrackGroups() {
return this.tracks;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final void reevaluateBuffer(long j) {
}
public ExtractorMediaPeriod(Uri uri, DataSource dataSource, Extractor[] extractorArr, int i, MediaSourceEventListener.EventDispatcher eventDispatcher, Listener listener, Allocator allocator, @Nullable String str, int i2) {
this.uri = uri;
this.dataSource = dataSource;
this.minLoadableRetryCount = i;
this.eventDispatcher = eventDispatcher;
this.listener = listener;
this.allocator = allocator;
this.customCacheKey = str;
this.continueLoadingCheckIntervalBytes = i2;
this.extractorHolder = new ExtractorHolder(extractorArr, this);
this.actualMinLoadableRetryCount = i == -1 ? 3 : i;
eventDispatcher.mediaPeriodCreated();
}
public final void release() {
if (this.prepared) {
for (SampleQueue sampleQueue : this.sampleQueues) {
sampleQueue.discardToEnd();
}
}
this.loader.release(this);
this.handler.removeCallbacksAndMessages(null);
this.callback = null;
this.released = true;
this.eventDispatcher.mediaPeriodReleased();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.ReleaseCallback
public final void onLoaderReleased() {
for (SampleQueue sampleQueue : this.sampleQueues) {
sampleQueue.reset();
}
this.extractorHolder.release();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void prepare(MediaPeriod.Callback callback, long j) {
this.callback = callback;
this.loadCondition.open();
startLoading();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void maybeThrowPrepareError() throws IOException {
maybeThrowError();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long selectTracks(TrackSelection[] trackSelectionArr, boolean[] zArr, SampleStream[] sampleStreamArr, boolean[] zArr2, long j) {
TrackSelection trackSelection;
Assertions.checkState(this.prepared);
int i = this.enabledTrackCount;
int i2 = 0;
for (int i3 = 0; i3 < trackSelectionArr.length; i3++) {
SampleStream sampleStream = sampleStreamArr[i3];
if (sampleStream != null && (trackSelectionArr[i3] == null || !zArr[i3])) {
int i4 = ((SampleStreamImpl) sampleStream).track;
Assertions.checkState(this.trackEnabledStates[i4]);
this.enabledTrackCount--;
this.trackEnabledStates[i4] = false;
sampleStreamArr[i3] = null;
}
}
boolean z = !this.seenFirstTrackSelection ? j == 0 : i != 0;
for (int i5 = 0; i5 < trackSelectionArr.length; i5++) {
if (sampleStreamArr[i5] == null && (trackSelection = trackSelectionArr[i5]) != null) {
Assertions.checkState(trackSelection.length() == 1);
Assertions.checkState(trackSelection.getIndexInTrackGroup(0) == 0);
int indexOf = this.tracks.indexOf(trackSelection.getTrackGroup());
Assertions.checkState(!this.trackEnabledStates[indexOf]);
this.enabledTrackCount++;
this.trackEnabledStates[indexOf] = true;
sampleStreamArr[i5] = new SampleStreamImpl(indexOf);
zArr2[i5] = true;
if (!z) {
SampleQueue sampleQueue = this.sampleQueues[indexOf];
sampleQueue.rewind();
z = sampleQueue.advanceTo(j, true, true) == -1 && sampleQueue.getReadIndex() != 0;
}
}
}
if (this.enabledTrackCount == 0) {
this.pendingDeferredRetry = false;
this.notifyDiscontinuity = false;
if (this.loader.isLoading()) {
SampleQueue[] sampleQueueArr = this.sampleQueues;
int length = sampleQueueArr.length;
while (i2 < length) {
sampleQueueArr[i2].discardToEnd();
i2++;
}
this.loader.cancelLoading();
} else {
SampleQueue[] sampleQueueArr2 = this.sampleQueues;
int length2 = sampleQueueArr2.length;
while (i2 < length2) {
sampleQueueArr2[i2].reset();
i2++;
}
}
} else if (z) {
j = seekToUs(j);
while (i2 < sampleStreamArr.length) {
if (sampleStreamArr[i2] != null) {
zArr2[i2] = true;
}
i2++;
}
}
this.seenFirstTrackSelection = true;
return j;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void discardBuffer(long j, boolean z) {
int length = this.sampleQueues.length;
for (int i = 0; i < length; i++) {
this.sampleQueues[i].discardTo(j, z, this.trackEnabledStates[i]);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final boolean continueLoading(long j) {
if (this.loadingFinished || this.pendingDeferredRetry) {
return false;
}
if (this.prepared && this.enabledTrackCount == 0) {
return false;
}
boolean open = this.loadCondition.open();
if (this.loader.isLoading()) {
return open;
}
startLoading();
return true;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getNextLoadPositionUs() {
if (this.enabledTrackCount == 0) {
return Long.MIN_VALUE;
}
return getBufferedPositionUs();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long readDiscontinuity() {
if (!this.notifiedReadingStarted) {
this.eventDispatcher.readingStarted();
this.notifiedReadingStarted = true;
}
if (!this.notifyDiscontinuity) {
return C.TIME_UNSET;
}
if (!this.loadingFinished && getExtractedSamplesCount() <= this.extractedSamplesCountAtStartOfLoad) {
return C.TIME_UNSET;
}
this.notifyDiscontinuity = false;
return this.lastSeekPositionUs;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getBufferedPositionUs() {
long largestQueuedTimestampUs;
if (this.loadingFinished) {
return Long.MIN_VALUE;
}
if (isPendingReset()) {
return this.pendingResetPositionUs;
}
if (this.haveAudioVideoTracks) {
int length = this.sampleQueues.length;
largestQueuedTimestampUs = Long.MAX_VALUE;
for (int i = 0; i < length; i++) {
if (this.trackIsAudioVideoFlags[i]) {
largestQueuedTimestampUs = Math.min(largestQueuedTimestampUs, this.sampleQueues[i].getLargestQueuedTimestampUs());
}
}
} else {
largestQueuedTimestampUs = getLargestQueuedTimestampUs();
}
return largestQueuedTimestampUs == Long.MIN_VALUE ? this.lastSeekPositionUs : largestQueuedTimestampUs;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long seekToUs(long j) {
if (!this.seekMap.isSeekable()) {
j = 0;
}
this.lastSeekPositionUs = j;
this.notifyDiscontinuity = false;
if (!isPendingReset() && seekInsideBufferUs(j)) {
return j;
}
this.pendingDeferredRetry = false;
this.pendingResetPositionUs = j;
this.loadingFinished = false;
if (this.loader.isLoading()) {
this.loader.cancelLoading();
} else {
for (SampleQueue sampleQueue : this.sampleQueues) {
sampleQueue.reset();
}
}
return j;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long getAdjustedSeekPositionUs(long j, SeekParameters seekParameters) {
if (!this.seekMap.isSeekable()) {
return 0L;
}
SeekMap.SeekPoints seekPoints = this.seekMap.getSeekPoints(j);
return Util.resolveSeekPositionUs(j, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
public final boolean isReady(int i) {
return !suppressRead() && (this.loadingFinished || this.sampleQueues[i].hasNextSample());
}
public final void maybeThrowError() throws IOException {
this.loader.maybeThrowError(this.actualMinLoadableRetryCount);
}
public final int readData(int i, FormatHolder formatHolder, DecoderInputBuffer decoderInputBuffer, boolean z) {
if (suppressRead()) {
return -3;
}
int read = this.sampleQueues[i].read(formatHolder, decoderInputBuffer, z, this.loadingFinished, this.lastSeekPositionUs);
if (read == -4) {
maybeNotifyTrackFormat(i);
} else if (read == -3) {
maybeStartDeferredRetry(i);
}
return read;
}
public final int skipData(int i, long j) {
int i2 = 0;
if (suppressRead()) {
return 0;
}
SampleQueue sampleQueue = this.sampleQueues[i];
if (this.loadingFinished && j > sampleQueue.getLargestQueuedTimestampUs()) {
i2 = sampleQueue.advanceToEnd();
} else {
int advanceTo = sampleQueue.advanceTo(j, true, true);
if (advanceTo != -1) {
i2 = advanceTo;
}
}
if (i2 > 0) {
maybeNotifyTrackFormat(i);
} else {
maybeStartDeferredRetry(i);
}
return i2;
}
private void maybeNotifyTrackFormat(int i) {
if (this.trackFormatNotificationSent[i]) {
return;
}
Format format = this.tracks.get(i).getFormat(0);
this.eventDispatcher.downstreamFormatChanged(MimeTypes.getTrackType(format.sampleMimeType), format, 0, null, this.lastSeekPositionUs);
this.trackFormatNotificationSent[i] = true;
}
private void maybeStartDeferredRetry(int i) {
if (this.pendingDeferredRetry && this.trackIsAudioVideoFlags[i] && !this.sampleQueues[i].hasNextSample()) {
this.pendingResetPositionUs = 0L;
this.pendingDeferredRetry = false;
this.notifyDiscontinuity = true;
this.lastSeekPositionUs = 0L;
this.extractedSamplesCountAtStartOfLoad = 0;
for (SampleQueue sampleQueue : this.sampleQueues) {
sampleQueue.reset();
}
this.callback.onContinueLoadingRequested(this);
}
}
private boolean suppressRead() {
return this.notifyDiscontinuity || isPendingReset();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Callback
public final void onLoadCompleted(ExtractingLoadable extractingLoadable, long j, long j2) {
if (this.durationUs == C.TIME_UNSET) {
long largestQueuedTimestampUs = getLargestQueuedTimestampUs();
long j3 = largestQueuedTimestampUs == Long.MIN_VALUE ? 0L : largestQueuedTimestampUs + 10000;
this.durationUs = j3;
this.listener.onSourceInfoRefreshed(j3, this.seekMap.isSeekable());
}
this.eventDispatcher.loadCompleted(extractingLoadable.dataSpec, 1, -1, null, 0, null, extractingLoadable.seekTimeUs, this.durationUs, j, j2, extractingLoadable.bytesLoaded);
copyLengthFromLoader(extractingLoadable);
this.loadingFinished = true;
this.callback.onContinueLoadingRequested(this);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Callback
public final void onLoadCanceled(ExtractingLoadable extractingLoadable, long j, long j2, boolean z) {
this.eventDispatcher.loadCanceled(extractingLoadable.dataSpec, 1, -1, null, 0, null, extractingLoadable.seekTimeUs, this.durationUs, j, j2, extractingLoadable.bytesLoaded);
if (z) {
return;
}
copyLengthFromLoader(extractingLoadable);
for (SampleQueue sampleQueue : this.sampleQueues) {
sampleQueue.reset();
}
if (this.enabledTrackCount > 0) {
this.callback.onContinueLoadingRequested(this);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Callback
public final int onLoadError(ExtractingLoadable extractingLoadable, long j, long j2, IOException iOException) {
ExtractingLoadable extractingLoadable2;
boolean z;
boolean isLoadableExceptionFatal = isLoadableExceptionFatal(iOException);
this.eventDispatcher.loadError(extractingLoadable.dataSpec, 1, -1, null, 0, null, extractingLoadable.seekTimeUs, this.durationUs, j, j2, extractingLoadable.bytesLoaded, iOException, isLoadableExceptionFatal);
copyLengthFromLoader(extractingLoadable);
if (isLoadableExceptionFatal) {
return 3;
}
int extractedSamplesCount = getExtractedSamplesCount();
if (extractedSamplesCount > this.extractedSamplesCountAtStartOfLoad) {
extractingLoadable2 = extractingLoadable;
z = true;
} else {
extractingLoadable2 = extractingLoadable;
z = false;
}
if (configureRetry(extractingLoadable2, extractedSamplesCount)) {
return z ? 1 : 0;
}
return 2;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorOutput
public final TrackOutput track(int i, int i2) {
int length = this.sampleQueues.length;
for (int i3 = 0; i3 < length; i3++) {
if (this.sampleQueueTrackIds[i3] == i) {
return this.sampleQueues[i3];
}
}
SampleQueue sampleQueue = new SampleQueue(this.allocator);
sampleQueue.setUpstreamFormatChangeListener(this);
int i4 = length + 1;
int[] copyOf = Arrays.copyOf(this.sampleQueueTrackIds, i4);
this.sampleQueueTrackIds = copyOf;
copyOf[length] = i;
SampleQueue[] sampleQueueArr = (SampleQueue[]) Arrays.copyOf(this.sampleQueues, i4);
this.sampleQueues = sampleQueueArr;
sampleQueueArr[length] = sampleQueue;
return sampleQueue;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorOutput
public final void endTracks() {
this.sampleQueuesBuilt = true;
this.handler.post(this.maybeFinishPrepareRunnable);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorOutput
public final void seekMap(SeekMap seekMap) {
this.seekMap = seekMap;
this.handler.post(this.maybeFinishPrepareRunnable);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleQueue.UpstreamFormatChangedListener
public final void onUpstreamFormatChanged(Format format) {
this.handler.post(this.maybeFinishPrepareRunnable);
}
/* JADX INFO: Access modifiers changed from: private */
public void maybeFinishPrepare() {
if (this.released || this.prepared || this.seekMap == null || !this.sampleQueuesBuilt) {
return;
}
for (SampleQueue sampleQueue : this.sampleQueues) {
if (sampleQueue.getUpstreamFormat() == null) {
return;
}
}
this.loadCondition.close();
int length = this.sampleQueues.length;
TrackGroup[] trackGroupArr = new TrackGroup[length];
this.trackIsAudioVideoFlags = new boolean[length];
this.trackEnabledStates = new boolean[length];
this.trackFormatNotificationSent = new boolean[length];
this.durationUs = this.seekMap.getDurationUs();
int i = 0;
while (true) {
boolean z = true;
if (i >= length) {
break;
}
Format upstreamFormat = this.sampleQueues[i].getUpstreamFormat();
trackGroupArr[i] = new TrackGroup(upstreamFormat);
String str = upstreamFormat.sampleMimeType;
if (!MimeTypes.isVideo(str) && !MimeTypes.isAudio(str)) {
z = false;
}
this.trackIsAudioVideoFlags[i] = z;
this.haveAudioVideoTracks = z | this.haveAudioVideoTracks;
i++;
}
this.tracks = new TrackGroupArray(trackGroupArr);
if (this.minLoadableRetryCount == -1 && this.length == -1 && this.seekMap.getDurationUs() == C.TIME_UNSET) {
this.actualMinLoadableRetryCount = 6;
}
this.prepared = true;
this.listener.onSourceInfoRefreshed(this.durationUs, this.seekMap.isSeekable());
this.callback.onPrepared(this);
}
private void copyLengthFromLoader(ExtractingLoadable extractingLoadable) {
if (this.length == -1) {
this.length = extractingLoadable.length;
}
}
private void startLoading() {
ExtractingLoadable extractingLoadable = new ExtractingLoadable(this.uri, this.dataSource, this.extractorHolder, this.loadCondition);
if (this.prepared) {
Assertions.checkState(isPendingReset());
long j = this.durationUs;
if (j != C.TIME_UNSET && this.pendingResetPositionUs >= j) {
this.loadingFinished = true;
this.pendingResetPositionUs = C.TIME_UNSET;
return;
} else {
extractingLoadable.setLoadPosition(this.seekMap.getSeekPoints(this.pendingResetPositionUs).first.position, this.pendingResetPositionUs);
this.pendingResetPositionUs = C.TIME_UNSET;
}
}
this.extractedSamplesCountAtStartOfLoad = getExtractedSamplesCount();
this.eventDispatcher.loadStarted(extractingLoadable.dataSpec, 1, -1, null, 0, null, extractingLoadable.seekTimeUs, this.durationUs, this.loader.startLoading(extractingLoadable, this, this.actualMinLoadableRetryCount));
}
private boolean configureRetry(ExtractingLoadable extractingLoadable, int i) {
SeekMap seekMap;
if (this.length != -1 || ((seekMap = this.seekMap) != null && seekMap.getDurationUs() != C.TIME_UNSET)) {
this.extractedSamplesCountAtStartOfLoad = i;
return true;
}
if (this.prepared && !suppressRead()) {
this.pendingDeferredRetry = true;
return false;
}
this.notifyDiscontinuity = this.prepared;
this.lastSeekPositionUs = 0L;
this.extractedSamplesCountAtStartOfLoad = 0;
for (SampleQueue sampleQueue : this.sampleQueues) {
sampleQueue.reset();
}
extractingLoadable.setLoadPosition(0L, 0L);
return true;
}
private boolean seekInsideBufferUs(long j) {
int length = this.sampleQueues.length;
for (int i = 0; i < length; i++) {
SampleQueue sampleQueue = this.sampleQueues[i];
sampleQueue.rewind();
if (sampleQueue.advanceTo(j, true, false) == -1 && (this.trackIsAudioVideoFlags[i] || !this.haveAudioVideoTracks)) {
return false;
}
}
return true;
}
private int getExtractedSamplesCount() {
int i = 0;
for (SampleQueue sampleQueue : this.sampleQueues) {
i += sampleQueue.getWriteIndex();
}
return i;
}
private long getLargestQueuedTimestampUs() {
long j = Long.MIN_VALUE;
for (SampleQueue sampleQueue : this.sampleQueues) {
j = Math.max(j, sampleQueue.getLargestQueuedTimestampUs());
}
return j;
}
private static boolean isLoadableExceptionFatal(IOException iOException) {
return iOException instanceof UnrecognizedInputFormatException;
}
public final class SampleStreamImpl implements SampleStream {
private final int track;
public SampleStreamImpl(int i) {
this.track = i;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final boolean isReady() {
return ExtractorMediaPeriod.this.isReady(this.track);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final void maybeThrowError() throws IOException {
ExtractorMediaPeriod.this.maybeThrowError();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final int readData(FormatHolder formatHolder, DecoderInputBuffer decoderInputBuffer, boolean z) {
return ExtractorMediaPeriod.this.readData(this.track, formatHolder, decoderInputBuffer, z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final int skipData(long j) {
return ExtractorMediaPeriod.this.skipData(this.track, j);
}
}
public final class ExtractingLoadable implements Loader.Loadable {
private long bytesLoaded;
private final DataSource dataSource;
private DataSpec dataSpec;
private final ExtractorHolder extractorHolder;
private volatile boolean loadCanceled;
private final ConditionVariable loadCondition;
private long seekTimeUs;
private final Uri uri;
private final PositionHolder positionHolder = new PositionHolder();
private boolean pendingExtractorSeek = true;
private long length = -1;
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void cancelLoad() {
this.loadCanceled = true;
}
public ExtractingLoadable(Uri uri, DataSource dataSource, ExtractorHolder extractorHolder, ConditionVariable conditionVariable) {
this.uri = (Uri) Assertions.checkNotNull(uri);
this.dataSource = (DataSource) Assertions.checkNotNull(dataSource);
this.extractorHolder = (ExtractorHolder) Assertions.checkNotNull(extractorHolder);
this.loadCondition = conditionVariable;
}
public final void setLoadPosition(long j, long j2) {
this.positionHolder.position = j;
this.seekTimeUs = j2;
this.pendingExtractorSeek = true;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void load() throws IOException, InterruptedException {
long j;
DefaultExtractorInput defaultExtractorInput;
int i = 0;
while (i == 0 && !this.loadCanceled) {
DefaultExtractorInput defaultExtractorInput2 = null;
try {
j = this.positionHolder.position;
DataSpec dataSpec = new DataSpec(this.uri, j, -1L, ExtractorMediaPeriod.this.customCacheKey);
this.dataSpec = dataSpec;
long open = this.dataSource.open(dataSpec);
this.length = open;
if (open != -1) {
this.length = open + j;
}
defaultExtractorInput = new DefaultExtractorInput(this.dataSource, j, this.length);
} catch (Throwable th) {
th = th;
}
try {
Extractor selectExtractor = this.extractorHolder.selectExtractor(defaultExtractorInput, this.dataSource.getUri());
if (this.pendingExtractorSeek) {
selectExtractor.seek(j, this.seekTimeUs);
this.pendingExtractorSeek = false;
}
while (i == 0 && !this.loadCanceled) {
this.loadCondition.block();
i = selectExtractor.read(defaultExtractorInput, this.positionHolder);
if (defaultExtractorInput.getPosition() > ExtractorMediaPeriod.this.continueLoadingCheckIntervalBytes + j) {
j = defaultExtractorInput.getPosition();
this.loadCondition.close();
ExtractorMediaPeriod.this.handler.post(ExtractorMediaPeriod.this.onContinueLoadingRequestedRunnable);
}
}
if (i == 1) {
i = 0;
} else {
this.positionHolder.position = defaultExtractorInput.getPosition();
this.bytesLoaded = this.positionHolder.position - this.dataSpec.absoluteStreamPosition;
}
Util.closeQuietly(this.dataSource);
} catch (Throwable th2) {
th = th2;
defaultExtractorInput2 = defaultExtractorInput;
if (i != 1 && defaultExtractorInput2 != null) {
this.positionHolder.position = defaultExtractorInput2.getPosition();
this.bytesLoaded = this.positionHolder.position - this.dataSpec.absoluteStreamPosition;
}
Util.closeQuietly(this.dataSource);
throw th;
}
}
}
}
public static final class ExtractorHolder {
private Extractor extractor;
private final ExtractorOutput extractorOutput;
private final Extractor[] extractors;
public ExtractorHolder(Extractor[] extractorArr, ExtractorOutput extractorOutput) {
this.extractors = extractorArr;
this.extractorOutput = extractorOutput;
}
public final Extractor selectExtractor(ExtractorInput extractorInput, Uri uri) throws IOException, InterruptedException {
Extractor extractor = this.extractor;
if (extractor != null) {
return extractor;
}
Extractor[] extractorArr = this.extractors;
int length = extractorArr.length;
int i = 0;
while (true) {
if (i >= length) {
break;
}
Extractor extractor2 = extractorArr[i];
try {
if (extractor2.sniff(extractorInput)) {
this.extractor = extractor2;
extractorInput.resetPeekPosition();
break;
}
} catch (EOFException unused) {
} catch (Throwable th) {
extractorInput.resetPeekPosition();
throw th;
}
extractorInput.resetPeekPosition();
i++;
}
Extractor extractor3 = this.extractor;
if (extractor3 == null) {
throw new UnrecognizedInputFormatException("None of the available extractors (" + Util.getCommaDelimitedSimpleClassNames(this.extractors) + ") could read the stream.", uri);
}
extractor3.init(this.extractorOutput);
return this.extractor;
}
public final void release() {
Extractor extractor = this.extractor;
if (extractor != null) {
extractor.release();
this.extractor = null;
}
}
}
}

View File

@@ -0,0 +1,198 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.net.Uri;
import android.os.Handler;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.DefaultExtractorsFactory;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorsFactory;
import com.mbridge.msdk.playercommon.exoplayer2.source.ExtractorMediaPeriod;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener;
import com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class ExtractorMediaSource extends BaseMediaSource implements ExtractorMediaPeriod.Listener {
public static final int DEFAULT_LOADING_CHECK_INTERVAL_BYTES = 1048576;
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE = 6;
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND = 3;
public static final int MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA = -1;
private final int continueLoadingCheckIntervalBytes;
private final String customCacheKey;
private final DataSource.Factory dataSourceFactory;
private final ExtractorsFactory extractorsFactory;
private final int minLoadableRetryCount;
@Nullable
private final Object tag;
private long timelineDurationUs;
private boolean timelineIsSeekable;
private final Uri uri;
@Deprecated
public interface EventListener {
void onLoadError(IOException iOException);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void maybeThrowSourceInfoRefreshError() throws IOException {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void releaseSourceInternal() {
}
public static final class Factory implements AdsMediaSource.MediaSourceFactory {
@Nullable
private String customCacheKey;
private final DataSource.Factory dataSourceFactory;
@Nullable
private ExtractorsFactory extractorsFactory;
private boolean isCreateCalled;
@Nullable
private Object tag;
private int minLoadableRetryCount = -1;
private int continueLoadingCheckIntervalBytes = 1048576;
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource.MediaSourceFactory
public final int[] getSupportedTypes() {
return new int[]{3};
}
public Factory(DataSource.Factory factory) {
this.dataSourceFactory = factory;
}
public final Factory setExtractorsFactory(ExtractorsFactory extractorsFactory) {
Assertions.checkState(!this.isCreateCalled);
this.extractorsFactory = extractorsFactory;
return this;
}
public final Factory setCustomCacheKey(String str) {
Assertions.checkState(!this.isCreateCalled);
this.customCacheKey = str;
return this;
}
public final Factory setTag(Object obj) {
Assertions.checkState(!this.isCreateCalled);
this.tag = obj;
return this;
}
public final Factory setMinLoadableRetryCount(int i) {
Assertions.checkState(!this.isCreateCalled);
this.minLoadableRetryCount = i;
return this;
}
public final Factory setContinueLoadingCheckIntervalBytes(int i) {
Assertions.checkState(!this.isCreateCalled);
this.continueLoadingCheckIntervalBytes = i;
return this;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource.MediaSourceFactory
public final ExtractorMediaSource createMediaSource(Uri uri) {
this.isCreateCalled = true;
if (this.extractorsFactory == null) {
this.extractorsFactory = new DefaultExtractorsFactory();
}
return new ExtractorMediaSource(uri, this.dataSourceFactory, this.extractorsFactory, this.minLoadableRetryCount, this.customCacheKey, this.continueLoadingCheckIntervalBytes, this.tag);
}
@Deprecated
public final ExtractorMediaSource createMediaSource(Uri uri, @Nullable Handler handler, @Nullable MediaSourceEventListener mediaSourceEventListener) {
ExtractorMediaSource createMediaSource = createMediaSource(uri);
if (handler != null && mediaSourceEventListener != null) {
createMediaSource.addEventListener(handler, mediaSourceEventListener);
}
return createMediaSource;
}
}
@Deprecated
public ExtractorMediaSource(Uri uri, DataSource.Factory factory, ExtractorsFactory extractorsFactory, Handler handler, EventListener eventListener) {
this(uri, factory, extractorsFactory, handler, eventListener, null);
}
@Deprecated
public ExtractorMediaSource(Uri uri, DataSource.Factory factory, ExtractorsFactory extractorsFactory, Handler handler, EventListener eventListener, String str) {
this(uri, factory, extractorsFactory, -1, handler, eventListener, str, 1048576);
}
@Deprecated
public ExtractorMediaSource(Uri uri, DataSource.Factory factory, ExtractorsFactory extractorsFactory, int i, Handler handler, EventListener eventListener, String str, int i2) {
this(uri, factory, extractorsFactory, i, str, i2, null);
if (eventListener == null || handler == null) {
return;
}
addEventListener(handler, new EventListenerWrapper(eventListener));
}
private ExtractorMediaSource(Uri uri, DataSource.Factory factory, ExtractorsFactory extractorsFactory, int i, @Nullable String str, int i2, @Nullable Object obj) {
this.uri = uri;
this.dataSourceFactory = factory;
this.extractorsFactory = extractorsFactory;
this.minLoadableRetryCount = i;
this.customCacheKey = str;
this.continueLoadingCheckIntervalBytes = i2;
this.timelineDurationUs = C.TIME_UNSET;
this.tag = obj;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void prepareSourceInternal(ExoPlayer exoPlayer, boolean z) {
notifySourceInfoRefreshed(this.timelineDurationUs, false);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final MediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator) {
Assertions.checkArgument(mediaPeriodId.periodIndex == 0);
return new ExtractorMediaPeriod(this.uri, this.dataSourceFactory.createDataSource(), this.extractorsFactory.createExtractors(), this.minLoadableRetryCount, createEventDispatcher(mediaPeriodId), this, allocator, this.customCacheKey, this.continueLoadingCheckIntervalBytes);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void releasePeriod(MediaPeriod mediaPeriod) {
((ExtractorMediaPeriod) mediaPeriod).release();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ExtractorMediaPeriod.Listener
public final void onSourceInfoRefreshed(long j, boolean z) {
if (j == C.TIME_UNSET) {
j = this.timelineDurationUs;
}
if (this.timelineDurationUs == j && this.timelineIsSeekable == z) {
return;
}
notifySourceInfoRefreshed(j, z);
}
private void notifySourceInfoRefreshed(long j, boolean z) {
this.timelineDurationUs = j;
this.timelineIsSeekable = z;
refreshSourceInfo(new SinglePeriodTimeline(this.timelineDurationUs, this.timelineIsSeekable, false, this.tag), null);
}
public static final class EventListenerWrapper extends DefaultMediaSourceEventListener {
private final EventListener eventListener;
public EventListenerWrapper(EventListener eventListener) {
this.eventListener = (EventListener) Assertions.checkNotNull(eventListener);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.DefaultMediaSourceEventListener, com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onLoadError(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData, IOException iOException, boolean z) {
this.eventListener.onLoadError(iOException);
}
}
}

View File

@@ -0,0 +1,57 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
/* loaded from: classes4.dex */
public abstract class ForwardingTimeline extends Timeline {
protected final Timeline timeline;
public ForwardingTimeline(Timeline timeline) {
this.timeline = timeline;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getWindowCount() {
return this.timeline.getWindowCount();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getNextWindowIndex(int i, int i2, boolean z) {
return this.timeline.getNextWindowIndex(i, i2, z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getPreviousWindowIndex(int i, int i2, boolean z) {
return this.timeline.getPreviousWindowIndex(i, i2, z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getLastWindowIndex(boolean z) {
return this.timeline.getLastWindowIndex(z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getFirstWindowIndex(boolean z) {
return this.timeline.getFirstWindowIndex(z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public Timeline.Window getWindow(int i, Timeline.Window window, boolean z, long j) {
return this.timeline.getWindow(i, window, z, j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getPeriodCount() {
return this.timeline.getPeriodCount();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public Timeline.Period getPeriod(int i, Timeline.Period period, boolean z) {
return this.timeline.getPeriod(i, period, z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public int getIndexOfPeriod(Object obj) {
return this.timeline.getIndexOfPeriod(obj);
}
}

View File

@@ -0,0 +1,148 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
/* loaded from: classes4.dex */
public final class LoopingMediaSource extends CompositeMediaSource<Void> {
private int childPeriodCount;
private final MediaSource childSource;
private final int loopCount;
public LoopingMediaSource(MediaSource mediaSource) {
this(mediaSource, Integer.MAX_VALUE);
}
public LoopingMediaSource(MediaSource mediaSource, int i) {
Assertions.checkArgument(i > 0);
this.childSource = mediaSource;
this.loopCount = i;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void prepareSourceInternal(ExoPlayer exoPlayer, boolean z) {
super.prepareSourceInternal(exoPlayer, z);
prepareChildSource(null, this.childSource);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final MediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator) {
if (this.loopCount != Integer.MAX_VALUE) {
return this.childSource.createPeriod(mediaPeriodId.copyWithPeriodIndex(mediaPeriodId.periodIndex % this.childPeriodCount), allocator);
}
return this.childSource.createPeriod(mediaPeriodId, allocator);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void releasePeriod(MediaPeriod mediaPeriod) {
this.childSource.releasePeriod(mediaPeriod);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void releaseSourceInternal() {
super.releaseSourceInternal();
this.childPeriodCount = 0;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource
public final void onChildSourceInfoRefreshed(Void r1, MediaSource mediaSource, Timeline timeline, @Nullable Object obj) {
Timeline infinitelyLoopingTimeline;
this.childPeriodCount = timeline.getPeriodCount();
if (this.loopCount != Integer.MAX_VALUE) {
infinitelyLoopingTimeline = new LoopingTimeline(timeline, this.loopCount);
} else {
infinitelyLoopingTimeline = new InfinitelyLoopingTimeline(timeline);
}
refreshSourceInfo(infinitelyLoopingTimeline, obj);
}
public static final class LoopingTimeline extends AbstractConcatenatedTimeline {
private final int childPeriodCount;
private final Timeline childTimeline;
private final int childWindowCount;
private final int loopCount;
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final int getFirstPeriodIndexByChildIndex(int i) {
return i * this.childPeriodCount;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final int getFirstWindowIndexByChildIndex(int i) {
return i * this.childWindowCount;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getPeriodCount() {
return this.childPeriodCount * this.loopCount;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final Timeline getTimelineByChildIndex(int i) {
return this.childTimeline;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getWindowCount() {
return this.childWindowCount * this.loopCount;
}
public LoopingTimeline(Timeline timeline, int i) {
super(false, new ShuffleOrder.UnshuffledShuffleOrder(i));
this.childTimeline = timeline;
int periodCount = timeline.getPeriodCount();
this.childPeriodCount = periodCount;
this.childWindowCount = timeline.getWindowCount();
this.loopCount = i;
if (periodCount > 0) {
Assertions.checkState(i <= Integer.MAX_VALUE / periodCount, "LoopingMediaSource contains too many periods");
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final int getChildIndexByPeriodIndex(int i) {
return i / this.childPeriodCount;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final int getChildIndexByWindowIndex(int i) {
return i / this.childWindowCount;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final int getChildIndexByChildUid(Object obj) {
if (obj instanceof Integer) {
return ((Integer) obj).intValue();
}
return -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.AbstractConcatenatedTimeline
public final Object getChildUidByChildIndex(int i) {
return Integer.valueOf(i);
}
}
public static final class InfinitelyLoopingTimeline extends ForwardingTimeline {
public InfinitelyLoopingTimeline(Timeline timeline) {
super(timeline);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ForwardingTimeline, com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getNextWindowIndex(int i, int i2, boolean z) {
int nextWindowIndex = this.timeline.getNextWindowIndex(i, i2, z);
return nextWindowIndex == -1 ? getFirstWindowIndex(z) : nextWindowIndex;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ForwardingTimeline, com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getPreviousWindowIndex(int i, int i2, boolean z) {
int previousWindowIndex = this.timeline.getPreviousWindowIndex(i, i2, z);
return previousWindowIndex == -1 ? getLastWindowIndex(z) : previousWindowIndex;
}
}
}

View File

@@ -0,0 +1,42 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import com.mbridge.msdk.playercommon.exoplayer2.SeekParameters;
import com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader;
import com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection;
import java.io.IOException;
/* loaded from: classes4.dex */
public interface MediaPeriod extends SequenceableLoader {
public interface Callback extends SequenceableLoader.Callback<MediaPeriod> {
void onPrepared(MediaPeriod mediaPeriod);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
boolean continueLoading(long j);
void discardBuffer(long j, boolean z);
long getAdjustedSeekPositionUs(long j, SeekParameters seekParameters);
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
long getBufferedPositionUs();
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
long getNextLoadPositionUs();
TrackGroupArray getTrackGroups();
void maybeThrowPrepareError() throws IOException;
void prepare(Callback callback, long j);
long readDiscontinuity();
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
void reevaluateBuffer(long j);
long seekToUs(long j);
long selectTracks(TrackSelection[] trackSelectionArr, boolean[] zArr, SampleStream[] sampleStreamArr, boolean[] zArr2, long j);
}

View File

@@ -0,0 +1,76 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.os.Handler;
import androidx.annotation.Nullable;
import com.ironsource.mediationsdk.logger.IronSourceError;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import java.io.IOException;
/* loaded from: classes4.dex */
public interface MediaSource {
public interface SourceInfoRefreshListener {
void onSourceInfoRefreshed(MediaSource mediaSource, Timeline timeline, @Nullable Object obj);
}
void addEventListener(Handler handler, MediaSourceEventListener mediaSourceEventListener);
MediaPeriod createPeriod(MediaPeriodId mediaPeriodId, Allocator allocator);
void maybeThrowSourceInfoRefreshError() throws IOException;
void prepareSource(ExoPlayer exoPlayer, boolean z, SourceInfoRefreshListener sourceInfoRefreshListener);
void releasePeriod(MediaPeriod mediaPeriod);
void releaseSource(SourceInfoRefreshListener sourceInfoRefreshListener);
void removeEventListener(MediaSourceEventListener mediaSourceEventListener);
public static final class MediaPeriodId {
public final int adGroupIndex;
public final int adIndexInAdGroup;
public final int periodIndex;
public final long windowSequenceNumber;
public final int hashCode() {
return ((((((IronSourceError.ERROR_NON_EXISTENT_INSTANCE + this.periodIndex) * 31) + this.adGroupIndex) * 31) + this.adIndexInAdGroup) * 31) + ((int) this.windowSequenceNumber);
}
public final boolean isAd() {
return this.adGroupIndex != -1;
}
public MediaPeriodId(int i) {
this(i, -1L);
}
public MediaPeriodId(int i, long j) {
this(i, -1, -1, j);
}
public MediaPeriodId(int i, int i2, int i3, long j) {
this.periodIndex = i;
this.adGroupIndex = i2;
this.adIndexInAdGroup = i3;
this.windowSequenceNumber = j;
}
public final MediaPeriodId copyWithPeriodIndex(int i) {
return this.periodIndex == i ? this : new MediaPeriodId(i, this.adGroupIndex, this.adIndexInAdGroup, this.windowSequenceNumber);
}
public final boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || MediaPeriodId.class != obj.getClass()) {
return false;
}
MediaPeriodId mediaPeriodId = (MediaPeriodId) obj;
return this.periodIndex == mediaPeriodId.periodIndex && this.adGroupIndex == mediaPeriodId.adGroupIndex && this.adIndexInAdGroup == mediaPeriodId.adIndexInAdGroup && this.windowSequenceNumber == mediaPeriodId.windowSequenceNumber;
}
}
}

View File

@@ -0,0 +1,323 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.CheckResult;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.io.IOException;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;
/* loaded from: classes4.dex */
public interface MediaSourceEventListener {
void onDownstreamFormatChanged(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData);
void onLoadCanceled(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData);
void onLoadCompleted(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData);
void onLoadError(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData, IOException iOException, boolean z);
void onLoadStarted(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData);
void onMediaPeriodCreated(int i, MediaSource.MediaPeriodId mediaPeriodId);
void onMediaPeriodReleased(int i, MediaSource.MediaPeriodId mediaPeriodId);
void onReadingStarted(int i, MediaSource.MediaPeriodId mediaPeriodId);
void onUpstreamDiscarded(int i, MediaSource.MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData);
public static final class LoadEventInfo {
public final long bytesLoaded;
public final DataSpec dataSpec;
public final long elapsedRealtimeMs;
public final long loadDurationMs;
public LoadEventInfo(DataSpec dataSpec, long j, long j2, long j3) {
this.dataSpec = dataSpec;
this.elapsedRealtimeMs = j;
this.loadDurationMs = j2;
this.bytesLoaded = j3;
}
}
public static final class MediaLoadData {
public final int dataType;
public final long mediaEndTimeMs;
public final long mediaStartTimeMs;
@Nullable
public final Format trackFormat;
@Nullable
public final Object trackSelectionData;
public final int trackSelectionReason;
public final int trackType;
public MediaLoadData(int i, int i2, @Nullable Format format, int i3, @Nullable Object obj, long j, long j2) {
this.dataType = i;
this.trackType = i2;
this.trackFormat = format;
this.trackSelectionReason = i3;
this.trackSelectionData = obj;
this.mediaStartTimeMs = j;
this.mediaEndTimeMs = j2;
}
}
public static final class EventDispatcher {
private final CopyOnWriteArrayList<ListenerAndHandler> listenerAndHandlers;
@Nullable
public final MediaSource.MediaPeriodId mediaPeriodId;
private final long mediaTimeOffsetMs;
public final int windowIndex;
public EventDispatcher() {
this(new CopyOnWriteArrayList(), 0, null, 0L);
}
private EventDispatcher(CopyOnWriteArrayList<ListenerAndHandler> copyOnWriteArrayList, int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, long j) {
this.listenerAndHandlers = copyOnWriteArrayList;
this.windowIndex = i;
this.mediaPeriodId = mediaPeriodId;
this.mediaTimeOffsetMs = j;
}
@CheckResult
public final EventDispatcher withParameters(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, long j) {
return new EventDispatcher(this.listenerAndHandlers, i, mediaPeriodId, j);
}
public final void addEventListener(Handler handler, MediaSourceEventListener mediaSourceEventListener) {
Assertions.checkArgument((handler == null || mediaSourceEventListener == null) ? false : true);
this.listenerAndHandlers.add(new ListenerAndHandler(handler, mediaSourceEventListener));
}
public final void removeEventListener(MediaSourceEventListener mediaSourceEventListener) {
Iterator<ListenerAndHandler> it = this.listenerAndHandlers.iterator();
while (it.hasNext()) {
ListenerAndHandler next = it.next();
if (next.listener == mediaSourceEventListener) {
this.listenerAndHandlers.remove(next);
}
}
}
public final void mediaPeriodCreated() {
Assertions.checkState(this.mediaPeriodId != null);
Iterator<ListenerAndHandler> it = this.listenerAndHandlers.iterator();
while (it.hasNext()) {
ListenerAndHandler next = it.next();
final MediaSourceEventListener mediaSourceEventListener = next.listener;
postOrRun(next.handler, new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener.EventDispatcher.1
@Override // java.lang.Runnable
public void run() {
MediaSourceEventListener mediaSourceEventListener2 = mediaSourceEventListener;
EventDispatcher eventDispatcher = EventDispatcher.this;
mediaSourceEventListener2.onMediaPeriodCreated(eventDispatcher.windowIndex, eventDispatcher.mediaPeriodId);
}
});
}
}
public final void mediaPeriodReleased() {
Assertions.checkState(this.mediaPeriodId != null);
Iterator<ListenerAndHandler> it = this.listenerAndHandlers.iterator();
while (it.hasNext()) {
ListenerAndHandler next = it.next();
final MediaSourceEventListener mediaSourceEventListener = next.listener;
postOrRun(next.handler, new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener.EventDispatcher.2
@Override // java.lang.Runnable
public void run() {
MediaSourceEventListener mediaSourceEventListener2 = mediaSourceEventListener;
EventDispatcher eventDispatcher = EventDispatcher.this;
mediaSourceEventListener2.onMediaPeriodReleased(eventDispatcher.windowIndex, eventDispatcher.mediaPeriodId);
}
});
}
}
public final void loadStarted(DataSpec dataSpec, int i, long j) {
loadStarted(dataSpec, i, -1, null, 0, null, C.TIME_UNSET, C.TIME_UNSET, j);
}
public final void loadStarted(DataSpec dataSpec, int i, int i2, @Nullable Format format, int i3, @Nullable Object obj, long j, long j2, long j3) {
loadStarted(new LoadEventInfo(dataSpec, j3, 0L, 0L), new MediaLoadData(i, i2, format, i3, obj, adjustMediaTime(j), adjustMediaTime(j2)));
}
public final void loadStarted(final LoadEventInfo loadEventInfo, final MediaLoadData mediaLoadData) {
Iterator<ListenerAndHandler> it = this.listenerAndHandlers.iterator();
while (it.hasNext()) {
ListenerAndHandler next = it.next();
final MediaSourceEventListener mediaSourceEventListener = next.listener;
postOrRun(next.handler, new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener.EventDispatcher.3
@Override // java.lang.Runnable
public void run() {
MediaSourceEventListener mediaSourceEventListener2 = mediaSourceEventListener;
EventDispatcher eventDispatcher = EventDispatcher.this;
mediaSourceEventListener2.onLoadStarted(eventDispatcher.windowIndex, eventDispatcher.mediaPeriodId, loadEventInfo, mediaLoadData);
}
});
}
}
public final void loadCompleted(DataSpec dataSpec, int i, long j, long j2, long j3) {
loadCompleted(dataSpec, i, -1, null, 0, null, C.TIME_UNSET, C.TIME_UNSET, j, j2, j3);
}
public final void loadCompleted(DataSpec dataSpec, int i, int i2, @Nullable Format format, int i3, @Nullable Object obj, long j, long j2, long j3, long j4, long j5) {
loadCompleted(new LoadEventInfo(dataSpec, j3, j4, j5), new MediaLoadData(i, i2, format, i3, obj, adjustMediaTime(j), adjustMediaTime(j2)));
}
public final void loadCompleted(final LoadEventInfo loadEventInfo, final MediaLoadData mediaLoadData) {
Iterator<ListenerAndHandler> it = this.listenerAndHandlers.iterator();
while (it.hasNext()) {
ListenerAndHandler next = it.next();
final MediaSourceEventListener mediaSourceEventListener = next.listener;
postOrRun(next.handler, new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener.EventDispatcher.4
@Override // java.lang.Runnable
public void run() {
MediaSourceEventListener mediaSourceEventListener2 = mediaSourceEventListener;
EventDispatcher eventDispatcher = EventDispatcher.this;
mediaSourceEventListener2.onLoadCompleted(eventDispatcher.windowIndex, eventDispatcher.mediaPeriodId, loadEventInfo, mediaLoadData);
}
});
}
}
public final void loadCanceled(DataSpec dataSpec, int i, long j, long j2, long j3) {
loadCanceled(dataSpec, i, -1, null, 0, null, C.TIME_UNSET, C.TIME_UNSET, j, j2, j3);
}
public final void loadCanceled(DataSpec dataSpec, int i, int i2, @Nullable Format format, int i3, @Nullable Object obj, long j, long j2, long j3, long j4, long j5) {
loadCanceled(new LoadEventInfo(dataSpec, j3, j4, j5), new MediaLoadData(i, i2, format, i3, obj, adjustMediaTime(j), adjustMediaTime(j2)));
}
public final void loadCanceled(final LoadEventInfo loadEventInfo, final MediaLoadData mediaLoadData) {
Iterator<ListenerAndHandler> it = this.listenerAndHandlers.iterator();
while (it.hasNext()) {
ListenerAndHandler next = it.next();
final MediaSourceEventListener mediaSourceEventListener = next.listener;
postOrRun(next.handler, new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener.EventDispatcher.5
@Override // java.lang.Runnable
public void run() {
MediaSourceEventListener mediaSourceEventListener2 = mediaSourceEventListener;
EventDispatcher eventDispatcher = EventDispatcher.this;
mediaSourceEventListener2.onLoadCanceled(eventDispatcher.windowIndex, eventDispatcher.mediaPeriodId, loadEventInfo, mediaLoadData);
}
});
}
}
public final void loadError(DataSpec dataSpec, int i, long j, long j2, long j3, IOException iOException, boolean z) {
loadError(dataSpec, i, -1, null, 0, null, C.TIME_UNSET, C.TIME_UNSET, j, j2, j3, iOException, z);
}
public final void loadError(DataSpec dataSpec, int i, int i2, @Nullable Format format, int i3, @Nullable Object obj, long j, long j2, long j3, long j4, long j5, IOException iOException, boolean z) {
loadError(new LoadEventInfo(dataSpec, j3, j4, j5), new MediaLoadData(i, i2, format, i3, obj, adjustMediaTime(j), adjustMediaTime(j2)), iOException, z);
}
public final void loadError(final LoadEventInfo loadEventInfo, final MediaLoadData mediaLoadData, final IOException iOException, final boolean z) {
Iterator<ListenerAndHandler> it = this.listenerAndHandlers.iterator();
while (it.hasNext()) {
ListenerAndHandler next = it.next();
final MediaSourceEventListener mediaSourceEventListener = next.listener;
postOrRun(next.handler, new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener.EventDispatcher.6
@Override // java.lang.Runnable
public void run() {
MediaSourceEventListener mediaSourceEventListener2 = mediaSourceEventListener;
EventDispatcher eventDispatcher = EventDispatcher.this;
mediaSourceEventListener2.onLoadError(eventDispatcher.windowIndex, eventDispatcher.mediaPeriodId, loadEventInfo, mediaLoadData, iOException, z);
}
});
}
}
public final void readingStarted() {
Assertions.checkState(this.mediaPeriodId != null);
Iterator<ListenerAndHandler> it = this.listenerAndHandlers.iterator();
while (it.hasNext()) {
ListenerAndHandler next = it.next();
final MediaSourceEventListener mediaSourceEventListener = next.listener;
postOrRun(next.handler, new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener.EventDispatcher.7
@Override // java.lang.Runnable
public void run() {
MediaSourceEventListener mediaSourceEventListener2 = mediaSourceEventListener;
EventDispatcher eventDispatcher = EventDispatcher.this;
mediaSourceEventListener2.onReadingStarted(eventDispatcher.windowIndex, eventDispatcher.mediaPeriodId);
}
});
}
}
public final void upstreamDiscarded(int i, long j, long j2) {
upstreamDiscarded(new MediaLoadData(1, i, null, 3, null, adjustMediaTime(j), adjustMediaTime(j2)));
}
public final void upstreamDiscarded(final MediaLoadData mediaLoadData) {
Iterator<ListenerAndHandler> it = this.listenerAndHandlers.iterator();
while (it.hasNext()) {
ListenerAndHandler next = it.next();
final MediaSourceEventListener mediaSourceEventListener = next.listener;
postOrRun(next.handler, new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener.EventDispatcher.8
@Override // java.lang.Runnable
public void run() {
MediaSourceEventListener mediaSourceEventListener2 = mediaSourceEventListener;
EventDispatcher eventDispatcher = EventDispatcher.this;
mediaSourceEventListener2.onUpstreamDiscarded(eventDispatcher.windowIndex, eventDispatcher.mediaPeriodId, mediaLoadData);
}
});
}
}
public final void downstreamFormatChanged(int i, @Nullable Format format, int i2, @Nullable Object obj, long j) {
downstreamFormatChanged(new MediaLoadData(1, i, format, i2, obj, adjustMediaTime(j), C.TIME_UNSET));
}
public final void downstreamFormatChanged(final MediaLoadData mediaLoadData) {
Iterator<ListenerAndHandler> it = this.listenerAndHandlers.iterator();
while (it.hasNext()) {
ListenerAndHandler next = it.next();
final MediaSourceEventListener mediaSourceEventListener = next.listener;
postOrRun(next.handler, new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener.EventDispatcher.9
@Override // java.lang.Runnable
public void run() {
MediaSourceEventListener mediaSourceEventListener2 = mediaSourceEventListener;
EventDispatcher eventDispatcher = EventDispatcher.this;
mediaSourceEventListener2.onDownstreamFormatChanged(eventDispatcher.windowIndex, eventDispatcher.mediaPeriodId, mediaLoadData);
}
});
}
}
private long adjustMediaTime(long j) {
long usToMs = C.usToMs(j);
return usToMs == C.TIME_UNSET ? C.TIME_UNSET : this.mediaTimeOffsetMs + usToMs;
}
private void postOrRun(Handler handler, Runnable runnable) {
if (handler.getLooper() == Looper.myLooper()) {
runnable.run();
} else {
handler.post(runnable);
}
}
public static final class ListenerAndHandler {
public final Handler handler;
public final MediaSourceEventListener listener;
public ListenerAndHandler(Handler handler, MediaSourceEventListener mediaSourceEventListener) {
this.handler = handler;
this.listener = mediaSourceEventListener;
}
}
}
}

View File

@@ -0,0 +1,238 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.SeekParameters;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod;
import com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
/* loaded from: classes4.dex */
final class MergingMediaPeriod implements MediaPeriod, MediaPeriod.Callback {
private MediaPeriod.Callback callback;
private SequenceableLoader compositeSequenceableLoader;
private final CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory;
private MediaPeriod[] enabledPeriods;
public final MediaPeriod[] periods;
private TrackGroupArray trackGroups;
private final ArrayList<MediaPeriod> childrenPendingPreparation = new ArrayList<>();
private final IdentityHashMap<SampleStream, Integer> streamPeriodIndices = new IdentityHashMap<>();
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final TrackGroupArray getTrackGroups() {
return this.trackGroups;
}
public MergingMediaPeriod(CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory, MediaPeriod... mediaPeriodArr) {
this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
this.periods = mediaPeriodArr;
this.compositeSequenceableLoader = compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(new SequenceableLoader[0]);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void prepare(MediaPeriod.Callback callback, long j) {
this.callback = callback;
Collections.addAll(this.childrenPendingPreparation, this.periods);
for (MediaPeriod mediaPeriod : this.periods) {
mediaPeriod.prepare(this, j);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void maybeThrowPrepareError() throws IOException {
for (MediaPeriod mediaPeriod : this.periods) {
mediaPeriod.maybeThrowPrepareError();
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long selectTracks(TrackSelection[] trackSelectionArr, boolean[] zArr, SampleStream[] sampleStreamArr, boolean[] zArr2, long j) {
SampleStream[] sampleStreamArr2 = sampleStreamArr;
int[] iArr = new int[trackSelectionArr.length];
int[] iArr2 = new int[trackSelectionArr.length];
for (int i = 0; i < trackSelectionArr.length; i++) {
SampleStream sampleStream = sampleStreamArr2[i];
iArr[i] = sampleStream == null ? -1 : this.streamPeriodIndices.get(sampleStream).intValue();
iArr2[i] = -1;
TrackSelection trackSelection = trackSelectionArr[i];
if (trackSelection != null) {
TrackGroup trackGroup = trackSelection.getTrackGroup();
int i2 = 0;
while (true) {
MediaPeriod[] mediaPeriodArr = this.periods;
if (i2 >= mediaPeriodArr.length) {
break;
}
if (mediaPeriodArr[i2].getTrackGroups().indexOf(trackGroup) != -1) {
iArr2[i] = i2;
break;
}
i2++;
}
}
}
this.streamPeriodIndices.clear();
int length = trackSelectionArr.length;
SampleStream[] sampleStreamArr3 = new SampleStream[length];
SampleStream[] sampleStreamArr4 = new SampleStream[trackSelectionArr.length];
TrackSelection[] trackSelectionArr2 = new TrackSelection[trackSelectionArr.length];
ArrayList arrayList = new ArrayList(this.periods.length);
long j2 = j;
int i3 = 0;
while (i3 < this.periods.length) {
for (int i4 = 0; i4 < trackSelectionArr.length; i4++) {
TrackSelection trackSelection2 = null;
sampleStreamArr4[i4] = iArr[i4] == i3 ? sampleStreamArr2[i4] : null;
if (iArr2[i4] == i3) {
trackSelection2 = trackSelectionArr[i4];
}
trackSelectionArr2[i4] = trackSelection2;
}
int i5 = i3;
TrackSelection[] trackSelectionArr3 = trackSelectionArr2;
ArrayList arrayList2 = arrayList;
long selectTracks = this.periods[i3].selectTracks(trackSelectionArr2, zArr, sampleStreamArr4, zArr2, j2);
if (i5 == 0) {
j2 = selectTracks;
} else if (selectTracks != j2) {
throw new IllegalStateException("Children enabled at different positions.");
}
boolean z = false;
for (int i6 = 0; i6 < trackSelectionArr.length; i6++) {
if (iArr2[i6] == i5) {
Assertions.checkState(sampleStreamArr4[i6] != null);
sampleStreamArr3[i6] = sampleStreamArr4[i6];
this.streamPeriodIndices.put(sampleStreamArr4[i6], Integer.valueOf(i5));
z = true;
} else if (iArr[i6] == i5) {
Assertions.checkState(sampleStreamArr4[i6] == null);
}
}
if (z) {
arrayList2.add(this.periods[i5]);
}
i3 = i5 + 1;
arrayList = arrayList2;
trackSelectionArr2 = trackSelectionArr3;
sampleStreamArr2 = sampleStreamArr;
}
ArrayList arrayList3 = arrayList;
System.arraycopy(sampleStreamArr3, 0, sampleStreamArr2, 0, length);
MediaPeriod[] mediaPeriodArr2 = new MediaPeriod[arrayList3.size()];
this.enabledPeriods = mediaPeriodArr2;
arrayList3.toArray(mediaPeriodArr2);
this.compositeSequenceableLoader = this.compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(this.enabledPeriods);
return j2;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void discardBuffer(long j, boolean z) {
for (MediaPeriod mediaPeriod : this.enabledPeriods) {
mediaPeriod.discardBuffer(j, z);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final void reevaluateBuffer(long j) {
this.compositeSequenceableLoader.reevaluateBuffer(j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final boolean continueLoading(long j) {
if (!this.childrenPendingPreparation.isEmpty()) {
int size = this.childrenPendingPreparation.size();
for (int i = 0; i < size; i++) {
this.childrenPendingPreparation.get(i).continueLoading(j);
}
return false;
}
return this.compositeSequenceableLoader.continueLoading(j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getNextLoadPositionUs() {
return this.compositeSequenceableLoader.getNextLoadPositionUs();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long readDiscontinuity() {
long readDiscontinuity = this.periods[0].readDiscontinuity();
int i = 1;
while (true) {
MediaPeriod[] mediaPeriodArr = this.periods;
if (i >= mediaPeriodArr.length) {
if (readDiscontinuity != C.TIME_UNSET) {
for (MediaPeriod mediaPeriod : this.enabledPeriods) {
if (mediaPeriod != this.periods[0] && mediaPeriod.seekToUs(readDiscontinuity) != readDiscontinuity) {
throw new IllegalStateException("Unexpected child seekToUs result.");
}
}
}
return readDiscontinuity;
}
if (mediaPeriodArr[i].readDiscontinuity() != C.TIME_UNSET) {
throw new IllegalStateException("Child reported discontinuity.");
}
i++;
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getBufferedPositionUs() {
return this.compositeSequenceableLoader.getBufferedPositionUs();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long seekToUs(long j) {
long seekToUs = this.enabledPeriods[0].seekToUs(j);
int i = 1;
while (true) {
MediaPeriod[] mediaPeriodArr = this.enabledPeriods;
if (i >= mediaPeriodArr.length) {
return seekToUs;
}
if (mediaPeriodArr[i].seekToUs(seekToUs) != seekToUs) {
throw new IllegalStateException("Unexpected child seekToUs result.");
}
i++;
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long getAdjustedSeekPositionUs(long j, SeekParameters seekParameters) {
return this.enabledPeriods[0].getAdjustedSeekPositionUs(j, seekParameters);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod.Callback
public final void onPrepared(MediaPeriod mediaPeriod) {
this.childrenPendingPreparation.remove(mediaPeriod);
if (this.childrenPendingPreparation.isEmpty()) {
int i = 0;
for (MediaPeriod mediaPeriod2 : this.periods) {
i += mediaPeriod2.getTrackGroups().length;
}
TrackGroup[] trackGroupArr = new TrackGroup[i];
int i2 = 0;
for (MediaPeriod mediaPeriod3 : this.periods) {
TrackGroupArray trackGroups = mediaPeriod3.getTrackGroups();
int i3 = trackGroups.length;
int i4 = 0;
while (i4 < i3) {
trackGroupArr[i2] = trackGroups.get(i4);
i4++;
i2++;
}
}
this.trackGroups = new TrackGroupArray(trackGroupArr);
this.callback.onPrepared(this);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader.Callback
public final void onContinueLoadingRequested(MediaPeriod mediaPeriod) {
this.callback.onContinueLoadingRequested(this);
}
}

View File

@@ -0,0 +1,130 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
/* loaded from: classes4.dex */
public final class MergingMediaSource extends CompositeMediaSource<Integer> {
private static final int PERIOD_COUNT_UNSET = -1;
private final CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory;
private final MediaSource[] mediaSources;
private IllegalMergeException mergeError;
private final ArrayList<MediaSource> pendingTimelineSources;
private int periodCount;
private Object primaryManifest;
private Timeline primaryTimeline;
public static final class IllegalMergeException extends IOException {
public static final int REASON_PERIOD_COUNT_MISMATCH = 0;
public final int reason;
@Retention(RetentionPolicy.SOURCE)
public @interface Reason {
}
public IllegalMergeException(int i) {
this.reason = i;
}
}
public MergingMediaSource(MediaSource... mediaSourceArr) {
this(new DefaultCompositeSequenceableLoaderFactory(), mediaSourceArr);
}
public MergingMediaSource(CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory, MediaSource... mediaSourceArr) {
this.mediaSources = mediaSourceArr;
this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
this.pendingTimelineSources = new ArrayList<>(Arrays.asList(mediaSourceArr));
this.periodCount = -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void prepareSourceInternal(ExoPlayer exoPlayer, boolean z) {
super.prepareSourceInternal(exoPlayer, z);
for (int i = 0; i < this.mediaSources.length; i++) {
prepareChildSource(Integer.valueOf(i), this.mediaSources[i]);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void maybeThrowSourceInfoRefreshError() throws IOException {
IllegalMergeException illegalMergeException = this.mergeError;
if (illegalMergeException != null) {
throw illegalMergeException;
}
super.maybeThrowSourceInfoRefreshError();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final MediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator) {
int length = this.mediaSources.length;
MediaPeriod[] mediaPeriodArr = new MediaPeriod[length];
for (int i = 0; i < length; i++) {
mediaPeriodArr[i] = this.mediaSources[i].createPeriod(mediaPeriodId, allocator);
}
return new MergingMediaPeriod(this.compositeSequenceableLoaderFactory, mediaPeriodArr);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void releasePeriod(MediaPeriod mediaPeriod) {
MergingMediaPeriod mergingMediaPeriod = (MergingMediaPeriod) mediaPeriod;
int i = 0;
while (true) {
MediaSource[] mediaSourceArr = this.mediaSources;
if (i >= mediaSourceArr.length) {
return;
}
mediaSourceArr[i].releasePeriod(mergingMediaPeriod.periods[i]);
i++;
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void releaseSourceInternal() {
super.releaseSourceInternal();
this.primaryTimeline = null;
this.primaryManifest = null;
this.periodCount = -1;
this.mergeError = null;
this.pendingTimelineSources.clear();
Collections.addAll(this.pendingTimelineSources, this.mediaSources);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource
public final void onChildSourceInfoRefreshed(Integer num, MediaSource mediaSource, Timeline timeline, @Nullable Object obj) {
if (this.mergeError == null) {
this.mergeError = checkTimelineMerges(timeline);
}
if (this.mergeError != null) {
return;
}
this.pendingTimelineSources.remove(mediaSource);
if (mediaSource == this.mediaSources[0]) {
this.primaryTimeline = timeline;
this.primaryManifest = obj;
}
if (this.pendingTimelineSources.isEmpty()) {
refreshSourceInfo(this.primaryTimeline, this.primaryManifest);
}
}
private IllegalMergeException checkTimelineMerges(Timeline timeline) {
if (this.periodCount == -1) {
this.periodCount = timeline.getPeriodCount();
return null;
}
if (timeline.getPeriodCount() != this.periodCount) {
return new IllegalMergeException(0);
}
return null;
}
}

View File

@@ -0,0 +1,370 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.FormatHolder;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderInputBuffer;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
/* loaded from: classes4.dex */
final class SampleMetadataQueue {
private static final int SAMPLE_CAPACITY_INCREMENT = 1000;
private int absoluteFirstIndex;
private int length;
private int readPosition;
private int relativeFirstIndex;
private Format upstreamFormat;
private int upstreamSourceId;
private int capacity = 1000;
private int[] sourceIds = new int[1000];
private long[] offsets = new long[1000];
private long[] timesUs = new long[1000];
private int[] flags = new int[1000];
private int[] sizes = new int[1000];
private TrackOutput.CryptoData[] cryptoDatas = new TrackOutput.CryptoData[1000];
private Format[] formats = new Format[1000];
private long largestDiscardedTimestampUs = Long.MIN_VALUE;
private long largestQueuedTimestampUs = Long.MIN_VALUE;
private boolean upstreamFormatRequired = true;
private boolean upstreamKeyframeRequired = true;
public static final class SampleExtrasHolder {
public TrackOutput.CryptoData cryptoData;
public long offset;
public int size;
}
private int getRelativeIndex(int i) {
int i2 = this.relativeFirstIndex + i;
int i3 = this.capacity;
return i2 < i3 ? i2 : i2 - i3;
}
public final int getFirstIndex() {
return this.absoluteFirstIndex;
}
public final int getReadIndex() {
return this.absoluteFirstIndex + this.readPosition;
}
public final int getWriteIndex() {
return this.absoluteFirstIndex + this.length;
}
public final void reset(boolean z) {
this.length = 0;
this.absoluteFirstIndex = 0;
this.relativeFirstIndex = 0;
this.readPosition = 0;
this.upstreamKeyframeRequired = true;
this.largestDiscardedTimestampUs = Long.MIN_VALUE;
this.largestQueuedTimestampUs = Long.MIN_VALUE;
if (z) {
this.upstreamFormat = null;
this.upstreamFormatRequired = true;
}
}
public final void sourceId(int i) {
this.upstreamSourceId = i;
}
public final long discardUpstreamSamples(int i) {
int writeIndex = getWriteIndex() - i;
Assertions.checkArgument(writeIndex >= 0 && writeIndex <= this.length - this.readPosition);
int i2 = this.length - writeIndex;
this.length = i2;
this.largestQueuedTimestampUs = Math.max(this.largestDiscardedTimestampUs, getLargestTimestamp(i2));
int i3 = this.length;
if (i3 == 0) {
return 0L;
}
return this.offsets[getRelativeIndex(i3 - 1)] + this.sizes[r6];
}
public final int peekSourceId() {
return hasNextSample() ? this.sourceIds[getRelativeIndex(this.readPosition)] : this.upstreamSourceId;
}
public final synchronized boolean hasNextSample() {
return this.readPosition != this.length;
}
public final synchronized Format getUpstreamFormat() {
return this.upstreamFormatRequired ? null : this.upstreamFormat;
}
public final synchronized long getLargestQueuedTimestampUs() {
return this.largestQueuedTimestampUs;
}
public final synchronized long getFirstTimestampUs() {
return this.length == 0 ? Long.MIN_VALUE : this.timesUs[this.relativeFirstIndex];
}
public final synchronized void rewind() {
this.readPosition = 0;
}
public final synchronized int read(FormatHolder formatHolder, DecoderInputBuffer decoderInputBuffer, boolean z, boolean z2, Format format, SampleExtrasHolder sampleExtrasHolder) {
if (!hasNextSample()) {
if (z2) {
decoderInputBuffer.setFlags(4);
return -4;
}
Format format2 = this.upstreamFormat;
if (format2 == null || (!z && format2 == format)) {
return -3;
}
formatHolder.format = format2;
return -5;
}
int relativeIndex = getRelativeIndex(this.readPosition);
if (!z && this.formats[relativeIndex] == format) {
if (decoderInputBuffer.isFlagsOnly()) {
return -3;
}
decoderInputBuffer.timeUs = this.timesUs[relativeIndex];
decoderInputBuffer.setFlags(this.flags[relativeIndex]);
sampleExtrasHolder.size = this.sizes[relativeIndex];
sampleExtrasHolder.offset = this.offsets[relativeIndex];
sampleExtrasHolder.cryptoData = this.cryptoDatas[relativeIndex];
this.readPosition++;
return -4;
}
formatHolder.format = this.formats[relativeIndex];
return -5;
}
public final synchronized int advanceTo(long j, boolean z, boolean z2) {
int relativeIndex = getRelativeIndex(this.readPosition);
if (hasNextSample() && j >= this.timesUs[relativeIndex] && (j <= this.largestQueuedTimestampUs || z2)) {
int findSampleBefore = findSampleBefore(relativeIndex, this.length - this.readPosition, j, z);
if (findSampleBefore == -1) {
return -1;
}
this.readPosition += findSampleBefore;
return findSampleBefore;
}
return -1;
}
public final synchronized int advanceToEnd() {
int i;
int i2 = this.length;
i = i2 - this.readPosition;
this.readPosition = i2;
return i;
}
public final synchronized boolean setReadPosition(int i) {
int i2 = this.absoluteFirstIndex;
if (i2 > i || i > this.length + i2) {
return false;
}
this.readPosition = i - i2;
return true;
}
public final synchronized long discardTo(long j, boolean z, boolean z2) {
int i;
try {
int i2 = this.length;
if (i2 != 0) {
long[] jArr = this.timesUs;
int i3 = this.relativeFirstIndex;
if (j >= jArr[i3]) {
if (z2 && (i = this.readPosition) != i2) {
i2 = i + 1;
}
int findSampleBefore = findSampleBefore(i3, i2, j, z);
if (findSampleBefore == -1) {
return -1L;
}
return discardSamples(findSampleBefore);
}
}
return -1L;
} finally {
}
}
public final synchronized long discardToRead() {
int i = this.readPosition;
if (i == 0) {
return -1L;
}
return discardSamples(i);
}
public final synchronized long discardToEnd() {
int i = this.length;
if (i == 0) {
return -1L;
}
return discardSamples(i);
}
public final synchronized boolean format(Format format) {
if (format == null) {
this.upstreamFormatRequired = true;
return false;
}
this.upstreamFormatRequired = false;
if (Util.areEqual(format, this.upstreamFormat)) {
return false;
}
this.upstreamFormat = format;
return true;
}
public final synchronized void commitSample(long j, int i, long j2, int i2, TrackOutput.CryptoData cryptoData) {
try {
if (this.upstreamKeyframeRequired) {
if ((i & 1) == 0) {
return;
} else {
this.upstreamKeyframeRequired = false;
}
}
Assertions.checkState(!this.upstreamFormatRequired);
commitSampleTimestamp(j);
int relativeIndex = getRelativeIndex(this.length);
this.timesUs[relativeIndex] = j;
long[] jArr = this.offsets;
jArr[relativeIndex] = j2;
this.sizes[relativeIndex] = i2;
this.flags[relativeIndex] = i;
this.cryptoDatas[relativeIndex] = cryptoData;
this.formats[relativeIndex] = this.upstreamFormat;
this.sourceIds[relativeIndex] = this.upstreamSourceId;
int i3 = this.length + 1;
this.length = i3;
int i4 = this.capacity;
if (i3 == i4) {
int i5 = i4 + 1000;
int[] iArr = new int[i5];
long[] jArr2 = new long[i5];
long[] jArr3 = new long[i5];
int[] iArr2 = new int[i5];
int[] iArr3 = new int[i5];
TrackOutput.CryptoData[] cryptoDataArr = new TrackOutput.CryptoData[i5];
Format[] formatArr = new Format[i5];
int i6 = this.relativeFirstIndex;
int i7 = i4 - i6;
System.arraycopy(jArr, i6, jArr2, 0, i7);
System.arraycopy(this.timesUs, this.relativeFirstIndex, jArr3, 0, i7);
System.arraycopy(this.flags, this.relativeFirstIndex, iArr2, 0, i7);
System.arraycopy(this.sizes, this.relativeFirstIndex, iArr3, 0, i7);
System.arraycopy(this.cryptoDatas, this.relativeFirstIndex, cryptoDataArr, 0, i7);
System.arraycopy(this.formats, this.relativeFirstIndex, formatArr, 0, i7);
System.arraycopy(this.sourceIds, this.relativeFirstIndex, iArr, 0, i7);
int i8 = this.relativeFirstIndex;
System.arraycopy(this.offsets, 0, jArr2, i7, i8);
System.arraycopy(this.timesUs, 0, jArr3, i7, i8);
System.arraycopy(this.flags, 0, iArr2, i7, i8);
System.arraycopy(this.sizes, 0, iArr3, i7, i8);
System.arraycopy(this.cryptoDatas, 0, cryptoDataArr, i7, i8);
System.arraycopy(this.formats, 0, formatArr, i7, i8);
System.arraycopy(this.sourceIds, 0, iArr, i7, i8);
this.offsets = jArr2;
this.timesUs = jArr3;
this.flags = iArr2;
this.sizes = iArr3;
this.cryptoDatas = cryptoDataArr;
this.formats = formatArr;
this.sourceIds = iArr;
this.relativeFirstIndex = 0;
this.length = this.capacity;
this.capacity = i5;
}
} catch (Throwable th) {
throw th;
}
}
public final synchronized void commitSampleTimestamp(long j) {
this.largestQueuedTimestampUs = Math.max(this.largestQueuedTimestampUs, j);
}
public final synchronized boolean attemptSplice(long j) {
if (this.length == 0) {
return j > this.largestDiscardedTimestampUs;
}
if (Math.max(this.largestDiscardedTimestampUs, getLargestTimestamp(this.readPosition)) >= j) {
return false;
}
int i = this.length;
int relativeIndex = getRelativeIndex(i - 1);
while (i > this.readPosition && this.timesUs[relativeIndex] >= j) {
i--;
relativeIndex--;
if (relativeIndex == -1) {
relativeIndex = this.capacity - 1;
}
}
discardUpstreamSamples(this.absoluteFirstIndex + i);
return true;
}
private int findSampleBefore(int i, int i2, long j, boolean z) {
int i3 = -1;
for (int i4 = 0; i4 < i2 && this.timesUs[i] <= j; i4++) {
if (!z || (this.flags[i] & 1) != 0) {
i3 = i4;
}
i++;
if (i == this.capacity) {
i = 0;
}
}
return i3;
}
private long discardSamples(int i) {
this.largestDiscardedTimestampUs = Math.max(this.largestDiscardedTimestampUs, getLargestTimestamp(i));
int i2 = this.length - i;
this.length = i2;
this.absoluteFirstIndex += i;
int i3 = this.relativeFirstIndex + i;
this.relativeFirstIndex = i3;
int i4 = this.capacity;
if (i3 >= i4) {
this.relativeFirstIndex = i3 - i4;
}
int i5 = this.readPosition - i;
this.readPosition = i5;
if (i5 < 0) {
this.readPosition = 0;
}
if (i2 == 0) {
int i6 = this.relativeFirstIndex;
if (i6 != 0) {
i4 = i6;
}
return this.offsets[i4 - 1] + this.sizes[r2];
}
return this.offsets[this.relativeFirstIndex];
}
private long getLargestTimestamp(int i) {
long j = Long.MIN_VALUE;
if (i == 0) {
return Long.MIN_VALUE;
}
int relativeIndex = getRelativeIndex(i - 1);
for (int i2 = 0; i2 < i; i2++) {
j = Math.max(j, this.timesUs[relativeIndex]);
if ((this.flags[relativeIndex] & 1) != 0) {
break;
}
relativeIndex--;
if (relativeIndex == -1) {
relativeIndex = this.capacity - 1;
}
}
return j;
}
}

View File

@@ -0,0 +1,453 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.FormatHolder;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.CryptoInfo;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderInputBuffer;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorInput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput;
import com.mbridge.msdk.playercommon.exoplayer2.source.SampleMetadataQueue;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocation;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import com.mbridge.msdk.playercommon.exoplayer2.util.ParsableByteArray;
import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
import kotlin.jvm.internal.ByteCompanionObject;
/* loaded from: classes4.dex */
public final class SampleQueue implements TrackOutput {
public static final int ADVANCE_FAILED = -1;
private static final int INITIAL_SCRATCH_SIZE = 32;
private final int allocationLength;
private final Allocator allocator;
private Format downstreamFormat;
private final SampleMetadataQueue.SampleExtrasHolder extrasHolder;
private AllocationNode firstAllocationNode;
private Format lastUnadjustedFormat;
private final SampleMetadataQueue metadataQueue;
private boolean pendingFormatAdjustment;
private boolean pendingSplice;
private AllocationNode readAllocationNode;
private long sampleOffsetUs;
private final ParsableByteArray scratch;
private long totalBytesWritten;
private UpstreamFormatChangedListener upstreamFormatChangeListener;
private AllocationNode writeAllocationNode;
public interface UpstreamFormatChangedListener {
void onUpstreamFormatChanged(Format format);
}
public final void setSampleOffsetUs(long j) {
if (this.sampleOffsetUs != j) {
this.sampleOffsetUs = j;
this.pendingFormatAdjustment = true;
}
}
public final void setUpstreamFormatChangeListener(UpstreamFormatChangedListener upstreamFormatChangedListener) {
this.upstreamFormatChangeListener = upstreamFormatChangedListener;
}
public final void splice() {
this.pendingSplice = true;
}
public SampleQueue(Allocator allocator) {
this.allocator = allocator;
int individualAllocationLength = allocator.getIndividualAllocationLength();
this.allocationLength = individualAllocationLength;
this.metadataQueue = new SampleMetadataQueue();
this.extrasHolder = new SampleMetadataQueue.SampleExtrasHolder();
this.scratch = new ParsableByteArray(32);
AllocationNode allocationNode = new AllocationNode(0L, individualAllocationLength);
this.firstAllocationNode = allocationNode;
this.readAllocationNode = allocationNode;
this.writeAllocationNode = allocationNode;
}
public final void reset() {
reset(false);
}
public final void reset(boolean z) {
this.metadataQueue.reset(z);
clearAllocationNodes(this.firstAllocationNode);
AllocationNode allocationNode = new AllocationNode(0L, this.allocationLength);
this.firstAllocationNode = allocationNode;
this.readAllocationNode = allocationNode;
this.writeAllocationNode = allocationNode;
this.totalBytesWritten = 0L;
this.allocator.trim();
}
public final void sourceId(int i) {
this.metadataQueue.sourceId(i);
}
public final int getWriteIndex() {
return this.metadataQueue.getWriteIndex();
}
public final void discardUpstreamSamples(int i) {
long discardUpstreamSamples = this.metadataQueue.discardUpstreamSamples(i);
this.totalBytesWritten = discardUpstreamSamples;
if (discardUpstreamSamples != 0) {
AllocationNode allocationNode = this.firstAllocationNode;
if (discardUpstreamSamples != allocationNode.startPosition) {
while (this.totalBytesWritten > allocationNode.endPosition) {
allocationNode = allocationNode.next;
}
AllocationNode allocationNode2 = allocationNode.next;
clearAllocationNodes(allocationNode2);
AllocationNode allocationNode3 = new AllocationNode(allocationNode.endPosition, this.allocationLength);
allocationNode.next = allocationNode3;
if (this.totalBytesWritten == allocationNode.endPosition) {
allocationNode = allocationNode3;
}
this.writeAllocationNode = allocationNode;
if (this.readAllocationNode == allocationNode2) {
this.readAllocationNode = allocationNode3;
return;
}
return;
}
}
clearAllocationNodes(this.firstAllocationNode);
AllocationNode allocationNode4 = new AllocationNode(this.totalBytesWritten, this.allocationLength);
this.firstAllocationNode = allocationNode4;
this.readAllocationNode = allocationNode4;
this.writeAllocationNode = allocationNode4;
}
public final boolean hasNextSample() {
return this.metadataQueue.hasNextSample();
}
public final int getFirstIndex() {
return this.metadataQueue.getFirstIndex();
}
public final int getReadIndex() {
return this.metadataQueue.getReadIndex();
}
public final int peekSourceId() {
return this.metadataQueue.peekSourceId();
}
public final Format getUpstreamFormat() {
return this.metadataQueue.getUpstreamFormat();
}
public final long getLargestQueuedTimestampUs() {
return this.metadataQueue.getLargestQueuedTimestampUs();
}
public final long getFirstTimestampUs() {
return this.metadataQueue.getFirstTimestampUs();
}
public final void rewind() {
this.metadataQueue.rewind();
this.readAllocationNode = this.firstAllocationNode;
}
public final void discardTo(long j, boolean z, boolean z2) {
discardDownstreamTo(this.metadataQueue.discardTo(j, z, z2));
}
public final void discardToRead() {
discardDownstreamTo(this.metadataQueue.discardToRead());
}
public final void discardToEnd() {
discardDownstreamTo(this.metadataQueue.discardToEnd());
}
public final int advanceToEnd() {
return this.metadataQueue.advanceToEnd();
}
public final int advanceTo(long j, boolean z, boolean z2) {
return this.metadataQueue.advanceTo(j, z, z2);
}
public final boolean setReadPosition(int i) {
return this.metadataQueue.setReadPosition(i);
}
public final int read(FormatHolder formatHolder, DecoderInputBuffer decoderInputBuffer, boolean z, boolean z2, long j) {
int read = this.metadataQueue.read(formatHolder, decoderInputBuffer, z, z2, this.downstreamFormat, this.extrasHolder);
if (read == -5) {
this.downstreamFormat = formatHolder.format;
return -5;
}
if (read != -4) {
if (read == -3) {
return -3;
}
throw new IllegalStateException();
}
if (!decoderInputBuffer.isEndOfStream()) {
if (decoderInputBuffer.timeUs < j) {
decoderInputBuffer.addFlag(Integer.MIN_VALUE);
}
if (decoderInputBuffer.isEncrypted()) {
readEncryptionData(decoderInputBuffer, this.extrasHolder);
}
decoderInputBuffer.ensureSpaceForWrite(this.extrasHolder.size);
SampleMetadataQueue.SampleExtrasHolder sampleExtrasHolder = this.extrasHolder;
readData(sampleExtrasHolder.offset, decoderInputBuffer.data, sampleExtrasHolder.size);
}
return -4;
}
private void readEncryptionData(DecoderInputBuffer decoderInputBuffer, SampleMetadataQueue.SampleExtrasHolder sampleExtrasHolder) {
long j = sampleExtrasHolder.offset;
int i = 1;
this.scratch.reset(1);
readData(j, this.scratch.data, 1);
long j2 = j + 1;
byte b = this.scratch.data[0];
boolean z = (b & ByteCompanionObject.MIN_VALUE) != 0;
int i2 = b & Byte.MAX_VALUE;
CryptoInfo cryptoInfo = decoderInputBuffer.cryptoInfo;
if (cryptoInfo.iv == null) {
cryptoInfo.iv = new byte[16];
}
readData(j2, cryptoInfo.iv, i2);
long j3 = j2 + i2;
if (z) {
this.scratch.reset(2);
readData(j3, this.scratch.data, 2);
j3 += 2;
i = this.scratch.readUnsignedShort();
}
int i3 = i;
CryptoInfo cryptoInfo2 = decoderInputBuffer.cryptoInfo;
int[] iArr = cryptoInfo2.numBytesOfClearData;
if (iArr == null || iArr.length < i3) {
iArr = new int[i3];
}
int[] iArr2 = iArr;
int[] iArr3 = cryptoInfo2.numBytesOfEncryptedData;
if (iArr3 == null || iArr3.length < i3) {
iArr3 = new int[i3];
}
int[] iArr4 = iArr3;
if (z) {
int i4 = i3 * 6;
this.scratch.reset(i4);
readData(j3, this.scratch.data, i4);
j3 += i4;
this.scratch.setPosition(0);
for (int i5 = 0; i5 < i3; i5++) {
iArr2[i5] = this.scratch.readUnsignedShort();
iArr4[i5] = this.scratch.readUnsignedIntToInt();
}
} else {
iArr2[0] = 0;
iArr4[0] = sampleExtrasHolder.size - ((int) (j3 - sampleExtrasHolder.offset));
}
TrackOutput.CryptoData cryptoData = sampleExtrasHolder.cryptoData;
CryptoInfo cryptoInfo3 = decoderInputBuffer.cryptoInfo;
cryptoInfo3.set(i3, iArr2, iArr4, cryptoData.encryptionKey, cryptoInfo3.iv, cryptoData.cryptoMode, cryptoData.encryptedBlocks, cryptoData.clearBlocks);
long j4 = sampleExtrasHolder.offset;
int i6 = (int) (j3 - j4);
sampleExtrasHolder.offset = j4 + i6;
sampleExtrasHolder.size -= i6;
}
private void readData(long j, ByteBuffer byteBuffer, int i) {
advanceReadTo(j);
while (i > 0) {
int min = Math.min(i, (int) (this.readAllocationNode.endPosition - j));
AllocationNode allocationNode = this.readAllocationNode;
byteBuffer.put(allocationNode.allocation.data, allocationNode.translateOffset(j), min);
i -= min;
j += min;
AllocationNode allocationNode2 = this.readAllocationNode;
if (j == allocationNode2.endPosition) {
this.readAllocationNode = allocationNode2.next;
}
}
}
private void readData(long j, byte[] bArr, int i) {
advanceReadTo(j);
int i2 = i;
while (i2 > 0) {
int min = Math.min(i2, (int) (this.readAllocationNode.endPosition - j));
AllocationNode allocationNode = this.readAllocationNode;
System.arraycopy(allocationNode.allocation.data, allocationNode.translateOffset(j), bArr, i - i2, min);
i2 -= min;
j += min;
AllocationNode allocationNode2 = this.readAllocationNode;
if (j == allocationNode2.endPosition) {
this.readAllocationNode = allocationNode2.next;
}
}
}
private void advanceReadTo(long j) {
while (true) {
AllocationNode allocationNode = this.readAllocationNode;
if (j < allocationNode.endPosition) {
return;
} else {
this.readAllocationNode = allocationNode.next;
}
}
}
private void discardDownstreamTo(long j) {
AllocationNode allocationNode;
if (j == -1) {
return;
}
while (true) {
allocationNode = this.firstAllocationNode;
if (j < allocationNode.endPosition) {
break;
}
this.allocator.release(allocationNode.allocation);
this.firstAllocationNode = this.firstAllocationNode.clear();
}
if (this.readAllocationNode.startPosition < allocationNode.startPosition) {
this.readAllocationNode = allocationNode;
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput
public final void format(Format format) {
Format adjustedSampleFormat = getAdjustedSampleFormat(format, this.sampleOffsetUs);
boolean format2 = this.metadataQueue.format(adjustedSampleFormat);
this.lastUnadjustedFormat = format;
this.pendingFormatAdjustment = false;
UpstreamFormatChangedListener upstreamFormatChangedListener = this.upstreamFormatChangeListener;
if (upstreamFormatChangedListener == null || !format2) {
return;
}
upstreamFormatChangedListener.onUpstreamFormatChanged(adjustedSampleFormat);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput
public final int sampleData(ExtractorInput extractorInput, int i, boolean z) throws IOException, InterruptedException {
int preAppend = preAppend(i);
AllocationNode allocationNode = this.writeAllocationNode;
int read = extractorInput.read(allocationNode.allocation.data, allocationNode.translateOffset(this.totalBytesWritten), preAppend);
if (read != -1) {
postAppend(read);
return read;
}
if (z) {
return -1;
}
throw new EOFException();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput
public final void sampleData(ParsableByteArray parsableByteArray, int i) {
while (i > 0) {
int preAppend = preAppend(i);
AllocationNode allocationNode = this.writeAllocationNode;
parsableByteArray.readBytes(allocationNode.allocation.data, allocationNode.translateOffset(this.totalBytesWritten), preAppend);
i -= preAppend;
postAppend(preAppend);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput
public final void sampleMetadata(long j, int i, int i2, int i3, TrackOutput.CryptoData cryptoData) {
if (this.pendingFormatAdjustment) {
format(this.lastUnadjustedFormat);
}
if (this.pendingSplice) {
if ((i & 1) == 0 || !this.metadataQueue.attemptSplice(j)) {
return;
} else {
this.pendingSplice = false;
}
}
this.metadataQueue.commitSample(j + this.sampleOffsetUs, i, (this.totalBytesWritten - i2) - i3, i2, cryptoData);
}
private void clearAllocationNodes(AllocationNode allocationNode) {
if (allocationNode.wasInitialized) {
AllocationNode allocationNode2 = this.writeAllocationNode;
boolean z = allocationNode2.wasInitialized;
int i = (z ? 1 : 0) + (((int) (allocationNode2.startPosition - allocationNode.startPosition)) / this.allocationLength);
Allocation[] allocationArr = new Allocation[i];
for (int i2 = 0; i2 < i; i2++) {
allocationArr[i2] = allocationNode.allocation;
allocationNode = allocationNode.clear();
}
this.allocator.release(allocationArr);
}
}
private int preAppend(int i) {
AllocationNode allocationNode = this.writeAllocationNode;
if (!allocationNode.wasInitialized) {
allocationNode.initialize(this.allocator.allocate(), new AllocationNode(this.writeAllocationNode.endPosition, this.allocationLength));
}
return Math.min(i, (int) (this.writeAllocationNode.endPosition - this.totalBytesWritten));
}
private void postAppend(int i) {
long j = this.totalBytesWritten + i;
this.totalBytesWritten = j;
AllocationNode allocationNode = this.writeAllocationNode;
if (j == allocationNode.endPosition) {
this.writeAllocationNode = allocationNode.next;
}
}
private static Format getAdjustedSampleFormat(Format format, long j) {
if (format == null) {
return null;
}
if (j == 0) {
return format;
}
long j2 = format.subsampleOffsetUs;
return j2 != Long.MAX_VALUE ? format.copyWithSubsampleOffsetUs(j2 + j) : format;
}
public static final class AllocationNode {
@Nullable
public Allocation allocation;
public final long endPosition;
@Nullable
public AllocationNode next;
public final long startPosition;
public boolean wasInitialized;
public final AllocationNode clear() {
this.allocation = null;
AllocationNode allocationNode = this.next;
this.next = null;
return allocationNode;
}
public final void initialize(Allocation allocation, AllocationNode allocationNode) {
this.allocation = allocation;
this.next = allocationNode;
this.wasInitialized = true;
}
public AllocationNode(long j, int i) {
this.startPosition = j;
this.endPosition = j + i;
}
public final int translateOffset(long j) {
return ((int) (j - this.startPosition)) + this.allocation.offset;
}
}
}

View File

@@ -0,0 +1,16 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import com.mbridge.msdk.playercommon.exoplayer2.FormatHolder;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderInputBuffer;
import java.io.IOException;
/* loaded from: classes4.dex */
public interface SampleStream {
boolean isReady();
void maybeThrowError() throws IOException;
int readData(FormatHolder formatHolder, DecoderInputBuffer decoderInputBuffer, boolean z);
int skipData(long j);
}

View File

@@ -0,0 +1,17 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
/* loaded from: classes4.dex */
public interface SequenceableLoader {
public interface Callback<T extends SequenceableLoader> {
void onContinueLoadingRequested(T t);
}
boolean continueLoading(long j);
long getBufferedPositionUs();
long getNextLoadPositionUs();
void reevaluateBuffer(long j);
}

View File

@@ -0,0 +1,235 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import java.util.Arrays;
import java.util.Random;
/* loaded from: classes4.dex */
public interface ShuffleOrder {
ShuffleOrder cloneAndClear();
ShuffleOrder cloneAndInsert(int i, int i2);
ShuffleOrder cloneAndRemove(int i);
int getFirstIndex();
int getLastIndex();
int getLength();
int getNextIndex(int i);
int getPreviousIndex(int i);
public static class DefaultShuffleOrder implements ShuffleOrder {
private final int[] indexInShuffled;
private final Random random;
private final int[] shuffled;
public DefaultShuffleOrder(int i) {
this(i, new Random());
}
public DefaultShuffleOrder(int i, long j) {
this(i, new Random(j));
}
private DefaultShuffleOrder(int i, Random random) {
this(createShuffledList(i, random), random);
}
private DefaultShuffleOrder(int[] iArr, Random random) {
this.shuffled = iArr;
this.random = random;
this.indexInShuffled = new int[iArr.length];
for (int i = 0; i < iArr.length; i++) {
this.indexInShuffled[iArr[i]] = i;
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public int getLength() {
return this.shuffled.length;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public int getNextIndex(int i) {
int i2 = this.indexInShuffled[i] + 1;
int[] iArr = this.shuffled;
if (i2 < iArr.length) {
return iArr[i2];
}
return -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public int getPreviousIndex(int i) {
int i2 = this.indexInShuffled[i] - 1;
if (i2 >= 0) {
return this.shuffled[i2];
}
return -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public int getLastIndex() {
int[] iArr = this.shuffled;
if (iArr.length > 0) {
return iArr[iArr.length - 1];
}
return -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public int getFirstIndex() {
int[] iArr = this.shuffled;
if (iArr.length > 0) {
return iArr[0];
}
return -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public ShuffleOrder cloneAndInsert(int i, int i2) {
int[] iArr = new int[i2];
int[] iArr2 = new int[i2];
int i3 = 0;
int i4 = 0;
while (i4 < i2) {
iArr[i4] = this.random.nextInt(this.shuffled.length + 1);
int i5 = i4 + 1;
int nextInt = this.random.nextInt(i5);
iArr2[i4] = iArr2[nextInt];
iArr2[nextInt] = i4 + i;
i4 = i5;
}
Arrays.sort(iArr);
int[] iArr3 = new int[this.shuffled.length + i2];
int i6 = 0;
int i7 = 0;
while (true) {
int[] iArr4 = this.shuffled;
if (i3 < iArr4.length + i2) {
if (i6 < i2 && i7 == iArr[i6]) {
iArr3[i3] = iArr2[i6];
i6++;
} else {
int i8 = i7 + 1;
int i9 = iArr4[i7];
iArr3[i3] = i9;
if (i9 >= i) {
iArr3[i3] = i9 + i2;
}
i7 = i8;
}
i3++;
} else {
return new DefaultShuffleOrder(iArr3, new Random(this.random.nextLong()));
}
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public ShuffleOrder cloneAndRemove(int i) {
int[] iArr = new int[this.shuffled.length - 1];
int i2 = 0;
boolean z = false;
while (true) {
int[] iArr2 = this.shuffled;
if (i2 < iArr2.length) {
int i3 = iArr2[i2];
if (i3 == i) {
z = true;
} else {
int i4 = z ? i2 - 1 : i2;
if (i3 > i) {
i3--;
}
iArr[i4] = i3;
}
i2++;
} else {
return new DefaultShuffleOrder(iArr, new Random(this.random.nextLong()));
}
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public ShuffleOrder cloneAndClear() {
return new DefaultShuffleOrder(0, new Random(this.random.nextLong()));
}
private static int[] createShuffledList(int i, Random random) {
int[] iArr = new int[i];
int i2 = 0;
while (i2 < i) {
int i3 = i2 + 1;
int nextInt = random.nextInt(i3);
iArr[i2] = iArr[nextInt];
iArr[nextInt] = i2;
i2 = i3;
}
return iArr;
}
}
public static final class UnshuffledShuffleOrder implements ShuffleOrder {
private final int length;
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public final int getFirstIndex() {
return this.length > 0 ? 0 : -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public final int getLastIndex() {
int i = this.length;
if (i > 0) {
return i - 1;
}
return -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public final int getLength() {
return this.length;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public final int getNextIndex(int i) {
int i2 = i + 1;
if (i2 < this.length) {
return i2;
}
return -1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public final int getPreviousIndex(int i) {
int i2 = i - 1;
if (i2 >= 0) {
return i2;
}
return -1;
}
public UnshuffledShuffleOrder(int i) {
this.length = i;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public final ShuffleOrder cloneAndInsert(int i, int i2) {
return new UnshuffledShuffleOrder(this.length + i2);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public final ShuffleOrder cloneAndRemove(int i) {
return new UnshuffledShuffleOrder(this.length - 1);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ShuffleOrder
public final ShuffleOrder cloneAndClear() {
return new UnshuffledShuffleOrder(0);
}
}
}

View File

@@ -0,0 +1,129 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
/* loaded from: classes4.dex */
public final class SinglePeriodTimeline extends Timeline {
private static final Object UID = new Object();
private final boolean isDynamic;
private final boolean isSeekable;
private final long periodDurationUs;
private final long presentationStartTimeMs;
@Nullable
private final Object tag;
private final long windowDefaultStartPositionUs;
private final long windowDurationUs;
private final long windowPositionInPeriodUs;
private final long windowStartTimeMs;
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getPeriodCount() {
return 1;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getWindowCount() {
return 1;
}
public SinglePeriodTimeline(long j, boolean z, boolean z2) {
this(j, z, z2, null);
}
public SinglePeriodTimeline(long j, boolean z, boolean z2, @Nullable Object obj) {
this(j, j, 0L, 0L, z, z2, obj);
}
public SinglePeriodTimeline(long j, long j2, long j3, long j4, boolean z, boolean z2, @Nullable Object obj) {
this(C.TIME_UNSET, C.TIME_UNSET, j, j2, j3, j4, z, z2, obj);
}
public SinglePeriodTimeline(long j, long j2, long j3, long j4, long j5, long j6, boolean z, boolean z2, @Nullable Object obj) {
this.presentationStartTimeMs = j;
this.windowStartTimeMs = j2;
this.periodDurationUs = j3;
this.windowDurationUs = j4;
this.windowPositionInPeriodUs = j5;
this.windowDefaultStartPositionUs = j6;
this.isSeekable = z;
this.isDynamic = z2;
this.tag = obj;
}
/* JADX WARN: Code restructure failed: missing block: B:16:0x002e, code lost:
if (r1 > r4) goto L13;
*/
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final com.mbridge.msdk.playercommon.exoplayer2.Timeline.Window getWindow(int r19, com.mbridge.msdk.playercommon.exoplayer2.Timeline.Window r20, boolean r21, long r22) {
/*
r18 = this;
r0 = r18
r1 = 0
r2 = 1
r3 = r19
com.mbridge.msdk.playercommon.exoplayer2.util.Assertions.checkIndex(r3, r1, r2)
if (r21 == 0) goto Lf
java.lang.Object r1 = r0.tag
Ld:
r3 = r1
goto L11
Lf:
r1 = 0
goto Ld
L11:
long r1 = r0.windowDefaultStartPositionUs
boolean r9 = r0.isDynamic
if (r9 == 0) goto L31
r4 = 0
int r4 = (r22 > r4 ? 1 : (r22 == r4 ? 0 : -1))
if (r4 == 0) goto L31
long r4 = r0.windowDurationUs
r6 = -9223372036854775807(0x8000000000000001, double:-4.9E-324)
int r8 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1))
if (r8 != 0) goto L2a
L28:
r10 = r6
goto L32
L2a:
long r1 = r1 + r22
int r4 = (r1 > r4 ? 1 : (r1 == r4 ? 0 : -1))
if (r4 <= 0) goto L31
goto L28
L31:
r10 = r1
L32:
long r4 = r0.presentationStartTimeMs
long r6 = r0.windowStartTimeMs
boolean r8 = r0.isSeekable
long r12 = r0.windowDurationUs
r14 = 0
r15 = 0
long r1 = r0.windowPositionInPeriodUs
r16 = r1
r2 = r20
com.mbridge.msdk.playercommon.exoplayer2.Timeline$Window r1 = r2.set(r3, r4, r6, r8, r9, r10, r12, r14, r15, r16)
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.source.SinglePeriodTimeline.getWindow(int, com.mbridge.msdk.playercommon.exoplayer2.Timeline$Window, boolean, long):com.mbridge.msdk.playercommon.exoplayer2.Timeline$Window");
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final Timeline.Period getPeriod(int i, Timeline.Period period, boolean z) {
Assertions.checkIndex(i, 0, 1);
return period.set(null, z ? UID : null, 0, this.periodDurationUs, -this.windowPositionInPeriodUs);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final int getIndexOfPeriod(Object obj) {
return UID.equals(obj) ? 0 : -1;
}
}

View File

@@ -0,0 +1,289 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.FormatHolder;
import com.mbridge.msdk.playercommon.exoplayer2.SeekParameters;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderInputBuffer;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener;
import com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader;
import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
/* loaded from: classes4.dex */
final class SingleSampleMediaPeriod implements MediaPeriod, Loader.Callback<SourceLoadable> {
private static final int INITIAL_SAMPLE_SIZE = 1024;
private final DataSource.Factory dataSourceFactory;
private final DataSpec dataSpec;
private final long durationUs;
private int errorCount;
private final MediaSourceEventListener.EventDispatcher eventDispatcher;
final Format format;
boolean loadingFinished;
boolean loadingSucceeded;
private final int minLoadableRetryCount;
boolean notifiedReadingStarted;
byte[] sampleData;
int sampleSize;
private final TrackGroupArray tracks;
final boolean treatLoadErrorsAsEndOfStream;
private final ArrayList<SampleStreamImpl> sampleStreams = new ArrayList<>();
final Loader loader = new Loader("Loader:SingleSampleMediaPeriod");
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void discardBuffer(long j, boolean z) {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long getAdjustedSeekPositionUs(long j, SeekParameters seekParameters) {
return j;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getBufferedPositionUs() {
return this.loadingFinished ? Long.MIN_VALUE : 0L;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final TrackGroupArray getTrackGroups() {
return this.tracks;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void maybeThrowPrepareError() throws IOException {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final void reevaluateBuffer(long j) {
}
public SingleSampleMediaPeriod(DataSpec dataSpec, DataSource.Factory factory, Format format, long j, int i, MediaSourceEventListener.EventDispatcher eventDispatcher, boolean z) {
this.dataSpec = dataSpec;
this.dataSourceFactory = factory;
this.format = format;
this.durationUs = j;
this.minLoadableRetryCount = i;
this.eventDispatcher = eventDispatcher;
this.treatLoadErrorsAsEndOfStream = z;
this.tracks = new TrackGroupArray(new TrackGroup(format));
eventDispatcher.mediaPeriodCreated();
}
public final void release() {
this.loader.release();
this.eventDispatcher.mediaPeriodReleased();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final void prepare(MediaPeriod.Callback callback, long j) {
callback.onPrepared(this);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long selectTracks(TrackSelection[] trackSelectionArr, boolean[] zArr, SampleStream[] sampleStreamArr, boolean[] zArr2, long j) {
for (int i = 0; i < trackSelectionArr.length; i++) {
SampleStream sampleStream = sampleStreamArr[i];
if (sampleStream != null && (trackSelectionArr[i] == null || !zArr[i])) {
this.sampleStreams.remove(sampleStream);
sampleStreamArr[i] = null;
}
if (sampleStreamArr[i] == null && trackSelectionArr[i] != null) {
SampleStreamImpl sampleStreamImpl = new SampleStreamImpl();
this.sampleStreams.add(sampleStreamImpl);
sampleStreamArr[i] = sampleStreamImpl;
zArr2[i] = true;
}
}
return j;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final boolean continueLoading(long j) {
if (this.loadingFinished || this.loader.isLoading()) {
return false;
}
this.eventDispatcher.loadStarted(this.dataSpec, 1, -1, this.format, 0, null, 0L, this.durationUs, this.loader.startLoading(new SourceLoadable(this.dataSpec, this.dataSourceFactory.createDataSource()), this, this.minLoadableRetryCount));
return true;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long readDiscontinuity() {
if (this.notifiedReadingStarted) {
return C.TIME_UNSET;
}
this.eventDispatcher.readingStarted();
this.notifiedReadingStarted = true;
return C.TIME_UNSET;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod, com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public final long getNextLoadPositionUs() {
return (this.loadingFinished || this.loader.isLoading()) ? Long.MIN_VALUE : 0L;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod
public final long seekToUs(long j) {
for (int i = 0; i < this.sampleStreams.size(); i++) {
this.sampleStreams.get(i).reset();
}
return j;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Callback
public final void onLoadCompleted(SourceLoadable sourceLoadable, long j, long j2) {
this.eventDispatcher.loadCompleted(sourceLoadable.dataSpec, 1, -1, this.format, 0, null, 0L, this.durationUs, j, j2, sourceLoadable.sampleSize);
this.sampleSize = sourceLoadable.sampleSize;
this.sampleData = sourceLoadable.sampleData;
this.loadingFinished = true;
this.loadingSucceeded = true;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Callback
public final void onLoadCanceled(SourceLoadable sourceLoadable, long j, long j2, boolean z) {
this.eventDispatcher.loadCanceled(sourceLoadable.dataSpec, 1, -1, null, 0, null, 0L, this.durationUs, j, j2, sourceLoadable.sampleSize);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Callback
public final int onLoadError(SourceLoadable sourceLoadable, long j, long j2, IOException iOException) {
int i = this.errorCount + 1;
this.errorCount = i;
boolean z = this.treatLoadErrorsAsEndOfStream && i >= this.minLoadableRetryCount;
this.eventDispatcher.loadError(sourceLoadable.dataSpec, 1, -1, this.format, 0, null, 0L, this.durationUs, j, j2, sourceLoadable.sampleSize, iOException, z);
if (!z) {
return 0;
}
this.loadingFinished = true;
return 2;
}
public final class SampleStreamImpl implements SampleStream {
private static final int STREAM_STATE_END_OF_STREAM = 2;
private static final int STREAM_STATE_SEND_FORMAT = 0;
private static final int STREAM_STATE_SEND_SAMPLE = 1;
private boolean formatSent;
private int streamState;
public final void reset() {
if (this.streamState == 2) {
this.streamState = 1;
}
}
private SampleStreamImpl() {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final boolean isReady() {
return SingleSampleMediaPeriod.this.loadingFinished;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final void maybeThrowError() throws IOException {
SingleSampleMediaPeriod singleSampleMediaPeriod = SingleSampleMediaPeriod.this;
if (singleSampleMediaPeriod.treatLoadErrorsAsEndOfStream) {
return;
}
singleSampleMediaPeriod.loader.maybeThrowError();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final int readData(FormatHolder formatHolder, DecoderInputBuffer decoderInputBuffer, boolean z) {
int i = this.streamState;
if (i == 2) {
decoderInputBuffer.addFlag(4);
return -4;
}
if (z || i == 0) {
formatHolder.format = SingleSampleMediaPeriod.this.format;
this.streamState = 1;
return -5;
}
SingleSampleMediaPeriod singleSampleMediaPeriod = SingleSampleMediaPeriod.this;
if (!singleSampleMediaPeriod.loadingFinished) {
return -3;
}
if (singleSampleMediaPeriod.loadingSucceeded) {
decoderInputBuffer.timeUs = 0L;
decoderInputBuffer.addFlag(1);
decoderInputBuffer.ensureSpaceForWrite(SingleSampleMediaPeriod.this.sampleSize);
ByteBuffer byteBuffer = decoderInputBuffer.data;
SingleSampleMediaPeriod singleSampleMediaPeriod2 = SingleSampleMediaPeriod.this;
byteBuffer.put(singleSampleMediaPeriod2.sampleData, 0, singleSampleMediaPeriod2.sampleSize);
sendFormat();
} else {
decoderInputBuffer.addFlag(4);
}
this.streamState = 2;
return -4;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final int skipData(long j) {
if (j <= 0 || this.streamState == 2) {
return 0;
}
this.streamState = 2;
sendFormat();
return 1;
}
private void sendFormat() {
if (this.formatSent) {
return;
}
SingleSampleMediaPeriod.this.eventDispatcher.downstreamFormatChanged(MimeTypes.getTrackType(SingleSampleMediaPeriod.this.format.sampleMimeType), SingleSampleMediaPeriod.this.format, 0, null, 0L);
this.formatSent = true;
}
}
public static final class SourceLoadable implements Loader.Loadable {
private final DataSource dataSource;
public final DataSpec dataSpec;
private byte[] sampleData;
private int sampleSize;
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void cancelLoad() {
}
public SourceLoadable(DataSpec dataSpec, DataSource dataSource) {
this.dataSpec = dataSpec;
this.dataSource = dataSource;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void load() throws IOException, InterruptedException {
int i = 0;
this.sampleSize = 0;
try {
this.dataSource.open(this.dataSpec);
while (i != -1) {
int i2 = this.sampleSize + i;
this.sampleSize = i2;
byte[] bArr = this.sampleData;
if (bArr == null) {
this.sampleData = new byte[1024];
} else if (i2 == bArr.length) {
this.sampleData = Arrays.copyOf(bArr, bArr.length * 2);
}
DataSource dataSource = this.dataSource;
byte[] bArr2 = this.sampleData;
int i3 = this.sampleSize;
i = dataSource.read(bArr2, i3, bArr2.length - i3);
}
Util.closeQuietly(this.dataSource);
} catch (Throwable th) {
Util.closeQuietly(this.dataSource);
throw th;
}
}
}
}

View File

@@ -0,0 +1,146 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.net.Uri;
import android.os.Handler;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class SingleSampleMediaSource extends BaseMediaSource {
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3;
private final DataSource.Factory dataSourceFactory;
private final DataSpec dataSpec;
private final long durationUs;
private final Format format;
private final int minLoadableRetryCount;
private final Timeline timeline;
private final boolean treatLoadErrorsAsEndOfStream;
@Deprecated
public interface EventListener {
void onLoadError(int i, IOException iOException);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void maybeThrowSourceInfoRefreshError() throws IOException {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void releaseSourceInternal() {
}
public static final class Factory {
private final DataSource.Factory dataSourceFactory;
private boolean isCreateCalled;
private int minLoadableRetryCount = 3;
@Nullable
private Object tag;
private boolean treatLoadErrorsAsEndOfStream;
public Factory(DataSource.Factory factory) {
this.dataSourceFactory = (DataSource.Factory) Assertions.checkNotNull(factory);
}
public final Factory setTag(Object obj) {
Assertions.checkState(!this.isCreateCalled);
this.tag = obj;
return this;
}
public final Factory setMinLoadableRetryCount(int i) {
Assertions.checkState(!this.isCreateCalled);
this.minLoadableRetryCount = i;
return this;
}
public final Factory setTreatLoadErrorsAsEndOfStream(boolean z) {
Assertions.checkState(!this.isCreateCalled);
this.treatLoadErrorsAsEndOfStream = z;
return this;
}
public final SingleSampleMediaSource createMediaSource(Uri uri, Format format, long j) {
this.isCreateCalled = true;
return new SingleSampleMediaSource(uri, this.dataSourceFactory, format, j, this.minLoadableRetryCount, this.treatLoadErrorsAsEndOfStream, this.tag);
}
@Deprecated
public final SingleSampleMediaSource createMediaSource(Uri uri, Format format, long j, @Nullable Handler handler, @Nullable MediaSourceEventListener mediaSourceEventListener) {
SingleSampleMediaSource createMediaSource = createMediaSource(uri, format, j);
if (handler != null && mediaSourceEventListener != null) {
createMediaSource.addEventListener(handler, mediaSourceEventListener);
}
return createMediaSource;
}
}
@Deprecated
public SingleSampleMediaSource(Uri uri, DataSource.Factory factory, Format format, long j) {
this(uri, factory, format, j, 3);
}
@Deprecated
public SingleSampleMediaSource(Uri uri, DataSource.Factory factory, Format format, long j, int i) {
this(uri, factory, format, j, i, false, null);
}
@Deprecated
public SingleSampleMediaSource(Uri uri, DataSource.Factory factory, Format format, long j, int i, Handler handler, EventListener eventListener, int i2, boolean z) {
this(uri, factory, format, j, i, z, null);
if (handler == null || eventListener == null) {
return;
}
addEventListener(handler, new EventListenerWrapper(eventListener, i2));
}
private SingleSampleMediaSource(Uri uri, DataSource.Factory factory, Format format, long j, int i, boolean z, @Nullable Object obj) {
this.dataSourceFactory = factory;
this.format = format;
this.durationUs = j;
this.minLoadableRetryCount = i;
this.treatLoadErrorsAsEndOfStream = z;
this.dataSpec = new DataSpec(uri);
this.timeline = new SinglePeriodTimeline(j, true, false, obj);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void prepareSourceInternal(ExoPlayer exoPlayer, boolean z) {
refreshSourceInfo(this.timeline, null);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final MediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator) {
Assertions.checkArgument(mediaPeriodId.periodIndex == 0);
return new SingleSampleMediaPeriod(this.dataSpec, this.dataSourceFactory, this.format, this.durationUs, this.minLoadableRetryCount, createEventDispatcher(mediaPeriodId), this.treatLoadErrorsAsEndOfStream);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void releasePeriod(MediaPeriod mediaPeriod) {
((SingleSampleMediaPeriod) mediaPeriod).release();
}
public static final class EventListenerWrapper extends DefaultMediaSourceEventListener {
private final EventListener eventListener;
private final int eventSourceId;
public EventListenerWrapper(EventListener eventListener, int i) {
this.eventListener = (EventListener) Assertions.checkNotNull(eventListener);
this.eventSourceId = i;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.DefaultMediaSourceEventListener, com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onLoadError(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData, IOException iOException, boolean z) {
this.eventListener.onLoadError(this.eventSourceId, iOException);
}
}
}

View File

@@ -0,0 +1,93 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import com.ironsource.mediationsdk.logger.IronSourceError;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.util.Arrays;
/* loaded from: classes4.dex */
public final class TrackGroup implements Parcelable {
public static final Parcelable.Creator<TrackGroup> CREATOR = new Parcelable.Creator<TrackGroup>() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.TrackGroup.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public TrackGroup createFromParcel(Parcel parcel) {
return new TrackGroup(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public TrackGroup[] newArray(int i) {
return new TrackGroup[i];
}
};
private final Format[] formats;
private int hashCode;
public final int length;
@Override // android.os.Parcelable
public final int describeContents() {
return 0;
}
public TrackGroup(Format... formatArr) {
Assertions.checkState(formatArr.length > 0);
this.formats = formatArr;
this.length = formatArr.length;
}
public TrackGroup(Parcel parcel) {
int readInt = parcel.readInt();
this.length = readInt;
this.formats = new Format[readInt];
for (int i = 0; i < this.length; i++) {
this.formats[i] = (Format) parcel.readParcelable(Format.class.getClassLoader());
}
}
public final Format getFormat(int i) {
return this.formats[i];
}
public final int indexOf(Format format) {
int i = 0;
while (true) {
Format[] formatArr = this.formats;
if (i >= formatArr.length) {
return -1;
}
if (format == formatArr[i]) {
return i;
}
i++;
}
}
public final int hashCode() {
if (this.hashCode == 0) {
this.hashCode = IronSourceError.ERROR_NON_EXISTENT_INSTANCE + Arrays.hashCode(this.formats);
}
return this.hashCode;
}
public final boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || TrackGroup.class != obj.getClass()) {
return false;
}
TrackGroup trackGroup = (TrackGroup) obj;
return this.length == trackGroup.length && Arrays.equals(this.formats, trackGroup.formats);
}
@Override // android.os.Parcelable
public final void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(this.length);
for (int i2 = 0; i2 < this.length; i2++) {
parcel.writeParcelable(this.formats[i2], 0);
}
}
}

View File

@@ -0,0 +1,89 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import java.util.Arrays;
/* loaded from: classes4.dex */
public final class TrackGroupArray implements Parcelable {
private int hashCode;
public final int length;
private final TrackGroup[] trackGroups;
public static final TrackGroupArray EMPTY = new TrackGroupArray(new TrackGroup[0]);
public static final Parcelable.Creator<TrackGroupArray> CREATOR = new Parcelable.Creator<TrackGroupArray>() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.TrackGroupArray.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public TrackGroupArray createFromParcel(Parcel parcel) {
return new TrackGroupArray(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public TrackGroupArray[] newArray(int i) {
return new TrackGroupArray[i];
}
};
@Override // android.os.Parcelable
public final int describeContents() {
return 0;
}
public final boolean isEmpty() {
return this.length == 0;
}
public TrackGroupArray(TrackGroup... trackGroupArr) {
this.trackGroups = trackGroupArr;
this.length = trackGroupArr.length;
}
public TrackGroupArray(Parcel parcel) {
int readInt = parcel.readInt();
this.length = readInt;
this.trackGroups = new TrackGroup[readInt];
for (int i = 0; i < this.length; i++) {
this.trackGroups[i] = (TrackGroup) parcel.readParcelable(TrackGroup.class.getClassLoader());
}
}
public final TrackGroup get(int i) {
return this.trackGroups[i];
}
public final int indexOf(TrackGroup trackGroup) {
for (int i = 0; i < this.length; i++) {
if (this.trackGroups[i] == trackGroup) {
return i;
}
}
return -1;
}
public final int hashCode() {
if (this.hashCode == 0) {
this.hashCode = Arrays.hashCode(this.trackGroups);
}
return this.hashCode;
}
public final boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || TrackGroupArray.class != obj.getClass()) {
return false;
}
TrackGroupArray trackGroupArray = (TrackGroupArray) obj;
return this.length == trackGroupArray.length && Arrays.equals(this.trackGroups, trackGroupArray.trackGroups);
}
@Override // android.os.Parcelable
public final void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(this.length);
for (int i2 = 0; i2 < this.length; i2++) {
parcel.writeParcelable(this.trackGroups[i2], 0);
}
}
}

View File

@@ -0,0 +1,14 @@
package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.net.Uri;
import com.mbridge.msdk.playercommon.exoplayer2.ParserException;
/* loaded from: classes4.dex */
public class UnrecognizedInputFormatException extends ParserException {
public final Uri uri;
public UnrecognizedInputFormatException(String str, Uri uri) {
super(str);
this.uri = uri;
}
}

View File

@@ -0,0 +1,281 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.ads;
import android.net.Uri;
import androidx.annotation.CheckResult;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
/* loaded from: classes4.dex */
public final class AdPlaybackState {
public static final int AD_STATE_AVAILABLE = 1;
public static final int AD_STATE_ERROR = 4;
public static final int AD_STATE_PLAYED = 3;
public static final int AD_STATE_SKIPPED = 2;
public static final int AD_STATE_UNAVAILABLE = 0;
public static final AdPlaybackState NONE = new AdPlaybackState(new long[0]);
public final int adGroupCount;
public final long[] adGroupTimesUs;
public final AdGroup[] adGroups;
public final long adResumePositionUs;
public final long contentDurationUs;
@Retention(RetentionPolicy.SOURCE)
public @interface AdState {
}
public static final class AdGroup {
public final int count;
public final long[] durationsUs;
public final int[] states;
public final Uri[] uris;
public AdGroup() {
this(-1, new int[0], new Uri[0], new long[0]);
}
private AdGroup(int i, int[] iArr, Uri[] uriArr, long[] jArr) {
Assertions.checkArgument(iArr.length == uriArr.length);
this.count = i;
this.states = iArr;
this.uris = uriArr;
this.durationsUs = jArr;
}
public final int getFirstAdIndexToPlay() {
return getNextAdIndexToPlay(-1);
}
public final int getNextAdIndexToPlay(int i) {
int i2;
int i3 = i + 1;
while (true) {
int[] iArr = this.states;
if (i3 >= iArr.length || (i2 = iArr[i3]) == 0 || i2 == 1) {
break;
}
i3++;
}
return i3;
}
public final boolean hasUnplayedAds() {
return this.count == -1 || getFirstAdIndexToPlay() < this.count;
}
@CheckResult
public final AdGroup withAdCount(int i) {
Assertions.checkArgument(this.count == -1 && this.states.length <= i);
return new AdGroup(i, copyStatesWithSpaceForAdCount(this.states, i), (Uri[]) Arrays.copyOf(this.uris, i), copyDurationsUsWithSpaceForAdCount(this.durationsUs, i));
}
@CheckResult
public final AdGroup withAdUri(Uri uri, int i) {
int i2 = this.count;
Assertions.checkArgument(i2 == -1 || i < i2);
int[] copyStatesWithSpaceForAdCount = copyStatesWithSpaceForAdCount(this.states, i + 1);
Assertions.checkArgument(copyStatesWithSpaceForAdCount[i] == 0);
long[] jArr = this.durationsUs;
if (jArr.length != copyStatesWithSpaceForAdCount.length) {
jArr = copyDurationsUsWithSpaceForAdCount(jArr, copyStatesWithSpaceForAdCount.length);
}
Uri[] uriArr = (Uri[]) Arrays.copyOf(this.uris, copyStatesWithSpaceForAdCount.length);
uriArr[i] = uri;
copyStatesWithSpaceForAdCount[i] = 1;
return new AdGroup(this.count, copyStatesWithSpaceForAdCount, uriArr, jArr);
}
@CheckResult
public final AdGroup withAdState(int i, int i2) {
int i3 = this.count;
Assertions.checkArgument(i3 == -1 || i2 < i3);
int[] copyStatesWithSpaceForAdCount = copyStatesWithSpaceForAdCount(this.states, i2 + 1);
int i4 = copyStatesWithSpaceForAdCount[i2];
Assertions.checkArgument(i4 == 0 || i4 == 1 || i4 == i);
long[] jArr = this.durationsUs;
if (jArr.length != copyStatesWithSpaceForAdCount.length) {
jArr = copyDurationsUsWithSpaceForAdCount(jArr, copyStatesWithSpaceForAdCount.length);
}
Uri[] uriArr = this.uris;
if (uriArr.length != copyStatesWithSpaceForAdCount.length) {
uriArr = (Uri[]) Arrays.copyOf(uriArr, copyStatesWithSpaceForAdCount.length);
}
copyStatesWithSpaceForAdCount[i2] = i;
return new AdGroup(this.count, copyStatesWithSpaceForAdCount, uriArr, jArr);
}
@CheckResult
public final AdGroup withAdDurationsUs(long[] jArr) {
Assertions.checkArgument(this.count == -1 || jArr.length <= this.uris.length);
int length = jArr.length;
Uri[] uriArr = this.uris;
if (length < uriArr.length) {
jArr = copyDurationsUsWithSpaceForAdCount(jArr, uriArr.length);
}
return new AdGroup(this.count, this.states, this.uris, jArr);
}
@CheckResult
public final AdGroup withAllAdsSkipped() {
if (this.count == -1) {
return new AdGroup(0, new int[0], new Uri[0], new long[0]);
}
int[] iArr = this.states;
int length = iArr.length;
int[] copyOf = Arrays.copyOf(iArr, length);
for (int i = 0; i < length; i++) {
int i2 = copyOf[i];
if (i2 == 1 || i2 == 0) {
copyOf[i] = 2;
}
}
return new AdGroup(length, copyOf, this.uris, this.durationsUs);
}
@CheckResult
private static int[] copyStatesWithSpaceForAdCount(int[] iArr, int i) {
int length = iArr.length;
int max = Math.max(i, length);
int[] copyOf = Arrays.copyOf(iArr, max);
Arrays.fill(copyOf, length, max, 0);
return copyOf;
}
@CheckResult
private static long[] copyDurationsUsWithSpaceForAdCount(long[] jArr, int i) {
int length = jArr.length;
int max = Math.max(i, length);
long[] copyOf = Arrays.copyOf(jArr, max);
Arrays.fill(copyOf, length, max, C.TIME_UNSET);
return copyOf;
}
}
public AdPlaybackState(long... jArr) {
int length = jArr.length;
this.adGroupCount = length;
this.adGroupTimesUs = Arrays.copyOf(jArr, length);
this.adGroups = new AdGroup[length];
for (int i = 0; i < length; i++) {
this.adGroups[i] = new AdGroup();
}
this.adResumePositionUs = 0L;
this.contentDurationUs = C.TIME_UNSET;
}
private AdPlaybackState(long[] jArr, AdGroup[] adGroupArr, long j, long j2) {
this.adGroupCount = adGroupArr.length;
this.adGroupTimesUs = jArr;
this.adGroups = adGroupArr;
this.adResumePositionUs = j;
this.contentDurationUs = j2;
}
public final int getAdGroupIndexForPositionUs(long j) {
int length = this.adGroupTimesUs.length - 1;
while (length >= 0) {
long j2 = this.adGroupTimesUs[length];
if (j2 != Long.MIN_VALUE && j2 <= j) {
break;
}
length--;
}
if (length < 0 || !this.adGroups[length].hasUnplayedAds()) {
return -1;
}
return length;
}
public final int getAdGroupIndexAfterPositionUs(long j) {
int i = 0;
while (true) {
long[] jArr = this.adGroupTimesUs;
if (i >= jArr.length) {
break;
}
long j2 = jArr[i];
if (j2 == Long.MIN_VALUE || (j < j2 && this.adGroups[i].hasUnplayedAds())) {
break;
}
i++;
}
if (i < this.adGroupTimesUs.length) {
return i;
}
return -1;
}
@CheckResult
public final AdPlaybackState withAdCount(int i, int i2) {
Assertions.checkArgument(i2 > 0);
AdGroup[] adGroupArr = this.adGroups;
if (adGroupArr[i].count == i2) {
return this;
}
AdGroup[] adGroupArr2 = (AdGroup[]) Arrays.copyOf(adGroupArr, adGroupArr.length);
adGroupArr2[i] = this.adGroups[i].withAdCount(i2);
return new AdPlaybackState(this.adGroupTimesUs, adGroupArr2, this.adResumePositionUs, this.contentDurationUs);
}
@CheckResult
public final AdPlaybackState withAdUri(int i, int i2, Uri uri) {
AdGroup[] adGroupArr = this.adGroups;
AdGroup[] adGroupArr2 = (AdGroup[]) Arrays.copyOf(adGroupArr, adGroupArr.length);
adGroupArr2[i] = adGroupArr2[i].withAdUri(uri, i2);
return new AdPlaybackState(this.adGroupTimesUs, adGroupArr2, this.adResumePositionUs, this.contentDurationUs);
}
@CheckResult
public final AdPlaybackState withPlayedAd(int i, int i2) {
AdGroup[] adGroupArr = this.adGroups;
AdGroup[] adGroupArr2 = (AdGroup[]) Arrays.copyOf(adGroupArr, adGroupArr.length);
adGroupArr2[i] = adGroupArr2[i].withAdState(3, i2);
return new AdPlaybackState(this.adGroupTimesUs, adGroupArr2, this.adResumePositionUs, this.contentDurationUs);
}
@CheckResult
public final AdPlaybackState withSkippedAd(int i, int i2) {
AdGroup[] adGroupArr = this.adGroups;
AdGroup[] adGroupArr2 = (AdGroup[]) Arrays.copyOf(adGroupArr, adGroupArr.length);
adGroupArr2[i] = adGroupArr2[i].withAdState(2, i2);
return new AdPlaybackState(this.adGroupTimesUs, adGroupArr2, this.adResumePositionUs, this.contentDurationUs);
}
@CheckResult
public final AdPlaybackState withAdLoadError(int i, int i2) {
AdGroup[] adGroupArr = this.adGroups;
AdGroup[] adGroupArr2 = (AdGroup[]) Arrays.copyOf(adGroupArr, adGroupArr.length);
adGroupArr2[i] = adGroupArr2[i].withAdState(4, i2);
return new AdPlaybackState(this.adGroupTimesUs, adGroupArr2, this.adResumePositionUs, this.contentDurationUs);
}
@CheckResult
public final AdPlaybackState withSkippedAdGroup(int i) {
AdGroup[] adGroupArr = this.adGroups;
AdGroup[] adGroupArr2 = (AdGroup[]) Arrays.copyOf(adGroupArr, adGroupArr.length);
adGroupArr2[i] = adGroupArr2[i].withAllAdsSkipped();
return new AdPlaybackState(this.adGroupTimesUs, adGroupArr2, this.adResumePositionUs, this.contentDurationUs);
}
@CheckResult
public final AdPlaybackState withAdDurationsUs(long[][] jArr) {
AdGroup[] adGroupArr = this.adGroups;
AdGroup[] adGroupArr2 = (AdGroup[]) Arrays.copyOf(adGroupArr, adGroupArr.length);
for (int i = 0; i < this.adGroupCount; i++) {
adGroupArr2[i] = adGroupArr2[i].withAdDurationsUs(jArr[i]);
}
return new AdPlaybackState(this.adGroupTimesUs, adGroupArr2, this.adResumePositionUs, this.contentDurationUs);
}
@CheckResult
public final AdPlaybackState withAdResumePositionUs(long j) {
return this.adResumePositionUs == j ? this : new AdPlaybackState(this.adGroupTimesUs, this.adGroups, j, this.contentDurationUs);
}
@CheckResult
public final AdPlaybackState withContentDurationUs(long j) {
return this.contentDurationUs == j ? this : new AdPlaybackState(this.adGroupTimesUs, this.adGroups, this.adResumePositionUs, j);
}
}

View File

@@ -0,0 +1,31 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.ads;
import android.view.ViewGroup;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import java.io.IOException;
/* loaded from: classes4.dex */
public interface AdsLoader {
public interface EventListener {
void onAdClicked();
void onAdLoadError(AdsMediaSource.AdLoadException adLoadException, DataSpec dataSpec);
void onAdPlaybackState(AdPlaybackState adPlaybackState);
void onAdTapped();
}
void attachPlayer(ExoPlayer exoPlayer, EventListener eventListener, ViewGroup viewGroup);
void detachPlayer();
void handlePrepareError(int i, int i2, IOException iOException);
void release();
void setSupportedContentTypes(int... iArr);
}

View File

@@ -0,0 +1,384 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.ads;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.DeferredMediaPeriod;
import com.mbridge.msdk.playercommon.exoplayer2.source.ExtractorMediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaPeriod;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsLoader;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/* loaded from: classes4.dex */
public final class AdsMediaSource extends CompositeMediaSource<MediaSource.MediaPeriodId> {
private static final String TAG = "AdsMediaSource";
private long[][] adDurationsUs;
private MediaSource[][] adGroupMediaSources;
private final MediaSourceFactory adMediaSourceFactory;
private AdPlaybackState adPlaybackState;
private final ViewGroup adUiViewGroup;
private final AdsLoader adsLoader;
private ComponentListener componentListener;
private Object contentManifest;
private final MediaSource contentMediaSource;
private Timeline contentTimeline;
private final Map<MediaSource, List<DeferredMediaPeriod>> deferredMediaPeriodByAdMediaSource;
@Nullable
private final Handler eventHandler;
@Nullable
private final EventListener eventListener;
private final Handler mainHandler;
private final Timeline.Period period;
@Deprecated
public interface EventListener {
void onAdClicked();
void onAdLoadError(IOException iOException);
void onAdTapped();
void onInternalAdLoadError(RuntimeException runtimeException);
}
public interface MediaSourceFactory {
MediaSource createMediaSource(Uri uri);
int[] getSupportedTypes();
}
public static final class AdLoadException extends IOException {
public static final int TYPE_AD = 0;
public static final int TYPE_AD_GROUP = 1;
public static final int TYPE_ALL_ADS = 2;
public static final int TYPE_UNEXPECTED = 3;
public final int type;
@Retention(RetentionPolicy.SOURCE)
public @interface Type {
}
public static AdLoadException createForAd(Exception exc) {
return new AdLoadException(0, exc);
}
public static AdLoadException createForAdGroup(Exception exc, int i) {
return new AdLoadException(1, new IOException("Failed to load ad group " + i, exc));
}
public static AdLoadException createForAllAds(Exception exc) {
return new AdLoadException(2, exc);
}
public static AdLoadException createForUnexpected(RuntimeException runtimeException) {
return new AdLoadException(3, runtimeException);
}
private AdLoadException(int i, Exception exc) {
super(exc);
this.type = i;
}
public final RuntimeException getRuntimeExceptionForUnexpected() {
Assertions.checkState(this.type == 3);
return (RuntimeException) getCause();
}
}
public AdsMediaSource(MediaSource mediaSource, DataSource.Factory factory, AdsLoader adsLoader, ViewGroup viewGroup) {
this(mediaSource, new ExtractorMediaSource.Factory(factory), adsLoader, viewGroup, (Handler) null, (EventListener) null);
}
public AdsMediaSource(MediaSource mediaSource, MediaSourceFactory mediaSourceFactory, AdsLoader adsLoader, ViewGroup viewGroup) {
this(mediaSource, mediaSourceFactory, adsLoader, viewGroup, (Handler) null, (EventListener) null);
}
@Deprecated
public AdsMediaSource(MediaSource mediaSource, DataSource.Factory factory, AdsLoader adsLoader, ViewGroup viewGroup, @Nullable Handler handler, @Nullable EventListener eventListener) {
this(mediaSource, new ExtractorMediaSource.Factory(factory), adsLoader, viewGroup, handler, eventListener);
}
@Deprecated
public AdsMediaSource(MediaSource mediaSource, MediaSourceFactory mediaSourceFactory, AdsLoader adsLoader, ViewGroup viewGroup, @Nullable Handler handler, @Nullable EventListener eventListener) {
this.contentMediaSource = mediaSource;
this.adMediaSourceFactory = mediaSourceFactory;
this.adsLoader = adsLoader;
this.adUiViewGroup = viewGroup;
this.eventHandler = handler;
this.eventListener = eventListener;
this.mainHandler = new Handler(Looper.getMainLooper());
this.deferredMediaPeriodByAdMediaSource = new HashMap();
this.period = new Timeline.Period();
this.adGroupMediaSources = new MediaSource[0][];
this.adDurationsUs = new long[0][];
adsLoader.setSupportedContentTypes(mediaSourceFactory.getSupportedTypes());
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void prepareSourceInternal(final ExoPlayer exoPlayer, boolean z) {
super.prepareSourceInternal(exoPlayer, z);
Assertions.checkArgument(z);
final ComponentListener componentListener = new ComponentListener();
this.componentListener = componentListener;
prepareChildSource(new MediaSource.MediaPeriodId(0), this.contentMediaSource);
this.mainHandler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource.1
@Override // java.lang.Runnable
public void run() {
AdsMediaSource.this.adsLoader.attachPlayer(exoPlayer, componentListener, AdsMediaSource.this.adUiViewGroup);
}
});
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final MediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator) {
if (this.adPlaybackState.adGroupCount > 0 && mediaPeriodId.isAd()) {
int i = mediaPeriodId.adGroupIndex;
int i2 = mediaPeriodId.adIndexInAdGroup;
Uri uri = this.adPlaybackState.adGroups[i].uris[i2];
if (this.adGroupMediaSources[i].length <= i2) {
MediaSource createMediaSource = this.adMediaSourceFactory.createMediaSource(uri);
MediaSource[][] mediaSourceArr = this.adGroupMediaSources;
MediaSource[] mediaSourceArr2 = mediaSourceArr[i];
int length = mediaSourceArr2.length;
if (i2 >= length) {
int i3 = i2 + 1;
mediaSourceArr[i] = (MediaSource[]) Arrays.copyOf(mediaSourceArr2, i3);
long[][] jArr = this.adDurationsUs;
jArr[i] = Arrays.copyOf(jArr[i], i3);
Arrays.fill(this.adDurationsUs[i], length, i3, C.TIME_UNSET);
}
this.adGroupMediaSources[i][i2] = createMediaSource;
this.deferredMediaPeriodByAdMediaSource.put(createMediaSource, new ArrayList());
prepareChildSource(mediaPeriodId, createMediaSource);
}
MediaSource mediaSource = this.adGroupMediaSources[i][i2];
DeferredMediaPeriod deferredMediaPeriod = new DeferredMediaPeriod(mediaSource, new MediaSource.MediaPeriodId(0, mediaPeriodId.windowSequenceNumber), allocator);
deferredMediaPeriod.setPrepareErrorListener(new AdPrepareErrorListener(uri, i, i2));
List<DeferredMediaPeriod> list = this.deferredMediaPeriodByAdMediaSource.get(mediaSource);
if (list == null) {
deferredMediaPeriod.createPeriod();
} else {
list.add(deferredMediaPeriod);
}
return deferredMediaPeriod;
}
DeferredMediaPeriod deferredMediaPeriod2 = new DeferredMediaPeriod(this.contentMediaSource, mediaPeriodId, allocator);
deferredMediaPeriod2.createPeriod();
return deferredMediaPeriod2;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
public final void releasePeriod(MediaPeriod mediaPeriod) {
DeferredMediaPeriod deferredMediaPeriod = (DeferredMediaPeriod) mediaPeriod;
List<DeferredMediaPeriod> list = this.deferredMediaPeriodByAdMediaSource.get(deferredMediaPeriod.mediaSource);
if (list != null) {
list.remove(deferredMediaPeriod);
}
deferredMediaPeriod.releasePeriod();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource, com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
public final void releaseSourceInternal() {
super.releaseSourceInternal();
this.componentListener.release();
this.componentListener = null;
this.deferredMediaPeriodByAdMediaSource.clear();
this.contentTimeline = null;
this.contentManifest = null;
this.adPlaybackState = null;
this.adGroupMediaSources = new MediaSource[0][];
this.adDurationsUs = new long[0][];
this.mainHandler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource.2
@Override // java.lang.Runnable
public void run() {
AdsMediaSource.this.adsLoader.detachPlayer();
}
});
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource
public final void onChildSourceInfoRefreshed(MediaSource.MediaPeriodId mediaPeriodId, MediaSource mediaSource, Timeline timeline, @Nullable Object obj) {
if (mediaPeriodId.isAd()) {
onAdSourceInfoRefreshed(mediaSource, mediaPeriodId.adGroupIndex, mediaPeriodId.adIndexInAdGroup, timeline);
} else {
onContentSourceInfoRefreshed(timeline, obj);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource
@Nullable
public final MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(MediaSource.MediaPeriodId mediaPeriodId, MediaSource.MediaPeriodId mediaPeriodId2) {
return mediaPeriodId.isAd() ? mediaPeriodId : mediaPeriodId2;
}
/* JADX INFO: Access modifiers changed from: private */
public void onAdPlaybackState(AdPlaybackState adPlaybackState) {
if (this.adPlaybackState == null) {
MediaSource[][] mediaSourceArr = new MediaSource[adPlaybackState.adGroupCount][];
this.adGroupMediaSources = mediaSourceArr;
Arrays.fill(mediaSourceArr, new MediaSource[0]);
long[][] jArr = new long[adPlaybackState.adGroupCount][];
this.adDurationsUs = jArr;
Arrays.fill(jArr, new long[0]);
}
this.adPlaybackState = adPlaybackState;
maybeUpdateSourceInfo();
}
private void onContentSourceInfoRefreshed(Timeline timeline, Object obj) {
this.contentTimeline = timeline;
this.contentManifest = obj;
maybeUpdateSourceInfo();
}
private void onAdSourceInfoRefreshed(MediaSource mediaSource, int i, int i2, Timeline timeline) {
Assertions.checkArgument(timeline.getPeriodCount() == 1);
this.adDurationsUs[i][i2] = timeline.getPeriod(0, this.period).getDurationUs();
if (this.deferredMediaPeriodByAdMediaSource.containsKey(mediaSource)) {
List<DeferredMediaPeriod> list = this.deferredMediaPeriodByAdMediaSource.get(mediaSource);
for (int i3 = 0; i3 < list.size(); i3++) {
list.get(i3).createPeriod();
}
this.deferredMediaPeriodByAdMediaSource.remove(mediaSource);
}
maybeUpdateSourceInfo();
}
private void maybeUpdateSourceInfo() {
AdPlaybackState adPlaybackState = this.adPlaybackState;
if (adPlaybackState == null || this.contentTimeline == null) {
return;
}
AdPlaybackState withAdDurationsUs = adPlaybackState.withAdDurationsUs(this.adDurationsUs);
this.adPlaybackState = withAdDurationsUs;
refreshSourceInfo(withAdDurationsUs.adGroupCount == 0 ? this.contentTimeline : new SinglePeriodAdTimeline(this.contentTimeline, this.adPlaybackState), this.contentManifest);
}
public final class ComponentListener implements AdsLoader.EventListener {
private final Handler playerHandler = new Handler();
private volatile boolean released;
public ComponentListener() {
}
public final void release() {
this.released = true;
this.playerHandler.removeCallbacksAndMessages(null);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsLoader.EventListener
public final void onAdPlaybackState(final AdPlaybackState adPlaybackState) {
if (this.released) {
return;
}
this.playerHandler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource.ComponentListener.1
@Override // java.lang.Runnable
public void run() {
if (ComponentListener.this.released) {
return;
}
AdsMediaSource.this.onAdPlaybackState(adPlaybackState);
}
});
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsLoader.EventListener
public final void onAdClicked() {
if (this.released || AdsMediaSource.this.eventHandler == null || AdsMediaSource.this.eventListener == null) {
return;
}
AdsMediaSource.this.eventHandler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource.ComponentListener.2
@Override // java.lang.Runnable
public void run() {
if (ComponentListener.this.released) {
return;
}
AdsMediaSource.this.eventListener.onAdClicked();
}
});
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsLoader.EventListener
public final void onAdTapped() {
if (this.released || AdsMediaSource.this.eventHandler == null || AdsMediaSource.this.eventListener == null) {
return;
}
AdsMediaSource.this.eventHandler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource.ComponentListener.3
@Override // java.lang.Runnable
public void run() {
if (ComponentListener.this.released) {
return;
}
AdsMediaSource.this.eventListener.onAdTapped();
}
});
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsLoader.EventListener
public final void onAdLoadError(final AdLoadException adLoadException, DataSpec dataSpec) {
if (this.released) {
return;
}
AdsMediaSource.this.createEventDispatcher(null).loadError(dataSpec, 6, -1L, 0L, 0L, adLoadException, true);
if (AdsMediaSource.this.eventHandler == null || AdsMediaSource.this.eventListener == null) {
return;
}
AdsMediaSource.this.eventHandler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource.ComponentListener.4
@Override // java.lang.Runnable
public void run() {
if (ComponentListener.this.released) {
return;
}
if (adLoadException.type == 3) {
AdsMediaSource.this.eventListener.onInternalAdLoadError(adLoadException.getRuntimeExceptionForUnexpected());
} else {
AdsMediaSource.this.eventListener.onAdLoadError(adLoadException);
}
}
});
}
}
public final class AdPrepareErrorListener implements DeferredMediaPeriod.PrepareErrorListener {
private final int adGroupIndex;
private final int adIndexInAdGroup;
private final Uri adUri;
public AdPrepareErrorListener(Uri uri, int i, int i2) {
this.adUri = uri;
this.adGroupIndex = i;
this.adIndexInAdGroup = i2;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.DeferredMediaPeriod.PrepareErrorListener
public final void onPrepareError(MediaSource.MediaPeriodId mediaPeriodId, final IOException iOException) {
AdsMediaSource.this.createEventDispatcher(mediaPeriodId).loadError(new DataSpec(this.adUri), 6, -1L, 0L, 0L, AdLoadException.createForAd(iOException), true);
AdsMediaSource.this.mainHandler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.ads.AdsMediaSource.AdPrepareErrorListener.1
@Override // java.lang.Runnable
public void run() {
AdsMediaSource.this.adsLoader.handlePrepareError(AdPrepareErrorListener.this.adGroupIndex, AdPrepareErrorListener.this.adIndexInAdGroup, iOException);
}
});
}
}
}

View File

@@ -0,0 +1,34 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.ads;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.source.ForwardingTimeline;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
/* loaded from: classes4.dex */
final class SinglePeriodAdTimeline extends ForwardingTimeline {
private final AdPlaybackState adPlaybackState;
public SinglePeriodAdTimeline(Timeline timeline, AdPlaybackState adPlaybackState) {
super(timeline);
Assertions.checkState(timeline.getPeriodCount() == 1);
Assertions.checkState(timeline.getWindowCount() == 1);
this.adPlaybackState = adPlaybackState;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ForwardingTimeline, com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final Timeline.Period getPeriod(int i, Timeline.Period period, boolean z) {
this.timeline.getPeriod(i, period, z);
period.set(period.id, period.uid, period.windowIndex, period.durationUs, period.getPositionInWindowUs(), this.adPlaybackState);
return period;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.ForwardingTimeline, com.mbridge.msdk.playercommon.exoplayer2.Timeline
public final Timeline.Window getWindow(int i, Timeline.Window window, boolean z, long j) {
Timeline.Window window2 = super.getWindow(i, window, z, j);
if (window2.durationUs == C.TIME_UNSET) {
window2.durationUs = this.adPlaybackState.contentDurationUs;
}
return window2;
}
}

View File

@@ -0,0 +1,30 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
/* loaded from: classes4.dex */
public abstract class BaseMediaChunk extends MediaChunk {
private int[] firstSampleIndices;
private BaseMediaChunkOutput output;
public final long seekTimeUs;
public final BaseMediaChunkOutput getOutput() {
return this.output;
}
public BaseMediaChunk(DataSource dataSource, DataSpec dataSpec, Format format, int i, Object obj, long j, long j2, long j3, long j4) {
super(dataSource, dataSpec, format, i, obj, j, j2, j4);
this.seekTimeUs = j3;
}
public void init(BaseMediaChunkOutput baseMediaChunkOutput) {
this.output = baseMediaChunkOutput;
this.firstSampleIndices = baseMediaChunkOutput.getWriteIndices();
}
public final int getFirstSampleIndex(int i) {
return this.firstSampleIndices[i];
}
}

View File

@@ -0,0 +1,60 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import android.util.Log;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.DummyTrackOutput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput;
import com.mbridge.msdk.playercommon.exoplayer2.source.SampleQueue;
import com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkExtractorWrapper;
/* loaded from: classes4.dex */
public final class BaseMediaChunkOutput implements ChunkExtractorWrapper.TrackOutputProvider {
private static final String TAG = "BaseMediaChunkOutput";
private final SampleQueue[] sampleQueues;
private final int[] trackTypes;
public BaseMediaChunkOutput(int[] iArr, SampleQueue[] sampleQueueArr) {
this.trackTypes = iArr;
this.sampleQueues = sampleQueueArr;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkExtractorWrapper.TrackOutputProvider
public final TrackOutput track(int i, int i2) {
int i3 = 0;
while (true) {
int[] iArr = this.trackTypes;
if (i3 < iArr.length) {
if (i2 == iArr[i3]) {
return this.sampleQueues[i3];
}
i3++;
} else {
Log.e(TAG, "Unmatched track of type: " + i2);
return new DummyTrackOutput();
}
}
}
public final int[] getWriteIndices() {
int[] iArr = new int[this.sampleQueues.length];
int i = 0;
while (true) {
SampleQueue[] sampleQueueArr = this.sampleQueues;
if (i >= sampleQueueArr.length) {
return iArr;
}
SampleQueue sampleQueue = sampleQueueArr[i];
if (sampleQueue != null) {
iArr[i] = sampleQueue.getWriteIndex();
}
i++;
}
}
public final void setSampleOffsetUs(long j) {
for (SampleQueue sampleQueue : this.sampleQueues) {
if (sampleQueue != null) {
sampleQueue.setSampleOffsetUs(j);
}
}
}
}

View File

@@ -0,0 +1,39 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
/* loaded from: classes4.dex */
public abstract class Chunk implements Loader.Loadable {
protected final DataSource dataSource;
public final DataSpec dataSpec;
public final long endTimeUs;
public final long startTimeUs;
public final Format trackFormat;
@Nullable
public final Object trackSelectionData;
public final int trackSelectionReason;
public final int type;
public abstract long bytesLoaded();
public final long getDurationUs() {
return this.endTimeUs - this.startTimeUs;
}
public Chunk(DataSource dataSource, DataSpec dataSpec, int i, Format format, int i2, @Nullable Object obj, long j, long j2) {
this.dataSource = (DataSource) Assertions.checkNotNull(dataSource);
this.dataSpec = (DataSpec) Assertions.checkNotNull(dataSpec);
this.type = i;
this.trackFormat = format;
this.trackSelectionReason = i2;
this.trackSelectionData = obj;
this.startTimeUs = j;
this.endTimeUs = j2;
}
}

View File

@@ -0,0 +1,142 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import android.util.SparseArray;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.DummyTrackOutput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.Extractor;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorInput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorOutput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.SeekMap;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.ParsableByteArray;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class ChunkExtractorWrapper implements ExtractorOutput {
private final SparseArray<BindingTrackOutput> bindingTrackOutputs = new SparseArray<>();
public final Extractor extractor;
private boolean extractorInitialized;
private final Format primaryTrackManifestFormat;
private final int primaryTrackType;
private Format[] sampleFormats;
private SeekMap seekMap;
private TrackOutputProvider trackOutputProvider;
public interface TrackOutputProvider {
TrackOutput track(int i, int i2);
}
public final Format[] getSampleFormats() {
return this.sampleFormats;
}
public final SeekMap getSeekMap() {
return this.seekMap;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorOutput
public final void seekMap(SeekMap seekMap) {
this.seekMap = seekMap;
}
public ChunkExtractorWrapper(Extractor extractor, int i, Format format) {
this.extractor = extractor;
this.primaryTrackType = i;
this.primaryTrackManifestFormat = format;
}
public final void init(TrackOutputProvider trackOutputProvider, long j) {
this.trackOutputProvider = trackOutputProvider;
if (!this.extractorInitialized) {
this.extractor.init(this);
if (j != C.TIME_UNSET) {
this.extractor.seek(0L, j);
}
this.extractorInitialized = true;
return;
}
Extractor extractor = this.extractor;
if (j == C.TIME_UNSET) {
j = 0;
}
extractor.seek(0L, j);
for (int i = 0; i < this.bindingTrackOutputs.size(); i++) {
this.bindingTrackOutputs.valueAt(i).bind(trackOutputProvider);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorOutput
public final TrackOutput track(int i, int i2) {
BindingTrackOutput bindingTrackOutput = this.bindingTrackOutputs.get(i);
if (bindingTrackOutput == null) {
Assertions.checkState(this.sampleFormats == null);
bindingTrackOutput = new BindingTrackOutput(i, i2, i2 == this.primaryTrackType ? this.primaryTrackManifestFormat : null);
bindingTrackOutput.bind(this.trackOutputProvider);
this.bindingTrackOutputs.put(i, bindingTrackOutput);
}
return bindingTrackOutput;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorOutput
public final void endTracks() {
Format[] formatArr = new Format[this.bindingTrackOutputs.size()];
for (int i = 0; i < this.bindingTrackOutputs.size(); i++) {
formatArr[i] = this.bindingTrackOutputs.valueAt(i).sampleFormat;
}
this.sampleFormats = formatArr;
}
public static final class BindingTrackOutput implements TrackOutput {
private final int id;
private final Format manifestFormat;
public Format sampleFormat;
private TrackOutput trackOutput;
private final int type;
public BindingTrackOutput(int i, int i2, Format format) {
this.id = i;
this.type = i2;
this.manifestFormat = format;
}
public final void bind(TrackOutputProvider trackOutputProvider) {
if (trackOutputProvider == null) {
this.trackOutput = new DummyTrackOutput();
return;
}
TrackOutput track = trackOutputProvider.track(this.id, this.type);
this.trackOutput = track;
Format format = this.sampleFormat;
if (format != null) {
track.format(format);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput
public final void format(Format format) {
Format format2 = this.manifestFormat;
if (format2 != null) {
format = format.copyWithManifestFormatInfo(format2);
}
this.sampleFormat = format;
this.trackOutput.format(format);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput
public final int sampleData(ExtractorInput extractorInput, int i, boolean z) throws IOException, InterruptedException {
return this.trackOutput.sampleData(extractorInput, i, z);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput
public final void sampleData(ParsableByteArray parsableByteArray, int i) {
this.trackOutput.sampleData(parsableByteArray, i);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput
public final void sampleMetadata(long j, int i, int i2, int i3, TrackOutput.CryptoData cryptoData) {
this.trackOutput.sampleMetadata(j, i, i2, i3, cryptoData);
}
}
}

View File

@@ -0,0 +1,12 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
/* loaded from: classes4.dex */
public final class ChunkHolder {
public Chunk chunk;
public boolean endOfStream;
public final void clear() {
this.chunk = null;
this.endOfStream = false;
}
}

View File

@@ -0,0 +1,612 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.FormatHolder;
import com.mbridge.msdk.playercommon.exoplayer2.SeekParameters;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderInputBuffer;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener;
import com.mbridge.msdk.playercommon.exoplayer2.source.SampleQueue;
import com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream;
import com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader;
import com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/* loaded from: classes4.dex */
public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, SequenceableLoader, Loader.Callback<Chunk>, Loader.ReleaseCallback {
private static final String TAG = "ChunkSampleStream";
private final SequenceableLoader.Callback<ChunkSampleStream<T>> callback;
private final T chunkSource;
long decodeOnlyUntilPositionUs;
private final SampleQueue[] embeddedSampleQueues;
private final Format[] embeddedTrackFormats;
private final int[] embeddedTrackTypes;
private final boolean[] embeddedTracksSelected;
private final MediaSourceEventListener.EventDispatcher eventDispatcher;
private long lastSeekPositionUs;
boolean loadingFinished;
private final BaseMediaChunkOutput mediaChunkOutput;
private final ArrayList<BaseMediaChunk> mediaChunks;
private final int minLoadableRetryCount;
private long pendingResetPositionUs;
private Format primaryDownstreamTrackFormat;
private final SampleQueue primarySampleQueue;
public final int primaryTrackType;
private final List<BaseMediaChunk> readOnlyMediaChunks;
@Nullable
private ReleaseCallback<T> releaseCallback;
private final Loader loader = new Loader("Loader:ChunkSampleStream");
private final ChunkHolder nextChunkHolder = new ChunkHolder();
public interface ReleaseCallback<T extends ChunkSource> {
void onSampleStreamReleased(ChunkSampleStream<T> chunkSampleStream);
}
public T getChunkSource() {
return this.chunkSource;
}
public boolean isPendingReset() {
return this.pendingResetPositionUs != C.TIME_UNSET;
}
public ChunkSampleStream(int i, int[] iArr, Format[] formatArr, T t, SequenceableLoader.Callback<ChunkSampleStream<T>> callback, Allocator allocator, long j, int i2, MediaSourceEventListener.EventDispatcher eventDispatcher) {
this.primaryTrackType = i;
this.embeddedTrackTypes = iArr;
this.embeddedTrackFormats = formatArr;
this.chunkSource = t;
this.callback = callback;
this.eventDispatcher = eventDispatcher;
this.minLoadableRetryCount = i2;
ArrayList<BaseMediaChunk> arrayList = new ArrayList<>();
this.mediaChunks = arrayList;
this.readOnlyMediaChunks = Collections.unmodifiableList(arrayList);
int i3 = 0;
int length = iArr == null ? 0 : iArr.length;
this.embeddedSampleQueues = new SampleQueue[length];
this.embeddedTracksSelected = new boolean[length];
int i4 = length + 1;
int[] iArr2 = new int[i4];
SampleQueue[] sampleQueueArr = new SampleQueue[i4];
SampleQueue sampleQueue = new SampleQueue(allocator);
this.primarySampleQueue = sampleQueue;
iArr2[0] = i;
sampleQueueArr[0] = sampleQueue;
while (i3 < length) {
SampleQueue sampleQueue2 = new SampleQueue(allocator);
this.embeddedSampleQueues[i3] = sampleQueue2;
int i5 = i3 + 1;
sampleQueueArr[i5] = sampleQueue2;
iArr2[i5] = iArr[i3];
i3 = i5;
}
this.mediaChunkOutput = new BaseMediaChunkOutput(iArr2, sampleQueueArr);
this.pendingResetPositionUs = j;
this.lastSeekPositionUs = j;
}
public void discardBuffer(long j, boolean z) {
int firstIndex = this.primarySampleQueue.getFirstIndex();
this.primarySampleQueue.discardTo(j, z, true);
int firstIndex2 = this.primarySampleQueue.getFirstIndex();
if (firstIndex2 <= firstIndex) {
return;
}
long firstTimestampUs = this.primarySampleQueue.getFirstTimestampUs();
int i = 0;
while (true) {
SampleQueue[] sampleQueueArr = this.embeddedSampleQueues;
if (i < sampleQueueArr.length) {
sampleQueueArr[i].discardTo(firstTimestampUs, z, this.embeddedTracksSelected[i]);
i++;
} else {
discardDownstreamMediaChunks(firstIndex2);
return;
}
}
}
public ChunkSampleStream<T>.EmbeddedSampleStream selectEmbeddedTrack(long j, int i) {
for (int i2 = 0; i2 < this.embeddedSampleQueues.length; i2++) {
if (this.embeddedTrackTypes[i2] == i) {
Assertions.checkState(!this.embeddedTracksSelected[i2]);
this.embeddedTracksSelected[i2] = true;
this.embeddedSampleQueues[i2].rewind();
this.embeddedSampleQueues[i2].advanceTo(j, true, true);
return new EmbeddedSampleStream(this, this.embeddedSampleQueues[i2], i2);
}
}
throw new IllegalStateException();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public long getBufferedPositionUs() {
if (this.loadingFinished) {
return Long.MIN_VALUE;
}
if (isPendingReset()) {
return this.pendingResetPositionUs;
}
long j = this.lastSeekPositionUs;
BaseMediaChunk lastMediaChunk = getLastMediaChunk();
if (!lastMediaChunk.isLoadCompleted()) {
if (this.mediaChunks.size() > 1) {
lastMediaChunk = this.mediaChunks.get(r2.size() - 2);
} else {
lastMediaChunk = null;
}
}
if (lastMediaChunk != null) {
j = Math.max(j, lastMediaChunk.endTimeUs);
}
return Math.max(j, this.primarySampleQueue.getLargestQueuedTimestampUs());
}
public long getAdjustedSeekPositionUs(long j, SeekParameters seekParameters) {
return this.chunkSource.getAdjustedSeekPositionUs(j, seekParameters);
}
public void seekToUs(long j) {
BaseMediaChunk baseMediaChunk;
boolean z;
this.lastSeekPositionUs = j;
this.primarySampleQueue.rewind();
if (!isPendingReset()) {
for (int i = 0; i < this.mediaChunks.size(); i++) {
baseMediaChunk = this.mediaChunks.get(i);
long j2 = baseMediaChunk.startTimeUs;
if (j2 == j && baseMediaChunk.seekTimeUs == C.TIME_UNSET) {
break;
} else {
if (j2 > j) {
break;
}
}
}
baseMediaChunk = null;
if (baseMediaChunk != null) {
z = this.primarySampleQueue.setReadPosition(baseMediaChunk.getFirstSampleIndex(0));
this.decodeOnlyUntilPositionUs = Long.MIN_VALUE;
} else {
z = this.primarySampleQueue.advanceTo(j, true, (j > getNextLoadPositionUs() ? 1 : (j == getNextLoadPositionUs() ? 0 : -1)) < 0) != -1;
this.decodeOnlyUntilPositionUs = this.lastSeekPositionUs;
}
if (z) {
for (SampleQueue sampleQueue : this.embeddedSampleQueues) {
sampleQueue.rewind();
sampleQueue.advanceTo(j, true, false);
}
return;
}
}
this.pendingResetPositionUs = j;
this.loadingFinished = false;
this.mediaChunks.clear();
if (this.loader.isLoading()) {
this.loader.cancelLoading();
return;
}
this.primarySampleQueue.reset();
for (SampleQueue sampleQueue2 : this.embeddedSampleQueues) {
sampleQueue2.reset();
}
}
public void release() {
release(null);
}
public void release(@Nullable ReleaseCallback<T> releaseCallback) {
this.releaseCallback = releaseCallback;
this.primarySampleQueue.discardToEnd();
for (SampleQueue sampleQueue : this.embeddedSampleQueues) {
sampleQueue.discardToEnd();
}
this.loader.release(this);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.ReleaseCallback
public void onLoaderReleased() {
this.primarySampleQueue.reset();
for (SampleQueue sampleQueue : this.embeddedSampleQueues) {
sampleQueue.reset();
}
ReleaseCallback<T> releaseCallback = this.releaseCallback;
if (releaseCallback != null) {
releaseCallback.onSampleStreamReleased(this);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public boolean isReady() {
return this.loadingFinished || (!isPendingReset() && this.primarySampleQueue.hasNextSample());
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public void maybeThrowError() throws IOException {
this.loader.maybeThrowError();
if (this.loader.isLoading()) {
return;
}
this.chunkSource.maybeThrowError();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public int readData(FormatHolder formatHolder, DecoderInputBuffer decoderInputBuffer, boolean z) {
if (isPendingReset()) {
return -3;
}
int read = this.primarySampleQueue.read(formatHolder, decoderInputBuffer, z, this.loadingFinished, this.decodeOnlyUntilPositionUs);
if (read == -4) {
maybeNotifyPrimaryTrackFormatChanged(this.primarySampleQueue.getReadIndex(), 1);
}
return read;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public int skipData(long j) {
int i = 0;
if (isPendingReset()) {
return 0;
}
if (this.loadingFinished && j > this.primarySampleQueue.getLargestQueuedTimestampUs()) {
i = this.primarySampleQueue.advanceToEnd();
} else {
int advanceTo = this.primarySampleQueue.advanceTo(j, true, true);
if (advanceTo != -1) {
i = advanceTo;
}
}
if (i > 0) {
maybeNotifyPrimaryTrackFormatChanged(this.primarySampleQueue.getReadIndex(), i);
}
return i;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Callback
public void onLoadCompleted(Chunk chunk, long j, long j2) {
this.chunkSource.onChunkLoadCompleted(chunk);
this.eventDispatcher.loadCompleted(chunk.dataSpec, chunk.type, this.primaryTrackType, chunk.trackFormat, chunk.trackSelectionReason, chunk.trackSelectionData, chunk.startTimeUs, chunk.endTimeUs, j, j2, chunk.bytesLoaded());
this.callback.onContinueLoadingRequested(this);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Callback
public void onLoadCanceled(Chunk chunk, long j, long j2, boolean z) {
this.eventDispatcher.loadCanceled(chunk.dataSpec, chunk.type, this.primaryTrackType, chunk.trackFormat, chunk.trackSelectionReason, chunk.trackSelectionData, chunk.startTimeUs, chunk.endTimeUs, j, j2, chunk.bytesLoaded());
if (z) {
return;
}
this.primarySampleQueue.reset();
for (SampleQueue sampleQueue : this.embeddedSampleQueues) {
sampleQueue.reset();
}
this.callback.onContinueLoadingRequested(this);
}
/* JADX WARN: Removed duplicated region for block: B:22:0x007c */
/* JADX WARN: Removed duplicated region for block: B:25:0x0083 A[RETURN] */
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Callback
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public int onLoadError(com.mbridge.msdk.playercommon.exoplayer2.source.chunk.Chunk r24, long r25, long r27, java.io.IOException r29) {
/*
r23 = this;
r0 = r23
r1 = r24
long r17 = r24.bytesLoaded()
boolean r2 = r23.isMediaChunk(r24)
java.util.ArrayList<com.mbridge.msdk.playercommon.exoplayer2.source.chunk.BaseMediaChunk> r3 = r0.mediaChunks
int r3 = r3.size()
r4 = 1
int r3 = r3 - r4
r5 = 0
int r5 = (r17 > r5 ? 1 : (r17 == r5 ? 0 : -1))
r21 = 0
if (r5 == 0) goto L28
if (r2 == 0) goto L28
boolean r5 = r0.haveReadFromMediaChunk(r3)
if (r5 != 0) goto L25
goto L28
L25:
r5 = r21
goto L29
L28:
r5 = r4
L29:
T extends com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkSource r6 = r0.chunkSource
r15 = r29
boolean r6 = r6.onChunkLoadError(r1, r5, r15)
if (r6 == 0) goto L5b
if (r5 != 0) goto L3d
java.lang.String r2 = "ChunkSampleStream"
java.lang.String r3 = "Ignoring attempt to cancel non-cancelable load."
android.util.Log.w(r2, r3)
goto L5b
L3d:
if (r2 == 0) goto L58
com.mbridge.msdk.playercommon.exoplayer2.source.chunk.BaseMediaChunk r2 = r0.discardUpstreamMediaChunksFromIndex(r3)
if (r2 != r1) goto L47
r2 = r4
goto L49
L47:
r2 = r21
L49:
com.mbridge.msdk.playercommon.exoplayer2.util.Assertions.checkState(r2)
java.util.ArrayList<com.mbridge.msdk.playercommon.exoplayer2.source.chunk.BaseMediaChunk> r2 = r0.mediaChunks
boolean r2 = r2.isEmpty()
if (r2 == 0) goto L58
long r2 = r0.lastSeekPositionUs
r0.pendingResetPositionUs = r2
L58:
r22 = r4
goto L5d
L5b:
r22 = r21
L5d:
com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener$EventDispatcher r2 = r0.eventDispatcher
com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec r3 = r1.dataSpec
int r4 = r1.type
int r5 = r0.primaryTrackType
com.mbridge.msdk.playercommon.exoplayer2.Format r6 = r1.trackFormat
int r7 = r1.trackSelectionReason
java.lang.Object r8 = r1.trackSelectionData
long r9 = r1.startTimeUs
long r11 = r1.endTimeUs
r13 = r25
r15 = r27
r19 = r29
r20 = r22
r2.loadError(r3, r4, r5, r6, r7, r8, r9, r11, r13, r15, r17, r19, r20)
if (r22 == 0) goto L83
com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader$Callback<com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkSampleStream<T extends com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkSource>> r1 = r0.callback
r1.onContinueLoadingRequested(r0)
r1 = 2
return r1
L83:
return r21
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkSampleStream.onLoadError(com.mbridge.msdk.playercommon.exoplayer2.source.chunk.Chunk, long, long, java.io.IOException):int");
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public boolean continueLoading(long j) {
BaseMediaChunk lastMediaChunk;
long j2;
if (this.loadingFinished || this.loader.isLoading()) {
return false;
}
boolean isPendingReset = isPendingReset();
if (isPendingReset) {
j2 = this.pendingResetPositionUs;
lastMediaChunk = null;
} else {
lastMediaChunk = getLastMediaChunk();
j2 = lastMediaChunk.endTimeUs;
}
this.chunkSource.getNextChunk(lastMediaChunk, j, j2, this.nextChunkHolder);
ChunkHolder chunkHolder = this.nextChunkHolder;
boolean z = chunkHolder.endOfStream;
Chunk chunk = chunkHolder.chunk;
chunkHolder.clear();
if (z) {
this.pendingResetPositionUs = C.TIME_UNSET;
this.loadingFinished = true;
return true;
}
if (chunk == null) {
return false;
}
if (isMediaChunk(chunk)) {
BaseMediaChunk baseMediaChunk = (BaseMediaChunk) chunk;
if (isPendingReset) {
long j3 = baseMediaChunk.startTimeUs;
long j4 = this.pendingResetPositionUs;
if (j3 == j4) {
j4 = Long.MIN_VALUE;
}
this.decodeOnlyUntilPositionUs = j4;
this.pendingResetPositionUs = C.TIME_UNSET;
}
baseMediaChunk.init(this.mediaChunkOutput);
this.mediaChunks.add(baseMediaChunk);
}
this.eventDispatcher.loadStarted(chunk.dataSpec, chunk.type, this.primaryTrackType, chunk.trackFormat, chunk.trackSelectionReason, chunk.trackSelectionData, chunk.startTimeUs, chunk.endTimeUs, this.loader.startLoading(chunk, this, this.minLoadableRetryCount));
return true;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public long getNextLoadPositionUs() {
if (isPendingReset()) {
return this.pendingResetPositionUs;
}
if (this.loadingFinished) {
return Long.MIN_VALUE;
}
return getLastMediaChunk().endTimeUs;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SequenceableLoader
public void reevaluateBuffer(long j) {
int size;
int preferredQueueSize;
if (this.loader.isLoading() || isPendingReset() || (size = this.mediaChunks.size()) <= (preferredQueueSize = this.chunkSource.getPreferredQueueSize(j, this.readOnlyMediaChunks))) {
return;
}
while (true) {
if (preferredQueueSize >= size) {
preferredQueueSize = size;
break;
} else if (!haveReadFromMediaChunk(preferredQueueSize)) {
break;
} else {
preferredQueueSize++;
}
}
if (preferredQueueSize == size) {
return;
}
long j2 = getLastMediaChunk().endTimeUs;
BaseMediaChunk discardUpstreamMediaChunksFromIndex = discardUpstreamMediaChunksFromIndex(preferredQueueSize);
if (this.mediaChunks.isEmpty()) {
this.pendingResetPositionUs = this.lastSeekPositionUs;
}
this.loadingFinished = false;
this.eventDispatcher.upstreamDiscarded(this.primaryTrackType, discardUpstreamMediaChunksFromIndex.startTimeUs, j2);
}
private boolean isMediaChunk(Chunk chunk) {
return chunk instanceof BaseMediaChunk;
}
private boolean haveReadFromMediaChunk(int i) {
int readIndex;
BaseMediaChunk baseMediaChunk = this.mediaChunks.get(i);
if (this.primarySampleQueue.getReadIndex() > baseMediaChunk.getFirstSampleIndex(0)) {
return true;
}
int i2 = 0;
do {
SampleQueue[] sampleQueueArr = this.embeddedSampleQueues;
if (i2 >= sampleQueueArr.length) {
return false;
}
readIndex = sampleQueueArr[i2].getReadIndex();
i2++;
} while (readIndex <= baseMediaChunk.getFirstSampleIndex(i2));
return true;
}
private void discardDownstreamMediaChunks(int i) {
int primaryStreamIndexToMediaChunkIndex = primaryStreamIndexToMediaChunkIndex(i, 0);
if (primaryStreamIndexToMediaChunkIndex > 0) {
Util.removeRange(this.mediaChunks, 0, primaryStreamIndexToMediaChunkIndex);
}
}
private void maybeNotifyPrimaryTrackFormatChanged(int i, int i2) {
int primaryStreamIndexToMediaChunkIndex = primaryStreamIndexToMediaChunkIndex(i - i2, 0);
int primaryStreamIndexToMediaChunkIndex2 = i2 == 1 ? primaryStreamIndexToMediaChunkIndex : primaryStreamIndexToMediaChunkIndex(i - 1, primaryStreamIndexToMediaChunkIndex);
while (primaryStreamIndexToMediaChunkIndex <= primaryStreamIndexToMediaChunkIndex2) {
maybeNotifyPrimaryTrackFormatChanged(primaryStreamIndexToMediaChunkIndex);
primaryStreamIndexToMediaChunkIndex++;
}
}
private void maybeNotifyPrimaryTrackFormatChanged(int i) {
BaseMediaChunk baseMediaChunk = this.mediaChunks.get(i);
Format format = baseMediaChunk.trackFormat;
if (!format.equals(this.primaryDownstreamTrackFormat)) {
this.eventDispatcher.downstreamFormatChanged(this.primaryTrackType, format, baseMediaChunk.trackSelectionReason, baseMediaChunk.trackSelectionData, baseMediaChunk.startTimeUs);
}
this.primaryDownstreamTrackFormat = format;
}
private int primaryStreamIndexToMediaChunkIndex(int i, int i2) {
do {
i2++;
if (i2 >= this.mediaChunks.size()) {
return this.mediaChunks.size() - 1;
}
} while (this.mediaChunks.get(i2).getFirstSampleIndex(0) <= i);
return i2 - 1;
}
private BaseMediaChunk getLastMediaChunk() {
return this.mediaChunks.get(r0.size() - 1);
}
private BaseMediaChunk discardUpstreamMediaChunksFromIndex(int i) {
BaseMediaChunk baseMediaChunk = this.mediaChunks.get(i);
ArrayList<BaseMediaChunk> arrayList = this.mediaChunks;
Util.removeRange(arrayList, i, arrayList.size());
int i2 = 0;
this.primarySampleQueue.discardUpstreamSamples(baseMediaChunk.getFirstSampleIndex(0));
while (true) {
SampleQueue[] sampleQueueArr = this.embeddedSampleQueues;
if (i2 >= sampleQueueArr.length) {
return baseMediaChunk;
}
SampleQueue sampleQueue = sampleQueueArr[i2];
i2++;
sampleQueue.discardUpstreamSamples(baseMediaChunk.getFirstSampleIndex(i2));
}
}
public final class EmbeddedSampleStream implements SampleStream {
private boolean formatNotificationSent;
private final int index;
public final ChunkSampleStream<T> parent;
private final SampleQueue sampleQueue;
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final void maybeThrowError() throws IOException {
}
public EmbeddedSampleStream(ChunkSampleStream<T> chunkSampleStream, SampleQueue sampleQueue, int i) {
this.parent = chunkSampleStream;
this.sampleQueue = sampleQueue;
this.index = i;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final boolean isReady() {
ChunkSampleStream chunkSampleStream = ChunkSampleStream.this;
return chunkSampleStream.loadingFinished || (!chunkSampleStream.isPendingReset() && this.sampleQueue.hasNextSample());
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final int skipData(long j) {
int advanceTo;
if (ChunkSampleStream.this.loadingFinished && j > this.sampleQueue.getLargestQueuedTimestampUs()) {
advanceTo = this.sampleQueue.advanceToEnd();
} else {
advanceTo = this.sampleQueue.advanceTo(j, true, true);
if (advanceTo == -1) {
advanceTo = 0;
}
}
if (advanceTo > 0) {
maybeNotifyTrackFormatChanged();
}
return advanceTo;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.SampleStream
public final int readData(FormatHolder formatHolder, DecoderInputBuffer decoderInputBuffer, boolean z) {
if (ChunkSampleStream.this.isPendingReset()) {
return -3;
}
SampleQueue sampleQueue = this.sampleQueue;
ChunkSampleStream chunkSampleStream = ChunkSampleStream.this;
int read = sampleQueue.read(formatHolder, decoderInputBuffer, z, chunkSampleStream.loadingFinished, chunkSampleStream.decodeOnlyUntilPositionUs);
if (read == -4) {
maybeNotifyTrackFormatChanged();
}
return read;
}
public final void release() {
Assertions.checkState(ChunkSampleStream.this.embeddedTracksSelected[this.index]);
ChunkSampleStream.this.embeddedTracksSelected[this.index] = false;
}
private void maybeNotifyTrackFormatChanged() {
if (this.formatNotificationSent) {
return;
}
ChunkSampleStream.this.eventDispatcher.downstreamFormatChanged(ChunkSampleStream.this.embeddedTrackTypes[this.index], ChunkSampleStream.this.embeddedTrackFormats[this.index], 0, null, ChunkSampleStream.this.lastSeekPositionUs);
this.formatNotificationSent = true;
}
}
}

View File

@@ -0,0 +1,20 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import com.mbridge.msdk.playercommon.exoplayer2.SeekParameters;
import java.io.IOException;
import java.util.List;
/* loaded from: classes4.dex */
public interface ChunkSource {
long getAdjustedSeekPositionUs(long j, SeekParameters seekParameters);
void getNextChunk(MediaChunk mediaChunk, long j, long j2, ChunkHolder chunkHolder);
int getPreferredQueueSize(long j, List<? extends MediaChunk> list);
void maybeThrowError() throws IOException;
void onChunkLoadCompleted(Chunk chunk);
boolean onChunkLoadError(Chunk chunk, boolean z, Exception exc);
}

View File

@@ -0,0 +1,40 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import android.util.Log;
import com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.HttpDataSource;
/* loaded from: classes4.dex */
public final class ChunkedTrackBlacklistUtil {
public static final long DEFAULT_TRACK_BLACKLIST_MS = 60000;
private static final String TAG = "ChunkedTrackBlacklist";
private ChunkedTrackBlacklistUtil() {
}
public static boolean maybeBlacklistTrack(TrackSelection trackSelection, int i, Exception exc) {
return maybeBlacklistTrack(trackSelection, i, exc, DEFAULT_TRACK_BLACKLIST_MS);
}
public static boolean maybeBlacklistTrack(TrackSelection trackSelection, int i, Exception exc, long j) {
if (!shouldBlacklist(exc)) {
return false;
}
boolean blacklist = trackSelection.blacklist(i, j);
int i2 = ((HttpDataSource.InvalidResponseCodeException) exc).responseCode;
if (blacklist) {
Log.w(TAG, "Blacklisted: duration=" + j + ", responseCode=" + i2 + ", format=" + trackSelection.getFormat(i));
} else {
Log.w(TAG, "Blacklisting failed (cannot blacklist last enabled track): responseCode=" + i2 + ", format=" + trackSelection.getFormat(i));
}
return blacklist;
}
public static boolean shouldBlacklist(Exception exc) {
if (!(exc instanceof HttpDataSource.InvalidResponseCodeException)) {
return false;
}
int i = ((HttpDataSource.InvalidResponseCodeException) exc).responseCode;
return i == 404 || i == 410;
}
}

View File

@@ -0,0 +1,81 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.DefaultExtractorInput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.Extractor;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.io.IOException;
/* loaded from: classes4.dex */
public class ContainerMediaChunk extends BaseMediaChunk {
private volatile int bytesLoaded;
private final int chunkCount;
private final ChunkExtractorWrapper extractorWrapper;
private volatile boolean loadCanceled;
private volatile boolean loadCompleted;
private final long sampleOffsetUs;
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.chunk.Chunk
public final long bytesLoaded() {
return this.bytesLoaded;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void cancelLoad() {
this.loadCanceled = true;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.chunk.MediaChunk
public long getNextChunkIndex() {
return this.chunkIndex + this.chunkCount;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.chunk.MediaChunk
public boolean isLoadCompleted() {
return this.loadCompleted;
}
public ContainerMediaChunk(DataSource dataSource, DataSpec dataSpec, Format format, int i, Object obj, long j, long j2, long j3, long j4, int i2, long j5, ChunkExtractorWrapper chunkExtractorWrapper) {
super(dataSource, dataSpec, format, i, obj, j, j2, j3, j4);
this.chunkCount = i2;
this.sampleOffsetUs = j5;
this.extractorWrapper = chunkExtractorWrapper;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void load() throws IOException, InterruptedException {
DataSpec subrange = this.dataSpec.subrange(this.bytesLoaded);
try {
DataSource dataSource = this.dataSource;
DefaultExtractorInput defaultExtractorInput = new DefaultExtractorInput(dataSource, subrange.absoluteStreamPosition, dataSource.open(subrange));
if (this.bytesLoaded == 0) {
BaseMediaChunkOutput output = getOutput();
output.setSampleOffsetUs(this.sampleOffsetUs);
ChunkExtractorWrapper chunkExtractorWrapper = this.extractorWrapper;
long j = this.seekTimeUs;
chunkExtractorWrapper.init(output, j == C.TIME_UNSET ? 0L : j - this.sampleOffsetUs);
}
try {
Extractor extractor = this.extractorWrapper.extractor;
int i = 0;
while (i == 0 && !this.loadCanceled) {
i = extractor.read(defaultExtractorInput, null);
}
Assertions.checkState(i != 1);
this.bytesLoaded = (int) (defaultExtractorInput.getPosition() - this.dataSpec.absoluteStreamPosition);
Util.closeQuietly(this.dataSource);
this.loadCompleted = true;
} catch (Throwable th) {
this.bytesLoaded = (int) (defaultExtractorInput.getPosition() - this.dataSpec.absoluteStreamPosition);
throw th;
}
} catch (Throwable th2) {
Util.closeQuietly(this.dataSource);
throw th2;
}
}
}

View File

@@ -0,0 +1,72 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.io.IOException;
import java.util.Arrays;
/* loaded from: classes4.dex */
public abstract class DataChunk extends Chunk {
private static final int READ_GRANULARITY = 16384;
private byte[] data;
private int limit;
private volatile boolean loadCanceled;
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.chunk.Chunk
public long bytesLoaded() {
return this.limit;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void cancelLoad() {
this.loadCanceled = true;
}
public abstract void consume(byte[] bArr, int i) throws IOException;
public byte[] getDataHolder() {
return this.data;
}
public DataChunk(DataSource dataSource, DataSpec dataSpec, int i, Format format, int i2, Object obj, byte[] bArr) {
super(dataSource, dataSpec, i, format, i2, obj, C.TIME_UNSET, C.TIME_UNSET);
this.data = bArr;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void load() throws IOException, InterruptedException {
try {
this.dataSource.open(this.dataSpec);
this.limit = 0;
while (!this.loadCanceled) {
maybeExpandData();
int read = this.dataSource.read(this.data, this.limit, 16384);
if (read != -1) {
this.limit += read;
}
if (read == -1) {
break;
}
}
if (!this.loadCanceled) {
consume(this.data, this.limit);
}
Util.closeQuietly(this.dataSource);
} catch (Throwable th) {
Util.closeQuietly(this.dataSource);
throw th;
}
}
private void maybeExpandData() {
byte[] bArr = this.data;
if (bArr == null) {
this.data = new byte[16384];
} else if (bArr.length < this.limit + 16384) {
this.data = Arrays.copyOf(bArr, bArr.length + 16384);
}
}
}

View File

@@ -0,0 +1,60 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.DefaultExtractorInput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.Extractor;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class InitializationChunk extends Chunk {
private volatile int bytesLoaded;
private final ChunkExtractorWrapper extractorWrapper;
private volatile boolean loadCanceled;
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.chunk.Chunk
public final long bytesLoaded() {
return this.bytesLoaded;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void cancelLoad() {
this.loadCanceled = true;
}
public InitializationChunk(DataSource dataSource, DataSpec dataSpec, Format format, int i, @Nullable Object obj, ChunkExtractorWrapper chunkExtractorWrapper) {
super(dataSource, dataSpec, 2, format, i, obj, C.TIME_UNSET, C.TIME_UNSET);
this.extractorWrapper = chunkExtractorWrapper;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void load() throws IOException, InterruptedException {
DataSpec subrange = this.dataSpec.subrange(this.bytesLoaded);
try {
DataSource dataSource = this.dataSource;
DefaultExtractorInput defaultExtractorInput = new DefaultExtractorInput(dataSource, subrange.absoluteStreamPosition, dataSource.open(subrange));
if (this.bytesLoaded == 0) {
this.extractorWrapper.init(null, C.TIME_UNSET);
}
try {
Extractor extractor = this.extractorWrapper.extractor;
int i = 0;
while (i == 0 && !this.loadCanceled) {
i = extractor.read(defaultExtractorInput, null);
}
Assertions.checkState(i != 1);
this.bytesLoaded = (int) (defaultExtractorInput.getPosition() - this.dataSpec.absoluteStreamPosition);
} catch (Throwable th) {
this.bytesLoaded = (int) (defaultExtractorInput.getPosition() - this.dataSpec.absoluteStreamPosition);
throw th;
}
} finally {
Util.closeQuietly(this.dataSource);
}
}
}

View File

@@ -0,0 +1,27 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
/* loaded from: classes4.dex */
public abstract class MediaChunk extends Chunk {
public final long chunkIndex;
public long getNextChunkIndex() {
long j = this.chunkIndex;
if (j != -1) {
return 1 + j;
}
return -1L;
}
public abstract boolean isLoadCompleted();
public MediaChunk(DataSource dataSource, DataSpec dataSpec, Format format, int i, Object obj, long j, long j2, long j3) {
super(dataSource, dataSpec, 1, format, i, obj, j, j2);
Assertions.checkNotNull(format);
this.chunkIndex = j3;
}
}

View File

@@ -0,0 +1,62 @@
package com.mbridge.msdk.playercommon.exoplayer2.source.chunk;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.DefaultExtractorInput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSpec;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.io.IOException;
/* loaded from: classes4.dex */
public final class SingleSampleMediaChunk extends BaseMediaChunk {
private volatile int bytesLoaded;
private volatile boolean loadCompleted;
private final Format sampleFormat;
private final int trackType;
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.chunk.Chunk
public final long bytesLoaded() {
return this.bytesLoaded;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void cancelLoad() {
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.chunk.MediaChunk
public final boolean isLoadCompleted() {
return this.loadCompleted;
}
public SingleSampleMediaChunk(DataSource dataSource, DataSpec dataSpec, Format format, int i, Object obj, long j, long j2, long j3, int i2, Format format2) {
super(dataSource, dataSpec, format, i, obj, j, j2, C.TIME_UNSET, j3);
this.trackType = i2;
this.sampleFormat = format2;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.upstream.Loader.Loadable
public final void load() throws IOException, InterruptedException {
try {
long open = this.dataSource.open(this.dataSpec.subrange(this.bytesLoaded));
if (open != -1) {
open += this.bytesLoaded;
}
DefaultExtractorInput defaultExtractorInput = new DefaultExtractorInput(this.dataSource, this.bytesLoaded, open);
BaseMediaChunkOutput output = getOutput();
output.setSampleOffsetUs(0L);
TrackOutput track = output.track(0, this.trackType);
track.format(this.sampleFormat);
for (int i = 0; i != -1; i = track.sampleData(defaultExtractorInput, Integer.MAX_VALUE, true)) {
this.bytesLoaded += i;
}
track.sampleMetadata(this.startTimeUs, 1, this.bytesLoaded, 0, null);
Util.closeQuietly(this.dataSource);
this.loadCompleted = true;
} catch (Throwable th) {
Util.closeQuietly(this.dataSource);
throw th;
}
}
}