Loading core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java +7 −3 Original line number Diff line number Diff line Loading @@ -174,13 +174,17 @@ public class LegacyCameraDevice implements AutoCloseable { private final RequestThreadManager mRequestThreadManager; /** * Check if a given surface uses {@link ImageFormat#YUV_420_888} format. * Check if a given surface uses {@link ImageFormat#YUV_420_888} or format that can be readily * converted to this; YV12 and NV21 are the two currently supported formats. * * @param s the surface to check. * @return {@code true} if the surfaces uses {@link ImageFormat#YUV_420_888}. * @return {@code true} if the surfaces uses {@link ImageFormat#YUV_420_888} or a compatible * format. */ static boolean needsConversion(Surface s) { return LegacyCameraDevice.nativeDetectSurfaceType(s) == ImageFormat.YUV_420_888; int nativeType = LegacyCameraDevice.nativeDetectSurfaceType(s); return nativeType == ImageFormat.YUV_420_888 || nativeType == ImageFormat.YV12 || nativeType == ImageFormat.NV21; } /** Loading core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ public class LegacyMetadataMapper { private static final float LENS_INFO_MINIMUM_FOCUS_DISTANCE_FIXED_FOCUS = 0.0f; private static final long APPROXIMATE_CAPTURE_DELAY_MS = 200; // ms private static final long APPROXIMATE_SENSOR_AREA = (1 << 20); // 8mp private static final long APPROXIMATE_SENSOR_AREA = (1 << 23); // 8mp private static final long APPROXIMATE_JPEG_ENCODE_TIME = 600; // ms private static final long NS_PER_MS = 1000000; Loading core/java/android/hardware/camera2/legacy/RequestQueue.java +1 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ public class RequestQueue { for (BurstHolder b : mRequestQueue) { total += b.getNumberOfRequests(); if (b.getRequestId() == requestId) { return total; return total - 1; } } throw new IllegalStateException( Loading core/java/android/hardware/camera2/legacy/RequestThreadManager.java +6 −1 Original line number Diff line number Diff line Loading @@ -239,6 +239,9 @@ public class RequestThreadManager { mGLThreadManager.queueNewFrame(holder.getHolderTargets()); } /** * TODO: Get timestamp from GL thread after buffer update. */ mLastPreviewTimestamp = surfaceTexture.getTimestamp(); mReceivedPreview.open(); } Loading Loading @@ -495,7 +498,6 @@ public class RequestThreadManager { if (holder.hasJpegTargets()) { mReceivedJpeg.close(); doJpegCapture(holder); mReceivedJpeg.block(); if (!mReceivedJpeg.block(JPEG_FRAME_TIMEOUT)) { // TODO: report error to CameraDevice Log.e(TAG, "Hit timeout for jpeg callback!"); Loading @@ -507,6 +509,9 @@ public class RequestThreadManager { // TODO: err handling throw new IOError(e); } if (timestamp == 0) { timestamp = SystemClock.elapsedRealtimeNanos(); } CameraMetadataNative result = LegacyMetadataMapper.convertResultMetadata(mParams, request, timestamp); mDeviceState.setCaptureResult(holder, result); Loading core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java +1 −1 Original line number Diff line number Diff line Loading @@ -439,7 +439,7 @@ public class SurfaceTextureRenderer { for (Surface s : surfaces) { // If pixel conversions aren't handled by egl, use a pbuffer if (LegacyCameraDevice.needsConversion(s)) { LegacyCameraDevice.nativeSetSurfaceFormat(s, ImageFormat.NV21); LegacyCameraDevice.nativeSetSurfaceFormat(s, ImageFormat.YV12); EGLSurfaceHolder holder = new EGLSurfaceHolder(); holder.surface = s; mConversionSurfaces.add(holder); Loading Loading
core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java +7 −3 Original line number Diff line number Diff line Loading @@ -174,13 +174,17 @@ public class LegacyCameraDevice implements AutoCloseable { private final RequestThreadManager mRequestThreadManager; /** * Check if a given surface uses {@link ImageFormat#YUV_420_888} format. * Check if a given surface uses {@link ImageFormat#YUV_420_888} or format that can be readily * converted to this; YV12 and NV21 are the two currently supported formats. * * @param s the surface to check. * @return {@code true} if the surfaces uses {@link ImageFormat#YUV_420_888}. * @return {@code true} if the surfaces uses {@link ImageFormat#YUV_420_888} or a compatible * format. */ static boolean needsConversion(Surface s) { return LegacyCameraDevice.nativeDetectSurfaceType(s) == ImageFormat.YUV_420_888; int nativeType = LegacyCameraDevice.nativeDetectSurfaceType(s); return nativeType == ImageFormat.YUV_420_888 || nativeType == ImageFormat.YV12 || nativeType == ImageFormat.NV21; } /** Loading
core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ public class LegacyMetadataMapper { private static final float LENS_INFO_MINIMUM_FOCUS_DISTANCE_FIXED_FOCUS = 0.0f; private static final long APPROXIMATE_CAPTURE_DELAY_MS = 200; // ms private static final long APPROXIMATE_SENSOR_AREA = (1 << 20); // 8mp private static final long APPROXIMATE_SENSOR_AREA = (1 << 23); // 8mp private static final long APPROXIMATE_JPEG_ENCODE_TIME = 600; // ms private static final long NS_PER_MS = 1000000; Loading
core/java/android/hardware/camera2/legacy/RequestQueue.java +1 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ public class RequestQueue { for (BurstHolder b : mRequestQueue) { total += b.getNumberOfRequests(); if (b.getRequestId() == requestId) { return total; return total - 1; } } throw new IllegalStateException( Loading
core/java/android/hardware/camera2/legacy/RequestThreadManager.java +6 −1 Original line number Diff line number Diff line Loading @@ -239,6 +239,9 @@ public class RequestThreadManager { mGLThreadManager.queueNewFrame(holder.getHolderTargets()); } /** * TODO: Get timestamp from GL thread after buffer update. */ mLastPreviewTimestamp = surfaceTexture.getTimestamp(); mReceivedPreview.open(); } Loading Loading @@ -495,7 +498,6 @@ public class RequestThreadManager { if (holder.hasJpegTargets()) { mReceivedJpeg.close(); doJpegCapture(holder); mReceivedJpeg.block(); if (!mReceivedJpeg.block(JPEG_FRAME_TIMEOUT)) { // TODO: report error to CameraDevice Log.e(TAG, "Hit timeout for jpeg callback!"); Loading @@ -507,6 +509,9 @@ public class RequestThreadManager { // TODO: err handling throw new IOError(e); } if (timestamp == 0) { timestamp = SystemClock.elapsedRealtimeNanos(); } CameraMetadataNative result = LegacyMetadataMapper.convertResultMetadata(mParams, request, timestamp); mDeviceState.setCaptureResult(holder, result); Loading
core/java/android/hardware/camera2/legacy/SurfaceTextureRenderer.java +1 −1 Original line number Diff line number Diff line Loading @@ -439,7 +439,7 @@ public class SurfaceTextureRenderer { for (Surface s : surfaces) { // If pixel conversions aren't handled by egl, use a pbuffer if (LegacyCameraDevice.needsConversion(s)) { LegacyCameraDevice.nativeSetSurfaceFormat(s, ImageFormat.NV21); LegacyCameraDevice.nativeSetSurfaceFormat(s, ImageFormat.YV12); EGLSurfaceHolder holder = new EGLSurfaceHolder(); holder.surface = s; mConversionSurfaces.add(holder); Loading