do not mirror back camera. fixes #3693
This commit is contained in:
parent
5a5f887229
commit
e70b6eec98
|
@ -639,14 +639,14 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchCamera(final View view) {
|
private void switchCamera(final View view) {
|
||||||
Futures.addCallback(requireRtpConnection().switchCamera(), new FutureCallback<Void>() {
|
Futures.addCallback(requireRtpConnection().switchCamera(), new FutureCallback<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(@NullableDecl Void result) {
|
public void onSuccess(@NullableDecl Boolean isFrontCamera) {
|
||||||
|
binding.localVideo.setMirror(isFrontCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(final Throwable throwable) {
|
public void onFailure(@NonNull final Throwable throwable) {
|
||||||
Log.d(Config.LOGTAG,"could not switch camera", Throwables.getRootCause(throwable));
|
Log.d(Config.LOGTAG,"could not switch camera", Throwables.getRootCause(throwable));
|
||||||
Toast.makeText(RtpSessionActivity.this, R.string.could_not_switch_camera, Toast.LENGTH_LONG).show();
|
Toast.makeText(RtpSessionActivity.this, R.string.could_not_switch_camera, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
||||||
ensureSurfaceViewRendererIsSetup(binding.localVideo);
|
ensureSurfaceViewRendererIsSetup(binding.localVideo);
|
||||||
//paint local view over remote view
|
//paint local view over remote view
|
||||||
binding.localVideo.setZOrderMediaOverlay(true);
|
binding.localVideo.setZOrderMediaOverlay(true);
|
||||||
binding.localVideo.setMirror(true);
|
binding.localVideo.setMirror(requireRtpConnection().isFrontCamera());
|
||||||
localVideoTrack.get().addSink(binding.localVideo);
|
localVideoTrack.get().addSink(binding.localVideo);
|
||||||
} else {
|
} else {
|
||||||
binding.localVideo.setVisibility(View.GONE);
|
binding.localVideo.setVisibility(View.GONE);
|
||||||
|
|
|
@ -1043,7 +1043,11 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
||||||
return webRTCWrapper.isCameraSwitchable();
|
return webRTCWrapper.isCameraSwitchable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListenableFuture<Void> switchCamera() {
|
public boolean isFrontCamera() {
|
||||||
|
return webRTCWrapper.isFrontCamera();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListenableFuture<Boolean> switchCamera() {
|
||||||
return webRTCWrapper.switchCamera();
|
return webRTCWrapper.switchCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,16 +277,22 @@ public class WebRTCWrapper {
|
||||||
return capturerChoice != null && capturerChoice.availableCameras.size() > 1;
|
return capturerChoice != null && capturerChoice.availableCameras.size() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListenableFuture<Void> switchCamera() {
|
boolean isFrontCamera() {
|
||||||
|
final CapturerChoice capturerChoice = this.capturerChoice;
|
||||||
|
return capturerChoice == null || capturerChoice.isFrontCamera;
|
||||||
|
}
|
||||||
|
|
||||||
|
ListenableFuture<Boolean> switchCamera() {
|
||||||
final CapturerChoice capturerChoice = this.capturerChoice;
|
final CapturerChoice capturerChoice = this.capturerChoice;
|
||||||
if (capturerChoice == null) {
|
if (capturerChoice == null) {
|
||||||
return Futures.immediateFailedFuture(new IllegalStateException("CameraCapturer has not been initialized"));
|
return Futures.immediateFailedFuture(new IllegalStateException("CameraCapturer has not been initialized"));
|
||||||
}
|
}
|
||||||
final SettableFuture<Void> future = SettableFuture.create();
|
final SettableFuture<Boolean> future = SettableFuture.create();
|
||||||
capturerChoice.cameraVideoCapturer.switchCamera(new CameraVideoCapturer.CameraSwitchHandler() {
|
capturerChoice.cameraVideoCapturer.switchCamera(new CameraVideoCapturer.CameraSwitchHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onCameraSwitchDone(boolean isFrontCamera) {
|
public void onCameraSwitchDone(boolean isFrontCamera) {
|
||||||
future.set(null);
|
capturerChoice.isFrontCamera = isFrontCamera;
|
||||||
|
future.set(isFrontCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -438,7 +444,12 @@ public class WebRTCWrapper {
|
||||||
final Set<String> deviceNames = ImmutableSet.copyOf(enumerator.getDeviceNames());
|
final Set<String> deviceNames = ImmutableSet.copyOf(enumerator.getDeviceNames());
|
||||||
for (final String deviceName : deviceNames) {
|
for (final String deviceName : deviceNames) {
|
||||||
if (enumerator.isFrontFacing(deviceName)) {
|
if (enumerator.isFrontFacing(deviceName)) {
|
||||||
return Optional.fromNullable(of(enumerator, deviceName, deviceNames));
|
final CapturerChoice capturerChoice = of(enumerator, deviceName, deviceNames);
|
||||||
|
if (capturerChoice == null) {
|
||||||
|
return Optional.absent();
|
||||||
|
}
|
||||||
|
capturerChoice.isFrontCamera = true;
|
||||||
|
return Optional.of(capturerChoice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deviceNames.size() == 0) {
|
if (deviceNames.size() == 0) {
|
||||||
|
@ -548,6 +559,7 @@ public class WebRTCWrapper {
|
||||||
private final CameraVideoCapturer cameraVideoCapturer;
|
private final CameraVideoCapturer cameraVideoCapturer;
|
||||||
private final CameraEnumerationAndroid.CaptureFormat captureFormat;
|
private final CameraEnumerationAndroid.CaptureFormat captureFormat;
|
||||||
private final Set<String> availableCameras;
|
private final Set<String> availableCameras;
|
||||||
|
private boolean isFrontCamera = false;
|
||||||
|
|
||||||
CapturerChoice(CameraVideoCapturer cameraVideoCapturer, CameraEnumerationAndroid.CaptureFormat captureFormat, Set<String> cameras) {
|
CapturerChoice(CameraVideoCapturer cameraVideoCapturer, CameraEnumerationAndroid.CaptureFormat captureFormat, Set<String> cameras) {
|
||||||
this.cameraVideoCapturer = cameraVideoCapturer;
|
this.cameraVideoCapturer = cameraVideoCapturer;
|
||||||
|
|
Loading…
Reference in New Issue