How to get multiple streams in a peerConnection

610 Views Asked by At

Hello I am going to create a surveillance system. I would like to get a webcam video and a shared screen, but using addtrack will only get the media stream I declared later. Is there any way to get both streams. thanks.

here is code offer side

let stream = video.srcObject;
let stream2 = shareVideo.srcObject;
stream.getTracks().forEach(track => peerConnection.addTrack(track, stream));
stream2.getTracks().forEach(track => peerConnection.addTrack(track, stream2));

and here is answer side

peerConnections[id].ontrack = (event) => {
console.log(event);

when i checked log. event has one track and stream[0] has mediastream bu steam[1] has no mediastream

0

There are 0 best solutions below