Files
rr3-apk/decompiled-community/sources/com/mbridge/msdk/playercommon/exoplayer2/source/ClippingMediaSource.java
Daniel Elliott c080f0d97f 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
2026-02-18 15:48:36 -08:00

245 lines
11 KiB
Java

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);
}
}
}