首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >rtcPeerConnection异常行为?

rtcPeerConnection异常行为?
EN

Stack Overflow用户
提问于 2013-09-10 07:53:10
回答 1查看 507关注 0票数 2

我开始用rtcPeerConnection做一些测试,我是一个懂这种技术的乞丐,我想知道它是否正常:在控制台中,我打印方法onicecandidate调用时的冰候选,但我不知道是否正常,控制台在这里,输出控制台中出现了许多RTCIceCandidate

代码语言:javascript
复制
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);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-10 10:31:39

是的--很多ICE候选人都是正常的。(您将从apprtc.appspot.com获得类似的结果。)

注意,要显示视频,需要在视频元素上设置一个自动播放属性,或者在video.play()成功处理程序中使用gUM。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18713390

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档