@Test public void getSuggestedResolutionsForMixedUseCaseInLimitedDevice() { setupCamera( false); SupportedSurfaceCombination supportedSurfaceCombination = new SupportedSurfaceCombination( mContext, LIMITED_CAMERA_ID, mMockCamcorderProfileHelper); Rational aspectRatio = new Rational(16, 9); PreviewConfig.Builder previewConfigBuilder = new PreviewConfig.Builder(); VideoCaptureConfig.Builder videoCaptureConfigBuilder = new VideoCaptureConfig.Builder(); ImageCaptureConfig.Builder imageCaptureConfigBuilder = new ImageCaptureConfig.Builder(); previewConfigBuilder.setTargetAspectRatio(aspectRatio); videoCaptureConfigBuilder.setTargetAspectRatio(aspectRatio); imageCaptureConfigBuilder.setTargetAspectRatio(aspectRatio); imageCaptureConfigBuilder.setLensFacing(LensFacing.BACK); ImageCapture imageCapture = new ImageCapture(imageCaptureConfigBuilder.build()); videoCaptureConfigBuilder.setLensFacing(LensFacing.BACK); VideoCapture videoCapture = new VideoCapture(videoCaptureConfigBuilder.build()); previewConfigBuilder.setLensFacing(LensFacing.BACK); Preview preview = new Preview(previewConfigBuilder.build()); List<UseCase> useCases = new ArrayList<>(); useCases.add(imageCapture); useCases.add(videoCapture); useCases.add(preview); Map<UseCase, Size> suggestedResolutionMap = supportedSurfaceCombination.getSuggestedResolutions(null, useCases); assertThat(suggestedResolutionMap).containsEntry(imageCapture, mRecordSize); assertThat(suggestedResolutionMap).containsEntry(videoCapture, mMaximumVideoSize); assertThat(suggestedResolutionMap).containsEntry(preview, mPreviewSize); }
Map<UseCase, Size> getSuggestedResolutions( List<UseCase> originalUseCases, List<UseCase> newUseCases) { Map<UseCase, Size> suggestedResolutionsMap = new HashMap<>(); List<Integer> useCasesPriorityOrder = getUseCasesPriorityOrder(newUseCases); List<List<Size>> supportedOutputSizesList = new ArrayList<>(); for (Integer index : useCasesPriorityOrder) { List<Size> supportedOutputSizes = getSupportedOutputSizes(newUseCases.get(index)); supportedOutputSizesList.add(supportedOutputSizes); } List<List<Size>> allPossibleSizeArrangements = getAllPossibleSizeArrangements(supportedOutputSizesList); for (List<Size> possibleSizeList : allPossibleSizeArrangements) { List<SurfaceConfig> surfaceConfigList = new ArrayList<>(); if (originalUseCases != null) { for (UseCase useCase : originalUseCases) { CameraDeviceConfig config = (CameraDeviceConfig) useCase.getUseCaseConfig(); String useCaseCameraId; try { useCaseCameraId = CameraX.getCameraWithLensFacing(config.getLensFacing()); } catch (Exception e) { throw new IllegalArgumentException( "Unable to get camera ID for use case " + useCase.getName(), e); } Size resolution = useCase.getAttachedSurfaceResolution(useCaseCameraId); surfaceConfigList.add( transformSurfaceConfig(useCase.getImageFormat(), resolution)); } } for (int i = 0; i < possibleSizeList.size(); i++) { Size size = possibleSizeList.get(i); UseCase newUseCase = newUseCases.get(useCasesPriorityOrder.get(i)); surfaceConfigList.add(transformSurfaceConfig(newUseCase.getImageFormat(), size)); } if (checkSupported(surfaceConfigList)) { for (UseCase useCase : newUseCases) { suggestedResolutionsMap.put( useCase, possibleSizeList.get( useCasesPriorityOrder.indexOf(newUseCases.indexOf(useCase)))); } break; } } return suggestedResolutionsMap; }
SupportedSurfaceCombination { Map<UseCase, Size> getSuggestedResolutions( List<UseCase> originalUseCases, List<UseCase> newUseCases) { Map<UseCase, Size> suggestedResolutionsMap = new HashMap<>(); List<Integer> useCasesPriorityOrder = getUseCasesPriorityOrder(newUseCases); List<List<Size>> supportedOutputSizesList = new ArrayList<>(); for (Integer index : useCasesPriorityOrder) { List<Size> supportedOutputSizes = getSupportedOutputSizes(newUseCases.get(index)); supportedOutputSizesList.add(supportedOutputSizes); } List<List<Size>> allPossibleSizeArrangements = getAllPossibleSizeArrangements(supportedOutputSizesList); for (List<Size> possibleSizeList : allPossibleSizeArrangements) { List<SurfaceConfig> surfaceConfigList = new ArrayList<>(); if (originalUseCases != null) { for (UseCase useCase : originalUseCases) { CameraDeviceConfig config = (CameraDeviceConfig) useCase.getUseCaseConfig(); String useCaseCameraId; try { useCaseCameraId = CameraX.getCameraWithLensFacing(config.getLensFacing()); } catch (Exception e) { throw new IllegalArgumentException( "Unable to get camera ID for use case " + useCase.getName(), e); } Size resolution = useCase.getAttachedSurfaceResolution(useCaseCameraId); surfaceConfigList.add( transformSurfaceConfig(useCase.getImageFormat(), resolution)); } } for (int i = 0; i < possibleSizeList.size(); i++) { Size size = possibleSizeList.get(i); UseCase newUseCase = newUseCases.get(useCasesPriorityOrder.get(i)); surfaceConfigList.add(transformSurfaceConfig(newUseCase.getImageFormat(), size)); } if (checkSupported(surfaceConfigList)) { for (UseCase useCase : newUseCases) { suggestedResolutionsMap.put( useCase, possibleSizeList.get( useCasesPriorityOrder.indexOf(newUseCases.indexOf(useCase)))); } break; } } return suggestedResolutionsMap; } }
SupportedSurfaceCombination { Map<UseCase, Size> getSuggestedResolutions( List<UseCase> originalUseCases, List<UseCase> newUseCases) { Map<UseCase, Size> suggestedResolutionsMap = new HashMap<>(); List<Integer> useCasesPriorityOrder = getUseCasesPriorityOrder(newUseCases); List<List<Size>> supportedOutputSizesList = new ArrayList<>(); for (Integer index : useCasesPriorityOrder) { List<Size> supportedOutputSizes = getSupportedOutputSizes(newUseCases.get(index)); supportedOutputSizesList.add(supportedOutputSizes); } List<List<Size>> allPossibleSizeArrangements = getAllPossibleSizeArrangements(supportedOutputSizesList); for (List<Size> possibleSizeList : allPossibleSizeArrangements) { List<SurfaceConfig> surfaceConfigList = new ArrayList<>(); if (originalUseCases != null) { for (UseCase useCase : originalUseCases) { CameraDeviceConfig config = (CameraDeviceConfig) useCase.getUseCaseConfig(); String useCaseCameraId; try { useCaseCameraId = CameraX.getCameraWithLensFacing(config.getLensFacing()); } catch (Exception e) { throw new IllegalArgumentException( "Unable to get camera ID for use case " + useCase.getName(), e); } Size resolution = useCase.getAttachedSurfaceResolution(useCaseCameraId); surfaceConfigList.add( transformSurfaceConfig(useCase.getImageFormat(), resolution)); } } for (int i = 0; i < possibleSizeList.size(); i++) { Size size = possibleSizeList.get(i); UseCase newUseCase = newUseCases.get(useCasesPriorityOrder.get(i)); surfaceConfigList.add(transformSurfaceConfig(newUseCase.getImageFormat(), size)); } if (checkSupported(surfaceConfigList)) { for (UseCase useCase : newUseCases) { suggestedResolutionsMap.put( useCase, possibleSizeList.get( useCasesPriorityOrder.indexOf(newUseCases.indexOf(useCase)))); } break; } } return suggestedResolutionsMap; } SupportedSurfaceCombination(
            Context context, String cameraId, CamcorderProfileHelper camcorderProfileHelper); private  SupportedSurfaceCombination(); }
