javascript - 如何在 sipJS 中更改 STUN 服务器
问题描述
我在这里陷入困境,我搜索了 API 参考、谷歌和 stackoverflow,但找不到我正在寻找的答案。
如何更改在 sipJS-0.19 中使用的 stun 服务器
在早期版本的 sipJS 和 JsSip 中,我可以这样做
var callOptions = {
mediaConstraints: {
audio: true,
video: true
},
pcConfig: {
iceServers: [
{ urls: ["stun:my.stun.server.com"] }
],
iceTransportPolicy: "all"
}
};
我已经在最新的 sipJS 中尝试过这个
sessionDescriptionHandlerOptions: {
constraints: { audio: true, video: false },
peerConnectionConfiguration: {
iceServers: [{
urls:"stun:my.stun.server.com"
}],
'iceTransportPolicy': "all"
}
}
});
这仍然在控制台中显示默认的眩晕。
iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceTransportPolicy:"all"
我尝试将peerConnectionConfiguration更改为rtcConfiguration
或者把它加到userAgentOptions,还是一样的结果。
解决方案
根据当前 sip.js 的当前版本(0.20.0),这可以通过UserAgentOptions.sessionDescriptionHandlerFactoryOptions.peerConnectionConfiguration
选项来实现。
选项的完整架构是:
bundlePolicy: "balanced", // Note: max-bundle is not supported by the demo backend currently (5/15/17)
certificates: undefined,
iceCandidatePoolSize: 0,
iceServers: [{ urls: "stun:stun.l.google.com:19302" }], // TURN URL example: "turn:88.88.88.0:3478", "test", "test"
iceTransportPolicy: "all",
peerIdentity: undefined,
rtcpMuxPolicy: "require"
因此,要为您的 UserAgent 关闭 ice 服务器,只需添加
var agent = new UserAgent({
//... other options
sessionDescriptionHandlerFactoryOptions: {
iceGatheringTimeout: 500, //currently, the smallest allowed value
peerConnectionConfiguration: {
iceServers: []
}
}
});
要确认这一点,请获取一个“已建立”(Invitation.state) 邀请对象(来自来电),然后查看该sessionDescriptionHandler.sessionDescriptionHandlerConfiguration.peerConnectionConfiguration.iceServers
值,您应该会看到上面设置的空列表。
推荐阅读
- javascript - 如何在 tsx 文件中引用 getElementByID 等文档方法?
- python - 如何在循环中使用 Tkinter 中的条目小部件
- django - 在 Django login_required 装饰器中获取用户名
- javascript - 如何在 css classlist.add 中添加一个类来设置我的 javascript 样式
- c++ - 从 Linux-Windows 交叉编译,stdio 有未定义的引用(到 __imp___acrt_iob_func)
- javascript - 如何禁用整个 SharePoint 调查页面上的悬停文本框?
- c++ - 如何在 Visual Studio C++ 中使用代码关闭控制台窗口
- python - 在 Windows 10 上使用 python 3 运行 cassandra cqlsh
- javascript - 我可以在 JavaScript 中按值而不是引用返回对象吗?
- netlogo - 当系统达到 95% 平衡时停止 Netlogo 中的运行/模拟