第47月第30天 webrtc nodejs视频

1.socketio

https://www.jianshu.com/p/52ad47deebea

 

 

2.webrtc

https://www.jianshu.com/p/57fd3b5d2f80

https://github.com/developerajendra/web-rtc-practice

 

if (message.type === 'offer') {
    if (!isInitiator && !isStarted) {
      maybeStart();
    }
    pc.setRemoteDescription(new RTCSessionDescription(message));
    doAnswer();
  } else if (message.type === 'answer' && isStarted) {
    pc.setRemoteDescription(new RTCSessionDescription(message));
  } else if (message.type === 'candidate' && isStarted) {
    var candidate = new RTCIceCandidate({
      sdpMLineIndex: message.label,
      candidate: message.candidate
    });
    pc.addIceCandidate(candidate);
  } 

 

http://www.blogjava.net/linli/archive/2014/10/21/418910.html

//处理到来的信令
        socket.onmessage = function(event){
            var json = JSON.parse(event.data);
            console.log('onmessage: ', json);
            //如果是一个ICE的候选,则将其加入到PeerConnection中,否则设定对方的session描述为传递过来的描述
            if( json.event === "_ice_candidate" ){
                pc.addIceCandidate(new RTCIceCandidate(json.data.candidate));
            } else {
                pc.setRemoteDescription(new RTCSessionDescription(json.data.sdp));
                // 如果是一个offer,那么需要回复一个answer
                if(json.event === "_offer") {
                    pc.createAnswer(sendAnswerFn, function (error) {
                        console.log('Failure callback: ' + error);
                    });
                }
            }
        };

 

 

java

https://zhuanlan.zhihu.com/p/99757058

 

ios

https://www.jianshu.com/p/c49da1d93df4

https://github.com/tuyaohui/WebRTC_iOS

 

posted @ 2020-08-30 10:47  lianhuaren  阅读(213)  评论(0编辑  收藏  举报