I am working on pjsip video calling app. I want to switch preview camera in an ongoing call.
Here is the code that I am trying.
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 the class provided by pjsip.
I am not able to switch camera using above code.
If there is any other method please guide me to it.
I used this code, to switch between the front / back cameras.
int cameraId = isFront? 1 :2;
CallVidSetStreamParam callVidSetStreamParam = new CallVidSetStreamParam();
callVidSetStreamParam.setCapDev(cameraId);
try {
sipCall.vidSetStream(pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, callVidSetStreamParam);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With