2

私はrtcPeerConnectionでいくつかのテストを開始します。私はこの技術の初心者であり、それが正常かどうかを知りたいです:メソッドonicecandidateが呼び出されたときにコンソールにアイス候補を出力しますが、正常かどうかはわかりません多くの RTCIceCandidate が ここのコンソールに表示されます 出力コンソール

var isChrome = !!navigator.webkitGetUserMedia;
var STUN = {
    url: isChrome
        ? 'stun:stun.l.google.com:19302'
        : 'stun:23.21.150.121'
};
var TURN = {
    url: 'turn:homeo@turn.bistri.com:80',
    credential: 'homeo'
};
var iceServers = {
    iceServers: [STUN, TURN]
};
var sdpConstraints = {
    optional: [],
    mandatory: {
        OfferToReceiveAudio: true,
        OfferToReceiveVideo: true
    }
};
var video = document.getElementById('thevideo');
var button = document.getElementById('thebutton');

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
RTCPeerConnection = webkitRTCPeerConnection || mozRTCPeerConnection;
var local_stream;
navigator.getUserMedia({video:true, audio:false}, function(stream){
    local_stream = stream;
    video.src = URL.createObjectURL(stream);
    start();
}, function(err){
    console.log("The Following error ocurred:"+ err);
});
function start()
{
    pc = new RTCPeerConnection(iceServers);
    pc.onicecandidate = function(evt)
    {
        console.log(evt.candidate);
    }
    pc.createOffer(function(desc)
    {
        pc.setLocalDescription(desc);
        console.log(desc);
    },function(err){
            console.log("The Following error ocurred:"+ err);
        },sdpConstraints);
}
4

1 に答える 1