2

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

신재익
  • 21
  • 1
  • 2
  • the ontrack only adds the tracks one by one. So you will have multiple ontrack events called with each only one track – Dirk V Jul 24 '20 at 00:15
  • thanks for replying. i'm stuck with calling multiple ontrack.... because i use ontrack only once when callee makes createAnswer.... – 신재익 Jul 24 '20 at 12:23
  • What is the problem with calling it multiple times ? – Dirk V Jul 28 '20 at 01:17

0 Answers0