Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke switch camera method two times to switch camera from Front to Back camera #548

Closed
john-lq opened this issue Jul 23, 2020 · 3 comments
Assignees
Labels

Comments

@john-lq
Copy link

john-lq commented Jul 23, 2020

Hello Twilio Team,

I'm using the Twilio Video version 5.9.0.

When I switch camera from Front to Back camera I have to call VideoCapturer.switchCamera() method two times. It occurred on our devices(Samsung Galaxy S9(rooted device), Samsung Galaxy A50s(non-rooted device)).

I have debugged the app and see that the camera doesn't switch for the first call VideoCapturer.switchCamera() method. But the cameraSource variable is updated.
Screen Shot 2020-07-23 at 16 00 07

Another thing: In the CameraCapturer.java, the onCameraSwitchDone() callback should be written as below.

               @Override
                public void onCameraSwitchDone(boolean isFrontCamera) {
                    synchronized (CameraCapturer.this) {
                        cameraSource = isFrontCamera  ? CameraSource.FRONT_CAMERA  : CameraSource.BACK_CAMERA;
                    }
                    if (listener != null) {
                        listener.onCameraSwitched();
                    }
                }

Could you help me to check that!

Thanks,
John

@aaalaniz aaalaniz added the bug label Jul 23, 2020
@aaalaniz aaalaniz self-assigned this Jul 23, 2020
@aaalaniz
Copy link
Contributor

Hey @john-lq

Nice find with the camera switch logic. 👍

I filed a bug and we will fix this in an upcoming release.

As for the switch camera behavior, I suspect the issue is related to the device containing more than 2 cameras (front and back). Unlike Camera2Capturer, CameraCapturer cycles through the cameras in order when calling switchCamera. As a result, in cases where a device contains for example 4 cameras, the switchCamera logic will just go to the next camera which is not guaranteed to be oriented on a different side of the device than the previous camera. Your workaround (calling switch camera multiple times) is recommended in these cases where CameraCapturer is required. However, if Camera2Capturer is supported on these devices, then you have the option to call switchCamera with a specific camera ID so you do not have to iterate through cameras.

Thanks!

@john-lq
Copy link
Author

john-lq commented Jul 27, 2020

Hey @aaalaniz ,

I tried to use Camera2Capture. It works well on both devices.

Thanks,
John

@aaalaniz
Copy link
Contributor

Hey @john-lq

This issue was resolved in 5.10.2.

Thank you for finding and helping resolve the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants