mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 01:22:33 -06:00
254 lines
14 KiB
Java
254 lines
14 KiB
Java
package com.google.android.exoplayer2.source;
|
|
|
|
import android.os.Handler;
|
|
import com.google.android.exoplayer2.Timeline;
|
|
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
|
import com.google.android.exoplayer2.source.MediaSource;
|
|
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
|
import com.google.android.exoplayer2.upstream.TransferListener;
|
|
import com.google.android.exoplayer2.util.Assertions;
|
|
import com.google.android.exoplayer2.util.Util;
|
|
import java.io.IOException;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
|
private final HashMap<T, MediaSourceAndListener<T>> childSources = new HashMap<>();
|
|
private Handler eventHandler;
|
|
private TransferListener mediaTransferListener;
|
|
|
|
protected MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(T t, MediaSource.MediaPeriodId mediaPeriodId) {
|
|
return mediaPeriodId;
|
|
}
|
|
|
|
protected long getMediaTimeForChildMediaTime(T t, long j) {
|
|
return j;
|
|
}
|
|
|
|
protected int getWindowIndexForChildWindowIndex(T t, int i) {
|
|
return i;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
/* renamed from: onChildSourceInfoRefreshed, reason: merged with bridge method [inline-methods] */
|
|
public abstract void m5439x365769cd(T t, MediaSource mediaSource, Timeline timeline);
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.android.exoplayer2.source.BaseMediaSource
|
|
public void prepareSourceInternal(TransferListener transferListener) {
|
|
this.mediaTransferListener = transferListener;
|
|
this.eventHandler = Util.createHandlerForCurrentLooper();
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSource
|
|
public void maybeThrowSourceInfoRefreshError() throws IOException {
|
|
Iterator<MediaSourceAndListener<T>> it = this.childSources.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().mediaSource.maybeThrowSourceInfoRefreshError();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.BaseMediaSource
|
|
protected void enableInternal() {
|
|
for (MediaSourceAndListener<T> mediaSourceAndListener : this.childSources.values()) {
|
|
mediaSourceAndListener.mediaSource.enable(mediaSourceAndListener.caller);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.android.exoplayer2.source.BaseMediaSource
|
|
public void disableInternal() {
|
|
for (MediaSourceAndListener<T> mediaSourceAndListener : this.childSources.values()) {
|
|
mediaSourceAndListener.mediaSource.disable(mediaSourceAndListener.caller);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // com.google.android.exoplayer2.source.BaseMediaSource
|
|
public void releaseSourceInternal() {
|
|
for (MediaSourceAndListener<T> mediaSourceAndListener : this.childSources.values()) {
|
|
mediaSourceAndListener.mediaSource.releaseSource(mediaSourceAndListener.caller);
|
|
mediaSourceAndListener.mediaSource.removeEventListener(mediaSourceAndListener.eventListener);
|
|
mediaSourceAndListener.mediaSource.removeDrmEventListener(mediaSourceAndListener.eventListener);
|
|
}
|
|
this.childSources.clear();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public final void prepareChildSource(final T t, MediaSource mediaSource) {
|
|
Assertions.checkArgument(!this.childSources.containsKey(t));
|
|
MediaSource.MediaSourceCaller mediaSourceCaller = new MediaSource.MediaSourceCaller() { // from class: com.google.android.exoplayer2.source.CompositeMediaSource$$ExternalSyntheticLambda0
|
|
@Override // com.google.android.exoplayer2.source.MediaSource.MediaSourceCaller
|
|
public final void onSourceInfoRefreshed(MediaSource mediaSource2, Timeline timeline) {
|
|
CompositeMediaSource.this.m5439x365769cd(t, mediaSource2, timeline);
|
|
}
|
|
};
|
|
ForwardingEventListener forwardingEventListener = new ForwardingEventListener(t);
|
|
this.childSources.put(t, new MediaSourceAndListener<>(mediaSource, mediaSourceCaller, forwardingEventListener));
|
|
mediaSource.addEventListener((Handler) Assertions.checkNotNull(this.eventHandler), forwardingEventListener);
|
|
mediaSource.addDrmEventListener((Handler) Assertions.checkNotNull(this.eventHandler), forwardingEventListener);
|
|
mediaSource.prepareSource(mediaSourceCaller, this.mediaTransferListener, getPlayerId());
|
|
if (isEnabled()) {
|
|
return;
|
|
}
|
|
mediaSource.disable(mediaSourceCaller);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public final void enableChildSource(T t) {
|
|
MediaSourceAndListener mediaSourceAndListener = (MediaSourceAndListener) Assertions.checkNotNull(this.childSources.get(t));
|
|
mediaSourceAndListener.mediaSource.enable(mediaSourceAndListener.caller);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public final void disableChildSource(T t) {
|
|
MediaSourceAndListener mediaSourceAndListener = (MediaSourceAndListener) Assertions.checkNotNull(this.childSources.get(t));
|
|
mediaSourceAndListener.mediaSource.disable(mediaSourceAndListener.caller);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public final void releaseChildSource(T t) {
|
|
MediaSourceAndListener mediaSourceAndListener = (MediaSourceAndListener) Assertions.checkNotNull(this.childSources.remove(t));
|
|
mediaSourceAndListener.mediaSource.releaseSource(mediaSourceAndListener.caller);
|
|
mediaSourceAndListener.mediaSource.removeEventListener(mediaSourceAndListener.eventListener);
|
|
mediaSourceAndListener.mediaSource.removeDrmEventListener(mediaSourceAndListener.eventListener);
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
private static final class MediaSourceAndListener<T> {
|
|
public final MediaSource.MediaSourceCaller caller;
|
|
public final CompositeMediaSource<T>.ForwardingEventListener eventListener;
|
|
public final MediaSource mediaSource;
|
|
|
|
public MediaSourceAndListener(MediaSource mediaSource, MediaSource.MediaSourceCaller mediaSourceCaller, CompositeMediaSource<T>.ForwardingEventListener forwardingEventListener) {
|
|
this.mediaSource = mediaSource;
|
|
this.caller = mediaSourceCaller;
|
|
this.eventListener = forwardingEventListener;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
private final class ForwardingEventListener implements MediaSourceEventListener, DrmSessionEventListener {
|
|
private DrmSessionEventListener.EventDispatcher drmEventDispatcher;
|
|
private final T id;
|
|
private MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher;
|
|
|
|
public ForwardingEventListener(T t) {
|
|
this.mediaSourceEventDispatcher = CompositeMediaSource.this.createEventDispatcher(null);
|
|
this.drmEventDispatcher = CompositeMediaSource.this.createDrmEventDispatcher(null);
|
|
this.id = t;
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSourceEventListener
|
|
public void onLoadStarted(int i, MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.mediaSourceEventDispatcher.loadStarted(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData));
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSourceEventListener
|
|
public void onLoadCompleted(int i, MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.mediaSourceEventDispatcher.loadCompleted(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData));
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSourceEventListener
|
|
public void onLoadCanceled(int i, MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.mediaSourceEventDispatcher.loadCanceled(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData));
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSourceEventListener
|
|
public void onLoadError(int i, MediaSource.MediaPeriodId mediaPeriodId, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData, IOException iOException, boolean z) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.mediaSourceEventDispatcher.loadError(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData), iOException, z);
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSourceEventListener
|
|
public void onUpstreamDiscarded(int i, MediaSource.MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.mediaSourceEventDispatcher.upstreamDiscarded(maybeUpdateMediaLoadData(mediaLoadData));
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.source.MediaSourceEventListener
|
|
public void onDownstreamFormatChanged(int i, MediaSource.MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.mediaSourceEventDispatcher.downstreamFormatChanged(maybeUpdateMediaLoadData(mediaLoadData));
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.drm.DrmSessionEventListener
|
|
public void onDrmSessionAcquired(int i, MediaSource.MediaPeriodId mediaPeriodId, int i2) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.drmEventDispatcher.drmSessionAcquired(i2);
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.drm.DrmSessionEventListener
|
|
public void onDrmKeysLoaded(int i, MediaSource.MediaPeriodId mediaPeriodId) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.drmEventDispatcher.drmKeysLoaded();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.drm.DrmSessionEventListener
|
|
public void onDrmSessionManagerError(int i, MediaSource.MediaPeriodId mediaPeriodId, Exception exc) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.drmEventDispatcher.drmSessionManagerError(exc);
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.drm.DrmSessionEventListener
|
|
public void onDrmKeysRestored(int i, MediaSource.MediaPeriodId mediaPeriodId) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.drmEventDispatcher.drmKeysRestored();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.drm.DrmSessionEventListener
|
|
public void onDrmKeysRemoved(int i, MediaSource.MediaPeriodId mediaPeriodId) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.drmEventDispatcher.drmKeysRemoved();
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.exoplayer2.drm.DrmSessionEventListener
|
|
public void onDrmSessionReleased(int i, MediaSource.MediaPeriodId mediaPeriodId) {
|
|
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
|
|
this.drmEventDispatcher.drmSessionReleased();
|
|
}
|
|
}
|
|
|
|
private boolean maybeUpdateEventDispatcher(int i, MediaSource.MediaPeriodId mediaPeriodId) {
|
|
MediaSource.MediaPeriodId mediaPeriodId2;
|
|
if (mediaPeriodId != null) {
|
|
mediaPeriodId2 = CompositeMediaSource.this.getMediaPeriodIdForChildMediaPeriodId(this.id, mediaPeriodId);
|
|
if (mediaPeriodId2 == null) {
|
|
return false;
|
|
}
|
|
} else {
|
|
mediaPeriodId2 = null;
|
|
}
|
|
int windowIndexForChildWindowIndex = CompositeMediaSource.this.getWindowIndexForChildWindowIndex(this.id, i);
|
|
if (this.mediaSourceEventDispatcher.windowIndex != windowIndexForChildWindowIndex || !Util.areEqual(this.mediaSourceEventDispatcher.mediaPeriodId, mediaPeriodId2)) {
|
|
this.mediaSourceEventDispatcher = CompositeMediaSource.this.createEventDispatcher(windowIndexForChildWindowIndex, mediaPeriodId2, 0L);
|
|
}
|
|
if (this.drmEventDispatcher.windowIndex == windowIndexForChildWindowIndex && Util.areEqual(this.drmEventDispatcher.mediaPeriodId, mediaPeriodId2)) {
|
|
return true;
|
|
}
|
|
this.drmEventDispatcher = CompositeMediaSource.this.createDrmEventDispatcher(windowIndexForChildWindowIndex, mediaPeriodId2);
|
|
return true;
|
|
}
|
|
|
|
private MediaLoadData maybeUpdateMediaLoadData(MediaLoadData mediaLoadData) {
|
|
long mediaTimeForChildMediaTime = CompositeMediaSource.this.getMediaTimeForChildMediaTime(this.id, mediaLoadData.mediaStartTimeMs);
|
|
long mediaTimeForChildMediaTime2 = CompositeMediaSource.this.getMediaTimeForChildMediaTime(this.id, mediaLoadData.mediaEndTimeMs);
|
|
return (mediaTimeForChildMediaTime == mediaLoadData.mediaStartTimeMs && mediaTimeForChildMediaTime2 == mediaLoadData.mediaEndTimeMs) ? mediaLoadData : new MediaLoadData(mediaLoadData.dataType, mediaLoadData.trackType, mediaLoadData.trackFormat, mediaLoadData.trackSelectionReason, mediaLoadData.trackSelectionData, mediaTimeForChildMediaTime, mediaTimeForChildMediaTime2);
|
|
}
|
|
}
|
|
}
|