|
|
@ -47,7 +47,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Camera1(CameraView.CameraCallbacks callback) { |
|
|
|
Camera1(@NonNull CameraView.CameraCallbacks callback) { |
|
|
|
super(callback); |
|
|
|
super(callback); |
|
|
|
mMapper = new Mapper1(); |
|
|
|
mMapper = new Mapper1(); |
|
|
|
} |
|
|
|
} |
|
|
@ -298,7 +298,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onBufferAvailable(byte[] buffer) { |
|
|
|
public void onBufferAvailable(@NonNull byte[] buffer) { |
|
|
|
// TODO: sync with handler?
|
|
|
|
// TODO: sync with handler?
|
|
|
|
if (isCameraAvailable()) { |
|
|
|
if (isCameraAvailable()) { |
|
|
|
mCamera.addCallbackBuffer(buffer); |
|
|
|
mCamera.addCallbackBuffer(buffer); |
|
|
@ -327,7 +327,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setMode(Mode mode) { |
|
|
|
void setMode(@NonNull Mode mode) { |
|
|
|
if (mode != mMode) { |
|
|
|
if (mode != mMode) { |
|
|
|
mMode = mode; |
|
|
|
mMode = mode; |
|
|
|
schedule(null, true, new Runnable() { |
|
|
|
schedule(null, true, new Runnable() { |
|
|
@ -340,7 +340,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setLocation(Location location) { |
|
|
|
void setLocation(@Nullable Location location) { |
|
|
|
final Location oldLocation = mLocation; |
|
|
|
final Location oldLocation = mLocation; |
|
|
|
mLocation = location; |
|
|
|
mLocation = location; |
|
|
|
schedule(mLocationTask, true, new Runnable() { |
|
|
|
schedule(mLocationTask, true, new Runnable() { |
|
|
@ -352,7 +352,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean applyLocation(Camera.Parameters params, Location oldLocation) { |
|
|
|
private boolean applyLocation(@NonNull Camera.Parameters params, @Nullable Location oldLocation) { |
|
|
|
if (mLocation != null) { |
|
|
|
if (mLocation != null) { |
|
|
|
params.setGpsLatitude(mLocation.getLatitude()); |
|
|
|
params.setGpsLatitude(mLocation.getLatitude()); |
|
|
|
params.setGpsLongitude(mLocation.getLongitude()); |
|
|
|
params.setGpsLongitude(mLocation.getLongitude()); |
|
|
@ -364,7 +364,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setFacing(Facing facing) { |
|
|
|
void setFacing(@NonNull Facing facing) { |
|
|
|
final Facing old = mFacing; |
|
|
|
final Facing old = mFacing; |
|
|
|
if (facing != old) { |
|
|
|
if (facing != old) { |
|
|
|
mFacing = facing; |
|
|
|
mFacing = facing; |
|
|
@ -382,7 +382,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setWhiteBalance(WhiteBalance whiteBalance) { |
|
|
|
void setWhiteBalance(@NonNull WhiteBalance whiteBalance) { |
|
|
|
final WhiteBalance old = mWhiteBalance; |
|
|
|
final WhiteBalance old = mWhiteBalance; |
|
|
|
mWhiteBalance = whiteBalance; |
|
|
|
mWhiteBalance = whiteBalance; |
|
|
|
schedule(mWhiteBalanceTask, true, new Runnable() { |
|
|
|
schedule(mWhiteBalanceTask, true, new Runnable() { |
|
|
@ -394,7 +394,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean applyWhiteBalance(Camera.Parameters params, WhiteBalance oldWhiteBalance) { |
|
|
|
private boolean applyWhiteBalance(@NonNull Camera.Parameters params, @NonNull WhiteBalance oldWhiteBalance) { |
|
|
|
if (mCameraOptions.supports(mWhiteBalance)) { |
|
|
|
if (mCameraOptions.supports(mWhiteBalance)) { |
|
|
|
params.setWhiteBalance((String) mMapper.map(mWhiteBalance)); |
|
|
|
params.setWhiteBalance((String) mMapper.map(mWhiteBalance)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -404,7 +404,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setHdr(Hdr hdr) { |
|
|
|
void setHdr(@NonNull Hdr hdr) { |
|
|
|
final Hdr old = mHdr; |
|
|
|
final Hdr old = mHdr; |
|
|
|
mHdr = hdr; |
|
|
|
mHdr = hdr; |
|
|
|
schedule(mHdrTask, true, new Runnable() { |
|
|
|
schedule(mHdrTask, true, new Runnable() { |
|
|
@ -416,7 +416,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean applyHdr(Camera.Parameters params, Hdr oldHdr) { |
|
|
|
private boolean applyHdr(@NonNull Camera.Parameters params, @NonNull Hdr oldHdr) { |
|
|
|
if (mCameraOptions.supports(mHdr)) { |
|
|
|
if (mCameraOptions.supports(mHdr)) { |
|
|
|
params.setSceneMode((String) mMapper.map(mHdr)); |
|
|
|
params.setSceneMode((String) mMapper.map(mHdr)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -444,7 +444,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setAudio(Audio audio) { |
|
|
|
void setAudio(@NonNull Audio audio) { |
|
|
|
if (mAudio != audio) { |
|
|
|
if (mAudio != audio) { |
|
|
|
if (isTakingVideo()) { |
|
|
|
if (isTakingVideo()) { |
|
|
|
LOG.w("Audio setting was changed while recording. " + |
|
|
|
LOG.w("Audio setting was changed while recording. " + |
|
|
@ -455,7 +455,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setFlash(Flash flash) { |
|
|
|
void setFlash(@NonNull Flash flash) { |
|
|
|
final Flash old = mFlash; |
|
|
|
final Flash old = mFlash; |
|
|
|
mFlash = flash; |
|
|
|
mFlash = flash; |
|
|
|
schedule(mFlashTask, true, new Runnable() { |
|
|
|
schedule(mFlashTask, true, new Runnable() { |
|
|
@ -468,7 +468,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean applyFlash(Camera.Parameters params, Flash oldFlash) { |
|
|
|
private boolean applyFlash(@NonNull Camera.Parameters params, @NonNull Flash oldFlash) { |
|
|
|
if (mCameraOptions.supports(mFlash)) { |
|
|
|
if (mCameraOptions.supports(mFlash)) { |
|
|
|
params.setFlashMode((String) mMapper.map(mFlash)); |
|
|
|
params.setFlashMode((String) mMapper.map(mFlash)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -479,7 +479,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Choose the best default focus, based on session type.
|
|
|
|
// Choose the best default focus, based on session type.
|
|
|
|
private void applyDefaultFocus(Camera.Parameters params) { |
|
|
|
private void applyDefaultFocus(@NonNull Camera.Parameters params) { |
|
|
|
List<String> modes = params.getSupportedFocusModes(); |
|
|
|
List<String> modes = params.getSupportedFocusModes(); |
|
|
|
|
|
|
|
|
|
|
|
if (mMode == Mode.VIDEO && |
|
|
|
if (mMode == Mode.VIDEO && |
|
|
@ -500,6 +500,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
|
|
|
|
|
|
|
|
if (modes.contains(Camera.Parameters.FOCUS_MODE_FIXED)) { |
|
|
|
if (modes.contains(Camera.Parameters.FOCUS_MODE_FIXED)) { |
|
|
|
params.setFocusMode(Camera.Parameters.FOCUS_MODE_FIXED); |
|
|
|
params.setFocusMode(Camera.Parameters.FOCUS_MODE_FIXED); |
|
|
|
|
|
|
|
//noinspection UnnecessaryReturnStatement
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -552,7 +553,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void takePictureSnapshot(final AspectRatio viewAspectRatio) { |
|
|
|
void takePictureSnapshot(@NonNull final AspectRatio viewAspectRatio) { |
|
|
|
LOG.v("takePictureSnapshot: scheduling"); |
|
|
|
LOG.v("takePictureSnapshot: scheduling"); |
|
|
|
schedule(null, true, new Runnable() { |
|
|
|
schedule(null, true, new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -573,7 +574,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onPreviewFrame(byte[] data, Camera camera) { |
|
|
|
public void onPreviewFrame(@NonNull byte[] data, Camera camera) { |
|
|
|
Frame frame = mFrameManager.getFrame(data, |
|
|
|
Frame frame = mFrameManager.getFrame(data, |
|
|
|
System.currentTimeMillis(), |
|
|
|
System.currentTimeMillis(), |
|
|
|
offset(REF_SENSOR, REF_OUTPUT), |
|
|
|
offset(REF_SENSOR, REF_OUTPUT), |
|
|
@ -782,7 +783,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setZoom(final float zoom, final PointF[] points, final boolean notify) { |
|
|
|
void setZoom(final float zoom, @Nullable final PointF[] points, final boolean notify) { |
|
|
|
schedule(mZoomTask, true, new Runnable() { |
|
|
|
schedule(mZoomTask, true, new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
@ -802,8 +803,8 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setExposureCorrection(final float EVvalue, final float[] bounds, |
|
|
|
void setExposureCorrection(final float EVvalue, @NonNull final float[] bounds, |
|
|
|
final PointF[] points, final boolean notify) { |
|
|
|
@Nullable final PointF[] points, final boolean notify) { |
|
|
|
schedule(mExposureCorrectionTask, true, new Runnable() { |
|
|
|
schedule(mExposureCorrectionTask, true, new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
@ -831,7 +832,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void startAutoFocus(@Nullable final Gesture gesture, final PointF point) { |
|
|
|
void startAutoFocus(@Nullable final Gesture gesture, @NonNull final PointF point) { |
|
|
|
// Must get width and height from the UI thread.
|
|
|
|
// Must get width and height from the UI thread.
|
|
|
|
int viewWidth = 0, viewHeight = 0; |
|
|
|
int viewWidth = 0, viewHeight = 0; |
|
|
|
if (mPreview != null && mPreview.hasSurface()) { |
|
|
|
if (mPreview != null && mPreview.hasSurface()) { |
|
|
@ -880,7 +881,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
@WorkerThread |
|
|
|
@WorkerThread |
|
|
|
private static List<Camera.Area> computeMeteringAreas(double viewClickX, double viewClickY, |
|
|
|
private static List<Camera.Area> computeMeteringAreas(double viewClickX, double viewClickY, |
|
|
|
int viewWidth, int viewHeight, |
|
|
|
int viewWidth, int viewHeight, |
|
|
@ -911,7 +912,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
return list; |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
private static Rect computeMeteringArea(double centerX, double centerY, double size) { |
|
|
|
private static Rect computeMeteringArea(double centerX, double centerY, double size) { |
|
|
|
double delta = size / 2d; |
|
|
|
double delta = size / 2d; |
|
|
|
int top = (int) Math.max(centerY - delta, -1000); |
|
|
|
int top = (int) Math.max(centerY - delta, -1000); |
|
|
@ -928,7 +929,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
private List<Size> sizesFromList(List<Camera.Size> sizes) { |
|
|
|
private List<Size> sizesFromList(@Nullable List<Camera.Size> sizes) { |
|
|
|
if (sizes == null) return null; |
|
|
|
if (sizes == null) return null; |
|
|
|
List<Size> result = new ArrayList<>(sizes.size()); |
|
|
|
List<Size> result = new ArrayList<>(sizes.size()); |
|
|
|
for (Camera.Size size : sizes) { |
|
|
|
for (Camera.Size size : sizes) { |
|
|
@ -950,8 +951,5 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// -----------------
|
|
|
|
|
|
|
|
// Additional helper info
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|