[Android_WebRTC] Switch camera is not correct!

631 views
Skip to first unread message

teo nguyen van

unread,
Jul 26, 2018, 5:29:17 AM7/26/18
to discuss-webrtc
Hello Guys! I'm making an android app to make a video call with webRTC. I'm in error when switch the camera from the front camera to the back camera. The camera is in opposite directions
 (As picture). Please help me! Thank you!
Here is my code "switch camera":
private void switchCamera() {
        if (videoCapturerAndroid != null) {
            if (videoCapturerAndroid instanceof CameraVideoCapturer) {
                CameraVideoCapturer cameraVideoCapturer =
                        (CameraVideoCapturer) videoCapturerAndroid;
                cameraVideoCapturer.switchCamera(null);
            } else {
               }
        }
 }


David Thomas

unread,
Jul 27, 2018, 10:56:29 AM7/27/18
to discuss-webrtc
I think the problem is that you need to set the mirroring option for your view to false. I would guess you're switching to the back camera correctly but not changing the view which is a SurfaceViewRenderer. If you call setMirror(false) on that view I think it should be OK.

Peter

unread,
Jul 30, 2018, 1:14:14 AM7/30/18
to discuss-webrtc
Oh my god! Thank you Thank You So Much Mr. David Thomas! I have fixed it and I have successed. I'm very happy!
And Mr. David Thomas, can you help me about my problem with audio? I can't close audio after i stopped a call. It still  works after I turn off the call. Here is my code but it's not true:
"
public void stop() {

if (audioConstraints != null) {
audioConstraints = null;
}
if (audioSource != null) {
audioSource.dispose();
}
if (videoCapturerAndroid != null) {
videoCapturerAndroid.stopCapture();
videoCapturerAndroid.dispose();
}
if (mLocalVideoView != null) {
mLocalVideoView.release();
}
if (mRemoteVideoView != null) {
mRemoteVideoView.release();
}
if (localPeer != null) {
localPeer.close();
}
finish();
}
The audio not close, I still hear the sound of the phone of my partner.

Thank you so much again!



Vào 21:56:29 UTC+7 Thứ Sáu, ngày 27 tháng 7 năm 2018, David Thomas đã viết:

David Thomas

unread,
Jul 30, 2018, 4:31:31 AM7/30/18
to discuss-webrtc
Sorry, don't know that one. Maybe somebody else will help.

teo nguyen van

unread,
Jul 30, 2018, 6:20:16 AM7/30/18
to discuss...@googlegroups.com
Thank you Thomas!

Vào Th 2, 30 thg 7, 2018 vào lúc 15:31 David Thomas <dth...@cafex.com> đã viết:
Sorry, don't know that one. Maybe somebody else will help.


--------------------

Note: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer.  Thank you.  CafeX Communications.


--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/a8106973-7595-463c-8026-bcdf73891f77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages