I am making an App using React Native and react-native-webrtc. And I want to implement a feature where after connecting the call, I want to switch the camera from front to back and vice-versa based on a boolean flag value. If the value is true then the front camera will be used and if false then back camera will be used. Seems that only changing the facing mode updates the local stream and not the remote stream of the user connected with. Can anyone tell me how to solve this ?
(Solved) : After going about it for quite some I finally found a solution. I hope that would help anyone else facing the problem. Instead of toggling the facing mode based on a boolean value, I created a function toggleCamera which switches the camera without the requirement for renegotiation. I replaced the existing Stream Track with the new Track as follows
const toggleCamera = () => {
localStream.getVideoTracks().forEach((track) => {
console.log('sc',track);
track._switchCamera();
})
}
We’ve now got a handbook over here which has some useful code samples.
In time there will also be full blown example projects.