Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
package com.mbridge.msdk.playercommon.exoplayer2.video;
import com.mbridge.msdk.playercommon.exoplayer2.ParserException;
import com.mbridge.msdk.playercommon.exoplayer2.util.CodecSpecificDataUtil;
import com.mbridge.msdk.playercommon.exoplayer2.util.NalUnitUtil;
import com.mbridge.msdk.playercommon.exoplayer2.util.ParsableByteArray;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes4.dex */
public final class AvcConfig {
public final int height;
public final List<byte[]> initializationData;
public final int nalUnitLengthFieldLength;
public final float pixelWidthAspectRatio;
public final int width;
public static AvcConfig parse(ParsableByteArray parsableByteArray) throws ParserException {
int i;
int i2;
float f;
try {
parsableByteArray.skipBytes(4);
int readUnsignedByte = (parsableByteArray.readUnsignedByte() & 3) + 1;
if (readUnsignedByte == 3) {
throw new IllegalStateException();
}
ArrayList arrayList = new ArrayList();
int readUnsignedByte2 = parsableByteArray.readUnsignedByte() & 31;
for (int i3 = 0; i3 < readUnsignedByte2; i3++) {
arrayList.add(buildNalUnitForChild(parsableByteArray));
}
int readUnsignedByte3 = parsableByteArray.readUnsignedByte();
for (int i4 = 0; i4 < readUnsignedByte3; i4++) {
arrayList.add(buildNalUnitForChild(parsableByteArray));
}
if (readUnsignedByte2 > 0) {
NalUnitUtil.SpsData parseSpsNalUnit = NalUnitUtil.parseSpsNalUnit((byte[]) arrayList.get(0), readUnsignedByte, ((byte[]) arrayList.get(0)).length);
int i5 = parseSpsNalUnit.width;
int i6 = parseSpsNalUnit.height;
f = parseSpsNalUnit.pixelWidthAspectRatio;
i = i5;
i2 = i6;
} else {
i = -1;
i2 = -1;
f = 1.0f;
}
return new AvcConfig(arrayList, readUnsignedByte, i, i2, f);
} catch (ArrayIndexOutOfBoundsException e) {
throw new ParserException("Error parsing AVC config", e);
}
}
private AvcConfig(List<byte[]> list, int i, int i2, int i3, float f) {
this.initializationData = list;
this.nalUnitLengthFieldLength = i;
this.width = i2;
this.height = i3;
this.pixelWidthAspectRatio = f;
}
private static byte[] buildNalUnitForChild(ParsableByteArray parsableByteArray) {
int readUnsignedShort = parsableByteArray.readUnsignedShort();
int position = parsableByteArray.getPosition();
parsableByteArray.skipBytes(readUnsignedShort);
return CodecSpecificDataUtil.buildNalUnit(parsableByteArray.data, position, readUnsignedShort);
}
}

View File

@@ -0,0 +1,93 @@
package com.mbridge.msdk.playercommon.exoplayer2.video;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import com.ironsource.mediationsdk.logger.IronSourceError;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import java.util.Arrays;
/* loaded from: classes4.dex */
public final class ColorInfo implements Parcelable {
public static final Parcelable.Creator<ColorInfo> CREATOR = new Parcelable.Creator<ColorInfo>() { // from class: com.mbridge.msdk.playercommon.exoplayer2.video.ColorInfo.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public ColorInfo[] newArray(int i) {
return new ColorInfo[0];
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public ColorInfo createFromParcel(Parcel parcel) {
return new ColorInfo(parcel);
}
};
public final int colorRange;
public final int colorSpace;
public final int colorTransfer;
private int hashCode;
public final byte[] hdrStaticInfo;
@Override // android.os.Parcelable
public final int describeContents() {
return 0;
}
public ColorInfo(int i, int i2, int i3, byte[] bArr) {
this.colorSpace = i;
this.colorRange = i2;
this.colorTransfer = i3;
this.hdrStaticInfo = bArr;
}
public ColorInfo(Parcel parcel) {
this.colorSpace = parcel.readInt();
this.colorRange = parcel.readInt();
this.colorTransfer = parcel.readInt();
this.hdrStaticInfo = Util.readBoolean(parcel) ? parcel.createByteArray() : null;
}
public final boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || ColorInfo.class != obj.getClass()) {
return false;
}
ColorInfo colorInfo = (ColorInfo) obj;
return this.colorSpace == colorInfo.colorSpace && this.colorRange == colorInfo.colorRange && this.colorTransfer == colorInfo.colorTransfer && Arrays.equals(this.hdrStaticInfo, colorInfo.hdrStaticInfo);
}
public final String toString() {
StringBuilder sb = new StringBuilder();
sb.append("ColorInfo(");
sb.append(this.colorSpace);
sb.append(", ");
sb.append(this.colorRange);
sb.append(", ");
sb.append(this.colorTransfer);
sb.append(", ");
sb.append(this.hdrStaticInfo != null);
sb.append(")");
return sb.toString();
}
public final int hashCode() {
if (this.hashCode == 0) {
this.hashCode = ((((((IronSourceError.ERROR_NON_EXISTENT_INSTANCE + this.colorSpace) * 31) + this.colorRange) * 31) + this.colorTransfer) * 31) + Arrays.hashCode(this.hdrStaticInfo);
}
return this.hashCode;
}
@Override // android.os.Parcelable
public final void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(this.colorSpace);
parcel.writeInt(this.colorRange);
parcel.writeInt(this.colorTransfer);
Util.writeBoolean(parcel, this.hdrStaticInfo != null);
byte[] bArr = this.hdrStaticInfo;
if (bArr != null) {
parcel.writeByteArray(bArr);
}
}
}

View File

