Android camera device is not free up after Hang up with back camera on

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everyone!

I'm facing this bug across all versions of pjsip library since 4.5.0 (didn't try earlier ones though)...

I'm using this code to start video stream inside MyCall.java class (extends Call) callback method:

@Override
public void onCallMediaState(OnCallMediaStateParam prm) {
CallInfo ci;
try {
ci = getInfo();
} catch (Exception e) {
e.printStackTrace();
return;
}

CallMediaInfoVector cmiv = ci.getMedia();
for (int i = 0; i < cmiv.size(); i++) {
CallMediaInfo cmi = cmiv.get(i);
if (cmi.getType() == pjmedia_type.PJMEDIA_TYPE_AUDIO
&& (cmi.getStatus() == pjsua_call_media_status.PJSUA_CALL_MEDIA_ACTIVE
|| cmi.getStatus() == pjsua_call_media_status.PJSUA_CALL_MEDIA_REMOTE_HOLD) ) {
Media m = getMedia(i);
                 AudioMedia am = AudioMedia.typecastFromMedia(m);
                 try {
am.startTransmit(mEndpoint.audDevManager().getPlaybackDevMedia());
mEndpoint.audDevManager().getCaptureDevMedia().startTransmit(am);
                 } catch (Exception e) {
e.printStackTrace();
}
} else if (cmi.getType() == pjmedia_type.PJMEDIA_TYPE_VIDEO
&& cmi.getStatus() == pjsua_call_media_status.PJSUA_CALL_MEDIA_ACTIVE
&& cmi.getVideoIncomingWindowId() != pjsua2.INVALID_ID) {
try {
CallVidSetStreamParam callVidSetStreamParam = new CallVidSetStreamParam();
vidSetStream(pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_START_TRANSMIT, callVidSetStreamParam);
}catch (Exception e){
e.printStackTrace();
}
vidWin = new VideoWindow(cmi.getVideoIncomingWindowId());
vidPrev = new VideoPreview(cmi.getVideoCapDev());
}
}
if (callStateListener != null){
callStateListener.onMediaReady();
}
if (audioActivityListener != null){
audioActivityListener.onActive();
}
}

And I use this method inside MyCall.java class to change Camera:

public boolean changeCamera(int cameraId) {
try {
CallVidSetStreamParam callVidSetStreamParam = new CallVidSetStreamParam();
callVidSetStreamParam.setCapDev(cameraId);
vidSetStream(pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, callVidSetStreamParam);
currentCameraId = cameraId;
} catch (Exception e) {
e.printStackTrace();
}
return true;
}

The bug is the following:

When I start video call without changing camera (front camera by default) and then hangup - all is OK.
I can repeat this any times without any issues.
But when I start vide, change camera to back camera (via upper one method) and then hangup, I see errors in the log.
And the next call will freeze the app and crash after several seconds.
But if I will change camera back to front before hangup, then all goes OK. And works nice always.

So the main issue is video call hangup with back camera stream makes the next Call crashing the app.
This happens always and doesn't depend on call time, screen orientation etc.

Investigation:

On Android device pjsip uses swig to glue C code with Java. The library itself uses android.hardware.Camera API.
And when a call starts library uses PjCamera.java to work with android camera API.
So I added log prints into PjCamera.java to check what methods are called.
All calls are the same both for back and front camera, except 1 scenario - the call hangup.
When I call hangup with front camera, the library calls method stop() 2 times sequently (btw, why 2 times?).
But when I call hangup with back camera, the library calls method stop() and then method start() sequently, making the camera device left busy.

So in practice library actually don't free the camera device on hangup if back camera used during video call.

Please fix this or give me a key how to fix this issue.

Best Regards,
Sergey
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux