什么是具有一个呼叫的两个PeerConnections的缺点是什么?(what are disadv

2019-10-23 18:23发布

I am thinking of changing my application from using a single PeerConnection for transferring media both ways to one PeerConnection for upstream and one for downstream for a single call between two peer.

The advantages I foresee:

  • Less worry about signalling state of PeerConnection when changing offering media from video+audio to audio and vice-versa
  • Might be easier to plug an Media Servers like kurento into the application ( in case of multi user call, lesser upload bandwidth required by user).
  • (not sure of this one) single responsibility principle, each PeerConnection has single role.

the major reason I want to do this change is, I am noticing that if peer(peer1) offers only audio but other peer(peer2) answers with both video+audio, peer1 recieves only the audio for some reason, but if peer1 had been an answerer, it is able to recieve both MediaTracks without any problem. Not sure if it is a bug in my app or browser( got same result in firefox and chrome). I was able to make a workaround by maintaining states, changing offerer based on state and stuff, but having problems with both peers changing state (nearly) simultaneously. Thought above proposal would be simpler solution and I can get rid of maintaining states.

Other than the obvious disadvantages of extra overhead of more ICE candidate requests( n STUN n TURN), maintaining extra PeerConnections, any other issue possible following this design?

Answer 1:

没有什么能阻止你这样做,但我怀疑有您的问题,一个简单的解决方案,你有种埋:

主要的原因,我想这样做的变化是,我注意到,如果对(方1)只提供音频,但其他同行(对等方2)答案利用视频+音频,等方临危只有音频出于某种原因,

不要问我为什么,但是当PEER1只提供音频默认规范行为,是从对方只要求声音。 要覆盖这一点,会把自己暴露给接收视频,以及如果对方有它,使用RTCOfferOptions :

peer1.createOffer({ offerToReceiveVideo: true }).then( ... )

(如果您正在使用旧版非承诺API它的第三个参数。)

这样做的好处是,它是基于意图,所以你不必跟踪任何状态。 例如,使用总是{ offerToReceiveVideo: true, offerToReceiveAudio: true }可能是你的权利。



Answer 2:

资源问题是,你是可以利用更多的港口作为连接双方必须完成DTLS握手(这是做对等网络,而不是通过信令服务器)。

一个设计挑战是跟踪两个连接的正交。 这可能是毛茸茸的,并会在底层的WebRTC实现更容易显示错误,如果状态不正确的处理(浏览器状态错误等)。



文章来源: what are disadvantages of having two PeerConnections for one call?
标签: webrtc