@@ -0,0 +1,205 @@
package com.mbridge.msdk.playercommon.exoplayer2.video;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.EGL14;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.util.Log;
import android.view.Surface;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.EGLSurfaceTexture;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
@TargetApi(17)
/* loaded from: classes4.dex */
public final class DummySurface extends Surface {
private static final String EXTENSION_PROTECTED_CONTENT = "EGL_EXT_protected_content";
private static final String EXTENSION_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
private static final String TAG = "DummySurface";
private static int secureMode;
private static boolean secureModeInitialized;
public final boolean secure;
private final DummySurfaceThread thread;
private boolean threadReleased;
public static synchronized boolean isSecureSupported(Context context) {
boolean z;
synchronized (DummySurface.class) {
try {
if (!secureModeInitialized) {
secureMode = Util.SDK_INT < 24 ? 0 : getSecureModeV24(context);
secureModeInitialized = true;
}
z = secureMode != 0;
} catch (Throwable th) {
throw th;
}
}
return z;
}
public static DummySurface newInstanceV17(Context context, boolean z) {
assertApiLevel17OrHigher();
Assertions.checkState(!z || isSecureSupported(context));
return new DummySurfaceThread().init(z ? secureMode : 0);
}
private DummySurface(DummySurfaceThread dummySurfaceThread, SurfaceTexture surfaceTexture, boolean z) {
super(surfaceTexture);
this.thread = dummySurfaceThread;
this.secure = z;
}
@Override // android.view.Surface
public final void release() {
super.release();
synchronized (this.thread) {
try {
if (!this.threadReleased) {
this.thread.release();
this.threadReleased = true;
}
} catch (Throwable th) {
throw th;
}
}
}
private static void assertApiLevel17OrHigher() {
if (Util.SDK_INT < 17) {
throw new UnsupportedOperationException("Unsupported prior to API level 17");
}
}
@TargetApi(24)
private static int getSecureModeV24(Context context) {
String eglQueryString;
int i = Util.SDK_INT;
if (i < 26 && ("samsung".equals(Util.MANUFACTURER) || "XT1650".equals(Util.MODEL))) {
return 0;
}
if ((i >= 26 || context.getPackageManager().hasSystemFeature("android.hardware.vr.high_performance")) && (eglQueryString = EGL14.eglQueryString(EGL14.eglGetDisplay(0), 12373)) != null && eglQueryString.contains(EXTENSION_PROTECTED_CONTENT)) {
return eglQueryString.contains(EXTENSION_SURFACELESS_CONTEXT) ? 1 : 2;
}
return 0;
}
public static class DummySurfaceThread extends HandlerThread implements Handler.Callback {
private static final int MSG_INIT = 1;
private static final int MSG_RELEASE = 2;
@Nullable
private EGLSurfaceTexture eglSurfaceTexture;
@Nullable
private Handler handler;
@Nullable
private Error initError;
@Nullable
private RuntimeException initException;
@Nullable
private DummySurface surface;
public DummySurfaceThread() {
super("dummySurface");
}
public DummySurface init(int i) {
boolean z;
start();
this.handler = new Handler(getLooper(), this);
this.eglSurfaceTexture = new EGLSurfaceTexture(this.handler);
synchronized (this) {
z = false;
this.handler.obtainMessage(1, i, 0).sendToTarget();
while (this.surface == null && this.initException == null && this.initError == null) {
try {
wait();
} catch (InterruptedException unused) {
z = true;
}
}
}
if (z) {
Thread.currentThread().interrupt();
}
RuntimeException runtimeException = this.initException;
if (runtimeException != null) {
throw runtimeException;
}
Error error = this.initError;
if (error != null) {
throw error;
}
return (DummySurface) Assertions.checkNotNull(this.surface);
}
public void release() {
Assertions.checkNotNull(this.handler);
this.handler.sendEmptyMessage(2);
}
@Override // android.os.Handler.Callback
public boolean handleMessage(Message message) {
int i = message.what;
try {
if (i != 1) {
if (i != 2) {
return true;
}
try {
releaseInternal();
} finally {
try {
return true;
} finally {
}
}
return true;
}
try {
initInternal(message.arg1);
synchronized (this) {
notify();
}
} catch (Error e) {
Log.e(DummySurface.TAG, "Failed to initialize dummy surface", e);
this.initError = e;
synchronized (this) {
notify();
}
} catch (RuntimeException e2) {
Log.e(DummySurface.TAG, "Failed to initialize dummy surface", e2);
this.initException = e2;
synchronized (this) {
notify();
}
}
return true;
} catch (Throwable th) {
synchronized (this) {
notify();
throw th;
}
}
}
private void initInternal(int i) {
Assertions.checkNotNull(this.eglSurfaceTexture);
this.eglSurfaceTexture.init(i);
this.surface = new DummySurface(this, this.eglSurfaceTexture.getSurfaceTexture(), i != 0);
}
private void releaseInternal() {
Assertions.checkNotNull(this.eglSurfaceTexture);
this.eglSurfaceTexture.release();
}
}
}

View File

@@ -0,0 +1,56 @@
package com.mbridge.msdk.playercommon.exoplayer2.video;
import com.mbridge.msdk.playercommon.exoplayer2.ParserException;
import com.mbridge.msdk.playercommon.exoplayer2.util.NalUnitUtil;
import com.mbridge.msdk.playercommon.exoplayer2.util.ParsableByteArray;
import java.util.Collections;
import java.util.List;
/* loaded from: classes4.dex */
public final class HevcConfig {
public final List<byte[]> initializationData;
public final int nalUnitLengthFieldLength;
public static HevcConfig parse(ParsableByteArray parsableByteArray) throws ParserException {
try {
parsableByteArray.skipBytes(21);
int readUnsignedByte = parsableByteArray.readUnsignedByte() & 3;
int readUnsignedByte2 = parsableByteArray.readUnsignedByte();
int position = parsableByteArray.getPosition();
int i = 0;
for (int i2 = 0; i2 < readUnsignedByte2; i2++) {
parsableByteArray.skipBytes(1);
int readUnsignedShort = parsableByteArray.readUnsignedShort();
for (int i3 = 0; i3 < readUnsignedShort; i3++) {
int readUnsignedShort2 = parsableByteArray.readUnsignedShort();
i += readUnsignedShort2 + 4;
parsableByteArray.skipBytes(readUnsignedShort2);
}
}
parsableByteArray.setPosition(position);
byte[] bArr = new byte[i];
int i4 = 0;
for (int i5 = 0; i5 < readUnsignedByte2; i5++) {
parsableByteArray.skipBytes(1);
int readUnsignedShort3 = parsableByteArray.readUnsignedShort();
for (int i6 = 0; i6 < readUnsignedShort3; i6++) {
int readUnsignedShort4 = parsableByteArray.readUnsignedShort();
byte[] bArr2 = NalUnitUtil.NAL_START_CODE;
System.arraycopy(bArr2, 0, bArr, i4, bArr2.length);
int length = i4 + bArr2.length;
System.arraycopy(parsableByteArray.data, parsableByteArray.getPosition(), bArr, length, readUnsignedShort4);
i4 = length + readUnsignedShort4;
parsableByteArray.skipBytes(readUnsignedShort4);
}
}
return new HevcConfig(i == 0 ? null : Collections.singletonList(bArr), readUnsignedByte + 1);
} catch (ArrayIndexOutOfBoundsException e) {
throw new ParserException("Error parsing HEVC config", e);
}
}
private HevcConfig(List<byte[]> list, int i) {
this.initializationData = list;
this.nalUnitLengthFieldLength = i;
}
}

View File

