gpt4 book ai didi

javascript - rtcPeerConnection 异常行为?

转载 作者:行者123 更新时间:2023-11-28 00:05:31 30 4
gpt4 key购买 nike

我开始用 rtcPeerConnection 做一些测试,我是这个技术的初学者,我想知道它是否正常:在控制台中,当调用方法 onicecandidate 时,我打印了 ice candidate,但我不知道控制台中出现许多 RTCIceCandidate 是否正常 here the output console

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);
}

最佳答案

是的——那么多 ICE 候选人是正常的。 (您将从 apprtc.appspot.com 得到类似的结果。)

请注意,要显示视频,您需要视频元素上的自动播放属性,或 gUM 成功处理程序中的 video.play()

关于javascript - rtcPeerConnection 异常行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18713390/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com