Add failure type parameter to onFailure callback.
This allows Camera2Session to correctly signal camera disconnect when starting the camera. BUG=webrtc:7008 Review-Url: https://codereview.webrtc.org/2642703002 Cr-Commit-Position: refs/heads/master@{#16142}
This commit is contained in:
parent
2fcd2dd93a
commit
5850a9484d
@ -65,7 +65,7 @@ public class Camera1Session implements CameraSession {
|
||||
try {
|
||||
camera = android.hardware.Camera.open(cameraId);
|
||||
} catch (RuntimeException e) {
|
||||
callback.onFailure(e.getMessage());
|
||||
callback.onFailure(FailureType.ERROR, e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class Camera1Session implements CameraSession {
|
||||
camera.setPreviewTexture(surfaceTextureHelper.getSurfaceTexture());
|
||||
} catch (IOException e) {
|
||||
camera.release();
|
||||
callback.onFailure(e.getMessage());
|
||||
callback.onFailure(FailureType.ERROR, e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ public class Camera2Session implements CameraSession {
|
||||
state = SessionState.STOPPED;
|
||||
stopInternal();
|
||||
if (startFailure) {
|
||||
callback.onFailure("Camera disconnected / evicted.");
|
||||
callback.onFailure(FailureType.DISCONNECTED, "Camera disconnected / evicted.");
|
||||
} else {
|
||||
events.onCameraDisconnected(Camera2Session.this);
|
||||
}
|
||||
@ -406,7 +406,7 @@ public class Camera2Session implements CameraSession {
|
||||
state = SessionState.STOPPED;
|
||||
stopInternal();
|
||||
if (startFailure) {
|
||||
callback.onFailure(error);
|
||||
callback.onFailure(FailureType.ERROR, error);
|
||||
} else {
|
||||
events.onCameraError(this, error);
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public abstract class CameraCapturer implements CameraVideoCapturer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String error) {
|
||||
public void onFailure(CameraSession.FailureType failureType, String error) {
|
||||
checkIsOnCameraThread();
|
||||
uiThreadHandler.removeCallbacks(openCameraTimeoutRunnable);
|
||||
synchronized (stateLock) {
|
||||
@ -81,7 +81,11 @@ public abstract class CameraCapturer implements CameraVideoCapturer {
|
||||
switchState = SwitchState.IDLE;
|
||||
}
|
||||
|
||||
eventsHandler.onCameraError(error);
|
||||
if (failureType == CameraSession.FailureType.DISCONNECTED) {
|
||||
eventsHandler.onCameraDisconnected();
|
||||
} else {
|
||||
eventsHandler.onCameraError(error);
|
||||
}
|
||||
} else {
|
||||
Logging.w(TAG, "Opening camera failed, retry: " + error);
|
||||
|
||||
|
||||
@ -11,10 +11,12 @@
|
||||
package org.webrtc;
|
||||
|
||||
public interface CameraSession {
|
||||
enum FailureType { ERROR, DISCONNECTED }
|
||||
|
||||
// Callbacks are fired on the camera thread.
|
||||
public interface CreateSessionCallback {
|
||||
void onDone(CameraSession session);
|
||||
void onFailure(String error);
|
||||
void onFailure(FailureType failureType, String error);
|
||||
}
|
||||
|
||||
// Events are fired on the camera thread.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user