0

I am new here in webrtc, i have strange issue, when i worked with one to one user onaddstream event is working, i am getting its response, but after then 3rd person joined the room onaddstream event is not working, can anyone please help me how to resolve this issue ? here i have added my whole code for it, can anyone please review it and helped me to get event for all the remote users

var pc = new RTCPeerConnection(configuration);

pc.onaddstream = (remoteaddstream) => {
      console.log(remoteaddstream);     
};

navigator.mediaDevices.getUserMedia({
                audio: true,
                video: true,
              }).then(stream => {
                var localstreamid = stream.id;
                console.log("stream id :"+localstreamid);          
                pc.addStream(stream);
              }, function(e) {          
                  console.log(e);     
              });
Nikul Panchal
  • 1,542
  • 3
  • 35
  • 58
  • You provided way too little information to offer a meaningful help. What do you mean by room? What is the topology of your solution? – artur grzesiak Jan 08 '21 at 17:32
  • in room there can be 3 person joined the room, suppose i have created the room, when other person joined the room it call onaddstream event, which works, but when 3rd person joined the room the onaddstream event is not working – Nikul Panchal Jan 09 '21 at 06:59

1 Answers1

0

You need multiple peer connections to connect more than 2 parties, or alternatively you can make all the parties connect to a server that forwards the data.

From https://medium.com/@khan_honney/webrtc-servers-and-multi-party-communication-in-webrtc-6bf3870b15eb

Mesh Topology

Mesh is the simplest topology for a multiparty application. In this topology, every participant sends and receives its media to all other participants. We said it is the simplest because it is the most straightforward method.

Mixing Topology and MCU

Mixing is another topology where each participant sends its media to a central server and receives a media from the central server. This media may contain some or all other participant’s media

Routing Topology and SFU

Routing is a multiparty topology where each participant sends its media to a central server and receives all other’s media from the central server.

Maurice Lam
  • 1,577
  • 9
  • 14