Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Side by Side Diff: webrtc/api/java/android/org/webrtc/VideoCapturerAndroid.java

Issue 2024573002: Revert of Android: Add FramerateRange class (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 Logging.e(TAG, "Calling startPreviewOnCameraThread on stopped camera."); 407 Logging.e(TAG, "Calling startPreviewOnCameraThread on stopped camera.");
408 return; 408 return;
409 } 409 }
410 410
411 requestedWidth = width; 411 requestedWidth = width;
412 requestedHeight = height; 412 requestedHeight = height;
413 requestedFramerate = framerate; 413 requestedFramerate = framerate;
414 414
415 // Find closest supported format for |width| x |height| @ |framerate|. 415 // Find closest supported format for |width| x |height| @ |framerate|.
416 final android.hardware.Camera.Parameters parameters = camera.getParameters() ; 416 final android.hardware.Camera.Parameters parameters = camera.getParameters() ;
417 final List<CaptureFormat.FramerateRange> supportedFramerates = 417 for (int[] fpsRange : parameters.getSupportedPreviewFpsRange()) {
418 CameraEnumerator.convertFramerates(parameters.getSupportedPreviewFpsRang e()); 418 Logging.d(TAG, "Available fps range: " +
419 Logging.d(TAG, "Available fps ranges: " + supportedFramerates); 419 fpsRange[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDEX] + " :" +
420 420 fpsRange[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
421 final CaptureFormat.FramerateRange bestFpsRange;
422 if (supportedFramerates.isEmpty()) {
423 Logging.w(TAG, "No supported preview fps range");
424 bestFpsRange = new CaptureFormat.FramerateRange(0, 0);
425 } else {
426 bestFpsRange = CameraEnumerationAndroid.getClosestSupportedFramerateRange(
427 supportedFramerates, framerate);
428 } 421 }
429 422 final int[] range = CameraEnumerationAndroid.getFramerateRange(parameters, f ramerate * 1000);
430 final android.hardware.Camera.Size previewSize = 423 final android.hardware.Camera.Size previewSize =
431 CameraEnumerationAndroid.getClosestSupportedSize( 424 CameraEnumerationAndroid.getClosestSupportedSize(
432 parameters.getSupportedPreviewSizes(), width, height); 425 parameters.getSupportedPreviewSizes(), width, height);
433 final CaptureFormat captureFormat = new CaptureFormat( 426 final CaptureFormat captureFormat = new CaptureFormat(
434 previewSize.width, previewSize.height, bestFpsRange); 427 previewSize.width, previewSize.height,
428 range[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
429 range[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
435 430
436 // Check if we are already using this capture format, then we don't need to do anything. 431 // Check if we are already using this capture format, then we don't need to do anything.
437 if (captureFormat.isSameFormat(this.captureFormat)) { 432 if (captureFormat.isSameFormat(this.captureFormat)) {
438 return; 433 return;
439 } 434 }
440 435
441 // Update camera parameters. 436 // Update camera parameters.
442 Logging.d(TAG, "isVideoStabilizationSupported: " + 437 Logging.d(TAG, "isVideoStabilizationSupported: " +
443 parameters.isVideoStabilizationSupported()); 438 parameters.isVideoStabilizationSupported());
444 if (parameters.isVideoStabilizationSupported()) { 439 if (parameters.isVideoStabilizationSupported()) {
445 parameters.setVideoStabilization(true); 440 parameters.setVideoStabilization(true);
446 } 441 }
447 // Note: setRecordingHint(true) actually decrease frame rate on N5. 442 // Note: setRecordingHint(true) actually decrease frame rate on N5.
448 // parameters.setRecordingHint(true); 443 // parameters.setRecordingHint(true);
449 if (captureFormat.framerate.max > 0) { 444 if (captureFormat.maxFramerate > 0) {
450 parameters.setPreviewFpsRange(captureFormat.framerate.min, captureFormat.f ramerate.max); 445 parameters.setPreviewFpsRange(captureFormat.minFramerate, captureFormat.ma xFramerate);
451 } 446 }
452 parameters.setPreviewSize(captureFormat.width, captureFormat.height); 447 parameters.setPreviewSize(captureFormat.width, captureFormat.height);
453 448
454 if (!isCapturingToTexture) { 449 if (!isCapturingToTexture) {
455 parameters.setPreviewFormat(captureFormat.imageFormat); 450 parameters.setPreviewFormat(captureFormat.imageFormat);
456 } 451 }
457 // Picture size is for taking pictures and not for preview/video, but we nee d to set it anyway 452 // Picture size is for taking pictures and not for preview/video, but we nee d to set it anyway
458 // as a workaround for an aspect ratio problem on Nexus 7. 453 // as a workaround for an aspect ratio problem on Nexus 7.
459 final android.hardware.Camera.Size pictureSize = 454 final android.hardware.Camera.Size pictureSize =
460 CameraEnumerationAndroid.getClosestSupportedSize( 455 CameraEnumerationAndroid.getClosestSupportedSize(
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 // Undo the mirror that the OS "helps" us with. 659 // Undo the mirror that the OS "helps" us with.
665 // http://developer.android.com/reference/android/hardware/Camera.html#set DisplayOrientation(int) 660 // http://developer.android.com/reference/android/hardware/Camera.html#set DisplayOrientation(int)
666 transformMatrix = 661 transformMatrix =
667 RendererCommon.multiplyMatrices(transformMatrix, RendererCommon.horizo ntalFlipMatrix()); 662 RendererCommon.multiplyMatrices(transformMatrix, RendererCommon.horizo ntalFlipMatrix());
668 } 663 }
669 cameraStatistics.addFrame(); 664 cameraStatistics.addFrame();
670 frameObserver.onTextureFrameCaptured(captureFormat.width, captureFormat.heig ht, oesTextureId, 665 frameObserver.onTextureFrameCaptured(captureFormat.width, captureFormat.heig ht, oesTextureId,
671 transformMatrix, rotation, timestampNs); 666 transformMatrix, rotation, timestampNs);
672 } 667 }
673 } 668 }
OLDNEW
« no previous file with comments | « webrtc/api/java/android/org/webrtc/CameraEnumerator.java ('k') | webrtc/api/java/jni/androidvideocapturer_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698