168 lines
6.1 KiB
Java
168 lines
6.1 KiB
Java
package org.webrtc;
|
|
|
|
import android.graphics.Matrix;
|
|
import android.graphics.Point;
|
|
import android.view.View;
|
|
public class RendererCommon {
|
|
private static float BALANCED_VISIBLE_FRACTION = 0.5625f;
|
|
|
|
/* renamed from: org.webrtc.RendererCommon$1 reason: invalid class name */
|
|
public static /* synthetic */ class AnonymousClass1 {
|
|
public static final /* synthetic */ int[] $SwitchMap$org$webrtc$RendererCommon$ScalingType;
|
|
|
|
static {
|
|
ScalingType.values();
|
|
int[] iArr = new int[3];
|
|
$SwitchMap$org$webrtc$RendererCommon$ScalingType = iArr;
|
|
try {
|
|
iArr[ScalingType.SCALE_ASPECT_FIT.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$org$webrtc$RendererCommon$ScalingType[ScalingType.SCALE_ASPECT_FILL.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
$SwitchMap$org$webrtc$RendererCommon$ScalingType[ScalingType.SCALE_ASPECT_BALANCED.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public interface GlDrawer {
|
|
void drawOes(int i, float[] fArr, int i2, int i3, int i4, int i5, int i6, int i7);
|
|
|
|
void drawRgb(int i, float[] fArr, int i2, int i3, int i4, int i5, int i6, int i7);
|
|
|
|
void drawYuv(int[] iArr, float[] fArr, int i, int i2, int i3, int i4, int i5, int i6);
|
|
|
|
void release();
|
|
}
|
|
|
|
public interface RendererEvents {
|
|
void onFirstFrameRendered();
|
|
|
|
void onFrameResolutionChanged(int i, int i2, int i3);
|
|
}
|
|
|
|
public enum ScalingType {
|
|
SCALE_ASPECT_FIT,
|
|
SCALE_ASPECT_FILL,
|
|
SCALE_ASPECT_BALANCED
|
|
}
|
|
|
|
public static class VideoLayoutMeasure {
|
|
private float visibleFractionMatchOrientation;
|
|
private float visibleFractionMismatchOrientation;
|
|
|
|
public VideoLayoutMeasure() {
|
|
ScalingType scalingType = ScalingType.SCALE_ASPECT_BALANCED;
|
|
this.visibleFractionMatchOrientation = RendererCommon.access$000(scalingType);
|
|
this.visibleFractionMismatchOrientation = RendererCommon.access$000(scalingType);
|
|
}
|
|
|
|
public Point measure(int i, int i2, int i3, int i4) {
|
|
int defaultSize = View.getDefaultSize(Integer.MAX_VALUE, i);
|
|
int defaultSize2 = View.getDefaultSize(Integer.MAX_VALUE, i2);
|
|
if (i3 == 0 || i4 == 0 || defaultSize == 0 || defaultSize2 == 0) {
|
|
return new Point(defaultSize, defaultSize2);
|
|
}
|
|
float f = ((float) i3) / ((float) i4);
|
|
float f2 = ((float) defaultSize) / ((float) defaultSize2);
|
|
boolean z2 = true;
|
|
boolean z3 = f > 1.0f;
|
|
if (f2 <= 1.0f) {
|
|
z2 = false;
|
|
}
|
|
Point displaySize = RendererCommon.getDisplaySize(z3 == z2 ? this.visibleFractionMatchOrientation : this.visibleFractionMismatchOrientation, f, defaultSize, defaultSize2);
|
|
if (View.MeasureSpec.getMode(i) == 1073741824) {
|
|
displaySize.x = defaultSize;
|
|
}
|
|
if (View.MeasureSpec.getMode(i2) == 1073741824) {
|
|
displaySize.y = defaultSize2;
|
|
}
|
|
return displaySize;
|
|
}
|
|
|
|
public void setScalingType(ScalingType scalingType) {
|
|
setScalingType(scalingType, scalingType);
|
|
}
|
|
|
|
public void setScalingType(ScalingType scalingType, ScalingType scalingType2) {
|
|
this.visibleFractionMatchOrientation = RendererCommon.access$000(scalingType);
|
|
this.visibleFractionMismatchOrientation = RendererCommon.access$000(scalingType2);
|
|
}
|
|
|
|
public void setVisibleFraction(float f, float f2) {
|
|
this.visibleFractionMatchOrientation = f;
|
|
this.visibleFractionMismatchOrientation = f2;
|
|
}
|
|
}
|
|
|
|
public static /* synthetic */ float access$000(ScalingType scalingType) {
|
|
return convertScalingTypeToVisibleFraction(scalingType);
|
|
}
|
|
|
|
private static void adjustOrigin(float[] fArr) {
|
|
fArr[12] = fArr[12] - ((fArr[0] + fArr[4]) * 0.5f);
|
|
fArr[13] = fArr[13] - ((fArr[1] + fArr[5]) * 0.5f);
|
|
fArr[12] = fArr[12] + 0.5f;
|
|
fArr[13] = fArr[13] + 0.5f;
|
|
}
|
|
|
|
public static float[] convertMatrixFromAndroidGraphicsMatrix(Matrix matrix) {
|
|
float[] fArr = new float[9];
|
|
matrix.getValues(fArr);
|
|
return new float[]{fArr[0], fArr[3], 0.0f, fArr[6], fArr[1], fArr[4], 0.0f, fArr[7], 0.0f, 0.0f, 1.0f, 0.0f, fArr[2], fArr[5], 0.0f, fArr[8]};
|
|
}
|
|
|
|
public static Matrix convertMatrixToAndroidGraphicsMatrix(float[] fArr) {
|
|
float[] fArr2 = {fArr[0], fArr[4], fArr[12], fArr[1], fArr[5], fArr[13], fArr[3], fArr[7], fArr[15]};
|
|
Matrix matrix = new Matrix();
|
|
matrix.setValues(fArr2);
|
|
return matrix;
|
|
}
|
|
|
|
private static float convertScalingTypeToVisibleFraction(ScalingType scalingType) {
|
|
int ordinal = scalingType.ordinal();
|
|
if (ordinal == 0) {
|
|
return 1.0f;
|
|
}
|
|
if (ordinal == 1) {
|
|
return 0.0f;
|
|
}
|
|
if (ordinal == 2) {
|
|
return BALANCED_VISIBLE_FRACTION;
|
|
}
|
|
throw new IllegalArgumentException();
|
|
}
|
|
|
|
public static Point getDisplaySize(float f, float f2, int i, int i2) {
|
|
return (f == 0.0f || f2 == 0.0f) ? new Point(i, i2) : new Point(Math.min(i, Math.round((((float) i2) / f) * f2)), Math.min(i2, Math.round((((float) i) / f) / f2)));
|
|
}
|
|
|
|
public static Point getDisplaySize(ScalingType scalingType, float f, int i, int i2) {
|
|
return getDisplaySize(convertScalingTypeToVisibleFraction(scalingType), f, i, i2);
|
|
}
|
|
|
|
public static float[] getLayoutMatrix(boolean z2, float f, float f2) {
|
|
float f3;
|
|
float f4;
|
|
if (f2 > f) {
|
|
f4 = f / f2;
|
|
f3 = 1.0f;
|
|
} else {
|
|
f3 = f2 / f;
|
|
f4 = 1.0f;
|
|
}
|
|
if (z2) {
|
|
f3 *= -1.0f;
|
|
}
|
|
float[] fArr = new float[16];
|
|
android.opengl.Matrix.setIdentityM(fArr, 0);
|
|
android.opengl.Matrix.scaleM(fArr, 0, f3, f4, 1.0f);
|
|
adjustOrigin(fArr);
|
|
return fArr;
|
|
}
|
|
}
|