I am working on a pjsip video application. I want to switch the preview camera during the current call.
Here is the code I'm trying to do.
private void switchCamera(boolean isFront) {
try {
int w = (int) SipCallService.currentCall.vidPrev.getVideoWindow()
.getInfo().getSize().getW();
int h = (int) SipCallService.currentCall.vidPrev.getVideoWindow()
.getInfo().getSize().getH();
if (isFront) {
PjCamera camera = new PjCamera(0, w, h, 0, 0, 0,
mSurfaceCapture);
camera.SwitchDevice(0);
} else {
PjCamera camera = new PjCamera(0, w, h, 0, 0, 0,
mSurfaceCapture);
camera.SwitchDevice(1);
}
} catch (Exception e) {
e.printStackTrace();
showToast("Error while switching camera");
}
}
PjCamera is a class provided by pjsip.
I cannot switch the camera using the code above.
If there is any other method, please help me.
source
share