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,87 @@
package com.google.android.exoplayer2.video;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.android.exoplayer2.util.Util;
import com.ironsource.mediationsdk.logger.IronSourceError;
import java.util.Arrays;
/* loaded from: classes2.dex */
public final class ColorInfo implements Parcelable {
public static final Parcelable.Creator<ColorInfo> CREATOR = new Parcelable.Creator() { // from class: com.google.android.exoplayer2.video.ColorInfo.1
@Override // android.os.Parcelable.Creator
public ColorInfo createFromParcel(Parcel parcel) {
return new ColorInfo(parcel);
}
@Override // android.os.Parcelable.Creator
public ColorInfo[] newArray(int i) {
return new ColorInfo[i];
}
};
public final int colorRange;
public final int colorSpace;
public final int colorTransfer;
public int hashCode;
public final byte[] hdrStaticInfo;
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
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 boolean equals(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 String toString() {
int i = this.colorSpace;
int i2 = this.colorRange;
int i3 = this.colorTransfer;
boolean z = this.hdrStaticInfo != null;
StringBuilder sb = new StringBuilder(55);
sb.append("ColorInfo(");
sb.append(i);
sb.append(", ");
sb.append(i2);
sb.append(", ");
sb.append(i3);
sb.append(", ");
sb.append(z);
sb.append(")");
return sb.toString();
}
public 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 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,14 @@
package com.google.android.exoplayer2.video;
import android.view.Surface;
import androidx.annotation.RequiresApi;
@RequiresApi(17)
/* loaded from: classes2.dex */
public final class DummySurface extends Surface {
@Override // android.view.Surface
public void release() {
super.release();
throw null;
}
}

View File

@@ -0,0 +1,115 @@
package com.google.android.exoplayer2.video;
import android.content.Context;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import androidx.annotation.Nullable;
import androidx.work.Data;
import com.amazonaws.handlers.HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0;
import com.google.android.exoplayer2.util.GlUtil;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.util.concurrent.atomic.AtomicReference;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
/* loaded from: classes2.dex */
public final class VideoDecoderGLSurfaceView extends GLSurfaceView {
public static final /* synthetic */ int $r8$clinit = 0;
public final Renderer renderer;
public VideoDecoderGLSurfaceView(Context context) {
this(context, null);
}
public VideoDecoderGLSurfaceView(Context context, @Nullable AttributeSet attributeSet) {
super(context, attributeSet);
Renderer renderer = new Renderer(this);
this.renderer = renderer;
setPreserveEGLContextOnPause(true);
setEGLContextClientVersion(2);
setRenderer(renderer);
setRenderMode(0);
}
public void setOutputBuffer(VideoDecoderOutputBuffer videoDecoderOutputBuffer) {
this.renderer.setOutputBuffer(videoDecoderOutputBuffer);
}
public static final class Renderer implements GLSurfaceView.Renderer {
public int colorMatrixLocation;
public int program;
public final GLSurfaceView surfaceView;
public static final float[] kColorConversion601 = {1.164f, 1.164f, 1.164f, 0.0f, -0.392f, 2.017f, 1.596f, -0.813f, 0.0f};
public static final float[] kColorConversion709 = {1.164f, 1.164f, 1.164f, 0.0f, -0.213f, 2.112f, 1.793f, -0.533f, 0.0f};
public static final float[] kColorConversion2020 = {1.168f, 1.168f, 1.168f, 0.0f, -0.188f, 2.148f, 1.683f, -0.652f, 0.0f};
public static final String[] TEXTURE_UNIFORMS = {"y_tex", "u_tex", "v_tex"};
public static final FloatBuffer TEXTURE_VERTICES = GlUtil.createBuffer(new float[]{-1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f});
public final int[] yuvTextures = new int[3];
public final int[] texLocations = new int[3];
public final int[] previousWidths = new int[3];
public final int[] previousStrides = new int[3];
public final AtomicReference pendingOutputBufferReference = new AtomicReference();
public final FloatBuffer[] textureCoords = new FloatBuffer[3];
public Renderer(GLSurfaceView gLSurfaceView) {
this.surfaceView = gLSurfaceView;
for (int i = 0; i < 3; i++) {
int[] iArr = this.previousWidths;
this.previousStrides[i] = -1;
iArr[i] = -1;
}
}
@Override // android.opengl.GLSurfaceView.Renderer
public void onSurfaceCreated(GL10 gl10, EGLConfig eGLConfig) {
int compileProgram = GlUtil.compileProgram("varying vec2 interp_tc_y;\nvarying vec2 interp_tc_u;\nvarying vec2 interp_tc_v;\nattribute vec4 in_pos;\nattribute vec2 in_tc_y;\nattribute vec2 in_tc_u;\nattribute vec2 in_tc_v;\nvoid main() {\n gl_Position = in_pos;\n interp_tc_y = in_tc_y;\n interp_tc_u = in_tc_u;\n interp_tc_v = in_tc_v;\n}\n", "precision mediump float;\nvarying vec2 interp_tc_y;\nvarying vec2 interp_tc_u;\nvarying vec2 interp_tc_v;\nuniform sampler2D y_tex;\nuniform sampler2D u_tex;\nuniform sampler2D v_tex;\nuniform mat3 mColorConversion;\nvoid main() {\n vec3 yuv;\n yuv.x = texture2D(y_tex, interp_tc_y).r - 0.0625;\n yuv.y = texture2D(u_tex, interp_tc_u).r - 0.5;\n yuv.z = texture2D(v_tex, interp_tc_v).r - 0.5;\n gl_FragColor = vec4(mColorConversion * yuv, 1.0);\n}\n");
this.program = compileProgram;
GLES20.glUseProgram(compileProgram);
int glGetAttribLocation = GLES20.glGetAttribLocation(this.program, "in_pos");
GLES20.glEnableVertexAttribArray(glGetAttribLocation);
GLES20.glVertexAttribPointer(glGetAttribLocation, 2, 5126, false, 0, (Buffer) TEXTURE_VERTICES);
this.texLocations[0] = GLES20.glGetAttribLocation(this.program, "in_tc_y");
GLES20.glEnableVertexAttribArray(this.texLocations[0]);
this.texLocations[1] = GLES20.glGetAttribLocation(this.program, "in_tc_u");
GLES20.glEnableVertexAttribArray(this.texLocations[1]);
this.texLocations[2] = GLES20.glGetAttribLocation(this.program, "in_tc_v");
GLES20.glEnableVertexAttribArray(this.texLocations[2]);
GlUtil.checkGlError();
this.colorMatrixLocation = GLES20.glGetUniformLocation(this.program, "mColorConversion");
GlUtil.checkGlError();
setupTextures();
GlUtil.checkGlError();
}
@Override // android.opengl.GLSurfaceView.Renderer
public void onSurfaceChanged(GL10 gl10, int i, int i2) {
GLES20.glViewport(0, 0, i, i2);
}
@Override // android.opengl.GLSurfaceView.Renderer
public void onDrawFrame(GL10 gl10) {
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(this.pendingOutputBufferReference.getAndSet(null));
}
public void setOutputBuffer(VideoDecoderOutputBuffer videoDecoderOutputBuffer) {
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(this.pendingOutputBufferReference.getAndSet(videoDecoderOutputBuffer));
this.surfaceView.requestRender();
}
public final void setupTextures() {
GLES20.glGenTextures(3, this.yuvTextures, 0);
for (int i = 0; i < 3; i++) {
GLES20.glUniform1i(GLES20.glGetUniformLocation(this.program, TEXTURE_UNIFORMS[i]), i);
GLES20.glActiveTexture(33984 + i);
GLES20.glBindTexture(3553, this.yuvTextures[i]);
GLES20.glTexParameterf(3553, 10241, 9729.0f);
GLES20.glTexParameterf(3553, Data.MAX_DATA_BYTES, 9729.0f);
GLES20.glTexParameterf(3553, 10242, 33071.0f);
GLES20.glTexParameterf(3553, 10243, 33071.0f);
}
GlUtil.checkGlError();
}
}
}

View File

@@ -0,0 +1,7 @@
package com.google.android.exoplayer2.video;
import com.google.android.exoplayer2.decoder.OutputBuffer;
/* loaded from: classes2.dex */
public abstract class VideoDecoderOutputBuffer extends OutputBuffer {
}

View File

@@ -0,0 +1,40 @@
package com.google.android.exoplayer2.video;
import com.google.android.exoplayer2.Bundleable$Creator;
import com.google.android.exoplayer2.MediaItem$$ExternalSyntheticLambda0;
/* loaded from: classes2.dex */
public final class VideoSize {
public final int height;
public final float pixelWidthHeightRatio;
public final int unappliedRotationDegrees;
public final int width;
public static final VideoSize UNKNOWN = new VideoSize(0, 0);
public static final Bundleable$Creator CREATOR = new MediaItem$$ExternalSyntheticLambda0();
public VideoSize(int i, int i2) {
this(i, i2, 0, 1.0f);
}
public VideoSize(int i, int i2, int i3, float f) {
this.width = i;
this.height = i2;
this.unappliedRotationDegrees = i3;
this.pixelWidthHeightRatio = f;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof VideoSize)) {
return false;
}
VideoSize videoSize = (VideoSize) obj;
return this.width == videoSize.width && this.height == videoSize.height && this.unappliedRotationDegrees == videoSize.unappliedRotationDegrees && this.pixelWidthHeightRatio == videoSize.pixelWidthHeightRatio;
}
public int hashCode() {
return ((((((217 + this.width) * 31) + this.height) * 31) + this.unappliedRotationDegrees) * 31) + Float.floatToRawIntBits(this.pixelWidthHeightRatio);
}
}

