Loading core/java/android/hardware/camera2/impl/CameraDeviceImpl.java +24 −7 Original line number Diff line number Diff line Loading @@ -1924,6 +1924,28 @@ public class CameraDeviceImpl extends CameraDevice { return mCharacteristics; } /** * A high speed output surface can only be preview or hardware encoder surface. * * @param surface The high speed output surface to be checked. */ private void checkHighSpeedSurfaceFormat(Surface surface) { // TODO: remove this override since the default format should be // ImageFormat.PRIVATE. b/9487482 final int HAL_FORMAT_RGB_START = 1; // HAL_PIXEL_FORMAT_RGBA_8888 from graphics.h final int HAL_FORMAT_RGB_END = 5; // HAL_PIXEL_FORMAT_BGRA_8888 from graphics.h int surfaceFormat = SurfaceUtils.getSurfaceFormat(surface); if (surfaceFormat >= HAL_FORMAT_RGB_START && surfaceFormat <= HAL_FORMAT_RGB_END) { surfaceFormat = ImageFormat.PRIVATE; } if (surfaceFormat != ImageFormat.PRIVATE) { throw new IllegalArgumentException("Surface format(" + surfaceFormat + ") is not" + " for preview or hardware video encoding!"); } } private void checkConstrainedHighSpeedSurfaces(Collection<Surface> surfaces, Range<Integer> fpsRange) { if (surfaces == null || surfaces.size() == 0 || surfaces.size() > 2) { Loading @@ -1948,15 +1970,10 @@ public class CameraDeviceImpl extends CameraDevice { } for (Surface surface : surfaces) { checkHighSpeedSurfaceFormat(surface); // Surface size must be supported high speed sizes. Size surfaceSize = SurfaceUtils.getSurfaceSize(surface); int surfaceFormat = SurfaceUtils.getSurfaceFormat(surface); if (surfaceFormat != ImageFormat.PRIVATE) { throw new IllegalArgumentException("Surface format is not for preview or" + " hardware video encoding" + surfaceFormat); } if (!highSpeedSizes.contains(surfaceSize)) { throw new IllegalArgumentException("Surface size " + surfaceSize.toString() + " is" + " not part of the high speed supported size list " + Loading core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java +2 −2 Original line number Diff line number Diff line Loading @@ -565,7 +565,7 @@ public class LegacyCameraDevice implements AutoCloseable { throw new IllegalArgumentException("Surface was abandoned", e); } return previewConsumer && (surfaceFormat == ImageFormat.PRIVATE); return previewConsumer; } public static boolean isVideoEncoderConsumer(Surface output) { Loading @@ -583,7 +583,7 @@ public class LegacyCameraDevice implements AutoCloseable { throw new IllegalArgumentException("Surface was abandoned", e); } return videoEncoderConsumer && (surfaceFormat == ImageFormat.PRIVATE); return videoEncoderConsumer; } /** Loading core/java/android/hardware/camera2/utils/SurfaceUtils.java +4 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.hardware.camera2.utils; import android.graphics.ImageFormat; import android.hardware.camera2.legacy.LegacyCameraDevice; import android.hardware.camera2.legacy.LegacyExceptionUtils.BufferQueueAbandonedException; import android.util.Size; Loading @@ -27,7 +28,7 @@ import android.view.Surface; public class SurfaceUtils { /** * Check if a surface is for preview consumer. * Check if a surface is for preview consumer based on consumer end point Gralloc usage flags. * * @param surface The surface to be checked. * @return true if the surface is for preview consumer, false otherwise. Loading @@ -37,7 +38,8 @@ public class SurfaceUtils { } /** * Check if the surface is for hardware video encoder consumer. * Check if the surface is for hardware video encoder consumer based on consumer end point * Gralloc usage flags. * * @param surface The surface to be checked. * @return true if the surface is for hardware video encoder consumer, false otherwise. Loading Loading
core/java/android/hardware/camera2/impl/CameraDeviceImpl.java +24 −7 Original line number Diff line number Diff line Loading @@ -1924,6 +1924,28 @@ public class CameraDeviceImpl extends CameraDevice { return mCharacteristics; } /** * A high speed output surface can only be preview or hardware encoder surface. * * @param surface The high speed output surface to be checked. */ private void checkHighSpeedSurfaceFormat(Surface surface) { // TODO: remove this override since the default format should be // ImageFormat.PRIVATE. b/9487482 final int HAL_FORMAT_RGB_START = 1; // HAL_PIXEL_FORMAT_RGBA_8888 from graphics.h final int HAL_FORMAT_RGB_END = 5; // HAL_PIXEL_FORMAT_BGRA_8888 from graphics.h int surfaceFormat = SurfaceUtils.getSurfaceFormat(surface); if (surfaceFormat >= HAL_FORMAT_RGB_START && surfaceFormat <= HAL_FORMAT_RGB_END) { surfaceFormat = ImageFormat.PRIVATE; } if (surfaceFormat != ImageFormat.PRIVATE) { throw new IllegalArgumentException("Surface format(" + surfaceFormat + ") is not" + " for preview or hardware video encoding!"); } } private void checkConstrainedHighSpeedSurfaces(Collection<Surface> surfaces, Range<Integer> fpsRange) { if (surfaces == null || surfaces.size() == 0 || surfaces.size() > 2) { Loading @@ -1948,15 +1970,10 @@ public class CameraDeviceImpl extends CameraDevice { } for (Surface surface : surfaces) { checkHighSpeedSurfaceFormat(surface); // Surface size must be supported high speed sizes. Size surfaceSize = SurfaceUtils.getSurfaceSize(surface); int surfaceFormat = SurfaceUtils.getSurfaceFormat(surface); if (surfaceFormat != ImageFormat.PRIVATE) { throw new IllegalArgumentException("Surface format is not for preview or" + " hardware video encoding" + surfaceFormat); } if (!highSpeedSizes.contains(surfaceSize)) { throw new IllegalArgumentException("Surface size " + surfaceSize.toString() + " is" + " not part of the high speed supported size list " + Loading
core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java +2 −2 Original line number Diff line number Diff line Loading @@ -565,7 +565,7 @@ public class LegacyCameraDevice implements AutoCloseable { throw new IllegalArgumentException("Surface was abandoned", e); } return previewConsumer && (surfaceFormat == ImageFormat.PRIVATE); return previewConsumer; } public static boolean isVideoEncoderConsumer(Surface output) { Loading @@ -583,7 +583,7 @@ public class LegacyCameraDevice implements AutoCloseable { throw new IllegalArgumentException("Surface was abandoned", e); } return videoEncoderConsumer && (surfaceFormat == ImageFormat.PRIVATE); return videoEncoderConsumer; } /** Loading
core/java/android/hardware/camera2/utils/SurfaceUtils.java +4 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.hardware.camera2.utils; import android.graphics.ImageFormat; import android.hardware.camera2.legacy.LegacyCameraDevice; import android.hardware.camera2.legacy.LegacyExceptionUtils.BufferQueueAbandonedException; import android.util.Size; Loading @@ -27,7 +28,7 @@ import android.view.Surface; public class SurfaceUtils { /** * Check if a surface is for preview consumer. * Check if a surface is for preview consumer based on consumer end point Gralloc usage flags. * * @param surface The surface to be checked. * @return true if the surface is for preview consumer, false otherwise. Loading @@ -37,7 +38,8 @@ public class SurfaceUtils { } /** * Check if the surface is for hardware video encoder consumer. * Check if the surface is for hardware video encoder consumer based on consumer end point * Gralloc usage flags. * * @param surface The surface to be checked. * @return true if the surface is for hardware video encoder consumer, false otherwise. Loading