Problems with runtime CAMERA permission in video calls

VB
Vlasto Brecka
Wed, Nov 7, 2018 2:05 AM

I am working on video support via pjsip/pjsua2 for android.

My problem is with runtime camera permisson. No matter if I grant the
permission, video always fails on

2018-11-02 05:14:15.785 16674-16742/com.icewarp.instantmessanger
E/Default: Title:      pjsua_vid_dev_set_setting(dev_id,
PJMEDIA_VID_DEV_CAP_ORIENTATION, &orient, keep)
Code:        520008
Description: Invalid or unsupported video capability (PJMEDIA_EVID_INVCAP)
Location:    ../src/pjsua2/media.cpp:1498

java.lang.Exception: Title:

pjsua_vid_dev_set_setting(dev_id, PJMEDIA_VID_DEV_CAP_ORIENTATION,
&orient, keep)
Code:        520008
Description: Invalid or unsupported video capability (PJMEDIA_EVID_INVCAP)
Location:    ../src/pjsua2/media.cpp:1498

    at org.pjsip.pjsua2.pjsua2JNI.VidDevManager_setCaptureOrient__SWIG_0(Native

Method)
at org.pjsip.pjsua2.VidDevManager.setCaptureOrient(VidDevManager.java:91)
at com.foo.bar.sip.client.core.SipCallManager$callListener$1.onCallMediaActivated(SipCallManager.kt:534)
at com.foo.bar.sip.client.core.SipCall.onCallMediaState(SipCall.kt:336)
at org.pjsip.pjsua2.pjsua2JNI.SwigDirector_Call_onCallMediaState(pjsua2JNI.java:2539)

However, next app launch everything works (after the crash)

Also, if I try catch it and restart the library it works

(since permission is already now granted)

My hypothesis is that the library predates runtime permissions and caches
something on startup, to which it wont have access to since permission is
not granted yet at library startup, And then even if granted, it uses
cached (invalid) values.

Anyone any idea about this? Has anyone got video working on targetSdk 23+?

TLDR; I initialize endpoint / library at app startup. I ask for permission
after clicking on Make call button. Only after granting the permission I
actually make the call via pjsip.

Starting endpoint only after granting permission is problematic since I
need the account registration status from the library to show / hide the
makeCall button.
But solution could be to to restart the pjsip after granting the permission
after clicking makeCall button.

However while incoming call, it is very problematic, since restarting the
pjsip stack would decline to call essentially.

Thanks

I am working on video support via pjsip/pjsua2 for android. My problem is with runtime camera permisson. No matter if I grant the permission, video always fails on 2018-11-02 05:14:15.785 16674-16742/com.icewarp.instantmessanger E/Default: Title: pjsua_vid_dev_set_setting(dev_id, PJMEDIA_VID_DEV_CAP_ORIENTATION, &orient, keep) Code: 520008 Description: Invalid or unsupported video capability (PJMEDIA_EVID_INVCAP) Location: ../src/pjsua2/media.cpp:1498 java.lang.Exception: Title: pjsua_vid_dev_set_setting(dev_id, PJMEDIA_VID_DEV_CAP_ORIENTATION, &orient, keep) Code: 520008 Description: Invalid or unsupported video capability (PJMEDIA_EVID_INVCAP) Location: ../src/pjsua2/media.cpp:1498 at org.pjsip.pjsua2.pjsua2JNI.VidDevManager_setCaptureOrient__SWIG_0(Native Method) at org.pjsip.pjsua2.VidDevManager.setCaptureOrient(VidDevManager.java:91) at com.foo.bar.sip.client.core.SipCallManager$callListener$1.onCallMediaActivated(SipCallManager.kt:534) at com.foo.bar.sip.client.core.SipCall.onCallMediaState(SipCall.kt:336) at org.pjsip.pjsua2.pjsua2JNI.SwigDirector_Call_onCallMediaState(pjsua2JNI.java:2539) > *However, next app launch everything works (after the crash)* Also, if I try catch it and restart the library it works (since permission is already now granted) *My hypothesis is that the library predates runtime permissions and caches something on startup, to which it wont have access to since permission is not granted yet at library startup, And then even if granted, it uses cached (invalid) values.* Anyone any idea about this? Has anyone got video working on targetSdk 23+? TLDR; I initialize endpoint / library at app startup. I ask for permission after clicking on Make call button. Only after granting the permission I actually make the call via pjsip. Starting endpoint only after granting permission is problematic since I need the account registration status from the library to show / hide the makeCall button. But solution could be to to restart the pjsip after granting the permission after clicking makeCall button. However while incoming call, it is very problematic, since restarting the pjsip stack would decline to call essentially. Thanks