mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-12 10:32:36 +00:00
Use mirror only on front camera
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
aa8d058ef8
commit
534e0e5d7c
@ -225,6 +225,9 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private SpotlightView spotlightView;
|
private SpotlightView spotlightView;
|
||||||
|
|
||||||
|
private int camerasCount;
|
||||||
|
private int cameraSwitchCount;
|
||||||
|
|
||||||
private static int getSystemUiVisibility() {
|
private static int getSystemUiVisibility() {
|
||||||
int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
|
int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||||
flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||||
@ -515,7 +518,24 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
public void switchCamera() {
|
public void switchCamera() {
|
||||||
CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
|
CameraVideoCapturer cameraVideoCapturer = (CameraVideoCapturer) videoCapturer;
|
||||||
if (cameraVideoCapturer != null) {
|
if (cameraVideoCapturer != null) {
|
||||||
cameraVideoCapturer.switchCamera(null);
|
cameraVideoCapturer.switchCamera(new CameraVideoCapturer.CameraSwitchHandler() {
|
||||||
|
@Override
|
||||||
|
public void onCameraSwitchDone(boolean b) {
|
||||||
|
if (b && cameraSwitchCount != -1) {
|
||||||
|
if (cameraSwitchCount == camerasCount) {
|
||||||
|
cameraSwitchCount = 0;
|
||||||
|
pipVideoView.setMirror(true);
|
||||||
|
} else {
|
||||||
|
pipVideoView.setMirror(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCameraSwitchError(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,6 +557,8 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
private VideoCapturer createCameraCapturer(CameraEnumerator enumerator) {
|
private VideoCapturer createCameraCapturer(CameraEnumerator enumerator) {
|
||||||
final String[] deviceNames = enumerator.getDeviceNames();
|
final String[] deviceNames = enumerator.getDeviceNames();
|
||||||
|
|
||||||
|
camerasCount = deviceNames.length;
|
||||||
|
|
||||||
// First, try to find front facing camera
|
// First, try to find front facing camera
|
||||||
Logging.d(TAG, "Looking for front facing cameras.");
|
Logging.d(TAG, "Looking for front facing cameras.");
|
||||||
for (String deviceName : deviceNames) {
|
for (String deviceName : deviceNames) {
|
||||||
@ -544,12 +566,15 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
Logging.d(TAG, "Creating front facing camera capturer.");
|
Logging.d(TAG, "Creating front facing camera capturer.");
|
||||||
VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
|
VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
|
||||||
|
|
||||||
|
cameraSwitchCount = 0;
|
||||||
if (videoCapturer != null) {
|
if (videoCapturer != null) {
|
||||||
return videoCapturer;
|
return videoCapturer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cameraSwitchCount = -1;
|
||||||
|
|
||||||
// Front facing camera not found, try something else
|
// Front facing camera not found, try something else
|
||||||
Logging.d(TAG, "Looking for other cameras.");
|
Logging.d(TAG, "Looking for other cameras.");
|
||||||
for (String deviceName : deviceNames) {
|
for (String deviceName : deviceNames) {
|
||||||
@ -558,6 +583,7 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
|
VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
|
||||||
|
|
||||||
if (videoCapturer != null) {
|
if (videoCapturer != null) {
|
||||||
|
pipVideoView.setMirror(false);
|
||||||
return videoCapturer;
|
return videoCapturer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user