View File

@@ -0,0 +1,51 @@
package com.google.android.exoplayer2.video.spherical;
import android.opengl.Matrix;
import com.google.android.exoplayer2.util.TimedValueQueue;
/* loaded from: classes2.dex */
public final class FrameRotationQueue {
public boolean recenterMatrixComputed;
public final float[] recenterMatrix = new float[16];
public final float[] rotationMatrix = new float[16];
public final TimedValueQueue rotations = new TimedValueQueue();
public boolean pollRotationMatrix(float[] fArr, long j) {
float[] fArr2 = (float[]) this.rotations.pollFloor(j);
if (fArr2 == null) {
return false;
}
getRotationMatrixFromAngleAxis(this.rotationMatrix, fArr2);
if (!this.recenterMatrixComputed) {
computeRecenterMatrix(this.recenterMatrix, this.rotationMatrix);
this.recenterMatrixComputed = true;
}
Matrix.multiplyMM(fArr, 0, this.recenterMatrix, 0, this.rotationMatrix, 0);
return true;
}
public static void computeRecenterMatrix(float[] fArr, float[] fArr2) {
Matrix.setIdentityM(fArr, 0);
float f = fArr2[10];
float f2 = fArr2[8];
float sqrt = (float) Math.sqrt((f * f) + (f2 * f2));
float f3 = fArr2[10];
fArr[0] = f3 / sqrt;
float f4 = fArr2[8];
fArr[2] = f4 / sqrt;
fArr[8] = (-f4) / sqrt;
fArr[10] = f3 / sqrt;
}
public static void getRotationMatrixFromAngleAxis(float[] fArr, float[] fArr2) {
float f = fArr2[0];
float f2 = -fArr2[1];
float f3 = -fArr2[2];
float length = Matrix.length(f, f2, f3);
if (length != 0.0f) {
Matrix.setRotateM(fArr, 0, (float) Math.toDegrees(length), f / length, f2 / length, f3 / length);
} else {
Matrix.setIdentityM(fArr, 0);
}
}
}

