From b3f208d0ba45f140272e3e705b5cdadc3c76514b Mon Sep 17 00:00:00 2001 From: magjed Date: Tue, 31 May 2016 01:44:29 -0700 Subject: [PATCH] Revert of Android: Change camera fps range selection (patchset #4 id:100001 of https://codereview.webrtc.org/2013413002/ ) Reason for revert: Breaks chromium fyi: https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/13565 on step 'generate_build_files': gyp: /b/build/slave/Mac_Builder/build/src/third_party/build/android/test_runner.gypi not found Original issue's description: > Android: Change camera fps range selection > > This CL changes the logic in > CameraEnumerationAndroid.getClosestSupportedFramerateRange() to prefer > fps ranges with a low lower bound so the camera can adjust for > brightness conditions. > > To test the functionality of the fps range selection, JUnit tests are > added. This required a new target in api_tests.gyp. JUnit tests are > preferable over instrumentation tests > (libjingle_peerconnection_android_unittest) because they are faster and > simpler. > > R=kjellander@webrtc.org, sakal@webrtc.org > > Committed: https://crrev.com/b4ddb5c3d3706b1c02437f6a538576f3552ab908 > Cr-Commit-Position: refs/heads/master@{#12964} TBR=sakal@webrtc.org,kjellander@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.webrtc.org/2021233002 Cr-Commit-Position: refs/heads/master@{#12966} --- webrtc/androidjunit/OWNERS | 2 - .../src/org/webrtc/CameraEnumerationTest.java | 55 ------------------- .../org/webrtc/CameraEnumerationAndroid.java | 26 +-------- webrtc/webrtc_tests.gypi | 22 -------- 4 files changed, 2 insertions(+), 103 deletions(-) delete mode 100644 webrtc/androidjunit/OWNERS delete mode 100644 webrtc/androidjunit/src/org/webrtc/CameraEnumerationTest.java diff --git a/webrtc/androidjunit/OWNERS b/webrtc/androidjunit/OWNERS deleted file mode 100644 index 299e8b20ec..0000000000 --- a/webrtc/androidjunit/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -magjed@webrtc.org -sakal@webrtc.org diff --git a/webrtc/androidjunit/src/org/webrtc/CameraEnumerationTest.java b/webrtc/androidjunit/src/org/webrtc/CameraEnumerationTest.java deleted file mode 100644 index b1ebb6c360..0000000000 --- a/webrtc/androidjunit/src/org/webrtc/CameraEnumerationTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2016 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -package org.webrtc; - -import static org.junit.Assert.assertEquals; -import static org.webrtc.CameraEnumerationAndroid.getClosestSupportedFramerateRange; - -import org.webrtc.CameraEnumerationAndroid.CaptureFormat; -import org.webrtc.CameraEnumerationAndroid.CaptureFormat.FramerateRange; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.Arrays; - -/** - * Tests for CameraEnumerationAndroid. - */ -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) -public class CameraEnumerationTest { - @Test - public void testGetClosestSupportedFramerateRange() { - assertEquals(new FramerateRange(10000, 30000), - getClosestSupportedFramerateRange( - Arrays.asList(new FramerateRange(10000, 30000), - new FramerateRange(30000, 30000)), - 30 /* requestedFps */)); - - assertEquals(new FramerateRange(10000, 20000), - getClosestSupportedFramerateRange( - Arrays.asList(new FramerateRange(0, 30000), - new FramerateRange(10000, 20000), - new FramerateRange(14000, 16000), - new FramerateRange(15000, 15000)), - 15 /* requestedFps */)); - - assertEquals(new FramerateRange(10000, 20000), - getClosestSupportedFramerateRange( - Arrays.asList(new FramerateRange(15000, 15000), - new FramerateRange(10000, 20000), - new FramerateRange(10000, 30000)), - 10 /* requestedFps */)); - } -} diff --git a/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java b/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java index 87b9a40b62..2fa685d1fb 100644 --- a/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java +++ b/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java @@ -181,37 +181,15 @@ public class CameraEnumerationAndroid { } } - // Prefer a fps range with an upper bound close to |framerate|. Also prefer a fps range with a low - // lower bound, to allow the framerate to fluctuate based on lightning conditions. public static CaptureFormat.FramerateRange getClosestSupportedFramerateRange( List supportedFramerates, final int requestedFps) { return Collections.min(supportedFramerates, new ClosestComparator() { - // Progressive penalty if the upper bound is further away than |MAX_FPS_DIFF_THRESHOLD| - // from requested. - private static final int MAX_FPS_DIFF_THRESHOLD = 5000; - private static final int MAX_FPS_LOW_DIFF_WEIGHT = 1; - private static final int MAX_FPS_HIGH_DIFF_WEIGHT = 3; - - // Progressive penalty if the lower bound is bigger than |MIN_FPS_THRESHOLD|. - private static final int MIN_FPS_THRESHOLD = 8000; - private static final int MIN_FPS_LOW_VALUE_WEIGHT = 1; - private static final int MIN_FPS_HIGH_VALUE_WEIGHT = 4; - - // Use one weight for small |value| less than |threshold|, and another weight above. - private int progressivePenalty(int value, int threshold, int lowWeight, int highWeight) { - return (value < threshold) - ? value * lowWeight - : threshold * lowWeight + (value - threshold) * highWeight; - } + private static final int MAX_FPS_WEIGHT = 10; @Override int diff(CaptureFormat.FramerateRange range) { - final int minFpsError = progressivePenalty(range.min, - MIN_FPS_THRESHOLD, MIN_FPS_LOW_VALUE_WEIGHT, MIN_FPS_HIGH_VALUE_WEIGHT); - final int maxFpsError = progressivePenalty(Math.abs(requestedFps * 1000 - range.max), - MAX_FPS_DIFF_THRESHOLD, MAX_FPS_LOW_DIFF_WEIGHT, MAX_FPS_HIGH_DIFF_WEIGHT); - return minFpsError + maxFpsError; + return range.min + MAX_FPS_WEIGHT * abs(requestedFps * 1000 - range.max); } }); } diff --git a/webrtc/webrtc_tests.gypi b/webrtc/webrtc_tests.gypi index 22a8bf2686..4ade4728f4 100644 --- a/webrtc/webrtc_tests.gypi +++ b/webrtc/webrtc_tests.gypi @@ -353,28 +353,6 @@ '<(apk_tests_path):webrtc_nonparallel_tests_apk', ], }, - { - 'target_name': 'android_junit_tests', - 'type': 'none', - 'dependencies': [ - '<(webrtc_root)/api/api.gyp:libjingle_peerconnection_java', - '<(DEPTH)/base/base.gyp:base_java', - '<(DEPTH)/base/base.gyp:base_java_test_support', - '<(DEPTH)/base/base.gyp:base_junit_test_support', - ], - 'variables': { - 'main_class': 'org.chromium.testing.local.JunitTestMain', - 'src_paths': [ - 'androidjunit/', - ], - 'test_type': 'junit', - 'wrapper_script_name': 'helper/<(_target_name)', - }, - 'includes': [ - '../build/android/test_runner.gypi', - '../build/host_jar.gypi', - ], - }, ], 'conditions': [ ['test_isolation_mode != "noop"',