java webrtc视频会议,WebRTC视频会议(多对多)

I am about to build a videoconferencing system using webRTC+socket.io+node.js, so I have read this book as start point "Real Time communications with webRTC" by Simon Pietro Romano, I already finished reading it, I am gonna run this system over a 100 Mbps local network, so I am gonna use the mesh network topology since bandwidth is no an issue here, I don't wanna focus on this, I just have a simple question on working with many users, specifically on using these functions:

var pc // PeerConnection Object

pc.onaddstream = ...//for receiving stream from remote party

pc.setRemoteDescription()...//for setting .sdp file from remote party

I know I have to make a peer-to-peer connection on each peer, but Let's suppose that I have 3 users: A, B and C.

A is gonna be the room initiator, then B joins the room, here A sends an offer to B and receives an answer from B, A setRemoteDescription(answerB) and B setRemoteDescription(offerA), but when C joins the room, A and B will be its initiators, so both of them will be send offers to C, and C will send answers to them, here is my confusion:

When C first receives offer from A, this is C setRemoteDescription(offerA), but when receiving offer from B, this is C setRemoteDescription(offerB), I am setting a new value here and losing the previous offer from A, is this procedure just temporary?, isn't C going to need the A offer anymore?, I know this sdp file just contains webbrowser media info. I have the same doubt with onaddstream, Does this procedure automatically catch stream from one peer and then from another peer?, A first catch B's stream and second from C when this last one joined the room?, Does A lose B's stream when catching C's?.

On the other hand, addIceCandidate just adds remote candidates to each peer, so a local peer have the remote peers routes, it never loses the remote peers routes, I think, Am I right?

I have found source code about webRTC videoconferencing and I have seen that onaddstream and setRemoteDescription are like temporary functions, once the connection between peers is set, those are not neccesary anymore, I don't know, maybe I am wrong.

Thanks in advance.

解决方案

When C first receives offer from A, this is C

setRemoteDescription(offerA), but when receiving offer from B, this is

C setRemoteDescription(offerB), I am setting a new value here and

losing the previous offer from A, is this procedure just temporary?,

isn't C going to need the A offer anymore?

You will need to have a peer connection (pc) in your client side per each other participant, you will do something similar to:

socket.on('offer', function(from, data) {

users[from].pc.setRemoteDescription(new RTCSessionDescription(data));

// create answer..

});

Note that the Node server is sending the offer along with the id of the user who is sending it. Also, users will contain an entry per room participant with a reference to its pc. You will be adding the remote description for each participant to their own pc.

There are plenty of examples in internet, mine is on http://github.com/jconde/euphony :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值