View File

@@ -0,0 +1,89 @@
package com.google.android.exoplayer2.video.spherical;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.opengl.Matrix;
import android.view.Display;
/* loaded from: classes2.dex */
public final class OrientationListener implements SensorEventListener {
public final Display display;
public final Listener[] listeners;
public boolean recenterMatrixComputed;
public final float[] deviceOrientationMatrix4x4 = new float[16];
public final float[] tempMatrix4x4 = new float[16];
public final float[] recenterMatrix4x4 = new float[16];
public final float[] angles = new float[3];
public interface Listener {
void onOrientationChange(float[] fArr, float f);
}
@Override // android.hardware.SensorEventListener
public void onAccuracyChanged(Sensor sensor, int i) {
}
public OrientationListener(Display display, Listener... listenerArr) {
this.display = display;
this.listeners = listenerArr;
}
@Override // android.hardware.SensorEventListener
public void onSensorChanged(SensorEvent sensorEvent) {
SensorManager.getRotationMatrixFromVector(this.deviceOrientationMatrix4x4, sensorEvent.values);
rotateAroundZ(this.deviceOrientationMatrix4x4, this.display.getRotation());
float extractRoll = extractRoll(this.deviceOrientationMatrix4x4);
rotateYtoSky(this.deviceOrientationMatrix4x4);
recenter(this.deviceOrientationMatrix4x4);
notifyListeners(this.deviceOrientationMatrix4x4, extractRoll);
}
public final void notifyListeners(float[] fArr, float f) {
for (Listener listener : this.listeners) {
listener.onOrientationChange(fArr, f);
}
}
public final void recenter(float[] fArr) {
if (!this.recenterMatrixComputed) {
FrameRotationQueue.computeRecenterMatrix(this.recenterMatrix4x4, fArr);
this.recenterMatrixComputed = true;
}
float[] fArr2 = this.tempMatrix4x4;
System.arraycopy(fArr, 0, fArr2, 0, fArr2.length);
Matrix.multiplyMM(fArr, 0, this.tempMatrix4x4, 0, this.recenterMatrix4x4, 0);
}
public final float extractRoll(float[] fArr) {
SensorManager.remapCoordinateSystem(fArr, 1, 131, this.tempMatrix4x4);
SensorManager.getOrientation(this.tempMatrix4x4, this.angles);
return this.angles[2];
}
public final void rotateAroundZ(float[] fArr, int i) {
if (i != 0) {
int i2 = 129;
int i3 = 1;
if (i == 1) {
i3 = 129;
i2 = 2;
} else if (i == 2) {
i3 = 130;
} else {
if (i != 3) {
throw new IllegalStateException();
}
i2 = 130;
}
float[] fArr2 = this.tempMatrix4x4;
System.arraycopy(fArr, 0, fArr2, 0, fArr2.length);
SensorManager.remapCoordinateSystem(this.tempMatrix4x4, i2, i3, fArr);
}
}
public static void rotateYtoSky(float[] fArr) {
Matrix.rotateM(fArr, 0, 90.0f, 1.0f, 0.0f, 0.0f);
}
}

