0

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

vidDevManager().setCaptureOrient

https://gist.github.com/ursusursus/972356c40827347360917cd5eda07065

However, next app launch everything works.

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

(since permission is now granted)

My hypothesis is that the library predates runtime permissions and caches something on startup.

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

Thanks

urSus
  • 12,492
  • 12
  • 69
  • 89
  • Did you add permission in your manifest file?And you need Request permission at runtime. – aolphn Oct 31 '18 at 06:30
  • I know, I do, and request it, and have it. Everything that is okay, but first call crashes, unless I restart the pjsip library – urSus Oct 31 '18 at 22:20
  • Is there some error stack? – aolphn Oct 31 '18 at 23:31
  • yes, here it is https://gist.github.com/ursusursus/972356c40827347360917cd5eda07065 – urSus Nov 02 '18 at 04:15
  • what the value of orientation when you invoke `endPoint.vidDevManager().setCaptureOrient()` method. – aolphn Nov 02 '18 at 04:23
  • `val orientation = pjmedia_orient.PJMEDIA_ORIENT_ROTATE_270DEG vidDevManager.setCaptureOrient(videoCaptureDevice.id, orientation, true)` – urSus Nov 03 '18 at 08:38
  • but I think it has to with the permissions as O mentioned. Only after next app restart the same exact code works – urSus Nov 03 '18 at 08:39
  • @urSus Yes that's true. There is something with the library. I am using OnePlus 7 Pro which has front pop up camera. I have observed that when I am registering user at time of app initilization, it comes if the permission is granted. So, they might be doing something with camera. I am facing the same issue for runtime camera permission. Did you find the solution? – Aanal Shah Oct 23 '19 at 10:04

1 Answers1

0

Okay so after some research, I found the solution. Once the Camera permission is granted, you have to refresh video devices using VideoDeviceManager class.

In my case,

MyApp.ep?.vidDevManager()?.refreshDevs()
  • Here ep stands for EndPoint

It should work now. :)

Aanal Shah
  • 1,946
  • 2
  • 20
  • 30