| Index: webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java
|
| diff --git a/webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java b/webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java
|
| index e4c33d50a002acf0aee02dae3a93e80808015e39..84c418950949f57e290abb7decf9e7a3840b6ac4 100644
|
| --- a/webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java
|
| +++ b/webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java
|
| @@ -177,6 +177,7 @@ public class VideoCapturerAndroid implements
|
| // It does not matter if width and height are flipped. I.E, |width| = 640, |height| = 480 produce
|
| // the same result as |width| = 480, |height| = 640.
|
| // TODO(magjed/perkj): Document what this function does. Change name?
|
| + @Override
|
| public void onOutputFormatRequest(final int width, final int height, final int framerate) {
|
| maybePostOnCameraThread(new Runnable() {
|
| @Override public void run() {
|
| @@ -187,6 +188,7 @@ public class VideoCapturerAndroid implements
|
|
|
| // Reconfigure the camera to capture in a new format. This should only be called while the camera
|
| // is running.
|
| + @Override
|
| public void changeCaptureFormat(final int width, final int height, final int framerate) {
|
| maybePostOnCameraThread(new Runnable() {
|
| @Override public void run() {
|
| @@ -414,22 +416,20 @@ public class VideoCapturerAndroid implements
|
|
|
| // Find closest supported format for |width| x |height| @ |framerate|.
|
| final android.hardware.Camera.Parameters parameters = camera.getParameters();
|
| - for (int[] fpsRange : parameters.getSupportedPreviewFpsRange()) {
|
| - Logging.d(TAG, "Available fps range: " +
|
| - fpsRange[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDEX] + ":" +
|
| - fpsRange[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
|
| - }
|
| - final int[] range = CameraEnumerationAndroid.getFramerateRange(parameters, framerate * 1000);
|
| - final android.hardware.Camera.Size previewSize =
|
| - CameraEnumerationAndroid.getClosestSupportedSize(
|
| - parameters.getSupportedPreviewSizes(), width, height);
|
| - final CaptureFormat captureFormat = new CaptureFormat(
|
| - previewSize.width, previewSize.height,
|
| - range[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
|
| - range[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
|
| + final List<CaptureFormat.FramerateRange> supportedFramerates =
|
| + Camera1Enumerator.convertFramerates(parameters.getSupportedPreviewFpsRange());
|
| + Logging.d(TAG, "Available fps ranges: " + supportedFramerates);
|
| +
|
| + final CaptureFormat.FramerateRange fpsRange =
|
| + CameraEnumerationAndroid.getClosestSupportedFramerate(supportedFramerates, framerate);
|
| +
|
| + final CaptureFormat.Size previewSize = CameraEnumerationAndroid.getClosestSupportedSize(
|
| + Camera1Enumerator.convertSizes(parameters.getSupportedPreviewSizes()), width, height);
|
| +
|
| + final CaptureFormat captureFormat = new CaptureFormat(previewSize, fpsRange);
|
|
|
| // Check if we are already using this capture format, then we don't need to do anything.
|
| - if (captureFormat.isSameFormat(this.captureFormat)) {
|
| + if (captureFormat.equals(this.captureFormat)) {
|
| return;
|
| }
|
|
|
| @@ -441,19 +441,18 @@ public class VideoCapturerAndroid implements
|
| }
|
| // Note: setRecordingHint(true) actually decrease frame rate on N5.
|
| // parameters.setRecordingHint(true);
|
| - if (captureFormat.maxFramerate > 0) {
|
| - parameters.setPreviewFpsRange(captureFormat.minFramerate, captureFormat.maxFramerate);
|
| + if (captureFormat.framerate.max > 0) {
|
| + parameters.setPreviewFpsRange(captureFormat.framerate.min, captureFormat.framerate.max);
|
| }
|
| - parameters.setPreviewSize(captureFormat.width, captureFormat.height);
|
| + parameters.setPreviewSize(previewSize.width, previewSize.height);
|
|
|
| if (!isCapturingToTexture) {
|
| parameters.setPreviewFormat(captureFormat.imageFormat);
|
| }
|
| // Picture size is for taking pictures and not for preview/video, but we need to set it anyway
|
| // as a workaround for an aspect ratio problem on Nexus 7.
|
| - final android.hardware.Camera.Size pictureSize =
|
| - CameraEnumerationAndroid.getClosestSupportedSize(
|
| - parameters.getSupportedPictureSizes(), width, height);
|
| + final CaptureFormat.Size pictureSize = CameraEnumerationAndroid.getClosestSupportedSize(
|
| + Camera1Enumerator.convertSizes(parameters.getSupportedPictureSizes()), width, height);
|
| parameters.setPictureSize(pictureSize.width, pictureSize.height);
|
|
|
| // Temporarily stop preview if it's already running.
|
| @@ -637,8 +636,8 @@ public class VideoCapturerAndroid implements
|
| }
|
|
|
| cameraStatistics.addFrame();
|
| - frameObserver.onByteBufferFrameCaptured(data, captureFormat.width, captureFormat.height,
|
| - getFrameOrientation(), captureTimeNs);
|
| + frameObserver.onByteBufferFrameCaptured(data, captureFormat.size.width,
|
| + captureFormat.size.height, getFrameOrientation(), captureTimeNs);
|
| camera.addCallbackBuffer(data);
|
| }
|
|
|
| @@ -662,7 +661,7 @@ public class VideoCapturerAndroid implements
|
| RendererCommon.multiplyMatrices(transformMatrix, RendererCommon.horizontalFlipMatrix());
|
| }
|
| cameraStatistics.addFrame();
|
| - frameObserver.onTextureFrameCaptured(captureFormat.width, captureFormat.height, oesTextureId,
|
| - transformMatrix, rotation, timestampNs);
|
| + frameObserver.onTextureFrameCaptured(captureFormat.size.width, captureFormat.size.height,
|
| + oesTextureId, transformMatrix, rotation, timestampNs);
|
| }
|
| }
|
|
|