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

192 lines
9.7 KiB
Java

package androidx.media3.exoplayer;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import androidx.media3.common.util.Log;
import androidx.media3.exoplayer.audio.AudioRendererEventListener;
import androidx.media3.exoplayer.audio.AudioSink;
import androidx.media3.exoplayer.audio.DefaultAudioSink;
import androidx.media3.exoplayer.mediacodec.DefaultMediaCodecAdapterFactory;
import androidx.media3.exoplayer.mediacodec.MediaCodecAdapter;
import androidx.media3.exoplayer.mediacodec.MediaCodecSelector;
import androidx.media3.exoplayer.metadata.MetadataOutput;
import androidx.media3.exoplayer.metadata.MetadataRenderer;
import androidx.media3.exoplayer.text.TextOutput;
import androidx.media3.exoplayer.text.TextRenderer;
import androidx.media3.exoplayer.video.MediaCodecVideoRenderer;
import androidx.media3.exoplayer.video.VideoRendererEventListener;
import androidx.media3.exoplayer.video.spherical.CameraMotionRenderer;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.ArrayList;
/* loaded from: classes2.dex */
public class DefaultRenderersFactory implements RenderersFactory {
public static final long DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS = 5000;
public static final int EXTENSION_RENDERER_MODE_OFF = 0;
public static final int EXTENSION_RENDERER_MODE_ON = 1;
public static final int EXTENSION_RENDERER_MODE_PREFER = 2;
public static final int MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY = 50;
private static final String TAG = "DefaultRenderersFactory";
private final Context context;
private boolean enableAudioTrackPlaybackParams;
private boolean enableDecoderFallback;
private boolean enableFloatOutput;
private boolean enableOffload;
private final DefaultMediaCodecAdapterFactory codecAdapterFactory = new DefaultMediaCodecAdapterFactory();
private int extensionRendererMode = 0;
private long allowedVideoJoiningTimeMs = 5000;
private MediaCodecSelector mediaCodecSelector = MediaCodecSelector.DEFAULT;
@Target({ElementType.TYPE_USE})
@Documented
@Retention(RetentionPolicy.SOURCE)
/* loaded from: classes2.dex */
public @interface ExtensionRendererMode {
}
protected void buildMiscellaneousRenderers(Context context, Handler handler, int i, ArrayList<Renderer> arrayList) {
}
protected MediaCodecAdapter.Factory getCodecAdapterFactory() {
return this.codecAdapterFactory;
}
public DefaultRenderersFactory setAllowedVideoJoiningTimeMs(long j) {
this.allowedVideoJoiningTimeMs = j;
return this;
}
public DefaultRenderersFactory setEnableAudioFloatOutput(boolean z) {
this.enableFloatOutput = z;
return this;
}
public DefaultRenderersFactory setEnableAudioOffload(boolean z) {
this.enableOffload = z;
return this;
}
public DefaultRenderersFactory setEnableAudioTrackPlaybackParams(boolean z) {
this.enableAudioTrackPlaybackParams = z;
return this;
}
public DefaultRenderersFactory setEnableDecoderFallback(boolean z) {
this.enableDecoderFallback = z;
return this;
}
public DefaultRenderersFactory setExtensionRendererMode(int i) {
this.extensionRendererMode = i;
return this;
}
public DefaultRenderersFactory setMediaCodecSelector(MediaCodecSelector mediaCodecSelector) {
this.mediaCodecSelector = mediaCodecSelector;
return this;
}
public DefaultRenderersFactory(Context context) {
this.context = context;
}
public DefaultRenderersFactory forceEnableMediaCodecAsynchronousQueueing() {
this.codecAdapterFactory.forceEnableAsynchronous();
return this;
}
public DefaultRenderersFactory forceDisableMediaCodecAsynchronousQueueing() {
this.codecAdapterFactory.forceDisableAsynchronous();
return this;
}
public DefaultRenderersFactory experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled(boolean z) {
this.codecAdapterFactory.experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled(z);
return this;
}
@Override // androidx.media3.exoplayer.RenderersFactory
public Renderer[] createRenderers(Handler handler, VideoRendererEventListener videoRendererEventListener, AudioRendererEventListener audioRendererEventListener, TextOutput textOutput, MetadataOutput metadataOutput) {
ArrayList<Renderer> arrayList = new ArrayList<>();
buildVideoRenderers(this.context, this.extensionRendererMode, this.mediaCodecSelector, this.enableDecoderFallback, handler, videoRendererEventListener, this.allowedVideoJoiningTimeMs, arrayList);
AudioSink buildAudioSink = buildAudioSink(this.context, this.enableFloatOutput, this.enableAudioTrackPlaybackParams, this.enableOffload);
if (buildAudioSink != null) {
buildAudioRenderers(this.context, this.extensionRendererMode, this.mediaCodecSelector, this.enableDecoderFallback, buildAudioSink, handler, audioRendererEventListener, arrayList);
}
buildTextRenderers(this.context, textOutput, handler.getLooper(), this.extensionRendererMode, arrayList);
buildMetadataRenderers(this.context, metadataOutput, handler.getLooper(), this.extensionRendererMode, arrayList);
buildCameraMotionRenderers(this.context, this.extensionRendererMode, arrayList);
buildMiscellaneousRenderers(this.context, handler, this.extensionRendererMode, arrayList);
return (Renderer[]) arrayList.toArray(new Renderer[0]);
}
protected void buildVideoRenderers(Context context, int i, MediaCodecSelector mediaCodecSelector, boolean z, Handler handler, VideoRendererEventListener videoRendererEventListener, long j, ArrayList<Renderer> arrayList) {
int i2;
arrayList.add(new MediaCodecVideoRenderer(context, getCodecAdapterFactory(), mediaCodecSelector, j, z, handler, videoRendererEventListener, 50));
if (i == 0) {
return;
}
int size = arrayList.size();
if (i == 2) {
size--;
}
try {
try {
i2 = size + 1;
try {
arrayList.add(size, (Renderer) Class.forName("androidx.media3.decoder.vp9.LibvpxVideoRenderer").getConstructor(Long.TYPE, Handler.class, VideoRendererEventListener.class, Integer.TYPE).newInstance(Long.valueOf(j), handler, videoRendererEventListener, 50));
Log.i(TAG, "Loaded LibvpxVideoRenderer.");
} catch (ClassNotFoundException unused) {
size = i2;
i2 = size;
arrayList.add(i2, (Renderer) Class.forName("androidx.media3.decoder.av1.Libgav1VideoRenderer").getConstructor(Long.TYPE, Handler.class, VideoRendererEventListener.class, Integer.TYPE).newInstance(Long.valueOf(j), handler, videoRendererEventListener, 50));
Log.i(TAG, "Loaded Libgav1VideoRenderer.");
}
} catch (Exception e) {
throw new RuntimeException("Error instantiating VP9 extension", e);
}
} catch (ClassNotFoundException unused2) {
}
try {
arrayList.add(i2, (Renderer) Class.forName("androidx.media3.decoder.av1.Libgav1VideoRenderer").getConstructor(Long.TYPE, Handler.class, VideoRendererEventListener.class, Integer.TYPE).newInstance(Long.valueOf(j), handler, videoRendererEventListener, 50));
Log.i(TAG, "Loaded Libgav1VideoRenderer.");
} catch (ClassNotFoundException unused3) {
} catch (Exception e2) {
throw new RuntimeException("Error instantiating AV1 extension", e2);
}
}
/* JADX WARN: Can't wrap try/catch for region: R(15:5|(1:7)|8|(5:9|10|11|12|13)|14|15|16|17|(2:18|19)|21|22|23|24|25|(2:27|28)) */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
protected void buildAudioRenderers(android.content.Context r16, int r17, androidx.media3.exoplayer.mediacodec.MediaCodecSelector r18, boolean r19, androidx.media3.exoplayer.audio.AudioSink r20, android.os.Handler r21, androidx.media3.exoplayer.audio.AudioRendererEventListener r22, java.util.ArrayList<androidx.media3.exoplayer.Renderer> r23) {
/*
Method dump skipped, instructions count: 262
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.media3.exoplayer.DefaultRenderersFactory.buildAudioRenderers(android.content.Context, int, androidx.media3.exoplayer.mediacodec.MediaCodecSelector, boolean, androidx.media3.exoplayer.audio.AudioSink, android.os.Handler, androidx.media3.exoplayer.audio.AudioRendererEventListener, java.util.ArrayList):void");
}
protected void buildTextRenderers(Context context, TextOutput textOutput, Looper looper, int i, ArrayList<Renderer> arrayList) {
arrayList.add(new TextRenderer(textOutput, looper));
}
protected void buildMetadataRenderers(Context context, MetadataOutput metadataOutput, Looper looper, int i, ArrayList<Renderer> arrayList) {
arrayList.add(new MetadataRenderer(metadataOutput, looper));
}
protected void buildCameraMotionRenderers(Context context, int i, ArrayList<Renderer> arrayList) {
arrayList.add(new CameraMotionRenderer());
}
protected AudioSink buildAudioSink(Context context, boolean z, boolean z2, boolean z3) {
return new DefaultAudioSink.Builder(context).setEnableFloatOutput(z).setEnableAudioTrackPlaybackParams(z2).setOffloadMode(z3 ? 1 : 0).build();
}
}