0

I am given to understand that RTCPeerConnection.addStream() is deprecated and instead addTrack() should be used in its place. However this causes the server to add two tracks ( audio and video ) hence I receieve 2 mediaStream at my client side.

Is one of these mediaStreams enough? Is there a way to send only 1 stream back?

This is a part of my code :

server :

 filteredOne.forEach((el, index) => { //! incStream has the stream ID for identification
        foundGuest.tracks.forEach(t => peer[el.id].addTrack(t, foundGuest.incStream) && console.log('track added to other peer'))
        el.tracks && el.tracks.forEach(t => peer[id].addTrack(t, el.incStream) && console.log('track added to self peer'))

And client :

peer.ontrack = (e) => {
          console.log('e' , e.streams[0].id)

in which I receive 2 e.streams[0].id with same value.

Hypothesis
  • 1,208
  • 3
  • 17
  • 43

1 Answers1

3

This happens when your MediaStream has two tracks, one for audio, the other for video. The e.track in the track event will be different. The e.streams[0].id is the same because they belong to the same MediaStream.

Philipp Hancke
  • 15,855
  • 2
  • 23
  • 31