-
Notifications
You must be signed in to change notification settings - Fork 33
Description
We're trying to use LiveKit's fork of react-native-webrtc for our homegrown video streaming offering during a transition over to using full on LiveKit. We are able to create a camera feed for either the front or back camera on a device by specifying the facingMode constraint on the video when requesting a stream using getUserMedia(), like so:
const newStream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: {
facingMode: isFront ? 'user' : 'environment',
},
});However, when we then go to flip the camera using a toggle button, like in the following code, we end up with the original video stream from the first piece of code, but flipped vertically:
const videoTracks = streamRef.current.getVideoTracks();
const facingMode = isFront ? 'user' : 'environment';
if (videoTracks) {
videoTracks.forEach((track) =>
track.applyConstraints({
facingMode,
})
);
}It looks like how LiveKit itself handles this is by tearing down the old feed and then fetching a new feed using getUserMedia(), but our homegrown solution does not allow for that. I have confirmed this works with the upstream react-native-webrtc 124.0.6.