Cordova-plugin-twilio-video-v2preview and 2 back cameras?

I’m using Twilio and cordova-plugin-twilio-video-v2preview -plugin and I have a system that has two cameras but my problem is that both cameras report themselves as BACK_CAMERA and unfortunally cordova-plugin-twilio-video-v2preview -plugin is coded by default to expect front and back camera, but not 2 back cameras. It is not in my hands to the change the system so I would need help to make the plugin working with two back cameras. Any ideas? I need to create two back camera LocalVideoTracks, but I’m at lost. Don’t know enough about android and java. I did managed to add java code that I can get the system to tell me (alert) that there indeed are 2 cameras (usb) and they both are back cameras. Any help?

I think I have solved the two back cameras problem but I have another problem. My current java code is working on android 8.1.0 but not working on android 6.0.1 and for the life of me can’t figure out why. But I’m really not a java/android coder… Help please?

private void getCameraSources() {
this.cameraId = -1;
this.numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < this.numberOfCameras; i++) {
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(i, info);
if (i == 1) {
if (info.facing == 1) {
cameraCapturer = new CameraCapturer(this, CameraSource.FRONT_CAMERA);
}
else if (info.facing == 0) {
cameraCapturer = new CameraCapturer(this, CameraSource.BACK_CAMERA);
}
}
else if (i == 0) {
if (info.facing == 1) {
cameraCapturer2 = new CameraCapturer(this, CameraSource.FRONT_CAMERA);
}
else if (info.facing == 0) {
cameraCapturer2 = new CameraCapturer(this, CameraSource.BACK_CAMERA);
}
}
}
}

private void createAudioAndVideoTracks() {

    // Share your microphone
    localAudioTrack = LocalAudioTrack.create(this, true);

    // Share your video
    getCameraSources();

    localVideoTrack = LocalVideoTrack.create(this, true, cameraCapturer);
    primaryVideoView.setMirror(true);
    localVideoTrack.addRenderer(primaryVideoView);
    localVideoView = primaryVideoView;

    localVideoTrack2 = LocalVideoTrack.create(this, true, cameraCapturer2);
    // thumbnailVideoView2.setMirror(true);
    // localVideoTrack2.addRenderer(thumbnailVideoView2);
    // localVideoView2 = thumbnailVideoView2;
}

private void connectToRoom(String roomName) {
    MediaCodecVideoEncoder.disableVp8HwCodec();
    MediaCodecVideoEncoder.disableVp9HwCodec();
    MediaCodecVideoDecoder.disableVp8HwCodec();
    MediaCodecVideoDecoder.disableVp9HwCodec();
    configureAudio(true);
    ConnectOptions.Builder connectOptionsBuilder = new ConnectOptions.Builder(accessToken)
            .roomName(roomName);

    /*
     * Add local audio track to connect options to share with participants.
     */
    if (localAudioTrack != null) {
        connectOptionsBuilder
                .preferAudioCodecs(Arrays.asList(AudioCodec.OPUS, AudioCodec.ISAC))
                .audioTracks(Collections.singletonList(localAudioTrack));
    }

    /*
     * Add local video track to connect options to share with participants.
     */
    if (localVideoTrack != null & localVideoTrack2 == null) {
        connectOptionsBuilder.videoTracks(Collections.singletonList(localVideoTrack));
    }
    else if (localVideoTrack != null & localVideoTrack2 != null) {
        connectOptionsBuilder.videoTracks(Arrays.asList(localVideoTrack,localVideoTrack2));
    }

    room = Video.connect(this, connectOptionsBuilder.build(), roomListener());
    setDisconnectAction();
    
}

This code crashes on android 6.0.1 when the connection is made. On android 8.1.0 it’s working fine and the receiving end is getting two videos and is able to show them both. Why is it crashing on 6.0.1?

Forget about it. Just can’t be done. Atleast not with android 6 and android.hardware.camera -library. Doesn’t allow two cameras to be open at the same time. Coverting the plugin to camera2 -library maid work but I can’t do it. Not an java/android coder.

Apart from the 2 camera issue, did you get Twilio working ok with Ionic?
I have it working in an Angular project and want to create an Ionic app using Twilio now.