@@ -0,0 +1,940 @@
package com.mbridge.msdk.playercommon.exoplayer2.video;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Point;
import android.media.MediaCodec;
import android.media.MediaCrypto;
import android.media.MediaFormat;
import android.os.Handler;
import android.os.SystemClock;
import android.util.Log;
import android.view.Surface;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.work.WorkRequest;
import com.ironsource.v8;
import com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlaybackException;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderCounters;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderInputBuffer;
import com.mbridge.msdk.playercommon.exoplayer2.drm.DrmInitData;
import com.mbridge.msdk.playercommon.exoplayer2.drm.DrmSessionManager;
import com.mbridge.msdk.playercommon.exoplayer2.drm.FrameworkMediaCrypto;
import com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecInfo;
import com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer;
import com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecSelector;
import com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecUtil;
import com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaFormatUtil;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes;
import com.mbridge.msdk.playercommon.exoplayer2.util.TraceUtil;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import com.mbridge.msdk.playercommon.exoplayer2.video.VideoRendererEventListener;
import com.unity3d.ads.core.domain.HandleInvocationsFromAdViewer;
import java.nio.ByteBuffer;
@TargetApi(16)
/* loaded from: classes4.dex */
public class MediaCodecVideoRenderer extends MediaCodecRenderer {
private static final String KEY_CROP_BOTTOM = "crop-bottom";
private static final String KEY_CROP_LEFT = "crop-left";
private static final String KEY_CROP_RIGHT = "crop-right";
private static final String KEY_CROP_TOP = "crop-top";
private static final int MAX_PENDING_OUTPUT_STREAM_OFFSET_COUNT = 10;
private static final int[] STANDARD_LONG_EDGE_VIDEO_PX = {1920, 1600, 1440, 1280, 960, 854, 640, 540, 480};
private static final String TAG = "MediaCodecVideoRenderer";
private static boolean deviceNeedsSetOutputSurfaceWorkaround;
private static boolean evaluatedDeviceNeedsSetOutputSurfaceWorkaround;
private final long allowedJoiningTimeMs;
private int buffersInCodecCount;
private CodecMaxValues codecMaxValues;
private boolean codecNeedsSetOutputSurfaceWorkaround;
private int consecutiveDroppedFrameCount;
private final Context context;
private int currentHeight;
private float currentPixelWidthHeightRatio;
private int currentUnappliedRotationDegrees;
private int currentWidth;
private final boolean deviceNeedsAutoFrcWorkaround;
private long droppedFrameAccumulationStartTimeMs;
private int droppedFrames;
private Surface dummySurface;
private final VideoRendererEventListener.EventDispatcher eventDispatcher;
private final VideoFrameReleaseTimeHelper frameReleaseTimeHelper;
private long initialPositionUs;
private long joiningDeadlineMs;
private long lastInputTimeUs;
private long lastRenderTimeUs;
private final int maxDroppedFramesToNotify;
private long outputStreamOffsetUs;
private int pendingOutputStreamOffsetCount;
private final long[] pendingOutputStreamOffsetsUs;
private final long[] pendingOutputStreamSwitchTimesUs;
private float pendingPixelWidthHeightRatio;
private int pendingRotationDegrees;
private boolean renderedFirstFrame;
private int reportedHeight;
private float reportedPixelWidthHeightRatio;
private int reportedUnappliedRotationDegrees;
private int reportedWidth;
private int scalingMode;
private Surface surface;
private boolean tunneling;
private int tunnelingAudioSessionId;
OnFrameRenderedListenerV23 tunnelingOnFrameRenderedListener;
private void clearReportedVideoSize() {
this.reportedWidth = -1;
this.reportedHeight = -1;
this.reportedPixelWidthHeightRatio = -1.0f;
this.reportedUnappliedRotationDegrees = -1;
}
private static boolean isBufferLate(long j) {
return j < -30000;
}
private static boolean isBufferVeryLate(long j) {
return j < -500000;
}
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector) {
this(context, mediaCodecSelector, 0L);
}
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector, long j) {
this(context, mediaCodecSelector, j, null, null, -1);
}
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector, long j, @Nullable Handler handler, @Nullable VideoRendererEventListener videoRendererEventListener, int i) {
this(context, mediaCodecSelector, j, null, false, handler, videoRendererEventListener, i);
}
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector, long j, @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, boolean z, @Nullable Handler handler, @Nullable VideoRendererEventListener videoRendererEventListener, int i) {
super(2, mediaCodecSelector, drmSessionManager, z);
this.allowedJoiningTimeMs = j;
this.maxDroppedFramesToNotify = i;
Context applicationContext = context.getApplicationContext();
this.context = applicationContext;
this.frameReleaseTimeHelper = new VideoFrameReleaseTimeHelper(applicationContext);
this.eventDispatcher = new VideoRendererEventListener.EventDispatcher(handler, videoRendererEventListener);
this.deviceNeedsAutoFrcWorkaround = deviceNeedsAutoFrcWorkaround();
this.pendingOutputStreamOffsetsUs = new long[10];
this.pendingOutputStreamSwitchTimesUs = new long[10];
this.outputStreamOffsetUs = C.TIME_UNSET;
this.lastInputTimeUs = C.TIME_UNSET;
this.joiningDeadlineMs = C.TIME_UNSET;
this.currentWidth = -1;
this.currentHeight = -1;
this.currentPixelWidthHeightRatio = -1.0f;
this.pendingPixelWidthHeightRatio = -1.0f;
this.scalingMode = 1;
clearReportedVideoSize();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
public int supportsFormat(MediaCodecSelector mediaCodecSelector, DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, Format format) throws MediaCodecUtil.DecoderQueryException {
boolean z;
int i;
int i2;
String str = format.sampleMimeType;
if (!MimeTypes.isVideo(str)) {
return 0;
}
DrmInitData drmInitData = format.drmInitData;
if (drmInitData != null) {
z = false;
for (int i3 = 0; i3 < drmInitData.schemeDataCount; i3++) {
z |= drmInitData.get(i3).requiresSecureDecryption;
}
} else {
z = false;
}
MediaCodecInfo decoderInfo = mediaCodecSelector.getDecoderInfo(str, z);
if (decoderInfo == null) {
return (!z || mediaCodecSelector.getDecoderInfo(str, false) == null) ? 1 : 2;
}
if (!BaseRenderer.supportsFormatDrm(drmSessionManager, drmInitData)) {
return 2;
}
boolean isCodecSupported = decoderInfo.isCodecSupported(format.codecs);
if (isCodecSupported && (i = format.width) > 0 && (i2 = format.height) > 0) {
if (Util.SDK_INT >= 21) {
isCodecSupported = decoderInfo.isVideoSizeAndRateSupportedV21(i, i2, format.frameRate);
} else {
boolean z2 = i * i2 <= MediaCodecUtil.maxH264DecodableFrameSize();
if (!z2) {
StringBuilder sb = new StringBuilder();
sb.append("FalseCheck [legacyFrameSize, ");
sb.append(format.width);
sb.append("x");
sb.append(format.height);
sb.append("] [");
sb.append(Util.DEVICE_DEBUG_INFO);
sb.append(v8.i.e);
}
isCodecSupported = z2;
}
}
return (isCodecSupported ? 4 : 3) | (decoderInfo.adaptive ? 16 : 8) | (decoderInfo.tunneling ? 32 : 0);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer, com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
public void onEnabled(boolean z) throws ExoPlaybackException {
super.onEnabled(z);
int i = getConfiguration().tunnelingAudioSessionId;
this.tunnelingAudioSessionId = i;
this.tunneling = i != 0;
this.eventDispatcher.enabled(this.decoderCounters);
this.frameReleaseTimeHelper.enable();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
public void onStreamChanged(Format[] formatArr, long j) throws ExoPlaybackException {
if (this.outputStreamOffsetUs == C.TIME_UNSET) {
this.outputStreamOffsetUs = j;
} else {
int i = this.pendingOutputStreamOffsetCount;
if (i == this.pendingOutputStreamOffsetsUs.length) {
Log.w(TAG, "Too many stream changes, so dropping offset: " + this.pendingOutputStreamOffsetsUs[this.pendingOutputStreamOffsetCount - 1]);
} else {
this.pendingOutputStreamOffsetCount = i + 1;
}
long[] jArr = this.pendingOutputStreamOffsetsUs;
int i2 = this.pendingOutputStreamOffsetCount;
jArr[i2 - 1] = j;
this.pendingOutputStreamSwitchTimesUs[i2 - 1] = this.lastInputTimeUs;
}
super.onStreamChanged(formatArr, j);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer, com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
public void onPositionReset(long j, boolean z) throws ExoPlaybackException {
super.onPositionReset(j, z);
clearRenderedFirstFrame();
this.initialPositionUs = C.TIME_UNSET;
this.consecutiveDroppedFrameCount = 0;
this.lastInputTimeUs = C.TIME_UNSET;
int i = this.pendingOutputStreamOffsetCount;
if (i != 0) {
this.outputStreamOffsetUs = this.pendingOutputStreamOffsetsUs[i - 1];
this.pendingOutputStreamOffsetCount = 0;
}
if (z) {
setJoiningDeadlineMs();
} else {
this.joiningDeadlineMs = C.TIME_UNSET;
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer, com.mbridge.msdk.playercommon.exoplayer2.Renderer
public boolean isReady() {
Surface surface;
if (super.isReady() && (this.renderedFirstFrame || (((surface = this.dummySurface) != null && this.surface == surface) || getCodec() == null || this.tunneling))) {
this.joiningDeadlineMs = C.TIME_UNSET;
return true;
}
if (this.joiningDeadlineMs == C.TIME_UNSET) {
return false;
}
if (SystemClock.elapsedRealtime() < this.joiningDeadlineMs) {
return true;
}
this.joiningDeadlineMs = C.TIME_UNSET;
return false;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer, com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
public void onStarted() {
super.onStarted();
this.droppedFrames = 0;
this.droppedFrameAccumulationStartTimeMs = SystemClock.elapsedRealtime();
this.lastRenderTimeUs = SystemClock.elapsedRealtime() * 1000;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer, com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
public void onStopped() {
this.joiningDeadlineMs = C.TIME_UNSET;
maybeNotifyDroppedFrames();
super.onStopped();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer, com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
public void onDisabled() {
this.currentWidth = -1;
this.currentHeight = -1;
this.currentPixelWidthHeightRatio = -1.0f;
this.pendingPixelWidthHeightRatio = -1.0f;
this.outputStreamOffsetUs = C.TIME_UNSET;
this.lastInputTimeUs = C.TIME_UNSET;
this.pendingOutputStreamOffsetCount = 0;
clearReportedVideoSize();
clearRenderedFirstFrame();
this.frameReleaseTimeHelper.disable();
this.tunnelingOnFrameRenderedListener = null;
this.tunneling = false;
try {
super.onDisabled();
} finally {
this.decoderCounters.ensureUpdated();
this.eventDispatcher.disabled(this.decoderCounters);
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer, com.mbridge.msdk.playercommon.exoplayer2.PlayerMessage.Target
public void handleMessage(int i, Object obj) throws ExoPlaybackException {
if (i == 1) {
setSurface((Surface) obj);
return;
}
if (i == 4) {
this.scalingMode = ((Integer) obj).intValue();
MediaCodec codec = getCodec();
if (codec != null) {
codec.setVideoScalingMode(this.scalingMode);
return;
}
return;
}
super.handleMessage(i, obj);
}
private void setSurface(Surface surface) throws ExoPlaybackException {
if (surface == null) {
Surface surface2 = this.dummySurface;
if (surface2 != null) {
surface = surface2;
} else {
MediaCodecInfo codecInfo = getCodecInfo();
if (codecInfo != null && shouldUseDummySurface(codecInfo)) {
surface = DummySurface.newInstanceV17(this.context, codecInfo.secure);
this.dummySurface = surface;
}
}
}
if (this.surface == surface) {
if (surface == null || surface == this.dummySurface) {
return;
}
maybeRenotifyVideoSizeChanged();
maybeRenotifyRenderedFirstFrame();
return;
}
this.surface = surface;
int state = getState();
if (state == 1 || state == 2) {
MediaCodec codec = getCodec();
if (Util.SDK_INT >= 23 && codec != null && surface != null && !this.codecNeedsSetOutputSurfaceWorkaround) {
setOutputSurfaceV23(codec, surface);
} else {
releaseCodec();
maybeInitCodec();
}
}
if (surface != null && surface != this.dummySurface) {
maybeRenotifyVideoSizeChanged();
clearRenderedFirstFrame();
if (state == 2) {
setJoiningDeadlineMs();
return;
}
return;
}
clearReportedVideoSize();
clearRenderedFirstFrame();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
public boolean shouldInitCodec(MediaCodecInfo mediaCodecInfo) {
return this.surface != null || shouldUseDummySurface(mediaCodecInfo);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
public void configureCodec(MediaCodecInfo mediaCodecInfo, MediaCodec mediaCodec, Format format, MediaCrypto mediaCrypto) throws MediaCodecUtil.DecoderQueryException {
CodecMaxValues codecMaxValues = getCodecMaxValues(mediaCodecInfo, format, getStreamFormats());
this.codecMaxValues = codecMaxValues;
MediaFormat mediaFormat = getMediaFormat(format, codecMaxValues, this.deviceNeedsAutoFrcWorkaround, this.tunnelingAudioSessionId);
if (this.surface == null) {
Assertions.checkState(shouldUseDummySurface(mediaCodecInfo));
if (this.dummySurface == null) {
this.dummySurface = DummySurface.newInstanceV17(this.context, mediaCodecInfo.secure);
}
this.surface = this.dummySurface;
}
mediaCodec.configure(mediaFormat, this.surface, mediaCrypto, 0);
if (Util.SDK_INT < 23 || !this.tunneling) {
return;
}
this.tunnelingOnFrameRenderedListener = new OnFrameRenderedListenerV23(mediaCodec);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
public int canKeepCodec(MediaCodec mediaCodec, MediaCodecInfo mediaCodecInfo, Format format, Format format2) {
if (!areAdaptationCompatible(mediaCodecInfo.adaptive, format, format2)) {
return 0;
}
int i = format2.width;
CodecMaxValues codecMaxValues = this.codecMaxValues;
if (i > codecMaxValues.width || format2.height > codecMaxValues.height || getMaxInputSize(mediaCodecInfo, format2) > this.codecMaxValues.inputSize) {
return 0;
}
return format.initializationDataEquals(format2) ? 1 : 3;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
@CallSuper
public void releaseCodec() {
try {
super.releaseCodec();
this.buffersInCodecCount = 0;
Surface surface = this.dummySurface;
if (surface != null) {
if (this.surface == surface) {
this.surface = null;
}
surface.release();
this.dummySurface = null;
}
} catch (Throwable th) {
this.buffersInCodecCount = 0;
if (this.dummySurface != null) {
Surface surface2 = this.surface;
Surface surface3 = this.dummySurface;
if (surface2 == surface3) {
this.surface = null;
}
surface3.release();
this.dummySurface = null;
}
throw th;
}
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
@CallSuper
public void flushCodec() throws ExoPlaybackException {
super.flushCodec();
this.buffersInCodecCount = 0;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
public void onCodecInitialized(String str, long j, long j2) {
this.eventDispatcher.decoderInitialized(str, j, j2);
this.codecNeedsSetOutputSurfaceWorkaround = codecNeedsSetOutputSurfaceWorkaround(str);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
public void onInputFormatChanged(Format format) throws ExoPlaybackException {
super.onInputFormatChanged(format);
this.eventDispatcher.inputFormatChanged(format);
this.pendingPixelWidthHeightRatio = format.pixelWidthHeightRatio;
this.pendingRotationDegrees = format.rotationDegrees;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
@CallSuper
public void onQueueInputBuffer(DecoderInputBuffer decoderInputBuffer) {
this.buffersInCodecCount++;
this.lastInputTimeUs = Math.max(decoderInputBuffer.timeUs, this.lastInputTimeUs);
if (Util.SDK_INT >= 23 || !this.tunneling) {
return;
}
maybeNotifyRenderedFirstFrame();
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
public void onOutputFormatChanged(MediaCodec mediaCodec, MediaFormat mediaFormat) {
int integer;
int integer2;
boolean z = mediaFormat.containsKey(KEY_CROP_RIGHT) && mediaFormat.containsKey(KEY_CROP_LEFT) && mediaFormat.containsKey(KEY_CROP_BOTTOM) && mediaFormat.containsKey(KEY_CROP_TOP);
if (z) {
integer = (mediaFormat.getInteger(KEY_CROP_RIGHT) - mediaFormat.getInteger(KEY_CROP_LEFT)) + 1;
} else {
integer = mediaFormat.getInteger("width");
}
this.currentWidth = integer;
if (z) {
integer2 = (mediaFormat.getInteger(KEY_CROP_BOTTOM) - mediaFormat.getInteger(KEY_CROP_TOP)) + 1;
} else {
integer2 = mediaFormat.getInteger("height");
}
this.currentHeight = integer2;
float f = this.pendingPixelWidthHeightRatio;
this.currentPixelWidthHeightRatio = f;
if (Util.SDK_INT >= 21) {
int i = this.pendingRotationDegrees;
if (i == 90 || i == 270) {
int i2 = this.currentWidth;
this.currentWidth = integer2;
this.currentHeight = i2;
this.currentPixelWidthHeightRatio = 1.0f / f;
}
} else {
this.currentUnappliedRotationDegrees = this.pendingRotationDegrees;
}
mediaCodec.setVideoScalingMode(this.scalingMode);
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
public boolean processOutputBuffer(long j, long j2, MediaCodec mediaCodec, ByteBuffer byteBuffer, int i, int i2, long j3, boolean z) throws ExoPlaybackException {
if (this.initialPositionUs == C.TIME_UNSET) {
this.initialPositionUs = j;
}
long j4 = j3 - this.outputStreamOffsetUs;
if (z) {
skipOutputBuffer(mediaCodec, i, j4);
return true;
}
long j5 = j3 - j;
if (this.surface == this.dummySurface) {
if (!isBufferLate(j5)) {
return false;
}
skipOutputBuffer(mediaCodec, i, j4);
return true;
}
long elapsedRealtime = SystemClock.elapsedRealtime() * 1000;
boolean z2 = getState() == 2;
if (!this.renderedFirstFrame || (z2 && shouldForceRenderOutputBuffer(j5, elapsedRealtime - this.lastRenderTimeUs))) {
if (Util.SDK_INT >= 21) {
renderOutputBufferV21(mediaCodec, i, j4, System.nanoTime());
return true;
}
renderOutputBuffer(mediaCodec, i, j4);
return true;
}
if (z2 && j != this.initialPositionUs) {
long nanoTime = System.nanoTime();
long adjustReleaseTime = this.frameReleaseTimeHelper.adjustReleaseTime(j3, ((j5 - (elapsedRealtime - j2)) * 1000) + nanoTime);
long j6 = (adjustReleaseTime - nanoTime) / 1000;
if (shouldDropBuffersToKeyframe(j6, j2) && maybeDropBuffersToKeyframe(mediaCodec, i, j4, j)) {
return false;
}
if (shouldDropOutputBuffer(j6, j2)) {
dropOutputBuffer(mediaCodec, i, j4);
return true;
}
if (Util.SDK_INT >= 21) {
if (j6 < 50000) {
renderOutputBufferV21(mediaCodec, i, j4, adjustReleaseTime);
return true;
}
} else if (j6 < WorkRequest.DEFAULT_BACKOFF_DELAY_MILLIS) {
if (j6 > 11000) {
try {
Thread.sleep((j6 - WorkRequest.MIN_BACKOFF_MILLIS) / 1000);
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
return false;
}
}
renderOutputBuffer(mediaCodec, i, j4);
return true;
}
}
return false;
}
@Override // com.mbridge.msdk.playercommon.exoplayer2.mediacodec.MediaCodecRenderer
@CallSuper
public void onProcessedOutputBuffer(long j) {
this.buffersInCodecCount--;
while (true) {
int i = this.pendingOutputStreamOffsetCount;
if (i == 0 || j < this.pendingOutputStreamSwitchTimesUs[0]) {
return;
}
long[] jArr = this.pendingOutputStreamOffsetsUs;
this.outputStreamOffsetUs = jArr[0];
int i2 = i - 1;
this.pendingOutputStreamOffsetCount = i2;
System.arraycopy(jArr, 1, jArr, 0, i2);
long[] jArr2 = this.pendingOutputStreamSwitchTimesUs;
System.arraycopy(jArr2, 1, jArr2, 0, this.pendingOutputStreamOffsetCount);
}
}
public boolean shouldDropOutputBuffer(long j, long j2) {
return isBufferLate(j);
}
public boolean shouldDropBuffersToKeyframe(long j, long j2) {
return isBufferVeryLate(j);
}
public boolean shouldForceRenderOutputBuffer(long j, long j2) {
return isBufferLate(j) && j2 > 100000;
}
public void skipOutputBuffer(MediaCodec mediaCodec, int i, long j) {
TraceUtil.beginSection("skipVideoBuffer");
mediaCodec.releaseOutputBuffer(i, false);
TraceUtil.endSection();
this.decoderCounters.skippedOutputBufferCount++;
}
public void dropOutputBuffer(MediaCodec mediaCodec, int i, long j) {
TraceUtil.beginSection("dropVideoBuffer");
mediaCodec.releaseOutputBuffer(i, false);
TraceUtil.endSection();
updateDroppedBufferCounters(1);
}
public boolean maybeDropBuffersToKeyframe(MediaCodec mediaCodec, int i, long j, long j2) throws ExoPlaybackException {
int skipSource = skipSource(j2);
if (skipSource == 0) {
return false;
}
this.decoderCounters.droppedToKeyframeCount++;
updateDroppedBufferCounters(this.buffersInCodecCount + skipSource);
flushCodec();
return true;
}
public void updateDroppedBufferCounters(int i) {
DecoderCounters decoderCounters = this.decoderCounters;
decoderCounters.droppedBufferCount += i;
this.droppedFrames += i;
int i2 = this.consecutiveDroppedFrameCount + i;
this.consecutiveDroppedFrameCount = i2;
decoderCounters.maxConsecutiveDroppedBufferCount = Math.max(i2, decoderCounters.maxConsecutiveDroppedBufferCount);
if (this.droppedFrames >= this.maxDroppedFramesToNotify) {
maybeNotifyDroppedFrames();
}
}
public void renderOutputBuffer(MediaCodec mediaCodec, int i, long j) {
maybeNotifyVideoSizeChanged();
TraceUtil.beginSection("releaseOutputBuffer");
mediaCodec.releaseOutputBuffer(i, true);
TraceUtil.endSection();
this.lastRenderTimeUs = SystemClock.elapsedRealtime() * 1000;
this.decoderCounters.renderedOutputBufferCount++;
this.consecutiveDroppedFrameCount = 0;
maybeNotifyRenderedFirstFrame();
}
@TargetApi(21)
public void renderOutputBufferV21(MediaCodec mediaCodec, int i, long j, long j2) {
maybeNotifyVideoSizeChanged();
TraceUtil.beginSection("releaseOutputBuffer");
mediaCodec.releaseOutputBuffer(i, j2);
TraceUtil.endSection();
this.lastRenderTimeUs = SystemClock.elapsedRealtime() * 1000;
this.decoderCounters.renderedOutputBufferCount++;
this.consecutiveDroppedFrameCount = 0;
maybeNotifyRenderedFirstFrame();
}
private boolean shouldUseDummySurface(MediaCodecInfo mediaCodecInfo) {
return Util.SDK_INT >= 23 && !this.tunneling && !codecNeedsSetOutputSurfaceWorkaround(mediaCodecInfo.name) && (!mediaCodecInfo.secure || DummySurface.isSecureSupported(this.context));
}
private void setJoiningDeadlineMs() {
this.joiningDeadlineMs = this.allowedJoiningTimeMs > 0 ? SystemClock.elapsedRealtime() + this.allowedJoiningTimeMs : C.TIME_UNSET;
}
private void clearRenderedFirstFrame() {
MediaCodec codec;
this.renderedFirstFrame = false;
if (Util.SDK_INT < 23 || !this.tunneling || (codec = getCodec()) == null) {
return;
}
this.tunnelingOnFrameRenderedListener = new OnFrameRenderedListenerV23(codec);
}
public void maybeNotifyRenderedFirstFrame() {
if (this.renderedFirstFrame) {
return;
}
this.renderedFirstFrame = true;
this.eventDispatcher.renderedFirstFrame(this.surface);
}
private void maybeRenotifyRenderedFirstFrame() {
if (this.renderedFirstFrame) {
this.eventDispatcher.renderedFirstFrame(this.surface);
}
}
private void maybeNotifyVideoSizeChanged() {
int i = this.currentWidth;
if (i == -1 && this.currentHeight == -1) {
return;
}
if (this.reportedWidth == i && this.reportedHeight == this.currentHeight && this.reportedUnappliedRotationDegrees == this.currentUnappliedRotationDegrees && this.reportedPixelWidthHeightRatio == this.currentPixelWidthHeightRatio) {
return;
}
this.eventDispatcher.videoSizeChanged(i, this.currentHeight, this.currentUnappliedRotationDegrees, this.currentPixelWidthHeightRatio);
this.reportedWidth = this.currentWidth;
this.reportedHeight = this.currentHeight;
this.reportedUnappliedRotationDegrees = this.currentUnappliedRotationDegrees;
this.reportedPixelWidthHeightRatio = this.currentPixelWidthHeightRatio;
}
private void maybeRenotifyVideoSizeChanged() {
int i = this.reportedWidth;
if (i == -1 && this.reportedHeight == -1) {
return;
}
this.eventDispatcher.videoSizeChanged(i, this.reportedHeight, this.reportedUnappliedRotationDegrees, this.reportedPixelWidthHeightRatio);
}
private void maybeNotifyDroppedFrames() {
if (this.droppedFrames > 0) {
long elapsedRealtime = SystemClock.elapsedRealtime();
this.eventDispatcher.droppedFrames(this.droppedFrames, elapsedRealtime - this.droppedFrameAccumulationStartTimeMs);
this.droppedFrames = 0;
this.droppedFrameAccumulationStartTimeMs = elapsedRealtime;
}
}
@TargetApi(23)
private static void setOutputSurfaceV23(MediaCodec mediaCodec, Surface surface) {
mediaCodec.setOutputSurface(surface);
}
@TargetApi(21)
private static void configureTunnelingV21(MediaFormat mediaFormat, int i) {
mediaFormat.setFeatureEnabled("tunneled-playback", true);
mediaFormat.setInteger("audio-session-id", i);
}
@SuppressLint({"InlinedApi"})
public MediaFormat getMediaFormat(Format format, CodecMaxValues codecMaxValues, boolean z, int i) {
MediaFormat mediaFormat = new MediaFormat();
mediaFormat.setString("mime", format.sampleMimeType);
mediaFormat.setInteger("width", format.width);
mediaFormat.setInteger("height", format.height);
MediaFormatUtil.setCsdBuffers(mediaFormat, format.initializationData);
MediaFormatUtil.maybeSetFloat(mediaFormat, "frame-rate", format.frameRate);
MediaFormatUtil.maybeSetInteger(mediaFormat, "rotation-degrees", format.rotationDegrees);
MediaFormatUtil.maybeSetColorInfo(mediaFormat, format.colorInfo);
mediaFormat.setInteger("max-width", codecMaxValues.width);
mediaFormat.setInteger("max-height", codecMaxValues.height);
MediaFormatUtil.maybeSetInteger(mediaFormat, "max-input-size", codecMaxValues.inputSize);
if (Util.SDK_INT >= 23) {
mediaFormat.setInteger(HandleInvocationsFromAdViewer.KEY_DOWNLOAD_PRIORITY, 0);
}
if (z) {
mediaFormat.setInteger("auto-frc", 0);
}
if (i != 0) {
configureTunnelingV21(mediaFormat, i);
}
return mediaFormat;
}
public CodecMaxValues getCodecMaxValues(MediaCodecInfo mediaCodecInfo, Format format, Format[] formatArr) throws MediaCodecUtil.DecoderQueryException {
int i = format.width;
int i2 = format.height;
int maxInputSize = getMaxInputSize(mediaCodecInfo, format);
if (formatArr.length == 1) {
return new CodecMaxValues(i, i2, maxInputSize);
}
boolean z = false;
for (Format format2 : formatArr) {
if (areAdaptationCompatible(mediaCodecInfo.adaptive, format, format2)) {
int i3 = format2.width;
z |= i3 == -1 || format2.height == -1;
i = Math.max(i, i3);
i2 = Math.max(i2, format2.height);
maxInputSize = Math.max(maxInputSize, getMaxInputSize(mediaCodecInfo, format2));
}
}
if (z) {
Log.w(TAG, "Resolutions unknown. Codec max resolution: " + i + "x" + i2);
Point codecMaxSize = getCodecMaxSize(mediaCodecInfo, format);
if (codecMaxSize != null) {
i = Math.max(i, codecMaxSize.x);
i2 = Math.max(i2, codecMaxSize.y);
maxInputSize = Math.max(maxInputSize, getMaxInputSize(mediaCodecInfo, format.sampleMimeType, i, i2));
Log.w(TAG, "Codec max resolution adjusted to: " + i + "x" + i2);
}
}
return new CodecMaxValues(i, i2, maxInputSize);
}
private static Point getCodecMaxSize(MediaCodecInfo mediaCodecInfo, Format format) throws MediaCodecUtil.DecoderQueryException {
int i = format.height;
int i2 = format.width;
boolean z = i > i2;
int i3 = z ? i : i2;
if (z) {
i = i2;
}
float f = i / i3;
for (int i4 : STANDARD_LONG_EDGE_VIDEO_PX) {
int i5 = (int) (i4 * f);
if (i4 <= i3 || i5 <= i) {
break;
}
if (Util.SDK_INT >= 21) {
int i6 = z ? i5 : i4;
if (!z) {
i4 = i5;
}
Point alignVideoSizeV21 = mediaCodecInfo.alignVideoSizeV21(i6, i4);
if (mediaCodecInfo.isVideoSizeAndRateSupportedV21(alignVideoSizeV21.x, alignVideoSizeV21.y, format.frameRate)) {
return alignVideoSizeV21;
}
} else {
int ceilDivide = Util.ceilDivide(i4, 16) * 16;
int ceilDivide2 = Util.ceilDivide(i5, 16) * 16;
if (ceilDivide * ceilDivide2 <= MediaCodecUtil.maxH264DecodableFrameSize()) {
int i7 = z ? ceilDivide2 : ceilDivide;
if (!z) {
ceilDivide = ceilDivide2;
}
return new Point(i7, ceilDivide);
}
}
}
return null;
}
private static int getMaxInputSize(MediaCodecInfo mediaCodecInfo, Format format) {
if (format.maxInputSize != -1) {
int size = format.initializationData.size();
int i = 0;
for (int i2 = 0; i2 < size; i2++) {
i += format.initializationData.get(i2).length;
}
return format.maxInputSize + i;
}
return getMaxInputSize(mediaCodecInfo, format.sampleMimeType, format.width, format.height);
}
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
private static int getMaxInputSize(MediaCodecInfo mediaCodecInfo, String str, int i, int i2) {
char c;
int i3;
if (i == -1 || i2 == -1) {
return -1;
}
str.hashCode();
int i4 = 4;
switch (str.hashCode()) {
case -1664118616:
if (str.equals(MimeTypes.VIDEO_H263)) {
c = 0;
break;
}
c = 65535;
break;
case -1662541442:
if (str.equals("video/hevc")) {
c = 1;
break;
}
c = 65535;
break;
case 1187890754:
if (str.equals(MimeTypes.VIDEO_MP4V)) {
c = 2;
break;
}
c = 65535;
break;
case 1331836730:
if (str.equals("video/avc")) {
c = 3;
break;
}
c = 65535;
break;
case 1599127256:
if (str.equals(MimeTypes.VIDEO_VP8)) {
c = 4;
break;
}
c = 65535;
break;
case 1599127257:
if (str.equals(MimeTypes.VIDEO_VP9)) {
c = 5;
break;
}
c = 65535;
break;
default:
c = 65535;
break;
}
switch (c) {
case 0:
case 2:
case 4:
i3 = i * i2;
i4 = 2;
break;
case 1:
case 5:
i3 = i * i2;
break;
case 3:
String str2 = Util.MODEL;
if (!"BRAVIA 4K 2015".equals(str2) && (!"Amazon".equals(Util.MANUFACTURER) || (!"KFSOWI".equals(str2) && (!"AFTS".equals(str2) || !mediaCodecInfo.secure)))) {
i3 = Util.ceilDivide(i, 16) * Util.ceilDivide(i2, 16) * 256;
i4 = 2;
break;
}
break;
}
return -1;
}
private static boolean areAdaptationCompatible(boolean z, Format format, Format format2) {
return format.sampleMimeType.equals(format2.sampleMimeType) && format.rotationDegrees == format2.rotationDegrees && (z || (format.width == format2.width && format.height == format2.height)) && Util.areEqual(format.colorInfo, format2.colorInfo);
}
private static boolean deviceNeedsAutoFrcWorkaround() {
return Util.SDK_INT <= 22 && "foster".equals(Util.DEVICE) && "NVIDIA".equals(Util.MANUFACTURER);
}
/* JADX WARN: Removed duplicated region for block: B:23:0x05cb A[ADDED_TO_REGION] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public boolean codecNeedsSetOutputSurfaceWorkaround(java.lang.String r7) {
/*
Method dump skipped, instructions count: 2212
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.video.MediaCodecVideoRenderer.codecNeedsSetOutputSurfaceWorkaround(java.lang.String):boolean");
}
public static final class CodecMaxValues {
public final int height;
public final int inputSize;
public final int width;
public CodecMaxValues(int i, int i2, int i3) {
this.width = i;
this.height = i2;
this.inputSize = i3;
}
}
@TargetApi(23)
public final class OnFrameRenderedListenerV23 implements MediaCodec.OnFrameRenderedListener {
private OnFrameRenderedListenerV23(MediaCodec mediaCodec) {
mediaCodec.setOnFrameRenderedListener(this, new Handler());
}
@Override // android.media.MediaCodec.OnFrameRenderedListener
public final void onFrameRendered(@NonNull MediaCodec mediaCodec, long j, long j2) {
MediaCodecVideoRenderer mediaCodecVideoRenderer = MediaCodecVideoRenderer.this;
if (this != mediaCodecVideoRenderer.tunnelingOnFrameRenderedListener) {
return;
}
mediaCodecVideoRenderer.maybeNotifyRenderedFirstFrame();
}
}
}

View File

@@ -0,0 +1,307 @@
package com.mbridge.msdk.playercommon.exoplayer2.video;
import android.annotation.TargetApi;
import android.content.Context;
import android.hardware.display.DisplayManager;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.view.Choreographer;
import android.view.WindowManager;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
@TargetApi(16)
/* loaded from: classes4.dex */
public final class VideoFrameReleaseTimeHelper {
private static final long CHOREOGRAPHER_SAMPLE_DELAY_MILLIS = 500;
private static final long MAX_ALLOWED_DRIFT_NS = 20000000;
private static final int MIN_FRAMES_FOR_ADJUSTMENT = 6;
private static final long VSYNC_OFFSET_PERCENTAGE = 80;
private long adjustedLastFrameTimeNs;
private final DefaultDisplayListener displayListener;
private long frameCount;
private boolean haveSync;
private long lastFramePresentationTimeUs;
private long pendingAdjustedFrameTimeNs;
private long syncFramePresentationTimeNs;
private long syncUnadjustedReleaseTimeNs;
private long vsyncDurationNs;
private long vsyncOffsetNs;
private final VSyncSampler vsyncSampler;
private final WindowManager windowManager;
public VideoFrameReleaseTimeHelper() {
this(null);
}
public VideoFrameReleaseTimeHelper(@Nullable Context context) {
if (context != null) {
context = context.getApplicationContext();
this.windowManager = (WindowManager) context.getSystemService("window");
} else {
this.windowManager = null;
}
if (this.windowManager != null) {
this.displayListener = Util.SDK_INT >= 17 ? maybeBuildDefaultDisplayListenerV17(context) : null;
this.vsyncSampler = VSyncSampler.getInstance();
} else {
this.displayListener = null;
this.vsyncSampler = null;
}
this.vsyncDurationNs = C.TIME_UNSET;
this.vsyncOffsetNs = C.TIME_UNSET;
}
public final void enable() {
this.haveSync = false;
if (this.windowManager != null) {
this.vsyncSampler.addObserver();
DefaultDisplayListener defaultDisplayListener = this.displayListener;
if (defaultDisplayListener != null) {
defaultDisplayListener.register();
}
updateDefaultDisplayRefreshRateParams();
}
}
public final void disable() {
if (this.windowManager != null) {
DefaultDisplayListener defaultDisplayListener = this.displayListener;
if (defaultDisplayListener != null) {
defaultDisplayListener.unregister();
}
this.vsyncSampler.removeObserver();
}
}
/* JADX WARN: Removed duplicated region for block: B:14:0x0047 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final long adjustReleaseTime(long r11, long r13) {
/*
r10 = this;
r0 = 1000(0x3e8, double:4.94E-321)
long r0 = r0 * r11
boolean r2 = r10.haveSync
if (r2 == 0) goto L41
long r2 = r10.lastFramePresentationTimeUs
int r2 = (r11 > r2 ? 1 : (r11 == r2 ? 0 : -1))
if (r2 == 0) goto L18
long r2 = r10.frameCount
r4 = 1
long r2 = r2 + r4
r10.frameCount = r2
long r2 = r10.pendingAdjustedFrameTimeNs
r10.adjustedLastFrameTimeNs = r2
L18:
long r2 = r10.frameCount
r4 = 6
int r4 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1))
r5 = 0
if (r4 < 0) goto L39
long r6 = r10.syncFramePresentationTimeNs
long r6 = r0 - r6
long r6 = r6 / r2
long r2 = r10.adjustedLastFrameTimeNs
long r2 = r2 + r6
boolean r4 = r10.isDriftTooLarge(r2, r13)
if (r4 == 0) goto L32
r10.haveSync = r5
goto L41
L32:
long r4 = r10.syncUnadjustedReleaseTimeNs
long r4 = r4 + r2
long r6 = r10.syncFramePresentationTimeNs
long r4 = r4 - r6
goto L43
L39:
boolean r2 = r10.isDriftTooLarge(r0, r13)
if (r2 == 0) goto L41
r10.haveSync = r5
L41:
r4 = r13
r2 = r0
L43:
boolean r6 = r10.haveSync
if (r6 != 0) goto L52
r10.syncFramePresentationTimeNs = r0
r10.syncUnadjustedReleaseTimeNs = r13
r13 = 0
r10.frameCount = r13
r13 = 1
r10.haveSync = r13
L52:
r10.lastFramePresentationTimeUs = r11
r10.pendingAdjustedFrameTimeNs = r2
com.mbridge.msdk.playercommon.exoplayer2.video.VideoFrameReleaseTimeHelper$VSyncSampler r11 = r10.vsyncSampler
if (r11 == 0) goto L77
long r12 = r10.vsyncDurationNs
r0 = -9223372036854775807(0x8000000000000001, double:-4.9E-324)
int r12 = (r12 > r0 ? 1 : (r12 == r0 ? 0 : -1))
if (r12 != 0) goto L66
goto L77
L66:
long r6 = r11.sampledVsyncTimeNs
int r11 = (r6 > r0 ? 1 : (r6 == r0 ? 0 : -1))
if (r11 != 0) goto L6d
return r4
L6d:
long r8 = r10.vsyncDurationNs
long r11 = closestVsync(r4, r6, r8)
long r13 = r10.vsyncOffsetNs
long r11 = r11 - r13
return r11
L77:
return r4
*/
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.video.VideoFrameReleaseTimeHelper.adjustReleaseTime(long, long):long");
}
@TargetApi(17)
private DefaultDisplayListener maybeBuildDefaultDisplayListenerV17(Context context) {
DisplayManager displayManager = (DisplayManager) context.getSystemService("display");
if (displayManager == null) {
return null;
}
return new DefaultDisplayListener(displayManager);
}
/* JADX INFO: Access modifiers changed from: private */
public void updateDefaultDisplayRefreshRateParams() {
if (this.windowManager.getDefaultDisplay() != null) {
long refreshRate = (long) (1.0E9d / r0.getRefreshRate());
this.vsyncDurationNs = refreshRate;
this.vsyncOffsetNs = (refreshRate * VSYNC_OFFSET_PERCENTAGE) / 100;
}
}
private boolean isDriftTooLarge(long j, long j2) {
return Math.abs((j2 - this.syncUnadjustedReleaseTimeNs) - (j - this.syncFramePresentationTimeNs)) > MAX_ALLOWED_DRIFT_NS;
}
private static long closestVsync(long j, long j2, long j3) {
long j4;
long j5 = j2 + (((j - j2) / j3) * j3);
if (j <= j5) {
j4 = j5 - j3;
} else {
j5 = j3 + j5;
j4 = j5;
}
return j5 - j < j - j4 ? j5 : j4;
}
@TargetApi(17)
public final class DefaultDisplayListener implements DisplayManager.DisplayListener {
private final DisplayManager displayManager;
@Override // android.hardware.display.DisplayManager.DisplayListener
public final void onDisplayAdded(int i) {
}
@Override // android.hardware.display.DisplayManager.DisplayListener
public final void onDisplayRemoved(int i) {
}
public DefaultDisplayListener(DisplayManager displayManager) {
this.displayManager = displayManager;
}
public final void register() {
this.displayManager.registerDisplayListener(this, null);
}
public final void unregister() {
this.displayManager.unregisterDisplayListener(this);
}
@Override // android.hardware.display.DisplayManager.DisplayListener
public final void onDisplayChanged(int i) {
if (i == 0) {
VideoFrameReleaseTimeHelper.this.updateDefaultDisplayRefreshRateParams();
}
}
}
public static final class VSyncSampler implements Handler.Callback, Choreographer.FrameCallback {
private static final int CREATE_CHOREOGRAPHER = 0;
private static final VSyncSampler INSTANCE = new VSyncSampler();
private static final int MSG_ADD_OBSERVER = 1;
private static final int MSG_REMOVE_OBSERVER = 2;
private Choreographer choreographer;
private final HandlerThread choreographerOwnerThread;
private final Handler handler;
private int observerCount;
public volatile long sampledVsyncTimeNs = C.TIME_UNSET;
public static VSyncSampler getInstance() {
return INSTANCE;
}
private VSyncSampler() {
HandlerThread handlerThread = new HandlerThread("ChoreographerOwner:Handler");
this.choreographerOwnerThread = handlerThread;
handlerThread.start();
Handler handler = new Handler(handlerThread.getLooper(), this);
this.handler = handler;
handler.sendEmptyMessage(0);
}
public final void addObserver() {
this.handler.sendEmptyMessage(1);
}
public final void removeObserver() {
this.handler.sendEmptyMessage(2);
}
@Override // android.view.Choreographer.FrameCallback
public final void doFrame(long j) {
this.sampledVsyncTimeNs = j;
this.choreographer.postFrameCallbackDelayed(this, 500L);
}
@Override // android.os.Handler.Callback
public final boolean handleMessage(Message message) {
int i = message.what;
if (i == 0) {
createChoreographerInstanceInternal();
return true;
}
if (i == 1) {
addObserverInternal();
return true;
}
if (i != 2) {
return false;
}
removeObserverInternal();
return true;
}
private void createChoreographerInstanceInternal() {
this.choreographer = Choreographer.getInstance();
}
private void addObserverInternal() {
int i = this.observerCount + 1;
this.observerCount = i;
if (i == 1) {
this.choreographer.postFrameCallback(this);
}
}
private void removeObserverInternal() {
int i = this.observerCount - 1;
this.observerCount = i;
if (i == 0) {
this.choreographer.removeFrameCallback(this);
this.sampledVsyncTimeNs = C.TIME_UNSET;
}
}
}
}

View File

@@ -0,0 +1,8 @@
package com.mbridge.msdk.playercommon.exoplayer2.video;
/* loaded from: classes4.dex */
public interface VideoListener {
void onRenderedFirstFrame();
void onVideoSizeChanged(int i, int i2, int i3, float f);
}

View File

@@ -0,0 +1,117 @@
package com.mbridge.msdk.playercommon.exoplayer2.video;
import android.os.Handler;
import android.view.Surface;
import androidx.annotation.Nullable;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderCounters;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
/* loaded from: classes4.dex */
public interface VideoRendererEventListener {
void onDroppedFrames(int i, long j);
void onRenderedFirstFrame(Surface surface);
void onVideoDecoderInitialized(String str, long j, long j2);
void onVideoDisabled(DecoderCounters decoderCounters);
void onVideoEnabled(DecoderCounters decoderCounters);
void onVideoInputFormatChanged(Format format);
void onVideoSizeChanged(int i, int i2, int i3, float f);
public static final class EventDispatcher {
@Nullable
private final Handler handler;
@Nullable
private final VideoRendererEventListener listener;
public EventDispatcher(@Nullable Handler handler, @Nullable VideoRendererEventListener videoRendererEventListener) {
this.handler = videoRendererEventListener != null ? (Handler) Assertions.checkNotNull(handler) : null;
this.listener = videoRendererEventListener;
}
public final void enabled(final DecoderCounters decoderCounters) {
if (this.listener != null) {
this.handler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.video.VideoRendererEventListener.EventDispatcher.1
@Override // java.lang.Runnable
public void run() {
EventDispatcher.this.listener.onVideoEnabled(decoderCounters);
}
});
}
}
public final void decoderInitialized(final String str, final long j, final long j2) {
if (this.listener != null) {
this.handler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.video.VideoRendererEventListener.EventDispatcher.2
@Override // java.lang.Runnable
public void run() {
EventDispatcher.this.listener.onVideoDecoderInitialized(str, j, j2);
}
});
}
}
public final void inputFormatChanged(final Format format) {
if (this.listener != null) {
this.handler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.video.VideoRendererEventListener.EventDispatcher.3
@Override // java.lang.Runnable
public void run() {
EventDispatcher.this.listener.onVideoInputFormatChanged(format);
}
});
}
}
public final void droppedFrames(final int i, final long j) {
if (this.listener != null) {
this.handler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.video.VideoRendererEventListener.EventDispatcher.4
@Override // java.lang.Runnable
public void run() {
EventDispatcher.this.listener.onDroppedFrames(i, j);
}
});
}
}
public final void videoSizeChanged(final int i, final int i2, final int i3, final float f) {
if (this.listener != null) {
this.handler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.video.VideoRendererEventListener.EventDispatcher.5
@Override // java.lang.Runnable
public void run() {
EventDispatcher.this.listener.onVideoSizeChanged(i, i2, i3, f);
}
});
}
}
public final void renderedFirstFrame(final Surface surface) {
if (this.listener != null) {
this.handler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.video.VideoRendererEventListener.EventDispatcher.6
@Override // java.lang.Runnable
public void run() {
EventDispatcher.this.listener.onRenderedFirstFrame(surface);
}
});
}
}
public final void disabled(final DecoderCounters decoderCounters) {
if (this.listener != null) {
this.handler.post(new Runnable() { // from class: com.mbridge.msdk.playercommon.exoplayer2.video.VideoRendererEventListener.EventDispatcher.7
@Override // java.lang.Runnable
public void run() {
decoderCounters.ensureUpdated();
EventDispatcher.this.listener.onVideoDisabled(decoderCounters);
}
});
}
}
}
}