View File

@@ -0,0 +1,34 @@
package com.google.android.exoplayer2.video.spherical;
import android.opengl.GLES20;
import com.google.android.exoplayer2.util.GlUtil;
/* loaded from: classes2.dex */
public final class ProjectionRenderer {
public int mvpMatrixHandle;
public int positionHandle;
public int program;
public int texCoordsHandle;
public int textureHandle;
public int uTexMatrixHandle;
public static final String[] VERTEX_SHADER_CODE = {"uniform mat4 uMvpMatrix;", "uniform mat3 uTexMatrix;", "attribute vec4 aPosition;", "attribute vec2 aTexCoords;", "varying vec2 vTexCoords;", "void main() {", " gl_Position = uMvpMatrix * aPosition;", " vTexCoords = (uTexMatrix * vec3(aTexCoords, 1)).xy;", "}"};
public static final String[] FRAGMENT_SHADER_CODE = {"#extension GL_OES_EGL_image_external : require", "precision mediump float;", "uniform samplerExternalOES uTexture;", "varying vec2 vTexCoords;", "void main() {", " gl_FragColor = texture2D(uTexture, vTexCoords);", "}"};
public static final float[] TEX_MATRIX_WHOLE = {1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f};
public static final float[] TEX_MATRIX_TOP = {1.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.0f, 0.0f, 0.5f, 1.0f};
public static final float[] TEX_MATRIX_BOTTOM = {1.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.0f, 0.0f, 1.0f, 1.0f};
public static final float[] TEX_MATRIX_LEFT = {0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f};
public static final float[] TEX_MATRIX_RIGHT = {0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.5f, 1.0f, 1.0f};
public void draw(int i, float[] fArr, boolean z) {
}
public void init() {
int compileProgram = GlUtil.compileProgram(VERTEX_SHADER_CODE, FRAGMENT_SHADER_CODE);
this.program = compileProgram;
this.mvpMatrixHandle = GLES20.glGetUniformLocation(compileProgram, "uMvpMatrix");
this.uTexMatrixHandle = GLES20.glGetUniformLocation(this.program, "uTexMatrix");
this.positionHandle = GLES20.glGetAttribLocation(this.program, "aPosition");
this.texCoordsHandle = GLES20.glGetAttribLocation(this.program, "aTexCoords");
this.textureHandle = GLES20.glGetUniformLocation(this.program, "uTexture");
}
}

