webrt 开发之前必须了解的东西

1、创建offer的时候带上参数:{ offerToReceiveAudio: true, offerToReceiveVideo: true }

2、onicecandidate 必须写在 setLocalDescription 之前,因为一调用setLocalDescription,立马会产生icecandidate。

3、pc.addTrack(或者addStream)必须在pc.createAnswer之前,如果你的offer没有带上参数(第一条),那么也应该在pc.createOffer()之前。因为offer或者answer带有媒体信息。

4、webrtc 是 peer to peer ,不是peers to peers。A与B 相连,A需要new RTCPeerConnection,B也需要。A再与C相连,A还需要new  RTCPeerConnection

5、stun 服务器,是提供打洞的东西,turn服务器是提供数据中转的东西。打洞(Nat类型及穿透)请看我的另一篇博客,webrtc只支持 https和 localhost,所以局内网主机能开视频,另一端(另一台电脑)只能看。

6、火狐报错:xxx failed(需要turn但根本没有turn服务器),还有一种,turn Server appears to be broken:这个是turn服务器限制连接数量,就是说人较多,你挤不上去了。

免费的turn 是http://numb.viagenie.ca,去申请账号密码。

免费的stun : stun:stun.freeswitch.org 、stun.ekiga.net

自己布turn: github 搜 coturn

个人网页:gusheng123.top/webrtc,可测试多对多视频。

猜你喜欢

转载自www.cnblogs.com/gsgs/p/9315532.html
今日推荐