private Size chooseBestPreviewSize()

in AmazonKinesisVideoDemoApp/src/main/java/com/amazonaws/kinesisvideo/demoapp/fragment/StreamingFragment.java [194:213]


    private Size chooseBestPreviewSize(int width, int height) {
        List<Size> allSizes = CameraHardwareCapabilitiesHelper.getSupportedResolutionsForYUV420_888(getContext(), mConfiguration.getCameraId());
        List<Size> possibleSizes = new ArrayList<>();
        int longDimension = Math.max(width, height);
        int shortDimension = Math.min(width, height);
        for (Size possibility : allSizes) {
            if (possibility.getWidth() > longDimension && possibility.getHeight() > shortDimension) {
                possibleSizes.add(possibility);
            }
        }
        if (possibleSizes.size() >= 1) {
            return Collections.min(possibleSizes, new Comparator<Size>() {
                @Override
                public int compare(Size s1, Size s2) {
                    return Long.signum(s1.getWidth() * s1.getHeight() - s2.getWidth() * s2.getHeight());
                }
            });
        }
        return allSizes.get(0);
    }