How i create peer-connection without localStream?

后端 未结 1 1196
遥遥无期
遥遥无期 2021-01-27 02:15

I just want achieve one client send mediaSteam and another received the mediaSteam. So Receiver client needn\'t add localSteam.and i just code

相关标签:
1条回答
  • 2021-01-27 03:09

    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.

    0 讨论(0)
提交回复
热议问题