SupportedSurfaceCombination { Map<UseCase, Size> getSuggestedResolutions( List<UseCase> originalUseCases, List<UseCase> newUseCases) { Map<UseCase, Size> suggestedResolutionsMap = new HashMap<>(); List<Integer> useCasesPriorityOrder = getUseCasesPriorityOrder(newUseCases); List<List<Size>> supportedOutputSizesList = new ArrayList<>(); for (Integer index : useCasesPriorityOrder) { List<Size> supportedOutputSizes = getSupportedOutputSizes(newUseCases.get(index)); supportedOutputSizesList.add(supportedOutputSizes); } List<List<Size>> allPossibleSizeArrangements = getAllPossibleSizeArrangements(supportedOutputSizesList); for (List<Size> possibleSizeList : allPossibleSizeArrangements) { List<SurfaceConfig> surfaceConfigList = new ArrayList<>(); if (originalUseCases != null) { for (UseCase useCase : originalUseCases) { CameraDeviceConfig config = (CameraDeviceConfig) useCase.getUseCaseConfig(); String useCaseCameraId; try { useCaseCameraId = CameraX.getCameraWithLensFacing(config.getLensFacing()); } catch (Exception e) { throw new IllegalArgumentException( "Unable to get camera ID for use case " + useCase.getName(), e); } Size resolution = useCase.getAttachedSurfaceResolution(useCaseCameraId); surfaceConfigList.add( transformSurfaceConfig(useCase.getImageFormat(), resolution)); } } for (int i = 0; i < possibleSizeList.size(); i++) { Size size = possibleSizeList.get(i); UseCase newUseCase = newUseCases.get(useCasesPriorityOrder.get(i)); surfaceConfigList.add(transformSurfaceConfig(newUseCase.getImageFormat(), size)); } if (checkSupported(surfaceConfigList)) { for (UseCase useCase : newUseCases) { suggestedResolutionsMap.put( useCase, possibleSizeList.get( useCasesPriorityOrder.indexOf(newUseCases.indexOf(useCase)))); } break; } } return suggestedResolutionsMap; } SupportedSurfaceCombination(
            Context context, String cameraId, CamcorderProfileHelper camcorderProfileHelper); private  SupportedSurfaceCombination();  }
