How i create peer-connection without localStream?

不羁岁月 提交于 2019-12-02 07:49:14

问题


I just want achieve one client send mediaSteam and another received the mediaSteam. So Receiver client needn't add localSteam.and i just code pc.addStream(null).But not work. How i achieve this by WebRtc?


回答1:


Don't call pc.addStream with null. Instead, just don't call it.

  • When the receiver is also the answerer, this is all there is to it.
  • When the receiver is the offerer, you need a little extra work:

You need to specify these RTCOfferOptions to createOffer:

{ offerToReceiveVideo: true, offerToReceiveAudio: true }

The reason is that by default, the offerer only offers to receive the same kinds of streams it is sending. I know, a dumb default, but it gives the offerer a bit more control. On the upside, there's no harm in always specifying these options, if it matches your desired behavior.



来源:https://stackoverflow.com/questions/32035887/how-i-create-peer-connection-without-localstream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!