Files
rr3-apk/decompiled-community/sources/com/mbridge/msdk/playercommon/exoplayer2/source/CompositeMediaSource.java
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
2026-02-18 15:48:36 -08:00

197 lines
10 KiB
Java

package com.mbridge.msdk.playercommon.exoplayer2.source;
import android.os.Handler;
import androidx.annotation.CallSuper;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayer;
import com.mbridge.msdk.playercommon.exoplayer2.Timeline;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource;
import com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
/* loaded from: classes4.dex */
public abstract class CompositeMediaSource<T> extends BaseMediaSource {
private final HashMap<T, MediaSourceAndListener> childSources = new HashMap<>();
private Handler eventHandler;
private ExoPlayer player;
@Nullable
public MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(@Nullable T t, MediaSource.MediaPeriodId mediaPeriodId) {
return mediaPeriodId;
}
public long getMediaTimeForChildMediaTime(@Nullable T t, long j) {
return j;
}
public int getWindowIndexForChildWindowIndex(@Nullable T t, int i) {
return i;
}
public abstract void onChildSourceInfoRefreshed(@Nullable T t, MediaSource mediaSource, Timeline timeline, @Nullable Object obj);
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
@CallSuper
public void prepareSourceInternal(ExoPlayer exoPlayer, boolean z) {
this.player = exoPlayer;
this.eventHandler = new Handler();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource
@CallSuper
public void maybeThrowSourceInfoRefreshError() throws IOException {
Iterator<MediaSourceAndListener> it = this.childSources.values().iterator();
while (it.hasNext()) {
it.next().mediaSource.maybeThrowSourceInfoRefreshError();
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.BaseMediaSource
@CallSuper
public void releaseSourceInternal() {
for (MediaSourceAndListener mediaSourceAndListener : this.childSources.values()) {
mediaSourceAndListener.mediaSource.releaseSource(mediaSourceAndListener.listener);
mediaSourceAndListener.mediaSource.removeEventListener(mediaSourceAndListener.eventListener);
}
this.childSources.clear();
this.player = null;
}
public final void prepareChildSource(@Nullable final T t, MediaSource mediaSource) {
Assertions.checkArgument(!this.childSources.containsKey(t));
MediaSource.SourceInfoRefreshListener sourceInfoRefreshListener = new MediaSource.SourceInfoRefreshListener() { // from class: com.mbridge.msdk.playercommon.exoplayer2.source.CompositeMediaSource.1
/* JADX WARN: Multi-variable type inference failed */
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSource.SourceInfoRefreshListener
public void onSourceInfoRefreshed(MediaSource mediaSource2, Timeline timeline, @Nullable Object obj) {
CompositeMediaSource.this.onChildSourceInfoRefreshed(t, mediaSource2, timeline, obj);
}
};
ForwardingEventListener forwardingEventListener = new ForwardingEventListener(t);
this.childSources.put(t, new MediaSourceAndListener(mediaSource, sourceInfoRefreshListener, forwardingEventListener));
mediaSource.addEventListener(this.eventHandler, forwardingEventListener);
mediaSource.prepareSource(this.player, false, sourceInfoRefreshListener);
}
public final void releaseChildSource(@Nullable T t) {
MediaSourceAndListener remove = this.childSources.remove(t);
remove.mediaSource.releaseSource(remove.listener);
remove.mediaSource.removeEventListener(remove.eventListener);
}
public static final class MediaSourceAndListener {
public final MediaSourceEventListener eventListener;
public final MediaSource.SourceInfoRefreshListener listener;
public final MediaSource mediaSource;
public MediaSourceAndListener(MediaSource mediaSource, MediaSource.SourceInfoRefreshListener sourceInfoRefreshListener, MediaSourceEventListener mediaSourceEventListener) {
this.mediaSource = mediaSource;
this.listener = sourceInfoRefreshListener;
this.eventListener = mediaSourceEventListener;
}
}
public final class ForwardingEventListener implements MediaSourceEventListener {
private MediaSourceEventListener.EventDispatcher eventDispatcher;
@Nullable
private final T id;
public ForwardingEventListener(T t) {
this.eventDispatcher = CompositeMediaSource.this.createEventDispatcher(null);
this.id = t;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onMediaPeriodCreated(int i, MediaSource.MediaPeriodId mediaPeriodId) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.mediaPeriodCreated();
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onMediaPeriodReleased(int i, MediaSource.MediaPeriodId mediaPeriodId) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.mediaPeriodReleased();
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onLoadStarted(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.loadStarted(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData));
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onLoadCompleted(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.loadCompleted(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData));
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onLoadCanceled(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.loadCanceled(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData));
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onLoadError(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.LoadEventInfo loadEventInfo, MediaSourceEventListener.MediaLoadData mediaLoadData, IOException iOException, boolean z) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.loadError(loadEventInfo, maybeUpdateMediaLoadData(mediaLoadData), iOException, z);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onReadingStarted(int i, MediaSource.MediaPeriodId mediaPeriodId) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.readingStarted();
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onUpstreamDiscarded(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.MediaLoadData mediaLoadData) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.upstreamDiscarded(maybeUpdateMediaLoadData(mediaLoadData));
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.source.MediaSourceEventListener
public final void onDownstreamFormatChanged(int i, @Nullable MediaSource.MediaPeriodId mediaPeriodId, MediaSourceEventListener.MediaLoadData mediaLoadData) {
if (maybeUpdateEventDispatcher(i, mediaPeriodId)) {
this.eventDispatcher.downstreamFormatChanged(maybeUpdateMediaLoadData(mediaLoadData));
}
}
private boolean maybeUpdateEventDispatcher(int i, @Nullable 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);
MediaSourceEventListener.EventDispatcher eventDispatcher = this.eventDispatcher;
if (eventDispatcher.windowIndex == windowIndexForChildWindowIndex && Util.areEqual(eventDispatcher.mediaPeriodId, mediaPeriodId2)) {
return true;
}
this.eventDispatcher = CompositeMediaSource.this.createEventDispatcher(windowIndexForChildWindowIndex, mediaPeriodId2, 0L);
return true;
}
private MediaSourceEventListener.MediaLoadData maybeUpdateMediaLoadData(MediaSourceEventListener.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 MediaSourceEventListener.MediaLoadData(mediaLoadData.dataType, mediaLoadData.trackType, mediaLoadData.trackFormat, mediaLoadData.trackSelectionReason, mediaLoadData.trackSelectionData, mediaTimeForChildMediaTime, mediaTimeForChildMediaTime2);
}
}
}