Reputation: 55
I am brand new into PeerJs and WebRTC. I have got a 1:1 NodeJS/PeerJS application working in my remote server and that works great. However now I want to explore extending this to a 1:N model where a host ID can have multiple peers connecting to them and each of the peers can receive every other connected peer's audio/video. I am ok with about 4-5 parties in a call for now so a mesh architecture is fine. In the future I would progress into a Media server based architecture to get more participants in the same session.
Currently in my code if I have more than 2 parties in the call, the last one to join is kicking out the previous party.
Can you please let me know if PeerJS library can support multi-party video chatting (4-5 users is fine) ? If not can you please guide me to how I can enhance my 1:1 app to a 1:N model? I am unable to find any clear direction on the web.
Many thanks in advance ... :-)
Upvotes: 4
Views: 5473
Reputation: 135
am working on peerjs, for one to one, I want to extend it, so I have plan to achive by creating multiple peerjs instance and reseve one instance for each peer in a group call
Upvotes: 0
Reputation: 179
Showing some of your code would be helpful in solving your problem. By using clean WebRTC you can achieve conference call, so I think you can also do this in peerJs.
At the beginning of your call you need to call getUserMedia once and get your local stream.
var myStream;
navigator.getUserMedia({video: true, audio: true}, function(stream) {
myStream = stream;
}, function(err) {
console.log('Failed to get local stream' ,err);
});
So when you make offer to them, you can write
var call = peer.call('another-peers-id', myStream);
call.on('stream', function(remoteStream) {
// Show stream in some <video> element.
});
And when peer receives call, it answers with
peer.on('call', function(call) {
call.answer(myStream); // Answer the call with an A/V stream.
call.on('stream', function(remoteStream) {
// Show stream in some <video> element.
});
});
I hope this helps you to solve your problem.
Upvotes: 3