View File

@@ -0,0 +1,71 @@
package com.google.android.exoplayer2.video.spherical;
import android.graphics.SurfaceTexture;
import android.opengl.GLES20;
import android.opengl.Matrix;
import com.amazonaws.handlers.HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.GlUtil;
import com.google.android.exoplayer2.util.TimedValueQueue;
import java.util.concurrent.atomic.AtomicBoolean;
/* loaded from: classes2.dex */
public final class SceneRenderer {
public SurfaceTexture surfaceTexture;
public int textureId;
public final AtomicBoolean frameAvailable = new AtomicBoolean();
public final AtomicBoolean resetRotationAtNextFrame = new AtomicBoolean(true);
public final ProjectionRenderer projectionRenderer = new ProjectionRenderer();
public final FrameRotationQueue frameRotationQueue = new FrameRotationQueue();
public final TimedValueQueue sampleTimestampQueue = new TimedValueQueue();
public final TimedValueQueue projectionQueue = new TimedValueQueue();
public final float[] rotationMatrix = new float[16];
public final float[] tempMatrix = new float[16];
public volatile int defaultStereoMode = 0;
public int lastStereoMode = -1;
public void setDefaultStereoMode(int i) {
this.defaultStereoMode = i;
}
public SurfaceTexture init() {
GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
GlUtil.checkGlError();
this.projectionRenderer.init();
GlUtil.checkGlError();
this.textureId = GlUtil.createExternalTexture();
SurfaceTexture surfaceTexture = new SurfaceTexture(this.textureId);
this.surfaceTexture = surfaceTexture;
surfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() { // from class: com.google.android.exoplayer2.video.spherical.SceneRenderer$$ExternalSyntheticLambda0
@Override // android.graphics.SurfaceTexture.OnFrameAvailableListener
public final void onFrameAvailable(SurfaceTexture surfaceTexture2) {
SceneRenderer.this.lambda$init$0(surfaceTexture2);
}
});
return this.surfaceTexture;
}
public final /* synthetic */ void lambda$init$0(SurfaceTexture surfaceTexture) {
this.frameAvailable.set(true);
}
public void drawFrame(float[] fArr, boolean z) {
GLES20.glClear(16384);
GlUtil.checkGlError();
if (this.frameAvailable.compareAndSet(true, false)) {
((SurfaceTexture) Assertions.checkNotNull(this.surfaceTexture)).updateTexImage();
GlUtil.checkGlError();
if (this.resetRotationAtNextFrame.compareAndSet(true, false)) {
Matrix.setIdentityM(this.rotationMatrix, 0);
}
long timestamp = this.surfaceTexture.getTimestamp();
Long l = (Long) this.sampleTimestampQueue.poll(timestamp);
if (l != null) {
this.frameRotationQueue.pollRotationMatrix(this.rotationMatrix, l.longValue());
}
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(this.projectionQueue.pollFloor(timestamp));
}
Matrix.multiplyMM(this.tempMatrix, 0, fArr, 0, this.rotationMatrix, 0);
this.projectionRenderer.draw(this.textureId, this.tempMatrix, z);
}
}

