use of android.util.Size in project android_frameworks_base by ResurrectionRemix.
the class CameraMetadataNative method getLensShadingMap.
private LensShadingMap getLensShadingMap() {
float[] lsmArray = getBase(CaptureResult.STATISTICS_LENS_SHADING_MAP);
Size s = get(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE);
// Do not warn if lsmArray is null while s is not. This is valid.
if (lsmArray == null) {
return null;
}
if (s == null) {
Log.w(TAG, "getLensShadingMap - Lens shading map size was null.");
return null;
}
LensShadingMap map = new LensShadingMap(lsmArray, s.getHeight(), s.getWidth());
return map;
}
use of android.util.Size in project android_frameworks_base by ResurrectionRemix.
the class CameraTooTest method assertOptimalSize.
private void assertOptimalSize(Size[] options, int minWidth, int minHeight, Size expected) {
Size verdict = CameraTooActivity.chooseBigEnoughSize(options, minWidth, minHeight);
assertEquals(String.format("Expected optimal size %s but got %s", expected, verdict), verdict, expected);
}
use of android.util.Size in project android_frameworks_base by ResurrectionRemix.
the class SurfaceUtils method checkConstrainedHighSpeedSurfaces.
/**
* Verify that that the surfaces are valid for high-speed recording mode,
* and that the FPS range is supported
*
* @param surfaces the surfaces to verify as valid in terms of size and format
* @param fpsRange the target high-speed FPS range to validate
* @param config The stream configuration map for the device in question
*/
public static void checkConstrainedHighSpeedSurfaces(Collection<Surface> surfaces, Range<Integer> fpsRange, StreamConfigurationMap config) {
if (surfaces == null || surfaces.size() == 0 || surfaces.size() > 2) {
throw new IllegalArgumentException("Output target surface list must not be null and" + " the size must be 1 or 2");
}
List<Size> highSpeedSizes = null;
if (fpsRange == null) {
highSpeedSizes = Arrays.asList(config.getHighSpeedVideoSizes());
} else {
// Check the FPS range first if provided
Range<Integer>[] highSpeedFpsRanges = config.getHighSpeedVideoFpsRanges();
if (!Arrays.asList(highSpeedFpsRanges).contains(fpsRange)) {
throw new IllegalArgumentException("Fps range " + fpsRange.toString() + " in the" + " request is not a supported high speed fps range " + Arrays.toString(highSpeedFpsRanges));
}
highSpeedSizes = Arrays.asList(config.getHighSpeedVideoSizesFor(fpsRange));
}
for (Surface surface : surfaces) {
checkHighSpeedSurfaceFormat(surface);
// Surface size must be supported high speed sizes.
Size surfaceSize = SurfaceUtils.getSurfaceSize(surface);
if (!highSpeedSizes.contains(surfaceSize)) {
throw new IllegalArgumentException("Surface size " + surfaceSize.toString() + " is" + " not part of the high speed supported size list " + Arrays.toString(highSpeedSizes.toArray()));
}
// Each output surface must be either preview surface or recording surface.
if (!SurfaceUtils.isSurfaceForPreview(surface) && !SurfaceUtils.isSurfaceForHwVideoEncoder(surface)) {
throw new IllegalArgumentException("This output surface is neither preview nor " + "hardware video encoding surface");
}
if (SurfaceUtils.isSurfaceForPreview(surface) && SurfaceUtils.isSurfaceForHwVideoEncoder(surface)) {
throw new IllegalArgumentException("This output surface can not be both preview" + " and hardware video encoding surface");
}
}
// For 2 output surface case, they shouldn't be same type.
if (surfaces.size() == 2) {
// Up to here, each surface can only be either preview or recording.
Iterator<Surface> iterator = surfaces.iterator();
boolean isFirstSurfacePreview = SurfaceUtils.isSurfaceForPreview(iterator.next());
boolean isSecondSurfacePreview = SurfaceUtils.isSurfaceForPreview(iterator.next());
if (isFirstSurfacePreview == isSecondSurfacePreview) {
throw new IllegalArgumentException("The 2 output surfaces must have different" + " type");
}
}
}
use of android.util.Size in project android_frameworks_base by ResurrectionRemix.
the class StreamConfigurationMap method isOutputSupportedFor.
/**
* Determine whether or not the {@code surface} in its current state is suitable to be included
* in a {@link CameraDevice#createCaptureSession capture session} as an output.
*
* <p>Not all surfaces are usable with the {@link CameraDevice}, and not all configurations
* of that {@code surface} are compatible. Some classes that provide the {@code surface} are
* compatible with the {@link CameraDevice} in general
* (see {@link #isOutputSupportedFor(Class)}, but it is the caller's responsibility to put the
* {@code surface} into a state that will be compatible with the {@link CameraDevice}.</p>
*
* <p>Reasons for a {@code surface} being specifically incompatible might be:
* <ul>
* <li>Using a format that's not listed by {@link #getOutputFormats}
* <li>Using a format/size combination that's not listed by {@link #getOutputSizes}
* <li>The {@code surface} itself is not in a state where it can service a new producer.</p>
* </li>
* </ul>
*
* <p>Surfaces from flexible sources will return true even if the exact size of the Surface does
* not match a camera-supported size, as long as the format (or class) is supported and the
* camera device supports a size that is equal to or less than 1080p in that format. If such as
* Surface is used to create a capture session, it will have its size rounded to the nearest
* supported size, below or equal to 1080p. Flexible sources include SurfaceView, SurfaceTexture,
* and ImageReader.</p>
*
* <p>This is not an exhaustive list; see the particular class's documentation for further
* possible reasons of incompatibility.</p>
*
* @param surface a non-{@code null} {@link Surface} object reference
* @return {@code true} if this is supported, {@code false} otherwise
*
* @throws NullPointerException if {@code surface} was {@code null}
* @throws IllegalArgumentException if the Surface endpoint is no longer valid
*
* @see CameraDevice#createCaptureSession
* @see #isOutputSupportedFor(Class)
*/
public boolean isOutputSupportedFor(Surface surface) {
checkNotNull(surface, "surface must not be null");
Size surfaceSize = SurfaceUtils.getSurfaceSize(surface);
int surfaceFormat = SurfaceUtils.getSurfaceFormat(surface);
int surfaceDataspace = SurfaceUtils.getSurfaceDataspace(surface);
// See if consumer is flexible.
boolean isFlexible = SurfaceUtils.isFlexibleConsumer(surface);
// Override RGB formats to IMPLEMENTATION_DEFINED, b/9487482
if ((surfaceFormat >= LegacyMetadataMapper.HAL_PIXEL_FORMAT_RGBA_8888 && surfaceFormat <= LegacyMetadataMapper.HAL_PIXEL_FORMAT_BGRA_8888)) {
surfaceFormat = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
}
StreamConfiguration[] configs = surfaceDataspace != HAL_DATASPACE_DEPTH ? mConfigurations : mDepthConfigurations;
for (StreamConfiguration config : configs) {
if (config.getFormat() == surfaceFormat && config.isOutput()) {
// and a size no bigger than MAX_DIMEN_FOR_ROUNDING
if (config.getSize().equals(surfaceSize)) {
return true;
} else if (isFlexible && (config.getSize().getWidth() <= LegacyCameraDevice.MAX_DIMEN_FOR_ROUNDING)) {
return true;
}
}
}
return false;
}
use of android.util.Size in project android_frameworks_base by ResurrectionRemix.
the class StreamConfigurationMap method appendHighResOutputsString.
private void appendHighResOutputsString(StringBuilder sb) {
sb.append("HighResolutionOutputs(");
int[] formats = getOutputFormats();
for (int format : formats) {
Size[] sizes = getHighResolutionOutputSizes(format);
if (sizes == null)
continue;
for (Size size : sizes) {
long minFrameDuration = getOutputMinFrameDuration(format, size);
long stallDuration = getOutputStallDuration(format, size);
sb.append(String.format("[w:%d, h:%d, format:%s(%d), min_duration:%d, " + "stall:%d], ", size.getWidth(), size.getHeight(), formatToString(format), format, minFrameDuration, stallDuration));
}
}
// Remove the pending ", "
if (sb.charAt(sb.length() - 1) == ' ') {
sb.delete(sb.length() - 2, sb.length());
}
sb.append(")");
}
Aggregations