|
|
@ -4,10 +4,12 @@ import android.app.Activity;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.res.Configuration;
|
|
|
|
import android.content.res.Configuration;
|
|
|
|
import android.content.res.Resources;
|
|
|
|
import android.content.res.Resources;
|
|
|
|
|
|
|
|
import android.hardware.camera2.CameraCharacteristics;
|
|
|
|
import android.hardware.camera2.CameraManager;
|
|
|
|
import android.hardware.camera2.CameraManager;
|
|
|
|
import android.opengl.GLSurfaceView;
|
|
|
|
import android.opengl.GLSurfaceView;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.Surface;
|
|
|
|
import android.view.Surface;
|
|
|
|
|
|
|
|
|
|
|
|
import com.xypower.gpuv.egl.filter.GlFilter;
|
|
|
|
import com.xypower.gpuv.egl.filter.GlFilter;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -31,6 +33,10 @@ public class GPUCameraRecorderBuilder {
|
|
|
|
private GlFilter glFilter;
|
|
|
|
private GlFilter glFilter;
|
|
|
|
private long duration;
|
|
|
|
private long duration;
|
|
|
|
private int rotation;
|
|
|
|
private int rotation;
|
|
|
|
|
|
|
|
private Integer sensororientation;
|
|
|
|
|
|
|
|
private Integer facing;
|
|
|
|
|
|
|
|
private boolean ifmirror = false;
|
|
|
|
|
|
|
|
|
|
|
|
public GPUCameraRecorderBuilder(Activity activity, GLSurfaceView glSurfaceView) {
|
|
|
|
public GPUCameraRecorderBuilder(Activity activity, GLSurfaceView glSurfaceView) {
|
|
|
|
this.activity = activity;
|
|
|
|
this.activity = activity;
|
|
|
|
this.glSurfaceView = glSurfaceView;
|
|
|
|
this.glSurfaceView = glSurfaceView;
|
|
|
@ -88,6 +94,7 @@ public class GPUCameraRecorderBuilder {
|
|
|
|
this.rotation = d;
|
|
|
|
this.rotation = d;
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public GPUCameraRecorderBuilder recordNoFilter(boolean recordNoFilter) {
|
|
|
|
public GPUCameraRecorderBuilder recordNoFilter(boolean recordNoFilter) {
|
|
|
|
this.recordNoFilter = recordNoFilter;
|
|
|
|
this.recordNoFilter = recordNoFilter;
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
@ -101,15 +108,31 @@ public class GPUCameraRecorderBuilder {
|
|
|
|
CameraManager cameraManager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
|
|
|
|
CameraManager cameraManager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
|
|
|
|
boolean isLandscapeDevice = resources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
|
|
|
boolean isLandscapeDevice = resources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CameraCharacteristics cameraCharacteristics = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId);
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cameraCharacteristics != null) {
|
|
|
|
|
|
|
|
facing = cameraCharacteristics.get(CameraCharacteristics.LENS_FACING);
|
|
|
|
|
|
|
|
sensororientation = cameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
|
|
|
|
|
|
|
|
}
|
|
|
|
int degrees = 0;
|
|
|
|
int degrees = 0;
|
|
|
|
// if (isLandscapeDevice) {
|
|
|
|
if (facing == 1) {
|
|
|
|
// int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
|
|
|
|
if (rotation == -1) {
|
|
|
|
// Log.d("GPUCameraRecorder", "Surface.ROTATION_90 = " + Surface.ROTATION_90 + " rotation = " + rotation);
|
|
|
|
degrees = sensororientation;
|
|
|
|
// degrees = 90 * (rotation - 2);
|
|
|
|
} else {
|
|
|
|
// }
|
|
|
|
degrees = sensororientation + (rotation - 1) * 90;
|
|
|
|
if (isLandscapeDevice) {
|
|
|
|
}
|
|
|
|
Log.d("GPUCameraRecorder", "测试测试rotation" + rotation);
|
|
|
|
ifmirror = false;
|
|
|
|
degrees = rotation * 90;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (rotation == -1) {
|
|
|
|
|
|
|
|
degrees = sensororientation + 180;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
degrees = sensororientation + (rotation - 1) * 90 + 180;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ifmirror = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Log.d("GPUCameraRecorder", "测试测试" + degrees);
|
|
|
|
Log.d("GPUCameraRecorder", "测试测试" + degrees);
|
|
|
|
|
|
|
|
|
|
|
@ -129,7 +152,8 @@ public class GPUCameraRecorderBuilder {
|
|
|
|
isLandscapeDevice,
|
|
|
|
isLandscapeDevice,
|
|
|
|
degrees,
|
|
|
|
degrees,
|
|
|
|
recordNoFilter,
|
|
|
|
recordNoFilter,
|
|
|
|
duration
|
|
|
|
duration,
|
|
|
|
|
|
|
|
ifmirror
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
GPUCameraRecorder.setFilter(glFilter);
|
|
|
|
GPUCameraRecorder.setFilter(glFilter);
|
|
|
|