- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
162 lines
5.5 KiB
Java
162 lines
5.5 KiB
Java
package com.mbridge.msdk.playercommon.exoplayer2.trackselection;
|
|
|
|
import android.os.SystemClock;
|
|
import androidx.annotation.Nullable;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.Format;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.source.TrackGroup;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.source.chunk.MediaChunk;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
|
|
import java.util.Arrays;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public abstract class BaseTrackSelection implements TrackSelection {
|
|
private final long[] blacklistUntilTimes;
|
|
private final Format[] formats;
|
|
protected final TrackGroup group;
|
|
private int hashCode;
|
|
protected final int length;
|
|
protected final int[] tracks;
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public void disable() {
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public void enable() {
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public final TrackGroup getTrackGroup() {
|
|
return this.group;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public void onPlaybackSpeed(float f) {
|
|
}
|
|
|
|
public BaseTrackSelection(TrackGroup trackGroup, int... iArr) {
|
|
int i = 0;
|
|
Assertions.checkState(iArr.length > 0);
|
|
this.group = (TrackGroup) Assertions.checkNotNull(trackGroup);
|
|
int length = iArr.length;
|
|
this.length = length;
|
|
this.formats = new Format[length];
|
|
for (int i2 = 0; i2 < iArr.length; i2++) {
|
|
this.formats[i2] = trackGroup.getFormat(iArr[i2]);
|
|
}
|
|
Arrays.sort(this.formats, new DecreasingBandwidthComparator());
|
|
this.tracks = new int[this.length];
|
|
while (true) {
|
|
int i3 = this.length;
|
|
if (i < i3) {
|
|
this.tracks[i] = trackGroup.indexOf(this.formats[i]);
|
|
i++;
|
|
} else {
|
|
this.blacklistUntilTimes = new long[i3];
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public final int length() {
|
|
return this.tracks.length;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public final Format getFormat(int i) {
|
|
return this.formats[i];
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public final int getIndexInTrackGroup(int i) {
|
|
return this.tracks[i];
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public final int indexOf(Format format) {
|
|
for (int i = 0; i < this.length; i++) {
|
|
if (this.formats[i] == format) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public final int indexOf(int i) {
|
|
for (int i2 = 0; i2 < this.length; i2++) {
|
|
if (this.tracks[i2] == i) {
|
|
return i2;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public final Format getSelectedFormat() {
|
|
return this.formats[getSelectedIndex()];
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public final int getSelectedIndexInTrackGroup() {
|
|
return this.tracks[getSelectedIndex()];
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public int evaluateQueueSize(long j, List<? extends MediaChunk> list) {
|
|
return list.size();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.trackselection.TrackSelection
|
|
public final boolean blacklist(int i, long j) {
|
|
long elapsedRealtime = SystemClock.elapsedRealtime();
|
|
boolean isBlacklisted = isBlacklisted(i, elapsedRealtime);
|
|
int i2 = 0;
|
|
while (i2 < this.length && !isBlacklisted) {
|
|
isBlacklisted = (i2 == i || isBlacklisted(i2, elapsedRealtime)) ? false : true;
|
|
i2++;
|
|
}
|
|
if (!isBlacklisted) {
|
|
return false;
|
|
}
|
|
long[] jArr = this.blacklistUntilTimes;
|
|
jArr[i] = Math.max(jArr[i], elapsedRealtime + j);
|
|
return true;
|
|
}
|
|
|
|
public final boolean isBlacklisted(int i, long j) {
|
|
return this.blacklistUntilTimes[i] > j;
|
|
}
|
|
|
|
public int hashCode() {
|
|
if (this.hashCode == 0) {
|
|
this.hashCode = (System.identityHashCode(this.group) * 31) + Arrays.hashCode(this.tracks);
|
|
}
|
|
return this.hashCode;
|
|
}
|
|
|
|
public boolean equals(@Nullable Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (obj == null || getClass() != obj.getClass()) {
|
|
return false;
|
|
}
|
|
BaseTrackSelection baseTrackSelection = (BaseTrackSelection) obj;
|
|
return this.group == baseTrackSelection.group && Arrays.equals(this.tracks, baseTrackSelection.tracks);
|
|
}
|
|
|
|
public static final class DecreasingBandwidthComparator implements Comparator<Format> {
|
|
private DecreasingBandwidthComparator() {
|
|
}
|
|
|
|
@Override // java.util.Comparator
|
|
public final int compare(Format format, Format format2) {
|
|
return format2.bitrate - format.bitrate;
|
|
}
|
|
}
|
|
}
|