We need a way to know if the media stream is switched to the front camera or back camera when calling switchCamera()
When using the switchCamera() method it only returns if the switch was successful or not. I need to know if the camera that was switched into is front facing or not. We mirror the image on the canvas when the user is using the front facing camera and we need to disable it if the user switches the camera. With the current implementation of Skyway the switchCamera will cycle through all the available cameras and this will be a problem if there are multiple cameras on the device. I checked the code and it seems that on the MediaStream.switchCamera() the CameraSwitchHandler callback already has the information if the the camera is front facing. Is there a way for this to be sent back to the client? I am thinking maybe we can implement something like the following (the return type could also be removed):
public boolean switchCamera(CameraSwitchHandler switchHandler) { final AtomicBoolean result = new AtomicBoolean(false); final AtomicBoolean cameraFlag = new AtomicBoolean(false); if (this.videoCapturer instanceof CameraVideoCapturer) { final CountDownLatch latch = new CountDownLatch(1); CameraVideoCapturer capturer = (CameraVideoCapturer)this.videoCapturer; capturer.switchCamera(new CameraSwitchHandler() { public void onCameraSwitchDone(boolean isFrontCamera) { result.set(true); cameraFlag = isFrontCamera latch.countDown(); } public void onCameraSwitchError(String errorDescription) { latch.countDown(); } }); try { if (latch.await(10L, TimeUnit.MILLISECONDS)) { } } catch (InterruptedException var5) { } } if (result.get) { switchHandler.onCameraSwitchDone(cameraFlag) } else { switchHandler.onCameraSwitchError("") } return result.get(); }
サインインしてコメントを残してください。
コメント
0件のコメント