Skip to content
Snippets Groups Projects
Commit 5e039d65 authored by Leo Ma's avatar Leo Ma
Browse files

Fix preview rotation bug


Signed-off-by: default avatarLeo Ma <begeekmyfriend@gmail.com>
parent 6d923071
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -25,6 +25,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile project(path: ':library')
}
Loading
Loading
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Loading
Loading
Loading
Loading
@@ -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];
Loading
Loading
@@ -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 (orientation == Configuration.ORIENTATION_PORTRAIT) {
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;
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
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;
}
}
}
Loading
Loading
@@ -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)) {
params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
if (mIsTorchOn) {
params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
}
} else {
params.setFlashMode(supportedFlashModes.get(0));
}
Loading
Loading
Loading
Loading
@@ -97,7 +97,7 @@ public class SrsEncoder {
// Note: the stride of resolution must be set as 16x for hard encoding with some chip like MTK
// Since Y component is quadruple size as U and V component, the stride must be set as 32x
if (!useSoftEncoder && (vOutWidth % 32 != 0 || vOutHeight % 32 != 0)) {
if (!useSoftEncoder && vOutWidth % 32 != 0 || vOutHeight % 32 != 0) {
if (vmci.getName().contains("MTK")) {
//throw new AssertionError("MTK encoding revolution stride must be 32x");
}
Loading
Loading
@@ -284,7 +284,7 @@ public class SrsEncoder {
// Note: the stride of resolution must be set as 16x for hard encoding with some chip like MTK
// Since Y component is quadruple size as U and V component, the stride must be set as 32x
if (!useSoftEncoder && (vOutWidth % 32 != 0 || vOutHeight % 32 != 0)) {
if (!useSoftEncoder && vOutWidth % 32 != 0 || vOutHeight % 32 != 0) {
if (vmci.getName().contains("MTK")) {
//throw new AssertionError("MTK encoding revolution stride must be 32x");
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment