WebRTC 视频会议(多对多) [英] WebRTC videoconferencing (many-to-many)

查看:42
本文介绍了WebRTC 视频会议(多对多)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我即将使用 webRTC+socket.io+node.js 构建一个视频会议系统,所以我已经阅读了 Simon Pietro Romano 的《Real Timecommunications with webRTC》这本书作为起点,我已经读完了,我我要在 100 Mbps 本地网络上运行这个系统,所以我要使用网状网络拓扑,因为带宽在这里不是问题,我不想关注这个,我只是有一个关于与许多用户合作的简单问题,特别是使用这些功能:

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

我知道我必须在每个对等点上建立点对点连接,但假设我有 3 个用户:A、B 和 C.

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 将成为房间发起者,然后 B 加入房间,这里 A 向 B 发送报价并收到 B 的答复,A setRemoteDescription(answerB) 和 B setRemoteDescription(offerA),但是当 C 加入房间时,A 和 B 将是它的发起者,所以他们都会向 C 发送报价,而 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:

当 C 第一次收到 A 的报价时,这是 C setRemoteDescription(offerA),但是当收到 B 的报价时,这是 C setRemoteDescription(offerB),我在这里设置了一个新值,丢失了 A 的先前报价,是这个过程只是暂时的?,C 是不是不再需要 A 报价了?,我知道这个 sdp 文件只包含 webbrowser 媒体信息.我对 onaddstream 有同样的疑问,这个过程是否会自动从一个对等点然后从另一个对等点捕获流?,当最后一个加入房间时,A 首先捕获 B 的流,然后从 C 捕获第二个流?,当捕获 C 时,A 会丢失 B 的流?.

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?.

另一方面,addIceCandidate 只是将远程候选者添加到每个对等点,所以本地对等点拥有远程对等点路由,它永远不会丢失远程对等点路由,我想,我对吗?

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?

我找到了关于webRTC视频会议的源代码,我看到onaddstream和setRemoteDescription就像临时函数,一旦设置了对等点之间的连接,那些就不再需要了,我不知道,也许我错了.

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.

提前致谢.

推荐答案

当C第一次收到A的offer时,这是CsetRemoteDescription(offerA),但是当收到 B 的报价时,这是C setRemoteDescription(offerB),我在这里设置一个新值失去了 A 的先前报价,这个程序只是暂时的吗?,C 不再需要 A 的报价了吗?

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?

您需要在您的客户端为每个其他参与者建立一个对等连接 (pc),您将执行类似于:

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..
});

请注意,节点服务器正在发送报价以及发送它的用户的 ID.此外,users 将包含每个房间参与者的条目,并引用其 pc.您将为每个参与者添加远程描述到他们自己的 pc.

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.

互联网上有很多例子,我的在http://github.com/jconde/ephony :)

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

这篇关于WebRTC 视频会议(多对多)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