org.webrtc.CameraEnumerationAndroid.CaptureFormat Java Examples
The following examples show how to use
org.webrtc.CameraEnumerationAndroid.CaptureFormat.
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: Camera1Session.java From VideoCRE with MIT License | 6 votes |
private Camera1Session(Events events, boolean captureToTexture, Context applicationContext, SurfaceTextureHelper surfaceTextureHelper, MediaRecorder mediaRecorder, int cameraId, android.hardware.Camera camera, android.hardware.Camera.CameraInfo info, CaptureFormat captureFormat, long constructionTimeNs) { Logging.d(TAG, "Create new camera1 session on camera " + cameraId); this.cameraThreadHandler = new Handler(); this.events = events; this.captureToTexture = captureToTexture; this.applicationContext = applicationContext; this.surfaceTextureHelper = surfaceTextureHelper; this.cameraId = cameraId; this.camera = camera; this.info = info; this.captureFormat = captureFormat; this.constructionTimeNs = constructionTimeNs; this.activityOrientation = getDeviceOrientation(); startCapturing(); if (mediaRecorder != null) { camera.unlock(); mediaRecorder.setCamera(camera); } }
Example #2
Source File: Camera1Session.java From VideoCRE with MIT License | 6 votes |
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: Camera1Session.java From VideoCRE with MIT License | 6 votes |
private static void updateCameraParameters(android.hardware.Camera camera, android.hardware.Camera.Parameters parameters, CaptureFormat captureFormat, Size pictureSize, boolean captureToTexture) { final List<String> focusModes = parameters.getSupportedFocusModes(); parameters.setPreviewFpsRange(captureFormat.framerate.min, captureFormat.framerate.max); parameters.setPreviewSize(captureFormat.width, captureFormat.height); parameters.setPictureSize(pictureSize.width, pictureSize.height); if (!captureToTexture) { parameters.setPreviewFormat(captureFormat.imageFormat); } if (parameters.isVideoStabilizationSupported()) { parameters.setVideoStabilization(true); } if (focusModes.contains(android.hardware.Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) { parameters.setFocusMode(android.hardware.Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO); } camera.setParameters(parameters); }
Example #4
Source File: Camera2Session.java From webrtc_android with MIT License | 6 votes |
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 #5
Source File: Camera1Session.java From webrtc_android with MIT License | 6 votes |
private static void updateCameraParameters(android.hardware.Camera camera, android.hardware.Camera.Parameters parameters, CaptureFormat captureFormat, Size pictureSize, boolean captureToTexture) { final List<String> focusModes = parameters.getSupportedFocusModes(); parameters.setPreviewFpsRange(captureFormat.framerate.min, captureFormat.framerate.max); parameters.setPreviewSize(captureFormat.width, captureFormat.height); parameters.setPictureSize(pictureSize.width, pictureSize.height); if (!captureToTexture) { parameters.setPreviewFormat(captureFormat.imageFormat); } if (parameters.isVideoStabilizationSupported()) { parameters.setVideoStabilization(true); } if (focusModes.contains(android.hardware.Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) { parameters.setFocusMode(android.hardware.Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO); } camera.setParameters(parameters); }
Example #6
Source File: Camera1Session.java From webrtc_android with MIT License | 6 votes |
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 #7
Source File: Camera1Session.java From webrtc_android with MIT License | 6 votes |
private Camera1Session(Events events, boolean captureToTexture, Context applicationContext, SurfaceTextureHelper surfaceTextureHelper, int cameraId, android.hardware.Camera camera, android.hardware.Camera.CameraInfo info, CaptureFormat captureFormat, long constructionTimeNs) { Logging.d(TAG, "Create new camera1 session on camera " + cameraId); this.cameraThreadHandler = new Handler(); this.events = events; this.captureToTexture = captureToTexture; this.applicationContext = applicationContext; this.surfaceTextureHelper = surfaceTextureHelper; this.cameraId = cameraId; this.camera = camera; this.info = info; this.captureFormat = captureFormat; this.constructionTimeNs = constructionTimeNs; surfaceTextureHelper.setTextureSize(captureFormat.width, captureFormat.height); startCapturing(); }
Example #8
Source File: Camera2Session.java From VideoCRE with MIT License | 6 votes |
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 #9
Source File: Camera1Enumerator.java From webrtc_android with MIT License | 5 votes |
static synchronized List<CaptureFormat> getSupportedFormats(int cameraId) { if (cachedSupportedFormats == null) { cachedSupportedFormats = new ArrayList<List<CaptureFormat>>(); for (int i = 0; i < android.hardware.Camera.getNumberOfCameras(); ++i) { cachedSupportedFormats.add(enumerateFormats(i)); } } return cachedSupportedFormats.get(cameraId); }
Example #10
Source File: Camera1Enumerator.java From VideoCRE with MIT License | 5 votes |
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 #11
Source File: Camera1Enumerator.java From VideoCRE with MIT License | 5 votes |
static synchronized List<CaptureFormat> getSupportedFormats(int cameraId) { if (cachedSupportedFormats == null) { cachedSupportedFormats = new ArrayList<List<CaptureFormat>>(); for (int i = 0; i < android.hardware.Camera.getNumberOfCameras(); ++i) { cachedSupportedFormats.add(enumerateFormats(i)); } } return cachedSupportedFormats.get(cameraId); }
Example #12
Source File: Camera2Enumerator.java From VideoCRE with MIT License | 5 votes |
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 #13
Source File: Camera2Enumerator.java From webrtc_android with MIT License | 5 votes |
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 #14
Source File: CaptureQualityController.java From Yahala-Messenger with MIT License | 5 votes |
@Override public int compare(CaptureFormat first, CaptureFormat second) { int firstFps = calculateFramerate(targetBandwidth, first); int secondFps = calculateFramerate(targetBandwidth, second); if (firstFps >= FRAMERATE_THRESHOLD && secondFps >= FRAMERATE_THRESHOLD || firstFps == secondFps) { // Compare resolution. return first.width * first.height - second.width * second.height; } else { // Compare fps. return firstFps - secondFps; } }
Example #15
Source File: CaptureQualityController.java From Yahala-Messenger with MIT License | 5 votes |
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (progress == 0) { width = 0; height = 0; framerate = 0; captureFormatText.setText("Muted"); return; } // Extract max bandwidth (in millipixels / second). long maxCaptureBandwidth = Long.MIN_VALUE; for (CaptureFormat format : formats) { maxCaptureBandwidth = Math.max(maxCaptureBandwidth, (long) format.width * format.height * format.maxFramerate); } // Fraction between 0 and 1. double bandwidthFraction = (double) progress / 100.0; // Make a log-scale transformation, still between 0 and 1. final double kExpConstant = 3.0; bandwidthFraction = (Math.exp(kExpConstant * bandwidthFraction) - 1) / (Math.exp(kExpConstant) - 1); targetBandwidth = bandwidthFraction * maxCaptureBandwidth; // Choose the best format given a target bandwidth. final CaptureFormat bestFormat = Collections.max(formats, compareFormats); width = bestFormat.width; height = bestFormat.height; framerate = calculateFramerate(targetBandwidth, bestFormat); captureFormatText.setText(width + "x" + height + " @ " + framerate + "fps"); }
Example #16
Source File: Camera1Enumerator.java From webrtc_android with MIT License | 5 votes |
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 #17
Source File: Camera1Enumerator.java From webrtc_android with MIT License | 4 votes |
@Override public List<CaptureFormat> getSupportedFormats(String deviceName) { return getSupportedFormats(getCameraIndex(deviceName)); }
Example #18
Source File: CaptureQualityController.java From Yahala-Messenger with MIT License | 4 votes |
private int calculateFramerate(double bandwidth, CaptureFormat format) { return (int) Math.round(Math.min(format.maxFramerate, (int) Math.round(bandwidth / (format.width * format.height))) / 1000.0); }
Example #19
Source File: Camera2Enumerator.java From VideoCRE with MIT License | 4 votes |
static List<CaptureFormat> getSupportedFormats(Context context, String cameraId) { return getSupportedFormats( (CameraManager) context.getSystemService(Context.CAMERA_SERVICE), cameraId); }
Example #20
Source File: Camera2Enumerator.java From VideoCRE with MIT License | 4 votes |
@Override public List<CaptureFormat> getSupportedFormats(String deviceName) { return getSupportedFormats(context, deviceName); }
Example #21
Source File: Camera1Enumerator.java From VideoCRE with MIT License | 4 votes |
@Override public List<CaptureFormat> getSupportedFormats(String deviceName) { return getSupportedFormats(getCameraIndex(deviceName)); }
Example #22
Source File: Camera2Enumerator.java From webrtc_android with MIT License | 4 votes |
static List<CaptureFormat> getSupportedFormats(Context context, String cameraId) { return getSupportedFormats( (CameraManager) context.getSystemService(Context.CAMERA_SERVICE), cameraId); }
Example #23
Source File: Camera2Enumerator.java From webrtc_android with MIT License | 4 votes |
@Override public List<CaptureFormat> getSupportedFormats(String deviceName) { return getSupportedFormats(context, deviceName); }
Example #24
Source File: CameraEnumerator.java From VideoCRE with MIT License | votes |
public List<CaptureFormat> getSupportedFormats(String deviceName);
Example #25
Source File: CameraEnumerator.java From webrtc_android with MIT License | votes |
public List<CaptureFormat> getSupportedFormats(String deviceName);