Initial commit
This commit is contained in:
20
sources/com/bottle/hp/album/capture/camera/CameraSize.java
Normal file
20
sources/com/bottle/hp/album/capture/camera/CameraSize.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.bottle.hp.album.capture.camera;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CameraSize {
|
||||
private final int a;
|
||||
private final int b;
|
||||
|
||||
public CameraSize(int i, int i2) {
|
||||
this.a = i;
|
||||
this.b = i2;
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public int b() {
|
||||
return this.a;
|
||||
}
|
||||
}
|
216
sources/com/bottle/hp/album/capture/camera/CameraWrapper.java
Normal file
216
sources/com/bottle/hp/album/capture/camera/CameraWrapper.java
Normal file
@@ -0,0 +1,216 @@
|
||||
package com.bottle.hp.album.capture.camera;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.hardware.Camera;
|
||||
import android.media.CamcorderProfile;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceHolder;
|
||||
import com.bottle.hp.album.Utils;
|
||||
import com.bottle.hp.album.capture.camera.OpenCameraException;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CameraWrapper {
|
||||
private final int b;
|
||||
private NativeCamera c;
|
||||
private int e;
|
||||
private Context f;
|
||||
private final String a = CameraWrapper.class.getSimpleName();
|
||||
private Camera.Parameters d = null;
|
||||
|
||||
public CameraWrapper(NativeCamera nativeCamera, int i, int i2, Context context) {
|
||||
this.c = null;
|
||||
this.c = nativeCamera;
|
||||
this.b = i;
|
||||
this.e = i2;
|
||||
this.f = context;
|
||||
}
|
||||
|
||||
private CamcorderProfile k() {
|
||||
CamcorderProfile camcorderProfile = CamcorderProfile.get(1);
|
||||
if (camcorderProfile != null) {
|
||||
return camcorderProfile;
|
||||
}
|
||||
CamcorderProfile camcorderProfile2 = CamcorderProfile.get(0);
|
||||
if (camcorderProfile2 != null) {
|
||||
return camcorderProfile2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void a(SurfaceHolder surfaceHolder) throws IOException {
|
||||
this.c.a(surfaceHolder);
|
||||
this.c.f();
|
||||
}
|
||||
|
||||
public RecordingSize b(int i, int i2) {
|
||||
CameraSize a = a(a(Build.VERSION.SDK_INT), i, i2);
|
||||
if (a == null) {
|
||||
ALog.a(this.a).d("Failed to find supported recording size - falling back to requested: " + i + "x" + i2);
|
||||
return new RecordingSize(i, i2);
|
||||
}
|
||||
ALog.a(this.a).d("Recording size: " + a.b() + "x" + a.a());
|
||||
return new RecordingSize(a.b(), a.a());
|
||||
}
|
||||
|
||||
public Camera c() {
|
||||
return this.c.c();
|
||||
}
|
||||
|
||||
public int d() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int e() {
|
||||
return ((this.c.b() - (this.b * 90)) + 360) % 360;
|
||||
}
|
||||
|
||||
public Camera.Size f() {
|
||||
List<Camera.Size> supportedPictureSizes;
|
||||
this.d = this.c.d();
|
||||
Camera.Parameters parameters = this.d;
|
||||
if (parameters == null || (supportedPictureSizes = parameters.getSupportedPictureSizes()) == null || supportedPictureSizes.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
int b = Utils.b(this.f);
|
||||
int a = Utils.a(this.f);
|
||||
if (a < b) {
|
||||
b = a;
|
||||
}
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= supportedPictureSizes.size()) {
|
||||
i = -1;
|
||||
break;
|
||||
}
|
||||
if (b == supportedPictureSizes.get(i).height) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (i == -1) {
|
||||
i = supportedPictureSizes.size() / 2;
|
||||
}
|
||||
return supportedPictureSizes.get(i);
|
||||
}
|
||||
|
||||
public void g() throws OpenCameraException {
|
||||
try {
|
||||
this.c.a(this.e);
|
||||
if (this.c.c() == null) {
|
||||
throw new OpenCameraException(OpenCameraException.OpenType.NOCAMERA);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
throw new OpenCameraException(OpenCameraException.OpenType.INUSE);
|
||||
}
|
||||
}
|
||||
|
||||
public void h() throws PrepareCameraException {
|
||||
try {
|
||||
this.c.h();
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
throw new PrepareCameraException();
|
||||
}
|
||||
}
|
||||
|
||||
public void i() {
|
||||
if (c() == null) {
|
||||
return;
|
||||
}
|
||||
this.c.e();
|
||||
}
|
||||
|
||||
public void j() throws Exception {
|
||||
this.c.g();
|
||||
this.c.a();
|
||||
}
|
||||
|
||||
public void a(int i, int i2) {
|
||||
if (i == 0) {
|
||||
i = Utils.b(this.f);
|
||||
}
|
||||
if (i2 == 0) {
|
||||
i2 = Utils.a(this.f);
|
||||
}
|
||||
Camera.Parameters d = this.c.d();
|
||||
CameraSize a = a(d.getSupportedPreviewSizes(), i, i2);
|
||||
Camera.Size f = f();
|
||||
d.setPreviewSize(a.b(), a.a());
|
||||
d.setPictureSize(f == null ? a.b() : f.width, f == null ? a.a() : f.height);
|
||||
d.setPreviewFormat(17);
|
||||
this.c.a(d);
|
||||
this.c.b(d());
|
||||
ALog.a(this.a).d("Preview size: " + a.b() + "x" + a.a());
|
||||
}
|
||||
|
||||
public CamcorderProfile b() {
|
||||
if (Build.VERSION.SDK_INT < 11) {
|
||||
return k();
|
||||
}
|
||||
if (CamcorderProfile.hasProfile(5)) {
|
||||
return CamcorderProfile.get(5);
|
||||
}
|
||||
if (CamcorderProfile.hasProfile(4)) {
|
||||
return CamcorderProfile.get(4);
|
||||
}
|
||||
return k();
|
||||
}
|
||||
|
||||
public void a() {
|
||||
Camera.Parameters d = this.c.d();
|
||||
d.setFocusMode("continuous-video");
|
||||
this.c.a(d);
|
||||
}
|
||||
|
||||
@TargetApi(11)
|
||||
protected List<Camera.Size> a(int i) {
|
||||
Camera.Parameters d = this.c.d();
|
||||
if (i < 11) {
|
||||
Log.e(this.a, "Using supportedPreviewSizes iso supportedVideoSizes due to API restriction");
|
||||
return d.getSupportedPreviewSizes();
|
||||
}
|
||||
if (d.getSupportedVideoSizes() == null) {
|
||||
Log.e(this.a, "Using supportedPreviewSizes because supportedVideoSizes is null");
|
||||
return d.getSupportedPreviewSizes();
|
||||
}
|
||||
return d.getSupportedVideoSizes();
|
||||
}
|
||||
|
||||
public CameraSize a(List<Camera.Size> list, int i, int i2) {
|
||||
double d = i / i2;
|
||||
Camera.Size size = null;
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
double d2 = Double.MAX_VALUE;
|
||||
double d3 = Double.MAX_VALUE;
|
||||
for (Camera.Size size2 : list) {
|
||||
if (Math.abs((size2.width / size2.height) - d) <= 0.1d && Math.abs(size2.height - i2) < d3) {
|
||||
d3 = Math.abs(size2.height - i2);
|
||||
size = size2;
|
||||
}
|
||||
}
|
||||
if (size == null) {
|
||||
for (Camera.Size size3 : list) {
|
||||
if (Math.abs(size3.height - i2) < d2) {
|
||||
size = size3;
|
||||
d2 = Math.abs(size3.height - i2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (size != null) {
|
||||
return new CameraSize(size.width, size.height);
|
||||
}
|
||||
return new CameraSize(0, 0);
|
||||
}
|
||||
|
||||
public void a(Camera.ShutterCallback shutterCallback, Camera.PictureCallback pictureCallback, Camera.PictureCallback pictureCallback2) {
|
||||
c().takePicture(shutterCallback, pictureCallback, pictureCallback2);
|
||||
}
|
||||
}
|
77
sources/com/bottle/hp/album/capture/camera/NativeCamera.java
Normal file
77
sources/com/bottle/hp/album/capture/camera/NativeCamera.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package com.bottle.hp.album.capture.camera;
|
||||
|
||||
import android.hardware.Camera;
|
||||
import android.view.SurfaceHolder;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class NativeCamera {
|
||||
private Camera a = null;
|
||||
private Camera.Parameters b = null;
|
||||
|
||||
private int i() {
|
||||
int numberOfCameras = Camera.getNumberOfCameras();
|
||||
for (int i = 0; i < numberOfCameras; i++) {
|
||||
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
|
||||
Camera.getCameraInfo(i, cameraInfo);
|
||||
if (cameraInfo.facing == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void a(int i) throws RuntimeException {
|
||||
this.a = Camera.open(i);
|
||||
}
|
||||
|
||||
public void b(int i) {
|
||||
this.a.setDisplayOrientation(i);
|
||||
}
|
||||
|
||||
public Camera c() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public Camera.Parameters d() {
|
||||
if (this.b == null) {
|
||||
this.b = this.a.getParameters();
|
||||
}
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public void e() {
|
||||
this.a.release();
|
||||
}
|
||||
|
||||
public void f() {
|
||||
this.a.startPreview();
|
||||
}
|
||||
|
||||
public void g() {
|
||||
this.a.stopPreview();
|
||||
}
|
||||
|
||||
public void h() {
|
||||
this.a.unlock();
|
||||
}
|
||||
|
||||
public void a(SurfaceHolder surfaceHolder) throws IOException {
|
||||
this.a.setPreviewDisplay(surfaceHolder);
|
||||
}
|
||||
|
||||
public int b() {
|
||||
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
|
||||
Camera.getCameraInfo(i(), cameraInfo);
|
||||
return cameraInfo.orientation;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.a.setPreviewCallback(null);
|
||||
}
|
||||
|
||||
public void a(Camera.Parameters parameters) {
|
||||
this.b = parameters;
|
||||
this.a.setParameters(parameters);
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.bottle.hp.album.capture.camera;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class OpenCameraException extends Exception {
|
||||
private static final String LOG_PREFIX = "Unable to open camera - ";
|
||||
private static final long serialVersionUID = -7340415176385044242L;
|
||||
private final String TAG;
|
||||
private final OpenType mType;
|
||||
|
||||
public enum OpenType {
|
||||
INUSE("Camera disabled or in use by other process"),
|
||||
NOCAMERA("Device does not have camera");
|
||||
|
||||
private String mMessage;
|
||||
|
||||
OpenType(String str) {
|
||||
this.mMessage = str;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.mMessage;
|
||||
}
|
||||
}
|
||||
|
||||
public OpenCameraException(OpenType openType) {
|
||||
super(openType.getMessage());
|
||||
this.TAG = OpenCameraException.class.getSimpleName();
|
||||
this.mType = openType;
|
||||
}
|
||||
|
||||
@Override // java.lang.Throwable
|
||||
public void printStackTrace() {
|
||||
Log.e(this.TAG, LOG_PREFIX + this.mType.getMessage());
|
||||
super.printStackTrace();
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package com.bottle.hp.album.capture.camera;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PrepareCameraException extends Exception {
|
||||
private static final String LOG_PREFIX = "Unable to unlock camera - ";
|
||||
private static final String MESSAGE = "Unable to use camera for recording";
|
||||
private static final long serialVersionUID = 6305923762266448674L;
|
||||
private final String TAG = PrepareCameraException.class.getSimpleName();
|
||||
|
||||
@Override // java.lang.Throwable
|
||||
public String getMessage() {
|
||||
Log.e(this.TAG, "Unable to unlock camera - Unable to use camera for recording");
|
||||
return MESSAGE;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.bottle.hp.album.capture.camera;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class RecordingSize {
|
||||
public int a;
|
||||
public int b;
|
||||
|
||||
public RecordingSize(int i, int i2) {
|
||||
this.a = i;
|
||||
this.b = i2;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user