View File

@@ -0,0 +1,241 @@
package com.google.android.exoplayer2.video.spherical;
import android.content.Context;
import android.graphics.PointF;
import android.graphics.SurfaceTexture;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.Matrix;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.WindowManager;
import androidx.annotation.Nullable;
import com.amazonaws.handlers.HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.spherical.OrientationListener;
import com.google.android.exoplayer2.video.spherical.TouchTracker;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
/* loaded from: classes2.dex */
public final class SphericalGLSurfaceView extends GLSurfaceView {
public static final /* synthetic */ int $r8$clinit = 0;
public boolean isOrientationListenerRegistered;
public boolean isStarted;
public final Handler mainHandler;
public final OrientationListener orientationListener;
public final Sensor orientationSensor;
public final SceneRenderer scene;
public final SensorManager sensorManager;
public Surface surface;
public SurfaceTexture surfaceTexture;
public final TouchTracker touchTracker;
public boolean useSensorRotation;
public final CopyOnWriteArrayList videoSurfaceListeners;
public SphericalGLSurfaceView(Context context) {
this(context, null);
}
public SphericalGLSurfaceView(Context context, @Nullable AttributeSet attributeSet) {
super(context, attributeSet);
this.videoSurfaceListeners = new CopyOnWriteArrayList();
this.mainHandler = new Handler(Looper.getMainLooper());
SensorManager sensorManager = (SensorManager) Assertions.checkNotNull(context.getSystemService("sensor"));
this.sensorManager = sensorManager;
Sensor defaultSensor = Util.SDK_INT >= 18 ? sensorManager.getDefaultSensor(15) : null;
this.orientationSensor = defaultSensor == null ? sensorManager.getDefaultSensor(11) : defaultSensor;
SceneRenderer sceneRenderer = new SceneRenderer();
this.scene = sceneRenderer;
Renderer renderer = new Renderer(sceneRenderer);
TouchTracker touchTracker = new TouchTracker(context, renderer, 25.0f);
this.touchTracker = touchTracker;
this.orientationListener = new OrientationListener(((WindowManager) Assertions.checkNotNull((WindowManager) context.getSystemService("window"))).getDefaultDisplay(), touchTracker, renderer);
this.useSensorRotation = true;
setEGLContextClientVersion(2);
setRenderer(renderer);
setOnTouchListener(touchTracker);
}
public void setDefaultStereoMode(int i) {
this.scene.setDefaultStereoMode(i);
}
public void setUseSensorRotation(boolean z) {
this.useSensorRotation = z;
updateOrientationListenerRegistration();
}
@Override // android.opengl.GLSurfaceView
public void onResume() {
super.onResume();
this.isStarted = true;
updateOrientationListenerRegistration();
}
@Override // android.opengl.GLSurfaceView
public void onPause() {
this.isStarted = false;
updateOrientationListenerRegistration();
super.onPause();
}
@Override // android.opengl.GLSurfaceView, android.view.SurfaceView, android.view.View
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
this.mainHandler.post(new Runnable() { // from class: com.google.android.exoplayer2.video.spherical.SphericalGLSurfaceView$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
SphericalGLSurfaceView.this.lambda$onDetachedFromWindow$0();
}
});
}
public final /* synthetic */ void lambda$onDetachedFromWindow$0() {
Surface surface = this.surface;
if (surface != null) {
Iterator it = this.videoSurfaceListeners.iterator();
if (it.hasNext()) {
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(it.next());
throw null;
}
}
releaseSurface(this.surfaceTexture, surface);
this.surfaceTexture = null;
this.surface = null;
}
public final void updateOrientationListenerRegistration() {
boolean z = this.useSensorRotation && this.isStarted;
Sensor sensor = this.orientationSensor;
if (sensor == null || z == this.isOrientationListenerRegistered) {
return;
}
if (z) {
this.sensorManager.registerListener(this.orientationListener, sensor, 0);
} else {
this.sensorManager.unregisterListener(this.orientationListener);
}
this.isOrientationListenerRegistered = z;
}
public final void onSurfaceTextureAvailable(final SurfaceTexture surfaceTexture) {
this.mainHandler.post(new Runnable() { // from class: com.google.android.exoplayer2.video.spherical.SphericalGLSurfaceView$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
SphericalGLSurfaceView.this.lambda$onSurfaceTextureAvailable$1(surfaceTexture);
}
});
}
public final /* synthetic */ void lambda$onSurfaceTextureAvailable$1(SurfaceTexture surfaceTexture) {
SurfaceTexture surfaceTexture2 = this.surfaceTexture;
Surface surface = this.surface;
Surface surface2 = new Surface(surfaceTexture);
this.surfaceTexture = surfaceTexture;
this.surface = surface2;
Iterator it = this.videoSurfaceListeners.iterator();
if (it.hasNext()) {
HandlerChainFactory$$ExternalSyntheticThrowCCEIfNotNull0.m(it.next());
throw null;
}
releaseSurface(surfaceTexture2, surface);
}
public static void releaseSurface(SurfaceTexture surfaceTexture, Surface surface) {
if (surfaceTexture != null) {
surfaceTexture.release();
}
if (surface != null) {
surface.release();
}
}
public final class Renderer implements GLSurfaceView.Renderer, TouchTracker.Listener, OrientationListener.Listener {
public final float[] deviceOrientationMatrix;
public float deviceRoll;
public final SceneRenderer scene;
public float touchPitch;
public final float[] touchPitchMatrix;
public final float[] touchYawMatrix;
public final float[] projectionMatrix = new float[16];
public final float[] viewProjectionMatrix = new float[16];
public final float[] viewMatrix = new float[16];
public final float[] tempMatrix = new float[16];
public Renderer(SceneRenderer sceneRenderer) {
float[] fArr = new float[16];
this.deviceOrientationMatrix = fArr;
float[] fArr2 = new float[16];
this.touchPitchMatrix = fArr2;
float[] fArr3 = new float[16];
this.touchYawMatrix = fArr3;
this.scene = sceneRenderer;
Matrix.setIdentityM(fArr, 0);
Matrix.setIdentityM(fArr2, 0);
Matrix.setIdentityM(fArr3, 0);
this.deviceRoll = 3.1415927f;
}
@Override // android.opengl.GLSurfaceView.Renderer
public synchronized void onSurfaceCreated(GL10 gl10, EGLConfig eGLConfig) {
SphericalGLSurfaceView.this.onSurfaceTextureAvailable(this.scene.init());
}
@Override // android.opengl.GLSurfaceView.Renderer
public void onSurfaceChanged(GL10 gl10, int i, int i2) {
GLES20.glViewport(0, 0, i, i2);
float f = i / i2;
Matrix.perspectiveM(this.projectionMatrix, 0, calculateFieldOfViewInYDirection(f), f, 0.1f, 100.0f);
}
@Override // android.opengl.GLSurfaceView.Renderer
public void onDrawFrame(GL10 gl10) {
synchronized (this) {
Matrix.multiplyMM(this.tempMatrix, 0, this.deviceOrientationMatrix, 0, this.touchYawMatrix, 0);
Matrix.multiplyMM(this.viewMatrix, 0, this.touchPitchMatrix, 0, this.tempMatrix, 0);
}
Matrix.multiplyMM(this.viewProjectionMatrix, 0, this.projectionMatrix, 0, this.viewMatrix, 0);
this.scene.drawFrame(this.viewProjectionMatrix, false);
}
@Override // com.google.android.exoplayer2.video.spherical.OrientationListener.Listener
public synchronized void onOrientationChange(float[] fArr, float f) {
float[] fArr2 = this.deviceOrientationMatrix;
System.arraycopy(fArr, 0, fArr2, 0, fArr2.length);
this.deviceRoll = -f;
updatePitchMatrix();
}
public final void updatePitchMatrix() {
Matrix.setRotateM(this.touchPitchMatrix, 0, -this.touchPitch, (float) Math.cos(this.deviceRoll), (float) Math.sin(this.deviceRoll), 0.0f);
}
@Override // com.google.android.exoplayer2.video.spherical.TouchTracker.Listener
public synchronized void onScrollChange(PointF pointF) {
this.touchPitch = pointF.y;
updatePitchMatrix();
Matrix.setRotateM(this.touchYawMatrix, 0, -pointF.x, 0.0f, 1.0f, 0.0f);
}
@Override // com.google.android.exoplayer2.video.spherical.TouchTracker.Listener
public boolean onSingleTapUp(MotionEvent motionEvent) {
return SphericalGLSurfaceView.this.performClick();
}
public final float calculateFieldOfViewInYDirection(float f) {
if (f > 1.0f) {
return (float) (Math.toDegrees(Math.atan(Math.tan(Math.toRadians(45.0d)) / f)) * 2.0d);
}
return 90.0f;
}
}
}

