|
|
|
@ -38,6 +38,7 @@ public class SrsCameraView extends GLSurfaceView implements GLSurfaceView.Render
|
|
|
|
|
private int mPreviewWidth;
|
|
|
|
|
private int mPreviewHeight;
|
|
|
|
|
private boolean mIsEncoding;
|
|
|
|
|
private boolean mIsTorchOn = false;
|
|
|
|
|
private float mInputAspectRatio;
|
|
|
|
|
private float mOutputAspectRatio;
|
|
|
|
|
private float[] mProjectionMatrix = new float[16];
|
|
|
|
@ -199,17 +200,19 @@ public class SrsCameraView extends GLSurfaceView implements GLSurfaceView.Render
|
|
|
|
|
mPreviewOrientation = orientation;
|
|
|
|
|
Camera.CameraInfo info = new Camera.CameraInfo();
|
|
|
|
|
Camera.getCameraInfo(mCamId, info);
|
|
|
|
|
if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
|
|
|
|
|
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
|
|
|
mPreviewRotation = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? 270 : 90;
|
|
|
|
|
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
|
|
|
mPreviewRotation = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? 180 : 0;
|
|
|
|
|
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
|
|
|
|
mPreviewRotation = info.orientation % 360;
|
|
|
|
|
mPreviewRotation = (360 - mPreviewRotation) % 360; // compensate the mirror
|
|
|
|
|
} else { // back-facing
|
|
|
|
|
mPreviewRotation = (info.orientation + 360) % 360;
|
|
|
|
|
}
|
|
|
|
|
} else if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
|
|
|
|
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
|
|
|
mPreviewRotation = 90;
|
|
|
|
|
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
|
|
|
|
mPreviewRotation = 0;
|
|
|
|
|
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
|
|
|
|
mPreviewRotation = (info.orientation + 90) % 360;
|
|
|
|
|
mPreviewRotation = (360 - mPreviewRotation) % 360; // compensate the mirror
|
|
|
|
|
} else { // back-facing
|
|
|
|
|
mPreviewRotation = (info.orientation + 270) % 360;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -293,7 +296,9 @@ public class SrsCameraView extends GLSurfaceView implements GLSurfaceView.Render
|
|
|
|
|
List<String> supportedFlashModes = params.getSupportedFlashModes();
|
|
|
|
|
if (supportedFlashModes != null && !supportedFlashModes.isEmpty()) {
|
|
|
|
|
if (supportedFlashModes.contains(Camera.Parameters.FLASH_MODE_TORCH)) {
|
|
|
|
|
if (mIsTorchOn) {
|
|
|
|
|
params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
params.setFlashMode(supportedFlashModes.get(0));
|
|
|
|
|
}
|
|
|
|
|