SupportedSurfaceCombination { Map<UseCase, Size> getSuggestedResolutions( List<UseCase> originalUseCases, List<UseCase> newUseCases) { Map<UseCase, Size> suggestedResolutionsMap = new HashMap<>(); List<Integer> useCasesPriorityOrder = getUseCasesPriorityOrder(newUseCases); List<List<Size>> supportedOutputSizesList = new ArrayList<>(); for (Integer index : useCasesPriorityOrder) { List<Size> supportedOutputSizes = getSupportedOutputSizes(newUseCases.get(index)); supportedOutputSizesList.add(supportedOutputSizes); } List<List<Size>> allPossibleSizeArrangements = getAllPossibleSizeArrangements(supportedOutputSizesList); for (List<Size> possibleSizeList : allPossibleSizeArrangements) { List<SurfaceConfig> surfaceConfigList = new ArrayList<>(); if (originalUseCases != null) { for (UseCase useCase : originalUseCases) { CameraDeviceConfig config = (CameraDeviceConfig) useCase.getUseCaseConfig(); String useCaseCameraId; try { useCaseCameraId = CameraX.getCameraWithLensFacing(config.getLensFacing()); } catch (Exception e) { throw new IllegalArgumentException( "Unable to get camera ID for use case " + useCase.getName(), e); } Size resolution = useCase.getAttachedSurfaceResolution(useCaseCameraId); surfaceConfigList.add( transformSurfaceConfig(useCase.getImageFormat(), resolution)); } } for (int i = 0; i < possibleSizeList.size(); i++) { Size size = possibleSizeList.get(i); UseCase newUseCase = newUseCases.get(useCasesPriorityOrder.get(i)); surfaceConfigList.add(transformSurfaceConfig(newUseCase.getImageFormat(), size)); } if (checkSupported(surfaceConfigList)) { for (UseCase useCase : newUseCases) { suggestedResolutionsMap.put( useCase, possibleSizeList.get( useCasesPriorityOrder.indexOf(newUseCases.indexOf(useCase)))); } break; } } return suggestedResolutionsMap; } SupportedSurfaceCombination(
            Context context, String cameraId, CamcorderProfileHelper camcorderProfileHelper); private  SupportedSurfaceCombination();   }