Rabbit-R1/android (non root)/java/sources/androidx/media3/exoplayer/source/ConcatenatingMediaSource.java
2024-05-21 17:08:36 -04:00

713 lines
31 KiB
Java

package androidx.media3.exoplayer.source;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import androidx.media3.common.MediaItem;
import androidx.media3.common.Timeline;
import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.Util;
import androidx.media3.datasource.TransferListener;
import androidx.media3.exoplayer.AbstractConcatenatedTimeline;
import androidx.media3.exoplayer.source.MediaSource;
import androidx.media3.exoplayer.source.ShuffleOrder;
import androidx.media3.exoplayer.upstream.Allocator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/* loaded from: classes2.dex */
public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHolder> {
private static final int MSG_ADD = 0;
private static final int MSG_MOVE = 2;
private static final int MSG_ON_COMPLETION = 5;
private static final int MSG_REMOVE = 1;
private static final int MSG_SET_SHUFFLE_ORDER = 3;
private static final int MSG_UPDATE_TIMELINE = 4;
private static final MediaItem PLACEHOLDER_MEDIA_ITEM = new MediaItem.Builder().setUri(Uri.EMPTY).build();
private final Set<MediaSourceHolder> enabledMediaSourceHolders;
private final boolean isAtomic;
private final IdentityHashMap<MediaPeriod, MediaSourceHolder> mediaSourceByMediaPeriod;
private final Map<Object, MediaSourceHolder> mediaSourceByUid;
private final List<MediaSourceHolder> mediaSourceHolders;
private final List<MediaSourceHolder> mediaSourcesPublic;
private Set<HandlerAndRunnable> nextTimelineUpdateOnCompletionActions;
private final Set<HandlerAndRunnable> pendingOnCompletionActions;
private Handler playbackThreadHandler;
private ShuffleOrder shuffleOrder;
private boolean timelineUpdateScheduled;
private final boolean useLazyPreparation;
@Override // androidx.media3.exoplayer.source.CompositeMediaSource, androidx.media3.exoplayer.source.BaseMediaSource
protected void enableInternal() {
}
@Override // androidx.media3.exoplayer.source.MediaSource
public MediaItem getMediaItem() {
return PLACEHOLDER_MEDIA_ITEM;
}
@Override // androidx.media3.exoplayer.source.MediaSource
public boolean isSingleWindow() {
return false;
}
public ConcatenatingMediaSource(MediaSource... mediaSourceArr) {
this(false, mediaSourceArr);
}
public ConcatenatingMediaSource(boolean z, MediaSource... mediaSourceArr) {
this(z, new ShuffleOrder.DefaultShuffleOrder(0), mediaSourceArr);
}
public ConcatenatingMediaSource(boolean z, ShuffleOrder shuffleOrder, MediaSource... mediaSourceArr) {
this(z, false, shuffleOrder, mediaSourceArr);
}
public ConcatenatingMediaSource(boolean z, boolean z2, ShuffleOrder shuffleOrder, MediaSource... mediaSourceArr) {
for (MediaSource mediaSource : mediaSourceArr) {
Assertions.checkNotNull(mediaSource);
}
this.shuffleOrder = shuffleOrder.getLength() > 0 ? shuffleOrder.cloneAndClear() : shuffleOrder;
this.mediaSourceByMediaPeriod = new IdentityHashMap<>();
this.mediaSourceByUid = new HashMap();
this.mediaSourcesPublic = new ArrayList();
this.mediaSourceHolders = new ArrayList();
this.nextTimelineUpdateOnCompletionActions = new HashSet();
this.pendingOnCompletionActions = new HashSet();
this.enabledMediaSourceHolders = new HashSet();
this.isAtomic = z;
this.useLazyPreparation = z2;
addMediaSources(Arrays.asList(mediaSourceArr));
}
@Override // androidx.media3.exoplayer.source.MediaSource
public synchronized Timeline getInitialTimeline() {
return new ConcatenatedTimeline(this.mediaSourcesPublic, this.shuffleOrder.getLength() != this.mediaSourcesPublic.size() ? this.shuffleOrder.cloneAndClear().cloneAndInsert(0, this.mediaSourcesPublic.size()) : this.shuffleOrder, this.isAtomic);
}
public synchronized void addMediaSource(MediaSource mediaSource) {
addMediaSource(this.mediaSourcesPublic.size(), mediaSource);
}
public synchronized void addMediaSource(MediaSource mediaSource, Handler handler, Runnable runnable) {
addMediaSource(this.mediaSourcesPublic.size(), mediaSource, handler, runnable);
}
public synchronized void addMediaSource(int i, MediaSource mediaSource) {
addPublicMediaSources(i, Collections.singletonList(mediaSource), null, null);
}
public synchronized void addMediaSource(int i, MediaSource mediaSource, Handler handler, Runnable runnable) {
addPublicMediaSources(i, Collections.singletonList(mediaSource), handler, runnable);
}
public synchronized void addMediaSources(Collection<MediaSource> collection) {
addPublicMediaSources(this.mediaSourcesPublic.size(), collection, null, null);
}
public synchronized void addMediaSources(Collection<MediaSource> collection, Handler handler, Runnable runnable) {
addPublicMediaSources(this.mediaSourcesPublic.size(), collection, handler, runnable);
}
public synchronized void addMediaSources(int i, Collection<MediaSource> collection) {
addPublicMediaSources(i, collection, null, null);
}
public synchronized void addMediaSources(int i, Collection<MediaSource> collection, Handler handler, Runnable runnable) {
addPublicMediaSources(i, collection, handler, runnable);
}
public synchronized MediaSource removeMediaSource(int i) {
MediaSource mediaSource;
mediaSource = getMediaSource(i);
removePublicMediaSources(i, i + 1, null, null);
return mediaSource;
}
public synchronized MediaSource removeMediaSource(int i, Handler handler, Runnable runnable) {
MediaSource mediaSource;
mediaSource = getMediaSource(i);
removePublicMediaSources(i, i + 1, handler, runnable);
return mediaSource;
}
public synchronized void removeMediaSourceRange(int i, int i2) {
removePublicMediaSources(i, i2, null, null);
}
public synchronized void removeMediaSourceRange(int i, int i2, Handler handler, Runnable runnable) {
removePublicMediaSources(i, i2, handler, runnable);
}
public synchronized void moveMediaSource(int i, int i2) {
movePublicMediaSource(i, i2, null, null);
}
public synchronized void moveMediaSource(int i, int i2, Handler handler, Runnable runnable) {
movePublicMediaSource(i, i2, handler, runnable);
}
public synchronized void clear() {
removeMediaSourceRange(0, getSize());
}
public synchronized void clear(Handler handler, Runnable runnable) {
removeMediaSourceRange(0, getSize(), handler, runnable);
}
public synchronized int getSize() {
return this.mediaSourcesPublic.size();
}
public synchronized MediaSource getMediaSource(int i) {
return this.mediaSourcesPublic.get(i).mediaSource;
}
public synchronized void setShuffleOrder(ShuffleOrder shuffleOrder) {
setPublicShuffleOrder(shuffleOrder, null, null);
}
public synchronized void setShuffleOrder(ShuffleOrder shuffleOrder, Handler handler, Runnable runnable) {
setPublicShuffleOrder(shuffleOrder, handler, runnable);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.source.CompositeMediaSource, androidx.media3.exoplayer.source.BaseMediaSource
public synchronized void prepareSourceInternal(TransferListener transferListener) {
super.prepareSourceInternal(transferListener);
this.playbackThreadHandler = new Handler(new Handler.Callback() { // from class: androidx.media3.exoplayer.source.ConcatenatingMediaSource$$ExternalSyntheticLambda0
@Override // android.os.Handler.Callback
public final boolean handleMessage(Message message) {
boolean handleMessage;
handleMessage = ConcatenatingMediaSource.this.handleMessage(message);
return handleMessage;
}
});
if (this.mediaSourcesPublic.isEmpty()) {
updateTimelineAndScheduleOnCompletionActions();
} else {
this.shuffleOrder = this.shuffleOrder.cloneAndInsert(0, this.mediaSourcesPublic.size());
addMediaSourcesInternal(0, this.mediaSourcesPublic);
scheduleTimelineUpdate();
}
}
@Override // androidx.media3.exoplayer.source.MediaSource
public MediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator, long j) {
Object mediaSourceHolderUid = getMediaSourceHolderUid(mediaPeriodId.periodUid);
MediaSource.MediaPeriodId copyWithPeriodUid = mediaPeriodId.copyWithPeriodUid(getChildPeriodUid(mediaPeriodId.periodUid));
MediaSourceHolder mediaSourceHolder = this.mediaSourceByUid.get(mediaSourceHolderUid);
if (mediaSourceHolder == null) {
mediaSourceHolder = new MediaSourceHolder(new FakeMediaSource(), this.useLazyPreparation);
mediaSourceHolder.isRemoved = true;
prepareChildSource(mediaSourceHolder, mediaSourceHolder.mediaSource);
}
enableMediaSource(mediaSourceHolder);
mediaSourceHolder.activeMediaPeriodIds.add(copyWithPeriodUid);
MaskingMediaPeriod createPeriod = mediaSourceHolder.mediaSource.createPeriod(copyWithPeriodUid, allocator, j);
this.mediaSourceByMediaPeriod.put(createPeriod, mediaSourceHolder);
disableUnusedMediaSources();
return createPeriod;
}
@Override // androidx.media3.exoplayer.source.MediaSource
public void releasePeriod(MediaPeriod mediaPeriod) {
MediaSourceHolder mediaSourceHolder = (MediaSourceHolder) Assertions.checkNotNull(this.mediaSourceByMediaPeriod.remove(mediaPeriod));
mediaSourceHolder.mediaSource.releasePeriod(mediaPeriod);
mediaSourceHolder.activeMediaPeriodIds.remove(((MaskingMediaPeriod) mediaPeriod).id);
if (!this.mediaSourceByMediaPeriod.isEmpty()) {
disableUnusedMediaSources();
}
maybeReleaseChildSource(mediaSourceHolder);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.source.CompositeMediaSource, androidx.media3.exoplayer.source.BaseMediaSource
public void disableInternal() {
super.disableInternal();
this.enabledMediaSourceHolders.clear();
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.source.CompositeMediaSource, androidx.media3.exoplayer.source.BaseMediaSource
public synchronized void releaseSourceInternal() {
super.releaseSourceInternal();
this.mediaSourceHolders.clear();
this.enabledMediaSourceHolders.clear();
this.mediaSourceByUid.clear();
this.shuffleOrder = this.shuffleOrder.cloneAndClear();
Handler handler = this.playbackThreadHandler;
if (handler != null) {
handler.removeCallbacksAndMessages(null);
this.playbackThreadHandler = null;
}
this.timelineUpdateScheduled = false;
this.nextTimelineUpdateOnCompletionActions.clear();
dispatchOnCompletionActions(this.pendingOnCompletionActions);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.source.CompositeMediaSource
/* renamed from: onChildSourceInfoRefreshed, reason: avoid collision after fix types in other method and merged with bridge method [inline-methods] */
public void m5257x28f9175(MediaSourceHolder mediaSourceHolder, MediaSource mediaSource, Timeline timeline) {
updateMediaSourceInternal(mediaSourceHolder, timeline);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.source.CompositeMediaSource
public MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(MediaSourceHolder mediaSourceHolder, MediaSource.MediaPeriodId mediaPeriodId) {
for (int i = 0; i < mediaSourceHolder.activeMediaPeriodIds.size(); i++) {
if (mediaSourceHolder.activeMediaPeriodIds.get(i).windowSequenceNumber == mediaPeriodId.windowSequenceNumber) {
return mediaPeriodId.copyWithPeriodUid(getPeriodUid(mediaSourceHolder, mediaPeriodId.periodUid));
}
}
return null;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.source.CompositeMediaSource
public int getWindowIndexForChildWindowIndex(MediaSourceHolder mediaSourceHolder, int i) {
return i + mediaSourceHolder.firstWindowIndexInChild;
}
private void addPublicMediaSources(int i, Collection<MediaSource> collection, Handler handler, Runnable runnable) {
Assertions.checkArgument((handler == null) == (runnable == null));
Handler handler2 = this.playbackThreadHandler;
Iterator<MediaSource> it = collection.iterator();
while (it.hasNext()) {
Assertions.checkNotNull(it.next());
}
ArrayList arrayList = new ArrayList(collection.size());
Iterator<MediaSource> it2 = collection.iterator();
while (it2.hasNext()) {
arrayList.add(new MediaSourceHolder(it2.next(), this.useLazyPreparation));
}
this.mediaSourcesPublic.addAll(i, arrayList);
if (handler2 != null && !collection.isEmpty()) {
handler2.obtainMessage(0, new MessageData(i, arrayList, createOnCompletionAction(handler, runnable))).sendToTarget();
} else {
if (runnable == null || handler == null) {
return;
}
handler.post(runnable);
}
}
private void removePublicMediaSources(int i, int i2, Handler handler, Runnable runnable) {
Assertions.checkArgument((handler == null) == (runnable == null));
Handler handler2 = this.playbackThreadHandler;
Util.removeRange(this.mediaSourcesPublic, i, i2);
if (handler2 != null) {
handler2.obtainMessage(1, new MessageData(i, Integer.valueOf(i2), createOnCompletionAction(handler, runnable))).sendToTarget();
} else {
if (runnable == null || handler == null) {
return;
}
handler.post(runnable);
}
}
private void movePublicMediaSource(int i, int i2, Handler handler, Runnable runnable) {
Assertions.checkArgument((handler == null) == (runnable == null));
Handler handler2 = this.playbackThreadHandler;
List<MediaSourceHolder> list = this.mediaSourcesPublic;
list.add(i2, list.remove(i));
if (handler2 != null) {
handler2.obtainMessage(2, new MessageData(i, Integer.valueOf(i2), createOnCompletionAction(handler, runnable))).sendToTarget();
} else {
if (runnable == null || handler == null) {
return;
}
handler.post(runnable);
}
}
private void setPublicShuffleOrder(ShuffleOrder shuffleOrder, Handler handler, Runnable runnable) {
Assertions.checkArgument((handler == null) == (runnable == null));
Handler handler2 = this.playbackThreadHandler;
if (handler2 != null) {
int size = getSize();
if (shuffleOrder.getLength() != size) {
shuffleOrder = shuffleOrder.cloneAndClear().cloneAndInsert(0, size);
}
handler2.obtainMessage(3, new MessageData(0, shuffleOrder, createOnCompletionAction(handler, runnable))).sendToTarget();
return;
}
if (shuffleOrder.getLength() > 0) {
shuffleOrder = shuffleOrder.cloneAndClear();
}
this.shuffleOrder = shuffleOrder;
if (runnable == null || handler == null) {
return;
}
handler.post(runnable);
}
private HandlerAndRunnable createOnCompletionAction(Handler handler, Runnable runnable) {
if (handler == null || runnable == null) {
return null;
}
HandlerAndRunnable handlerAndRunnable = new HandlerAndRunnable(handler, runnable);
this.pendingOnCompletionActions.add(handlerAndRunnable);
return handlerAndRunnable;
}
/* JADX INFO: Access modifiers changed from: private */
/* JADX WARN: Multi-variable type inference failed */
public boolean handleMessage(Message message) {
int i = message.what;
if (i == 0) {
MessageData messageData = (MessageData) Util.castNonNull(message.obj);
this.shuffleOrder = this.shuffleOrder.cloneAndInsert(messageData.index, ((Collection) messageData.customData).size());
addMediaSourcesInternal(messageData.index, (Collection) messageData.customData);
scheduleTimelineUpdate(messageData.onCompletionAction);
} else if (i == 1) {
MessageData messageData2 = (MessageData) Util.castNonNull(message.obj);
int i2 = messageData2.index;
int intValue = ((Integer) messageData2.customData).intValue();
if (i2 == 0 && intValue == this.shuffleOrder.getLength()) {
this.shuffleOrder = this.shuffleOrder.cloneAndClear();
} else {
this.shuffleOrder = this.shuffleOrder.cloneAndRemove(i2, intValue);
}
for (int i3 = intValue - 1; i3 >= i2; i3--) {
removeMediaSourceInternal(i3);
}
scheduleTimelineUpdate(messageData2.onCompletionAction);
} else if (i == 2) {
MessageData messageData3 = (MessageData) Util.castNonNull(message.obj);
ShuffleOrder cloneAndRemove = this.shuffleOrder.cloneAndRemove(messageData3.index, messageData3.index + 1);
this.shuffleOrder = cloneAndRemove;
this.shuffleOrder = cloneAndRemove.cloneAndInsert(((Integer) messageData3.customData).intValue(), 1);
moveMediaSourceInternal(messageData3.index, ((Integer) messageData3.customData).intValue());
scheduleTimelineUpdate(messageData3.onCompletionAction);
} else if (i == 3) {
MessageData messageData4 = (MessageData) Util.castNonNull(message.obj);
this.shuffleOrder = (ShuffleOrder) messageData4.customData;
scheduleTimelineUpdate(messageData4.onCompletionAction);
} else if (i == 4) {
updateTimelineAndScheduleOnCompletionActions();
} else if (i == 5) {
dispatchOnCompletionActions((Set) Util.castNonNull(message.obj));
} else {
throw new IllegalStateException();
}
return true;
}
private void scheduleTimelineUpdate() {
scheduleTimelineUpdate(null);
}
private void scheduleTimelineUpdate(HandlerAndRunnable handlerAndRunnable) {
if (!this.timelineUpdateScheduled) {
getPlaybackThreadHandlerOnPlaybackThread().obtainMessage(4).sendToTarget();
this.timelineUpdateScheduled = true;
}
if (handlerAndRunnable != null) {
this.nextTimelineUpdateOnCompletionActions.add(handlerAndRunnable);
}
}
private void updateTimelineAndScheduleOnCompletionActions() {
this.timelineUpdateScheduled = false;
Set<HandlerAndRunnable> set = this.nextTimelineUpdateOnCompletionActions;
this.nextTimelineUpdateOnCompletionActions = new HashSet();
refreshSourceInfo(new ConcatenatedTimeline(this.mediaSourceHolders, this.shuffleOrder, this.isAtomic));
getPlaybackThreadHandlerOnPlaybackThread().obtainMessage(5, set).sendToTarget();
}
private Handler getPlaybackThreadHandlerOnPlaybackThread() {
return (Handler) Assertions.checkNotNull(this.playbackThreadHandler);
}
private synchronized void dispatchOnCompletionActions(Set<HandlerAndRunnable> set) {
Iterator<HandlerAndRunnable> it = set.iterator();
while (it.hasNext()) {
it.next().dispatch();
}
this.pendingOnCompletionActions.removeAll(set);
}
private void addMediaSourcesInternal(int i, Collection<MediaSourceHolder> collection) {
Iterator<MediaSourceHolder> it = collection.iterator();
while (it.hasNext()) {
addMediaSourceInternal(i, it.next());
i++;
}
}
private void addMediaSourceInternal(int i, MediaSourceHolder mediaSourceHolder) {
if (i > 0) {
MediaSourceHolder mediaSourceHolder2 = this.mediaSourceHolders.get(i - 1);
mediaSourceHolder.reset(i, mediaSourceHolder2.firstWindowIndexInChild + mediaSourceHolder2.mediaSource.getTimeline().getWindowCount());
} else {
mediaSourceHolder.reset(i, 0);
}
correctOffsets(i, 1, mediaSourceHolder.mediaSource.getTimeline().getWindowCount());
this.mediaSourceHolders.add(i, mediaSourceHolder);
this.mediaSourceByUid.put(mediaSourceHolder.uid, mediaSourceHolder);
prepareChildSource(mediaSourceHolder, mediaSourceHolder.mediaSource);
if (isEnabled() && this.mediaSourceByMediaPeriod.isEmpty()) {
this.enabledMediaSourceHolders.add(mediaSourceHolder);
} else {
disableChildSource(mediaSourceHolder);
}
}
private void updateMediaSourceInternal(MediaSourceHolder mediaSourceHolder, Timeline timeline) {
if (mediaSourceHolder.childIndex + 1 < this.mediaSourceHolders.size()) {
int windowCount = timeline.getWindowCount() - (this.mediaSourceHolders.get(mediaSourceHolder.childIndex + 1).firstWindowIndexInChild - mediaSourceHolder.firstWindowIndexInChild);
if (windowCount != 0) {
correctOffsets(mediaSourceHolder.childIndex + 1, 0, windowCount);
}
}
scheduleTimelineUpdate();
}
private void removeMediaSourceInternal(int i) {
MediaSourceHolder remove = this.mediaSourceHolders.remove(i);
this.mediaSourceByUid.remove(remove.uid);
correctOffsets(i, -1, -remove.mediaSource.getTimeline().getWindowCount());
remove.isRemoved = true;
maybeReleaseChildSource(remove);
}
private void moveMediaSourceInternal(int i, int i2) {
int min = Math.min(i, i2);
int max = Math.max(i, i2);
int i3 = this.mediaSourceHolders.get(min).firstWindowIndexInChild;
List<MediaSourceHolder> list = this.mediaSourceHolders;
list.add(i2, list.remove(i));
while (min <= max) {
MediaSourceHolder mediaSourceHolder = this.mediaSourceHolders.get(min);
mediaSourceHolder.childIndex = min;
mediaSourceHolder.firstWindowIndexInChild = i3;
i3 += mediaSourceHolder.mediaSource.getTimeline().getWindowCount();
min++;
}
}
private void correctOffsets(int i, int i2, int i3) {
while (i < this.mediaSourceHolders.size()) {
MediaSourceHolder mediaSourceHolder = this.mediaSourceHolders.get(i);
mediaSourceHolder.childIndex += i2;
mediaSourceHolder.firstWindowIndexInChild += i3;
i++;
}
}
private void maybeReleaseChildSource(MediaSourceHolder mediaSourceHolder) {
if (mediaSourceHolder.isRemoved && mediaSourceHolder.activeMediaPeriodIds.isEmpty()) {
this.enabledMediaSourceHolders.remove(mediaSourceHolder);
releaseChildSource(mediaSourceHolder);
}
}
private void enableMediaSource(MediaSourceHolder mediaSourceHolder) {
this.enabledMediaSourceHolders.add(mediaSourceHolder);
enableChildSource(mediaSourceHolder);
}
private void disableUnusedMediaSources() {
Iterator<MediaSourceHolder> it = this.enabledMediaSourceHolders.iterator();
while (it.hasNext()) {
MediaSourceHolder next = it.next();
if (next.activeMediaPeriodIds.isEmpty()) {
disableChildSource(next);
it.remove();
}
}
}
private static Object getMediaSourceHolderUid(Object obj) {
return ConcatenatedTimeline.getChildTimelineUidFromConcatenatedUid(obj);
}
private static Object getChildPeriodUid(Object obj) {
return ConcatenatedTimeline.getChildPeriodUidFromConcatenatedUid(obj);
}
private static Object getPeriodUid(MediaSourceHolder mediaSourceHolder, Object obj) {
return ConcatenatedTimeline.getConcatenatedUid(mediaSourceHolder.uid, obj);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public static final class MediaSourceHolder {
public int childIndex;
public int firstWindowIndexInChild;
public boolean isRemoved;
public final MaskingMediaSource mediaSource;
public final List<MediaSource.MediaPeriodId> activeMediaPeriodIds = new ArrayList();
public final Object uid = new Object();
public MediaSourceHolder(MediaSource mediaSource, boolean z) {
this.mediaSource = new MaskingMediaSource(mediaSource, z);
}
public void reset(int i, int i2) {
this.childIndex = i;
this.firstWindowIndexInChild = i2;
this.isRemoved = false;
this.activeMediaPeriodIds.clear();
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static final class MessageData<T> {
public final T customData;
public final int index;
public final HandlerAndRunnable onCompletionAction;
public MessageData(int i, T t, HandlerAndRunnable handlerAndRunnable) {
this.index = i;
this.customData = t;
this.onCompletionAction = handlerAndRunnable;
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static final class ConcatenatedTimeline extends AbstractConcatenatedTimeline {
private final HashMap<Object, Integer> childIndexByUid;
private final int[] firstPeriodInChildIndices;
private final int[] firstWindowInChildIndices;
private final int periodCount;
private final Timeline[] timelines;
private final Object[] uids;
private final int windowCount;
@Override // androidx.media3.common.Timeline
public int getPeriodCount() {
return this.periodCount;
}
@Override // androidx.media3.common.Timeline
public int getWindowCount() {
return this.windowCount;
}
public ConcatenatedTimeline(Collection<MediaSourceHolder> collection, ShuffleOrder shuffleOrder, boolean z) {
super(z, shuffleOrder);
int size = collection.size();
this.firstPeriodInChildIndices = new int[size];
this.firstWindowInChildIndices = new int[size];
this.timelines = new Timeline[size];
this.uids = new Object[size];
this.childIndexByUid = new HashMap<>();
int i = 0;
int i2 = 0;
int i3 = 0;
for (MediaSourceHolder mediaSourceHolder : collection) {
this.timelines[i3] = mediaSourceHolder.mediaSource.getTimeline();
this.firstWindowInChildIndices[i3] = i;
this.firstPeriodInChildIndices[i3] = i2;
i += this.timelines[i3].getWindowCount();
i2 += this.timelines[i3].getPeriodCount();
this.uids[i3] = mediaSourceHolder.uid;
this.childIndexByUid.put(this.uids[i3], Integer.valueOf(i3));
i3++;
}
this.windowCount = i;
this.periodCount = i2;
}
@Override // androidx.media3.exoplayer.AbstractConcatenatedTimeline
protected int getChildIndexByPeriodIndex(int i) {
return Util.binarySearchFloor(this.firstPeriodInChildIndices, i + 1, false, false);
}
@Override // androidx.media3.exoplayer.AbstractConcatenatedTimeline
protected int getChildIndexByWindowIndex(int i) {
return Util.binarySearchFloor(this.firstWindowInChildIndices, i + 1, false, false);
}
@Override // androidx.media3.exoplayer.AbstractConcatenatedTimeline
protected int getChildIndexByChildUid(Object obj) {
Integer num = this.childIndexByUid.get(obj);
if (num == null) {
return -1;
}
return num.intValue();
}
@Override // androidx.media3.exoplayer.AbstractConcatenatedTimeline
protected Timeline getTimelineByChildIndex(int i) {
return this.timelines[i];
}
@Override // androidx.media3.exoplayer.AbstractConcatenatedTimeline
protected int getFirstPeriodIndexByChildIndex(int i) {
return this.firstPeriodInChildIndices[i];
}
@Override // androidx.media3.exoplayer.AbstractConcatenatedTimeline
protected int getFirstWindowIndexByChildIndex(int i) {
return this.firstWindowInChildIndices[i];
}
@Override // androidx.media3.exoplayer.AbstractConcatenatedTimeline
protected Object getChildUidByChildIndex(int i) {
return this.uids[i];
}
}
/* loaded from: classes2.dex */
private static final class FakeMediaSource extends BaseMediaSource {
@Override // androidx.media3.exoplayer.source.MediaSource
public void maybeThrowSourceInfoRefreshError() {
}
@Override // androidx.media3.exoplayer.source.BaseMediaSource
protected void prepareSourceInternal(TransferListener transferListener) {
}
@Override // androidx.media3.exoplayer.source.MediaSource
public void releasePeriod(MediaPeriod mediaPeriod) {
}
@Override // androidx.media3.exoplayer.source.BaseMediaSource
protected void releaseSourceInternal() {
}
private FakeMediaSource() {
}
@Override // androidx.media3.exoplayer.source.MediaSource
public MediaItem getMediaItem() {
return ConcatenatingMediaSource.PLACEHOLDER_MEDIA_ITEM;
}
@Override // androidx.media3.exoplayer.source.MediaSource
public MediaPeriod createPeriod(MediaSource.MediaPeriodId mediaPeriodId, Allocator allocator, long j) {
throw new UnsupportedOperationException();
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static final class HandlerAndRunnable {
private final Handler handler;
private final Runnable runnable;
public HandlerAndRunnable(Handler handler, Runnable runnable) {
this.handler = handler;
this.runnable = runnable;
}
public void dispatch() {
this.handler.post(this.runnable);
}
}
}