react-native-twilio-video-webrtc
react-native-twilio-video-webrtc copied to clipboard
Camera1Enumerator does not find front or back cameras in buildDeviceInfo
The following twilio component is mounted in my component:
<TwilioVideo
ref={handleTwilioVideoRef}
onRoomDidConnect={handleRoomDidConnect}
onRoomDidDisconnect={handleRoomDidDisconnect}
onRoomDidFailToConnect={event => {
console.error(event.error) // This error happens on JS side
handleRoomDidFailToConnect(event.error)
}}
onRoomParticipantDidConnect={handleRoomParticipantDidConnect}
onRoomParticipantDidDisconnect={handleRoomParticipantDidDisconnect}
onParticipantAddedVideoTrack={handleParticipantAddedVideoTrack}
onParticipantRemovedVideoTrack={handleParticipantRemovedVideoTrack}
onParticipantEnabledVideoTrack={handleParticipantEnabledVideoTrack}
onParticipantDisabledVideoTrack={handleParticipantDisabledVideoTrack}
/>
Steps to reproduce
- Start Twilio video
- Somehow TOGGLE_VIDEO command is called immediately on native side
- in
buildDeviceInfo
,Camera1Enumerator
successfully gets devices
Expected behaviour
The following device names are found:
Camera 0, Facing back, Orientation 90
Camera 1, Facing front, Orientation 270
enumerator.isBackFacing
should resolve to Camera 0
enumerator.isFrontFacing
should resolve to Camera 1
Actual behaviour
enumerator.isBackFacing
and enumerator.isFrontFacing
never resolved to any of the provided device names
Environment
- Node.js version: 14.17.0
- React Native version: 0.61.4
- React Native platform + platform version: Android 12 (Pixel 4a)
react-native-twilio-video-webrtc
Version: master
Update
I tried updating CustomTwilioVideo.java
by replacing all instances/uses of the Camera1
apis with Camera2
and was successfully able to get local and remote video working on my Pixel 4a (Android 30)
Line 39
import com.twilio.video.Camera2Capturer;
Line 193
private static Camera2Capturer cameraCapturer;
Line 268
@Override
public void onError(@NonNull Camera2Capturer.Exception camera2CapturerException) {
Log.i("CustomTwilioVideoView", "Error getting camera");
Log.i("CustomTwilioVideoView", camera2CapturerException.getMessage(), camera2CapturerException);
}
Line 282
Camera2Enumerator enumerator = new Camera2Enumerator(getContext());
Should we adopt the CameraCompat
class from twilio android example repo to do this in a more robust way?
oof, of course android has multiple camera apis inconsistently implemented across versions / devices. Yeah, I think the cameracompat class will be needed. Sounds like this is something you already have a bead on, how would you feel about working on the PR?
Also thanks for all of your investigation so far, it's been really helpful and insightful!
@slycoder for sure - I have a working CameraCompat
port over from the twilio android example repo in my branch. Will fork/create PR and send it your way
That is awesome, thank you so much!