The great developers. I am using a webRTC library of io.pristine.libjingle:11139 for video calling. All is going good, now I just want to turn FLASHLIGHT on, I researched almost all the questions related to the FLASHLIGHT, where I found that the FLASHLIGHT is a feature of camera, so to turn on the FLASHLIGHT one have to go with CAMERA object. Now I stuck here because I am using the library, it does not allow me to access the camera object already opened. So how to turn on flashlight on without using camera, because camera is already used by the webrtc library ? Is there any any other latest library that allow to access the camera object of libjingle for webrtc for android ?
I need help it's a really like challenge.
regards, Dharma
I was facing this issue today and haven't found a solution anywhere so I wanted to share my solution, although it's quite late after the question was asked. There are basically two options: modify source & compile webrtc library yourself or an easier solution - override the functionality of the library a bit. I have to say that I'm using latest prebuilt library straight from Google's repository, so my libjingle library might be a bit different.
Now, to the code itself. Create a package
org.webrtcto be able to access package-private classes and interfaces you need to implement or modify.First of these is
interface CameraSession. Instance of this interface handles access to android's Camera. So I createdclass FlaslightCameraSession implements CameraSessionby copy-pasting code fromclass Camera1Sessionand adding a function to turn on/off the flashlight as follows.Next step is to modify
VideoCapturerused to getVideoFrames of the camera. To do this I simply made aclass FlashlightCameraCapturerby extending webrtc'sclass Camera1Capturerand added simple modification to control the flashlight.Final step is to modify
CameraEnumerator. Specifically, you need to override createCapturer function to create instance of our modified capturer. So I extendedclass Camera1Enumeratorto override this function as follows.Now you can simply use your new modified camera enumerator to get instance of camera capturer that can control the flashlight.
Hope this helps :)