mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Add logging to debug flipping from broken camera
This commit is contained in:
committed by
Michelle Tang
parent
ee0ee98cb6
commit
5fd4ac0a06
@@ -64,12 +64,12 @@ public class Camera implements CameraControl, CameraVideoCapturer.CameraSwitchHa
|
||||
|
||||
CameraState.Direction firstChoice = desiredCameraDirection.isUsable() ? desiredCameraDirection : FRONT;
|
||||
|
||||
CameraVideoCapturer capturerCandidate = createVideoCapturer(enumerator, firstChoice);
|
||||
CameraVideoCapturer capturerCandidate = createVideoCapturer(enumerator, firstChoice, false);
|
||||
if (capturerCandidate != null) {
|
||||
activeDirection = firstChoice;
|
||||
} else {
|
||||
CameraState.Direction secondChoice = firstChoice.switchDirection();
|
||||
capturerCandidate = createVideoCapturer(enumerator, secondChoice);
|
||||
capturerCandidate = createVideoCapturer(enumerator, secondChoice, false);
|
||||
if (capturerCandidate != null) {
|
||||
activeDirection = secondChoice;
|
||||
} else {
|
||||
@@ -153,23 +153,30 @@ public class Camera implements CameraControl, CameraVideoCapturer.CameraSwitchHa
|
||||
|
||||
public void disposeAndFlipCamera() {
|
||||
if (capturer != null) {
|
||||
Log.i(TAG, "disposeAndFlipCamera(): enabled: " + this.enabled + " isInitialized: " + this.isInitialized);
|
||||
capturer.dispose();
|
||||
boolean wasInitialized = isInitialized;
|
||||
isInitialized = false;
|
||||
CameraState.Direction candidateDirection = oldActiveDirection.switchDirection();
|
||||
CameraVideoCapturer captureCandidate = createVideoCapturer(getCameraEnumerator(context), candidateDirection);
|
||||
CameraVideoCapturer captureCandidate = createVideoCapturer(getCameraEnumerator(context), candidateDirection, true);
|
||||
Log.i(TAG, "disposeAndFlipCamera(): candidateDirection: " + candidateDirection + " oldActiveDirection: " + oldActiveDirection +
|
||||
" captureCandidate: " + captureCandidate + " wasInitialized: " + wasInitialized + " enabled: " + enabled);
|
||||
if (captureCandidate != null) {
|
||||
capturer = captureCandidate;
|
||||
activeDirection = candidateDirection;
|
||||
if (wasInitialized) {
|
||||
Log.i(TAG, "disposeAndFlipCamera(): re-initialize");
|
||||
initCapturer(this.observer);
|
||||
}
|
||||
if (enabled) {
|
||||
Log.i(TAG, "disposeAndFlipCamera(): setEnabled");
|
||||
setEnabled(true);
|
||||
}
|
||||
} else {
|
||||
activeDirection = NONE;
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "disposeAndFlipCamera(): capturer was null");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,13 +201,17 @@ public class Camera implements CameraControl, CameraVideoCapturer.CameraSwitchHa
|
||||
}
|
||||
|
||||
private @Nullable CameraVideoCapturer createVideoCapturer(@NonNull CameraEnumerator enumerator,
|
||||
@NonNull CameraState.Direction direction)
|
||||
@NonNull CameraState.Direction direction,
|
||||
boolean logSelectedCameraName)
|
||||
{
|
||||
String[] deviceNames = enumerator.getDeviceNames();
|
||||
for (String deviceName : deviceNames) {
|
||||
if ((direction == FRONT && enumerator.isFrontFacing(deviceName)) ||
|
||||
(direction == BACK && enumerator.isBackFacing(deviceName)))
|
||||
{
|
||||
if (logSelectedCameraName) {
|
||||
Log.i(TAG, "createVideoCapturer(): Trying device " + deviceName);
|
||||
}
|
||||
return enumerator.createCapturer(deviceName, null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user