View File

@@ -0,0 +1,70 @@
package com.google.android.exoplayer2.video.spherical;
import android.content.Context;
import android.graphics.PointF;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import com.google.android.exoplayer2.video.spherical.OrientationListener;
/* loaded from: classes2.dex */
public final class TouchTracker extends GestureDetector.SimpleOnGestureListener implements View.OnTouchListener, OrientationListener.Listener {
public final GestureDetector gestureDetector;
public final Listener listener;
public final float pxPerDegrees;
public final PointF previousTouchPointPx = new PointF();
public final PointF accumulatedTouchOffsetDegrees = new PointF();
public volatile float roll = 3.1415927f;
public interface Listener {
void onScrollChange(PointF pointF);
boolean onSingleTapUp(MotionEvent motionEvent);
}
@Override // com.google.android.exoplayer2.video.spherical.OrientationListener.Listener
public void onOrientationChange(float[] fArr, float f) {
this.roll = -f;
}
public TouchTracker(Context context, Listener listener, float f) {
this.listener = listener;
this.pxPerDegrees = f;
this.gestureDetector = new GestureDetector(context, this);
}
@Override // android.view.View.OnTouchListener
public boolean onTouch(View view, MotionEvent motionEvent) {
return this.gestureDetector.onTouchEvent(motionEvent);
}
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
public boolean onDown(MotionEvent motionEvent) {
this.previousTouchPointPx.set(motionEvent.getX(), motionEvent.getY());
return true;
}
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
float x = (motionEvent2.getX() - this.previousTouchPointPx.x) / this.pxPerDegrees;
float y = motionEvent2.getY();
PointF pointF = this.previousTouchPointPx;
float f3 = (y - pointF.y) / this.pxPerDegrees;
pointF.set(motionEvent2.getX(), motionEvent2.getY());
double d = this.roll;
float cos = (float) Math.cos(d);
float sin = (float) Math.sin(d);
PointF pointF2 = this.accumulatedTouchOffsetDegrees;
pointF2.x -= (cos * x) - (sin * f3);
float f4 = pointF2.y + (sin * x) + (cos * f3);
pointF2.y = f4;
pointF2.y = Math.max(-45.0f, Math.min(45.0f, f4));
this.listener.onScrollChange(this.accumulatedTouchOffsetDegrees);
return true;
}
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
public boolean onSingleTapUp(MotionEvent motionEvent) {
return this.listener.onSingleTapUp(motionEvent);
}
}