I've been experimenting with a video chat code that I stumbled upon on YouTube. However, every time I try to make a call, I encounter an error. It's been a few days now and I can't seem to pinpoint where the issue lies.
Here is the snippet of the code:
private localStream: MediaStream;
inCall = false;
localVideoActive = false;
constructor(private dataService: DataService) { }
async call(): Promise<void> {
this.createPeerConnection();
// Add the tracks from the local stream to the RTCPeerConnection
this.localStream.getTracks().forEach(
track => this.peerConnection.addTrack(track, this.localStream)
);
try {
const offer: RTCSessionDescriptionInit = await this.peerConnection.createOffer(offerOptions);
// Establish the offer as the local peer's current description.
await this.peerConnection.setLocalDescription(offer);
this.inCall = true;
this.dataService.sendMessage({type: 'offer', data: offer});
} catch (err:any) {
this.handleGetUserMediaError(err);
}