I tried to do a simple WebRTC p2p video chat browser app. I setup a signal server and have two peers doing all the SDP
and ICE
handshakes. Some of my code snippet:
pc = new RTCPeerConnection(config);
pc.onicecandidate = (event) => {
...
}
pc.ontrack(event) =>{
if (event.track.kind === 'video') {
// add the stream as the srcObject of a video tag
}
event.streams[0].onremovetrack = (e) => {
// want to remove the stream from the video tag
}
}
When a peer is done I do the following:
pc.stop();
I simply just close the RTCPeerConnection. But I don't see the onremovetrack
being triggered on the other peer.
What is the proper way to shutdown a peer so that the other peer can be notified and onremovetrack
triggered?