Errors when ICE Candidates are received before answer is sent

后端 未结 2 631
深忆病人
深忆病人 2020-12-10 16:01

I\'m establishing WebRTC connection on Chrome 23. To attach local stream you need to allow browser to use the camera and microphone. On the caller side I\'m checking if loca

2条回答
  •  旧巷少年郎
    2020-12-10 16:33

    The solution from Episodex helped me.

    First setRemoteDescription, then create own stream, then create and send the answer.

      // On read message
      if (msg.sdp.type === 'offer') {
    
            this.peerConnection.setRemoteDescription(new RTCSessionDescription(msg.sdp))
              .then(() => navigator.mediaDevices.getUserMedia({audio: true, video: true}))
              .then(stream => this.peerConnection.addStream(stream));
              .then(() => this.peerConnection.createAnswer())
              .then(answer => this.peerConnection.setLocalDescription(answer))
              .then(() => this.sendMessage({sdp: this.peerConnection.localDescription}))
    
      } 
    

提交回复
热议问题