alexandroid/decompiled/jadx/sources/com/google/android/exoplayer2/AbstractConcatenatedTimeline.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

218 lines
9.2 KiB
Java

package com.google.android.exoplayer2;
import android.util.Pair;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.ShuffleOrder;
import com.google.android.exoplayer2.util.Assertions;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes7.dex */
public abstract class AbstractConcatenatedTimeline extends Timeline {
private final int childCount;
private final boolean isAtomic;
private final ShuffleOrder shuffleOrder;
public AbstractConcatenatedTimeline(boolean z, ShuffleOrder shuffleOrder) {
this.isAtomic = z;
this.shuffleOrder = shuffleOrder;
this.childCount = shuffleOrder.getLength();
}
public static Object getChildPeriodUidFromConcatenatedUid(Object obj) {
return ((Pair) obj).second;
}
public static Object getChildTimelineUidFromConcatenatedUid(Object obj) {
return ((Pair) obj).first;
}
public static Object getConcatenatedUid(Object obj, Object obj2) {
return Pair.create(obj, obj2);
}
private int getNextChildIndex(int i, boolean z) {
if (z) {
return this.shuffleOrder.getNextIndex(i);
}
if (i < this.childCount - 1) {
return i + 1;
}
return -1;
}
private int getPreviousChildIndex(int i, boolean z) {
if (z) {
return this.shuffleOrder.getPreviousIndex(i);
}
if (i > 0) {
return i - 1;
}
return -1;
}
public abstract int getChildIndexByChildUid(Object obj);
public abstract int getChildIndexByPeriodIndex(int i);
public abstract int getChildIndexByWindowIndex(int i);
public abstract Object getChildUidByChildIndex(int i);
public abstract int getFirstPeriodIndexByChildIndex(int i);
@Override // com.google.android.exoplayer2.Timeline
public int getFirstWindowIndex(boolean z) {
if (this.childCount == 0) {
return -1;
}
if (this.isAtomic) {
z = false;
}
int firstIndex = z ? this.shuffleOrder.getFirstIndex() : 0;
while (getTimelineByChildIndex(firstIndex).isEmpty()) {
firstIndex = getNextChildIndex(firstIndex, z);
if (firstIndex == -1) {
return -1;
}
}
return getTimelineByChildIndex(firstIndex).getFirstWindowIndex(z) + getFirstWindowIndexByChildIndex(firstIndex);
}
public abstract int getFirstWindowIndexByChildIndex(int i);
@Override // com.google.android.exoplayer2.Timeline
public final int getIndexOfPeriod(Object obj) {
int indexOfPeriod;
if (!(obj instanceof Pair)) {
return -1;
}
Object childTimelineUidFromConcatenatedUid = getChildTimelineUidFromConcatenatedUid(obj);
Object childPeriodUidFromConcatenatedUid = getChildPeriodUidFromConcatenatedUid(obj);
int childIndexByChildUid = getChildIndexByChildUid(childTimelineUidFromConcatenatedUid);
if (childIndexByChildUid == -1 || (indexOfPeriod = getTimelineByChildIndex(childIndexByChildUid).getIndexOfPeriod(childPeriodUidFromConcatenatedUid)) == -1) {
return -1;
}
return getFirstPeriodIndexByChildIndex(childIndexByChildUid) + indexOfPeriod;
}
@Override // com.google.android.exoplayer2.Timeline
public int getLastWindowIndex(boolean z) {
int i = this.childCount;
if (i == 0) {
return -1;
}
if (this.isAtomic) {
z = false;
}
int lastIndex = z ? this.shuffleOrder.getLastIndex() : i - 1;
while (getTimelineByChildIndex(lastIndex).isEmpty()) {
lastIndex = getPreviousChildIndex(lastIndex, z);
if (lastIndex == -1) {
return -1;
}
}
return getTimelineByChildIndex(lastIndex).getLastWindowIndex(z) + getFirstWindowIndexByChildIndex(lastIndex);
}
@Override // com.google.android.exoplayer2.Timeline
public int getNextWindowIndex(int i, int i2, boolean z) {
if (this.isAtomic) {
if (i2 == 1) {
i2 = 2;
}
z = false;
}
int childIndexByWindowIndex = getChildIndexByWindowIndex(i);
int firstWindowIndexByChildIndex = getFirstWindowIndexByChildIndex(childIndexByWindowIndex);
int nextWindowIndex = getTimelineByChildIndex(childIndexByWindowIndex).getNextWindowIndex(i - firstWindowIndexByChildIndex, i2 != 2 ? i2 : 0, z);
if (nextWindowIndex != -1) {
return firstWindowIndexByChildIndex + nextWindowIndex;
}
int nextChildIndex = getNextChildIndex(childIndexByWindowIndex, z);
while (nextChildIndex != -1 && getTimelineByChildIndex(nextChildIndex).isEmpty()) {
nextChildIndex = getNextChildIndex(nextChildIndex, z);
}
if (nextChildIndex != -1) {
return getTimelineByChildIndex(nextChildIndex).getFirstWindowIndex(z) + getFirstWindowIndexByChildIndex(nextChildIndex);
}
if (i2 == 2) {
return getFirstWindowIndex(z);
}
return -1;
}
@Override // com.google.android.exoplayer2.Timeline
public final Timeline.Period getPeriod(int i, Timeline.Period period, boolean z) {
int childIndexByPeriodIndex = getChildIndexByPeriodIndex(i);
int firstWindowIndexByChildIndex = getFirstWindowIndexByChildIndex(childIndexByPeriodIndex);
getTimelineByChildIndex(childIndexByPeriodIndex).getPeriod(i - getFirstPeriodIndexByChildIndex(childIndexByPeriodIndex), period, z);
period.windowIndex += firstWindowIndexByChildIndex;
if (z) {
period.uid = getConcatenatedUid(getChildUidByChildIndex(childIndexByPeriodIndex), Assertions.checkNotNull(period.uid));
}
return period;
}
@Override // com.google.android.exoplayer2.Timeline
public final Timeline.Period getPeriodByUid(Object obj, Timeline.Period period) {
Object childTimelineUidFromConcatenatedUid = getChildTimelineUidFromConcatenatedUid(obj);
Object childPeriodUidFromConcatenatedUid = getChildPeriodUidFromConcatenatedUid(obj);
int childIndexByChildUid = getChildIndexByChildUid(childTimelineUidFromConcatenatedUid);
int firstWindowIndexByChildIndex = getFirstWindowIndexByChildIndex(childIndexByChildUid);
getTimelineByChildIndex(childIndexByChildUid).getPeriodByUid(childPeriodUidFromConcatenatedUid, period);
period.windowIndex += firstWindowIndexByChildIndex;
period.uid = obj;
return period;
}
@Override // com.google.android.exoplayer2.Timeline
public int getPreviousWindowIndex(int i, int i2, boolean z) {
if (this.isAtomic) {
if (i2 == 1) {
i2 = 2;
}
z = false;
}
int childIndexByWindowIndex = getChildIndexByWindowIndex(i);
int firstWindowIndexByChildIndex = getFirstWindowIndexByChildIndex(childIndexByWindowIndex);
int previousWindowIndex = getTimelineByChildIndex(childIndexByWindowIndex).getPreviousWindowIndex(i - firstWindowIndexByChildIndex, i2 != 2 ? i2 : 0, z);
if (previousWindowIndex != -1) {
return firstWindowIndexByChildIndex + previousWindowIndex;
}
int previousChildIndex = getPreviousChildIndex(childIndexByWindowIndex, z);
while (previousChildIndex != -1 && getTimelineByChildIndex(previousChildIndex).isEmpty()) {
previousChildIndex = getPreviousChildIndex(previousChildIndex, z);
}
if (previousChildIndex != -1) {
return getTimelineByChildIndex(previousChildIndex).getLastWindowIndex(z) + getFirstWindowIndexByChildIndex(previousChildIndex);
}
if (i2 == 2) {
return getLastWindowIndex(z);
}
return -1;
}
public abstract Timeline getTimelineByChildIndex(int i);
@Override // com.google.android.exoplayer2.Timeline
public final Object getUidOfPeriod(int i) {
int childIndexByPeriodIndex = getChildIndexByPeriodIndex(i);
return getConcatenatedUid(getChildUidByChildIndex(childIndexByPeriodIndex), getTimelineByChildIndex(childIndexByPeriodIndex).getUidOfPeriod(i - getFirstPeriodIndexByChildIndex(childIndexByPeriodIndex)));
}
@Override // com.google.android.exoplayer2.Timeline
public final Timeline.Window getWindow(int i, Timeline.Window window, long j) {
int childIndexByWindowIndex = getChildIndexByWindowIndex(i);
int firstWindowIndexByChildIndex = getFirstWindowIndexByChildIndex(childIndexByWindowIndex);
int firstPeriodIndexByChildIndex = getFirstPeriodIndexByChildIndex(childIndexByWindowIndex);
getTimelineByChildIndex(childIndexByWindowIndex).getWindow(i - firstWindowIndexByChildIndex, window, j);
Object childUidByChildIndex = getChildUidByChildIndex(childIndexByWindowIndex);
if (!Timeline.Window.SINGLE_WINDOW_UID.equals(window.uid)) {
childUidByChildIndex = getConcatenatedUid(childUidByChildIndex, window.uid);
}
window.uid = childUidByChildIndex;
window.firstPeriodIndex += firstPeriodIndexByChildIndex;
window.lastPeriodIndex += firstPeriodIndexByChildIndex;
return window;
}
}