Files
rr3-apk/decompiled-community/sources/com/mbridge/msdk/playercommon/exoplayer2/DefaultLoadControl.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

209 lines
8.4 KiB
Java

package com.mbridge.msdk.playercommon.exoplayer2;
import com.mbridge.msdk.playercommon.exoplayer2.source.TrackGroupArray;
import com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelectionArray;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.Allocator;
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DefaultAllocator;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.PriorityTaskManager;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
/* loaded from: classes4.dex */
public class DefaultLoadControl implements LoadControl {
public static final int DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS = 5000;
public static final int DEFAULT_BUFFER_FOR_PLAYBACK_MS = 2500;
public static final int DEFAULT_MAX_BUFFER_MS = 50000;
public static final int DEFAULT_MIN_BUFFER_MS = 15000;
public static final boolean DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDS = true;
public static final int DEFAULT_TARGET_BUFFER_BYTES = -1;
private final DefaultAllocator allocator;
private final long bufferForPlaybackAfterRebufferUs;
private final long bufferForPlaybackUs;
private boolean isBuffering;
private final long maxBufferUs;
private final long minBufferUs;
private final boolean prioritizeTimeOverSizeThresholds;
private final PriorityTaskManager priorityTaskManager;
private final int targetBufferBytesOverwrite;
private int targetBufferSize;
@Override // com.mbridge.msdk.playercommon.exoplayer2.LoadControl
public Allocator getAllocator() {
return this.allocator;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.LoadControl
public long getBackBufferDurationUs() {
return 0L;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.LoadControl
public boolean retainBackBufferFromKeyframe() {
return false;
}
public static final class Builder {
private DefaultAllocator allocator = null;
private int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS;
private int maxBufferMs = 50000;
private int bufferForPlaybackMs = 2500;
private int bufferForPlaybackAfterRebufferMs = 5000;
private int targetBufferBytes = -1;
private boolean prioritizeTimeOverSizeThresholds = true;
private PriorityTaskManager priorityTaskManager = null;
public final Builder setAllocator(DefaultAllocator defaultAllocator) {
this.allocator = defaultAllocator;
return this;
}
public final Builder setBufferDurationsMs(int i, int i2, int i3, int i4) {
this.minBufferMs = i;
this.maxBufferMs = i2;
this.bufferForPlaybackMs = i3;
this.bufferForPlaybackAfterRebufferMs = i4;
return this;
}
public final Builder setPrioritizeTimeOverSizeThresholds(boolean z) {
this.prioritizeTimeOverSizeThresholds = z;
return this;
}
public final Builder setPriorityTaskManager(PriorityTaskManager priorityTaskManager) {
this.priorityTaskManager = priorityTaskManager;
return this;
}
public final Builder setTargetBufferBytes(int i) {
this.targetBufferBytes = i;
return this;
}
public final DefaultLoadControl createDefaultLoadControl() {
if (this.allocator == null) {
this.allocator = new DefaultAllocator(true, 65536);
}
return new DefaultLoadControl(this.allocator, this.minBufferMs, this.maxBufferMs, this.bufferForPlaybackMs, this.bufferForPlaybackAfterRebufferMs, this.targetBufferBytes, this.prioritizeTimeOverSizeThresholds, this.priorityTaskManager);
}
}
public DefaultLoadControl() {
this(new DefaultAllocator(true, 65536));
}
@Deprecated
public DefaultLoadControl(DefaultAllocator defaultAllocator) {
this(defaultAllocator, DEFAULT_MIN_BUFFER_MS, 50000, 2500, 5000, -1, true);
}
@Deprecated
public DefaultLoadControl(DefaultAllocator defaultAllocator, int i, int i2, int i3, int i4, int i5, boolean z) {
this(defaultAllocator, i, i2, i3, i4, i5, z, null);
}
@Deprecated
public DefaultLoadControl(DefaultAllocator defaultAllocator, int i, int i2, int i3, int i4, int i5, boolean z, PriorityTaskManager priorityTaskManager) {
assertGreaterOrEqual(i3, 0, "bufferForPlaybackMs", "0");
assertGreaterOrEqual(i4, 0, "bufferForPlaybackAfterRebufferMs", "0");
assertGreaterOrEqual(i, i3, "minBufferMs", "bufferForPlaybackMs");
assertGreaterOrEqual(i, i4, "minBufferMs", "bufferForPlaybackAfterRebufferMs");
assertGreaterOrEqual(i2, i, "maxBufferMs", "minBufferMs");
this.allocator = defaultAllocator;
this.minBufferUs = i * 1000;
this.maxBufferUs = i2 * 1000;
this.bufferForPlaybackUs = i3 * 1000;
this.bufferForPlaybackAfterRebufferUs = i4 * 1000;
this.targetBufferBytesOverwrite = i5;
this.prioritizeTimeOverSizeThresholds = z;
this.priorityTaskManager = priorityTaskManager;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.LoadControl
public void onPrepared() {
reset(false);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.LoadControl
public void onTracksSelected(Renderer[] rendererArr, TrackGroupArray trackGroupArray, TrackSelectionArray trackSelectionArray) {
int i = this.targetBufferBytesOverwrite;
if (i == -1) {
i = calculateTargetBufferSize(rendererArr, trackSelectionArray);
}
this.targetBufferSize = i;
this.allocator.setTargetBufferSize(i);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.LoadControl
public void onStopped() {
reset(true);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.LoadControl
public void onReleased() {
reset(true);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.LoadControl
public boolean shouldContinueLoading(long j, float f) {
boolean z;
boolean z2 = true;
boolean z3 = this.allocator.getTotalBytesAllocated() >= this.targetBufferSize;
boolean z4 = this.isBuffering;
long j2 = this.minBufferUs;
if (f > 1.0f) {
j2 = Math.min(Util.getMediaDurationForPlayoutDuration(j2, f), this.maxBufferUs);
}
if (j < j2) {
if (!this.prioritizeTimeOverSizeThresholds && z3) {
z2 = false;
}
this.isBuffering = z2;
} else if (j > this.maxBufferUs || z3) {
this.isBuffering = false;
}
PriorityTaskManager priorityTaskManager = this.priorityTaskManager;
if (priorityTaskManager != null && (z = this.isBuffering) != z4) {
if (z) {
priorityTaskManager.add(0);
} else {
priorityTaskManager.remove(0);
}
}
return this.isBuffering;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.LoadControl
public boolean shouldStartPlayback(long j, float f, boolean z) {
long playoutDurationForMediaDuration = Util.getPlayoutDurationForMediaDuration(j, f);
long j2 = z ? this.bufferForPlaybackAfterRebufferUs : this.bufferForPlaybackUs;
return j2 <= 0 || playoutDurationForMediaDuration >= j2 || (!this.prioritizeTimeOverSizeThresholds && this.allocator.getTotalBytesAllocated() >= this.targetBufferSize);
}
public int calculateTargetBufferSize(Renderer[] rendererArr, TrackSelectionArray trackSelectionArray) {
int i = 0;
for (int i2 = 0; i2 < rendererArr.length; i2++) {
if (trackSelectionArray.get(i2) != null) {
i += Util.getDefaultBufferSize(rendererArr[i2].getTrackType());
}
}
return i;
}
private void reset(boolean z) {
this.targetBufferSize = 0;
PriorityTaskManager priorityTaskManager = this.priorityTaskManager;
if (priorityTaskManager != null && this.isBuffering) {
priorityTaskManager.remove(0);
}
this.isBuffering = false;
if (z) {
this.allocator.reset();
}
}
private static void assertGreaterOrEqual(int i, int i2, String str, String str2) {
Assertions.checkArgument(i >= i2, str + " cannot be less than " + str2);
}
}