Rabbit-R1/switch port/java/sources/androidx/media3/exoplayer/source/MaskingMediaSource.java

328 lines
15 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package androidx.media3.exoplayer.source;
import androidx.media3.common.AdPlaybackState;
import androidx.media3.common.MediaItem;
import androidx.media3.common.Timeline;
import androidx.media3.common.util.Util;
import androidx.media3.exoplayer.source.MediaSource;
import androidx.media3.exoplayer.upstream.Allocator;
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
/* loaded from: classes2.dex */
public final class MaskingMediaSource extends WrappingMediaSource {
private boolean hasRealTimeline;
private boolean hasStartedPreparing;
private boolean isPrepared;
private final Timeline.Period period;
private MaskingTimeline timeline;
private MaskingMediaPeriod unpreparedMaskingMediaPeriod;
private final boolean useLazyPreparation;
private final Timeline.Window window;
public Timeline getTimeline() {
return this.timeline;
}
@Override // androidx.media3.exoplayer.source.CompositeMediaSource, androidx.media3.exoplayer.source.MediaSource
public void maybeThrowSourceInfoRefreshError() {
}
public MaskingMediaSource(MediaSource mediaSource, boolean z) {
super(mediaSource);
this.useLazyPreparation = z && mediaSource.isSingleWindow();
this.window = new Timeline.Window();
this.period = new Timeline.Period();
Timeline initialTimeline = mediaSource.getInitialTimeline();
if (initialTimeline != null) {
this.timeline = MaskingTimeline.createWithRealTimeline(initialTimeline, null, null);
this.hasRealTimeline = true;
} else {
this.timeline = MaskingTimeline.createWithPlaceholderTimeline(mediaSource.getMediaItem());
}
}
@Override // androidx.media3.exoplayer.source.WrappingMediaSource
public void prepareSourceInternal() {
if (this.useLazyPreparation) {
return;
}
this.hasStartedPreparing = true;
prepareChildSource();
}
@Override // androidx.media3.exoplayer.source.WrappingMediaSource, androidx.media3.exoplayer.source.MediaSource
public MaskingMediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator, long j) {
MaskingMediaPeriod maskingMediaPeriod = new MaskingMediaPeriod(mediaPeriodId, allocator, j);
maskingMediaPeriod.setMediaSource(this.mediaSource);
if (this.isPrepared) {
maskingMediaPeriod.createPeriod(mediaPeriodId.copyWithPeriodUid(getInternalPeriodUid(mediaPeriodId.periodUid)));
} else {
this.unpreparedMaskingMediaPeriod = maskingMediaPeriod;
if (!this.hasStartedPreparing) {
this.hasStartedPreparing = true;
prepareChildSource();
}
}
return maskingMediaPeriod;
}
@Override // androidx.media3.exoplayer.source.WrappingMediaSource, androidx.media3.exoplayer.source.MediaSource
public void releasePeriod(MediaPeriod mediaPeriod) {
((MaskingMediaPeriod) mediaPeriod).releasePeriod();
if (mediaPeriod == this.unpreparedMaskingMediaPeriod) {
this.unpreparedMaskingMediaPeriod = null;
}
}
@Override // androidx.media3.exoplayer.source.CompositeMediaSource, androidx.media3.exoplayer.source.BaseMediaSource
public void releaseSourceInternal() {
this.isPrepared = false;
this.hasStartedPreparing = false;
super.releaseSourceInternal();
}
/* JADX WARN: Removed duplicated region for block: B:12:? A[RETURN, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:27:0x008d */
/* JADX WARN: Removed duplicated region for block: B:30:0x009e */
/* JADX WARN: Removed duplicated region for block: B:31:0x0094 */
/* JADX WARN: Removed duplicated region for block: B:9:0x00bd */
@Override // androidx.media3.exoplayer.source.WrappingMediaSource
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
protected void onChildSourceInfoRefreshed(androidx.media3.common.Timeline r15) {
/*
r14 = this;
boolean r0 = r14.isPrepared
if (r0 == 0) goto L19
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r0 = r14.timeline
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r15 = r0.cloneWithUpdatedTimeline(r15)
r14.timeline = r15
androidx.media3.exoplayer.source.MaskingMediaPeriod r15 = r14.unpreparedMaskingMediaPeriod
if (r15 == 0) goto Lb0
long r0 = r15.getPreparePositionOverrideUs()
r14.setPreparePositionOverrideToUnpreparedMaskingPeriod(r0)
goto Lb0
L19:
boolean r0 = r15.isEmpty()
if (r0 == 0) goto L36
boolean r0 = r14.hasRealTimeline
if (r0 == 0) goto L2a
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r0 = r14.timeline
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r15 = r0.cloneWithUpdatedTimeline(r15)
goto L32
L2a:
java.lang.Object r0 = androidx.media3.common.Timeline.Window.SINGLE_WINDOW_UID
java.lang.Object r1 = androidx.media3.exoplayer.source.MaskingMediaSource.MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r15 = androidx.media3.exoplayer.source.MaskingMediaSource.MaskingTimeline.createWithRealTimeline(r15, r0, r1)
L32:
r14.timeline = r15
goto Lb0
L36:
androidx.media3.common.Timeline$Window r0 = r14.window
r1 = 0
r15.getWindow(r1, r0)
androidx.media3.common.Timeline$Window r0 = r14.window
long r2 = r0.getDefaultPositionUs()
androidx.media3.common.Timeline$Window r0 = r14.window
java.lang.Object r0 = r0.uid
androidx.media3.exoplayer.source.MaskingMediaPeriod r4 = r14.unpreparedMaskingMediaPeriod
if (r4 == 0) goto L74
long r4 = r4.getPreparePositionUs()
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r6 = r14.timeline
androidx.media3.exoplayer.source.MaskingMediaPeriod r7 = r14.unpreparedMaskingMediaPeriod
androidx.media3.exoplayer.source.MediaSource$MediaPeriodId r7 = r7.id
java.lang.Object r7 = r7.periodUid
androidx.media3.common.Timeline$Period r8 = r14.period
r6.getPeriodByUid(r7, r8)
androidx.media3.common.Timeline$Period r6 = r14.period
long r6 = r6.getPositionInWindowUs()
long r6 = r6 + r4
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r4 = r14.timeline
androidx.media3.common.Timeline$Window r5 = r14.window
androidx.media3.common.Timeline$Window r1 = r4.getWindow(r1, r5)
long r4 = r1.getDefaultPositionUs()
int r1 = (r6 > r4 ? 1 : (r6 == r4 ? 0 : -1))
if (r1 == 0) goto L74
r12 = r6
goto L75
L74:
r12 = r2
L75:
androidx.media3.common.Timeline$Window r9 = r14.window
androidx.media3.common.Timeline$Period r10 = r14.period
r11 = 0
r8 = r15
android.util.Pair r1 = r8.getPeriodPositionUs(r9, r10, r11, r12)
java.lang.Object r2 = r1.first
java.lang.Object r1 = r1.second
java.lang.Long r1 = (java.lang.Long) r1
long r3 = r1.longValue()
boolean r1 = r14.hasRealTimeline
if (r1 == 0) goto L94
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r0 = r14.timeline
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r15 = r0.cloneWithUpdatedTimeline(r15)
goto L98
L94:
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r15 = androidx.media3.exoplayer.source.MaskingMediaSource.MaskingTimeline.createWithRealTimeline(r15, r0, r2)
L98:
r14.timeline = r15
androidx.media3.exoplayer.source.MaskingMediaPeriod r15 = r14.unpreparedMaskingMediaPeriod
if (r15 == 0) goto Lb0
r14.setPreparePositionOverrideToUnpreparedMaskingPeriod(r3)
androidx.media3.exoplayer.source.MediaSource$MediaPeriodId r0 = r15.id
androidx.media3.exoplayer.source.MediaSource$MediaPeriodId r15 = r15.id
java.lang.Object r15 = r15.periodUid
java.lang.Object r15 = r14.getInternalPeriodUid(r15)
androidx.media3.exoplayer.source.MediaSource$MediaPeriodId r15 = r0.copyWithPeriodUid(r15)
goto Lb1
Lb0:
r15 = 0
Lb1:
r0 = 1
r14.hasRealTimeline = r0
r14.isPrepared = r0
androidx.media3.exoplayer.source.MaskingMediaSource$MaskingTimeline r0 = r14.timeline
r14.refreshSourceInfo(r0)
if (r15 == 0) goto Lc8
androidx.media3.exoplayer.source.MaskingMediaPeriod r14 = r14.unpreparedMaskingMediaPeriod
java.lang.Object r14 = androidx.media3.common.util.Assertions.checkNotNull(r14)
androidx.media3.exoplayer.source.MaskingMediaPeriod r14 = (androidx.media3.exoplayer.source.MaskingMediaPeriod) r14
r14.createPeriod(r15)
Lc8:
return
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.media3.exoplayer.source.MaskingMediaSource.onChildSourceInfoRefreshed(androidx.media3.common.Timeline):void");
}
@Override // androidx.media3.exoplayer.source.WrappingMediaSource
protected MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(MediaSource.MediaPeriodId mediaPeriodId) {
return mediaPeriodId.copyWithPeriodUid(getExternalPeriodUid(mediaPeriodId.periodUid));
}
private Object getInternalPeriodUid(Object obj) {
return (this.timeline.replacedInternalPeriodUid == null || !obj.equals(MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID)) ? obj : this.timeline.replacedInternalPeriodUid;
}
private Object getExternalPeriodUid(Object obj) {
return (this.timeline.replacedInternalPeriodUid == null || !this.timeline.replacedInternalPeriodUid.equals(obj)) ? obj : MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID;
}
@RequiresNonNull({"unpreparedMaskingMediaPeriod"})
private void setPreparePositionOverrideToUnpreparedMaskingPeriod(long j) {
MaskingMediaPeriod maskingMediaPeriod = this.unpreparedMaskingMediaPeriod;
int indexOfPeriod = this.timeline.getIndexOfPeriod(maskingMediaPeriod.id.periodUid);
if (indexOfPeriod == -1) {
return;
}
long j2 = this.timeline.getPeriod(indexOfPeriod, this.period).durationUs;
if (j2 != -9223372036854775807L && j >= j2) {
j = Math.max(0L, j2 - 1);
}
maskingMediaPeriod.overridePreparePositionUs(j);
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static final class MaskingTimeline extends ForwardingTimeline {
public static final Object MASKING_EXTERNAL_PERIOD_UID = new Object();
private final Object replacedInternalPeriodUid;
private final Object replacedInternalWindowUid;
public static MaskingTimeline createWithPlaceholderTimeline(MediaItem mediaItem) {
return new MaskingTimeline(new PlaceholderTimeline(mediaItem), Timeline.Window.SINGLE_WINDOW_UID, MASKING_EXTERNAL_PERIOD_UID);
}
public static MaskingTimeline createWithRealTimeline(Timeline timeline, Object obj, Object obj2) {
return new MaskingTimeline(timeline, obj, obj2);
}
private MaskingTimeline(Timeline timeline, Object obj, Object obj2) {
super(timeline);
this.replacedInternalWindowUid = obj;
this.replacedInternalPeriodUid = obj2;
}
public MaskingTimeline cloneWithUpdatedTimeline(Timeline timeline) {
return new MaskingTimeline(timeline, this.replacedInternalWindowUid, this.replacedInternalPeriodUid);
}
@Override // androidx.media3.exoplayer.source.ForwardingTimeline, androidx.media3.common.Timeline
public Timeline.Window getWindow(int i, Timeline.Window window, long j) {
this.timeline.getWindow(i, window, j);
if (Util.areEqual(window.uid, this.replacedInternalWindowUid)) {
window.uid = Timeline.Window.SINGLE_WINDOW_UID;
}
return window;
}
@Override // androidx.media3.exoplayer.source.ForwardingTimeline, androidx.media3.common.Timeline
public Timeline.Period getPeriod(int i, Timeline.Period period, boolean z) {
this.timeline.getPeriod(i, period, z);
if (Util.areEqual(period.uid, this.replacedInternalPeriodUid) && z) {
period.uid = MASKING_EXTERNAL_PERIOD_UID;
}
return period;
}
@Override // androidx.media3.exoplayer.source.ForwardingTimeline, androidx.media3.common.Timeline
public int getIndexOfPeriod(Object obj) {
Object obj2;
Timeline timeline = this.timeline;
if (MASKING_EXTERNAL_PERIOD_UID.equals(obj) && (obj2 = this.replacedInternalPeriodUid) != null) {
obj = obj2;
}
return timeline.getIndexOfPeriod(obj);
}
@Override // androidx.media3.exoplayer.source.ForwardingTimeline, androidx.media3.common.Timeline
public Object getUidOfPeriod(int i) {
Object uidOfPeriod = this.timeline.getUidOfPeriod(i);
return Util.areEqual(uidOfPeriod, this.replacedInternalPeriodUid) ? MASKING_EXTERNAL_PERIOD_UID : uidOfPeriod;
}
}
/* loaded from: classes2.dex */
public static final class PlaceholderTimeline extends Timeline {
private final MediaItem mediaItem;
@Override // androidx.media3.common.Timeline
public int getPeriodCount() {
return 1;
}
@Override // androidx.media3.common.Timeline
public int getWindowCount() {
return 1;
}
public PlaceholderTimeline(MediaItem mediaItem) {
this.mediaItem = mediaItem;
}
@Override // androidx.media3.common.Timeline
public Timeline.Window getWindow(int i, Timeline.Window window, long j) {
window.set(Timeline.Window.SINGLE_WINDOW_UID, this.mediaItem, null, -9223372036854775807L, -9223372036854775807L, -9223372036854775807L, false, true, null, 0L, -9223372036854775807L, 0, 0, 0L);
window.isPlaceholder = true;
return window;
}
@Override // androidx.media3.common.Timeline
public Timeline.Period getPeriod(int i, Timeline.Period period, boolean z) {
period.set(z ? 0 : null, z ? MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID : null, 0, -9223372036854775807L, 0L, AdPlaybackState.NONE, true);
return period;
}
@Override // androidx.media3.common.Timeline
public int getIndexOfPeriod(Object obj) {
return obj == MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID ? 0 : -1;
}
@Override // androidx.media3.common.Timeline
public Object getUidOfPeriod(int i) {
return MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID;
}
}
}