Refactor VideoCapturerAndroid tests in WebRTC.

Camera1 tests are now separated from general CameraVideoCapturer tests.
Main motivation behind these changes is that Camera2 implementation can
be tested using the same tests.

CL also reduces code duplication on tests using textures.

BUG=webrtc:5519

Review-Url: https://codereview.webrtc.org/2024843002
Cr-Commit-Position: refs/heads/master@{#13130}
This commit is contained in:
sakal
2016-06-14 05:33:18 -07:00
committed by Commit bot
parent 1c7eef652b
commit 79ede033f6
8 changed files with 1084 additions and 937 deletions

View File

@ -11,10 +11,11 @@
package org.webrtc;
import static java.lang.Math.abs;
import android.graphics.ImageFormat;
import org.webrtc.Logging;
import android.graphics.ImageFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@ -137,6 +138,18 @@ public class CameraEnumerationAndroid {
+ ", Orientation " + info.orientation;
}
// Returns the camera index for camera with name |deviceName|, or throws IllegalArgumentException
// if no such camera can be found.
public static int getCameraIndex(String deviceName) {
Logging.d(TAG, "getCameraIndex: " + deviceName);
for (int i = 0; i < android.hardware.Camera.getNumberOfCameras(); ++i) {
if (deviceName.equals(CameraEnumerationAndroid.getDeviceName(i))) {
return i;
}
}
throw new IllegalArgumentException("No such camera: " + deviceName);
}
// Returns the name of the front facing camera. Returns null if the
// camera can not be used or does not exist.
public static String getNameOfFrontFacingDevice() {

View File

@ -10,15 +10,14 @@
package org.webrtc;
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
import android.content.Context;
import android.os.Handler;
import android.os.SystemClock;
import android.view.Surface;
import android.view.WindowManager;
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
import org.webrtc.Logging;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.HashSet;
@ -199,7 +198,7 @@ public class VideoCapturerAndroid implements
// Helper function to retrieve the current camera id synchronously. Note that the camera id might
// change at any point by switchCamera() calls.
int getCurrentCameraId() {
private int getCurrentCameraId() {
synchronized (cameraIdLock) {
return id;
}
@ -223,7 +222,7 @@ public class VideoCapturerAndroid implements
if (cameraName == null || cameraName == "") {
this.id = 0;
} else {
this.id = getCameraIndex(cameraName);
this.id = CameraEnumerationAndroid.getCameraIndex(cameraName);
}
this.eventsHandler = eventsHandler;
isCapturingToTexture = captureToTexture;
@ -240,18 +239,6 @@ public class VideoCapturerAndroid implements
}
}
// Returns the camera index for camera with name |deviceName|, or throws IllegalArgumentException
// if no such camera can be found.
private static int getCameraIndex(String deviceName) {
Logging.d(TAG, "getCameraIndex: " + deviceName);
for (int i = 0; i < android.hardware.Camera.getNumberOfCameras(); ++i) {
if (deviceName.equals(CameraEnumerationAndroid.getDeviceName(i))) {
return i;
}
}
throw new IllegalArgumentException("No such camera: " + deviceName);
}
private boolean maybePostOnCameraThread(Runnable runnable) {
return maybePostDelayedOnCameraThread(0 /* delayMs */, runnable);
}