mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-26 17:12:31 -06:00
142 lines
5.1 KiB
Java
142 lines
5.1 KiB
Java
package androidx.media3.common;
|
|
|
|
import android.os.Bundle;
|
|
import android.os.Parcelable;
|
|
import androidx.media3.common.Bundleable;
|
|
import androidx.media3.common.util.Assertions;
|
|
import androidx.media3.common.util.BundleableUtil;
|
|
import androidx.media3.common.util.Log;
|
|
import androidx.media3.common.util.Util;
|
|
import com.google.common.collect.ImmutableList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class TrackGroup implements Bundleable {
|
|
private static final String TAG = "TrackGroup";
|
|
private final Format[] formats;
|
|
private int hashCode;
|
|
public final String id;
|
|
public final int length;
|
|
public final int type;
|
|
private static final String FIELD_FORMATS = Util.intToStringMaxRadix(0);
|
|
private static final String FIELD_ID = Util.intToStringMaxRadix(1);
|
|
public static final Bundleable.Creator<TrackGroup> CREATOR = new Bundleable.Creator() { // from class: androidx.media3.common.TrackGroup$$ExternalSyntheticLambda0
|
|
@Override // androidx.media3.common.Bundleable.Creator
|
|
public final Bundleable fromBundle(Bundle bundle) {
|
|
return TrackGroup.lambda$static$0(bundle);
|
|
}
|
|
};
|
|
|
|
private static int normalizeRoleFlags(int i) {
|
|
return i | 16384;
|
|
}
|
|
|
|
public TrackGroup(Format... formatArr) {
|
|
this("", formatArr);
|
|
}
|
|
|
|
public TrackGroup(String str, Format... formatArr) {
|
|
Assertions.checkArgument(formatArr.length > 0);
|
|
this.id = str;
|
|
this.formats = formatArr;
|
|
this.length = formatArr.length;
|
|
int trackType = MimeTypes.getTrackType(formatArr[0].sampleMimeType);
|
|
this.type = trackType == -1 ? MimeTypes.getTrackType(formatArr[0].containerMimeType) : trackType;
|
|
verifyCorrectness();
|
|
}
|
|
|
|
public TrackGroup copyWithId(String str) {
|
|
return new TrackGroup(str, this.formats);
|
|
}
|
|
|
|
public Format getFormat(int i) {
|
|
return this.formats[i];
|
|
}
|
|
|
|
public 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 int hashCode() {
|
|
if (this.hashCode == 0) {
|
|
this.hashCode = ((527 + this.id.hashCode()) * 31) + Arrays.hashCode(this.formats);
|
|
}
|
|
return this.hashCode;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (obj == null || getClass() != obj.getClass()) {
|
|
return false;
|
|
}
|
|
TrackGroup trackGroup = (TrackGroup) obj;
|
|
return this.id.equals(trackGroup.id) && Arrays.equals(this.formats, trackGroup.formats);
|
|
}
|
|
|
|
@Override // androidx.media3.common.Bundleable
|
|
public Bundle toBundle() {
|
|
Bundle bundle = new Bundle();
|
|
ArrayList<? extends Parcelable> arrayList = new ArrayList<>(this.formats.length);
|
|
for (Format format : this.formats) {
|
|
arrayList.add(format.toBundle(true));
|
|
}
|
|
bundle.putParcelableArrayList(FIELD_FORMATS, arrayList);
|
|
bundle.putString(FIELD_ID, this.id);
|
|
return bundle;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static /* synthetic */ TrackGroup lambda$static$0(Bundle bundle) {
|
|
ImmutableList fromBundleList;
|
|
ArrayList parcelableArrayList = bundle.getParcelableArrayList(FIELD_FORMATS);
|
|
if (parcelableArrayList == null) {
|
|
fromBundleList = ImmutableList.of();
|
|
} else {
|
|
fromBundleList = BundleableUtil.fromBundleList(Format.CREATOR, parcelableArrayList);
|
|
}
|
|
return new TrackGroup(bundle.getString(FIELD_ID, ""), (Format[]) fromBundleList.toArray(new Format[0]));
|
|
}
|
|
|
|
private void verifyCorrectness() {
|
|
String normalizeLanguage = normalizeLanguage(this.formats[0].language);
|
|
int normalizeRoleFlags = normalizeRoleFlags(this.formats[0].roleFlags);
|
|
int i = 1;
|
|
while (true) {
|
|
Format[] formatArr = this.formats;
|
|
if (i >= formatArr.length) {
|
|
return;
|
|
}
|
|
if (!normalizeLanguage.equals(normalizeLanguage(formatArr[i].language))) {
|
|
logErrorMessage("languages", this.formats[0].language, this.formats[i].language, i);
|
|
return;
|
|
} else {
|
|
if (normalizeRoleFlags != normalizeRoleFlags(this.formats[i].roleFlags)) {
|
|
logErrorMessage("role flags", Integer.toBinaryString(this.formats[0].roleFlags), Integer.toBinaryString(this.formats[i].roleFlags), i);
|
|
return;
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static String normalizeLanguage(String str) {
|
|
return (str == null || str.equals("und")) ? "" : str;
|
|
}
|
|
|
|
private static void logErrorMessage(String str, String str2, String str3, int i) {
|
|
Log.e(TAG, "", new IllegalStateException("Different " + str + " combined in one TrackGroup: '" + str2 + "' (track 0) and '" + str3 + "' (track " + i + ")"));
|
|
}
|
|
}
|