Java Code Examples for org.webrtc.CameraEnumerationAndroid.CaptureFormat#FramerateRange

The following examples show how to use org.webrtc.CameraEnumerationAndroid.CaptureFormat#FramerateRange . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Camera2Session.java    From webrtc_android with MIT License 6 votes vote down vote up
private void findCaptureFormat() {
    checkIsOnCameraThread();

    Range<Integer>[] fpsRanges =
            cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
    fpsUnitFactor = Camera2Enumerator.getFpsUnitFactor(fpsRanges);
    List<CaptureFormat.FramerateRange> framerateRanges =
            Camera2Enumerator.convertFramerates(fpsRanges, fpsUnitFactor);
    List<Size> sizes = Camera2Enumerator.getSupportedSizes(cameraCharacteristics);
    Logging.d(TAG, "Available preview sizes: " + sizes);
    Logging.d(TAG, "Available fps ranges: " + framerateRanges);

    if (framerateRanges.isEmpty() || sizes.isEmpty()) {
        reportError("No supported capture formats.");
        return;
    }

    final CaptureFormat.FramerateRange bestFpsRange =
            CameraEnumerationAndroid.getClosestSupportedFramerateRange(framerateRanges, framerate);

    final Size bestSize = CameraEnumerationAndroid.getClosestSupportedSize(sizes, width, height);
    CameraEnumerationAndroid.reportCameraResolution(camera2ResolutionHistogram, bestSize);

    captureFormat = new CaptureFormat(bestSize.width, bestSize.height, bestFpsRange);
    Logging.d(TAG, "Using capture format: " + captureFormat);
}
 
Example 2
Source File: Camera1Session.java    From webrtc_android with MIT License 6 votes vote down vote up
private static CaptureFormat findClosestCaptureFormat(
    android.hardware.Camera.Parameters parameters, int width, int height, int framerate) {
  // Find closest supported format for |width| x |height| @ |framerate|.
  final List<CaptureFormat.FramerateRange> supportedFramerates =
      Camera1Enumerator.convertFramerates(parameters.getSupportedPreviewFpsRange());
  Logging.d(TAG, "Available fps ranges: " + supportedFramerates);

  final CaptureFormat.FramerateRange fpsRange =
      CameraEnumerationAndroid.getClosestSupportedFramerateRange(supportedFramerates, framerate);

  final Size previewSize = CameraEnumerationAndroid.getClosestSupportedSize(
      Camera1Enumerator.convertSizes(parameters.getSupportedPreviewSizes()), width, height);
  CameraEnumerationAndroid.reportCameraResolution(camera1ResolutionHistogram, previewSize);

  return new CaptureFormat(previewSize.width, previewSize.height, fpsRange);
}
 
Example 3
Source File: Camera2Session.java    From VideoCRE with MIT License 6 votes vote down vote up
private void findCaptureFormat() {
  checkIsOnCameraThread();

  Range<Integer>[] fpsRanges =
      cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
  fpsUnitFactor = Camera2Enumerator.getFpsUnitFactor(fpsRanges);
  List<CaptureFormat.FramerateRange> framerateRanges =
      Camera2Enumerator.convertFramerates(fpsRanges, fpsUnitFactor);
  List<Size> sizes = Camera2Enumerator.getSupportedSizes(cameraCharacteristics);
  Logging.d(TAG, "Available preview sizes: " + sizes);
  Logging.d(TAG, "Available fps ranges: " + framerateRanges);

  if (framerateRanges.isEmpty() || sizes.isEmpty()) {
    reportError("No supported capture formats.");
    return;
  }

  final CaptureFormat.FramerateRange bestFpsRange =
      CameraEnumerationAndroid.getClosestSupportedFramerateRange(framerateRanges, framerate);

  final Size bestSize = CameraEnumerationAndroid.getClosestSupportedSize(sizes, width, height);
  //CameraEnumerationAndroid.reportCameraResolution(camera2ResolutionHistogram, bestSize);

  captureFormat = new CaptureFormat(bestSize.width, bestSize.height, bestFpsRange);
  Logging.d(TAG, "Using capture format: " + captureFormat);
}
 
Example 4
Source File: Camera1Session.java    From VideoCRE with MIT License 6 votes vote down vote up
private static CaptureFormat findClosestCaptureFormat(
    android.hardware.Camera.Parameters parameters, int width, int height, int framerate) {
  // Find closest supported format for |width| x |height| @ |framerate|.
  final List<CaptureFormat.FramerateRange> supportedFramerates =
      Camera1Enumerator.convertFramerates(parameters.getSupportedPreviewFpsRange());
  Logging.d(TAG, "Available fps ranges: " + supportedFramerates);

  final CaptureFormat.FramerateRange fpsRange =
      CameraEnumerationAndroid.getClosestSupportedFramerateRange(supportedFramerates, framerate);

  final Size previewSize = CameraEnumerationAndroid.getClosestSupportedSize(
      Camera1Enumerator.convertSizes(parameters.getSupportedPreviewSizes()), width, height);
  //CameraEnumerationAndroid.reportCameraResolution(camera1ResolutionHistogram, previewSize);

  return new CaptureFormat(previewSize.width, previewSize.height, fpsRange);
}
 
Example 5
Source File: Camera1Enumerator.java    From webrtc_android with MIT License 5 votes vote down vote up
static List<CaptureFormat.FramerateRange> convertFramerates(List<int[]> arrayRanges) {
    final List<CaptureFormat.FramerateRange> ranges = new ArrayList<CaptureFormat.FramerateRange>();
    for (int[] range : arrayRanges) {
        ranges.add(new CaptureFormat.FramerateRange(
                range[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
                range[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_INDEX]));
    }
    return ranges;
}
 
Example 6
Source File: Camera2Enumerator.java    From webrtc_android with MIT License 5 votes vote down vote up
static List<CaptureFormat.FramerateRange> convertFramerates(
    Range<Integer>[] arrayRanges, int unitFactor) {
  final List<CaptureFormat.FramerateRange> ranges = new ArrayList<CaptureFormat.FramerateRange>();
  for (Range<Integer> range : arrayRanges) {
    ranges.add(new CaptureFormat.FramerateRange(
        range.getLower() * unitFactor, range.getUpper() * unitFactor));
  }
  return ranges;
}
 
Example 7
Source File: Camera1Enumerator.java    From VideoCRE with MIT License 5 votes vote down vote up
static List<CaptureFormat.FramerateRange> convertFramerates(List<int[]> arrayRanges) {
  final List<CaptureFormat.FramerateRange> ranges = new ArrayList<CaptureFormat.FramerateRange>();
  for (int[] range : arrayRanges) {
    ranges.add(new CaptureFormat.FramerateRange(
        range[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
        range[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_INDEX]));
  }
  return ranges;
}
 
Example 8
Source File: Camera2Enumerator.java    From VideoCRE with MIT License 5 votes vote down vote up
static List<CaptureFormat.FramerateRange> convertFramerates(
    Range<Integer>[] arrayRanges, int unitFactor) {
  final List<CaptureFormat.FramerateRange> ranges = new ArrayList<CaptureFormat.FramerateRange>();
  for (Range<Integer> range : arrayRanges) {
    ranges.add(new CaptureFormat.FramerateRange(
        range.getLower() * unitFactor, range.getUpper() * unitFactor));
  }
  return ranges;
}