RTCQuicTransport:提供的值无法转换为序列
RTCQuicTransport: The provided value cannot be converted to a sequence
当我尝试在 Javascript 上调用 RTCQuicTransport 的构造函数时,它抛出错误:Uncaught TypeError: Failed to construct 'RTCQuicTransport': The provided value cannot be converted to a sequence.
假设构造函数需要两个参数,一个 RTCIceTransport 对象和一个使用 RTCPeerConnection.generateCertificate() 生成的证书,它应该以这种方式工作但不是。
我试过将 'null' 作为证书传递,但仍然抛出相同的错误消息。如果我只是传递 RTCIceTransport 对象,它会抛出该构造需要两个参数。
// Include some helper functions
//import {trace, errorHandler, mySendLocalCandidate,
myIceGathererStateChange,
// myIceTransportStateChange, myDtlsTransportStateChange} from 'helper';
//import 'helper.js';
function initiate(mySignaller) {
// Prepare the IceGatherer
var gatherOptions = {
gatherPolicy: "all",
iceServers: [
{ urls: "stun:stun1.example.net" },
{ urls: "turn:turn.example.org", username: "user", credential:
"myPassword",
credentialType: "password" }
]
};
// Create the IceTransport
var ice = new RTCIceTransport();
ice.onstatechange = function(event) {
myIceGathererStateChange("iceGatherer", event.state);
};
// Handle errors
// Prepare to signal local candidates
ice.onlocalcandidate = function(event) {
mySignaller.mySendLocalCandidate(event.candidate);
};
// Start gathering
ice.gather(gatherOptions);
// Prepare to handle remote ICE candidates
console.log(ice);
mySignaller.onRemoteCandidate = function(remote) {
ice.addRemoteCandidate(remote.candidate);
};
// Create the certificate
var certs = {};
var keygenAlgorithm = { name: "ECDSA", namedCurve: "P-256"};
RTCPeerConnection.generateCertificate(keygenAlgorithm).
then(function(certificate){
certs[0] = certificate;
}, function(){
trace('Certificate could not be created');
});
// Create the DtlsTransport and QuicTransport
var quic = new RTCQuicTransport(ice, certs[0]);
console.log(quic);
mySignaller.sendInitiate({
ice: iceGatherer.getLocalParameters(),
quic: quic.getLocalParameters(),
// ... marshall RtpSender/RtpReceiver capabilities as in Section 6.6
Examples 8 and 9.
}, function(remote) {
// Start the IceTransport, DtlsTransport and QuicTransport
ice.start(iceGatherer, remote.ice, RTCIceRole.controlling);
dtls.start(remote.dtls);
quic.start(remote.quic);
// ... configure RtpSender/RtpReceiver objects as in Section 6.6
Examples 8 and 9.
});}
我正在关注 ORTC 快速示例,我希望获得一个 RTCQuicTransport 对象。
提前致谢
编辑:
我意识到当我在 generateCertificate() 函数中打印我的证书时,它工作正常:
RTCCertificate {expires: 1552505428000}
expires: 1552505428000
但是,从那个函数中,我得到了这个:
console.log(certs);
结果:
{}
[0] RTCCertificate
expires: 1552505951000
那我试试:
console.log(certs[0]);
结果:
undefined
与 RTCIceTransport 和 RTCQuic 传输兼容的网络浏览器是 Chrome 版本 73 Beta,据此:RTCQuicTransport over chrome
虽然我试图在 chrome 72 中使用 --enable-blink-features=RTCQuicTransport,RTCIceTransportExtension
标志 运行 它,但这还不够。
在 chrome 73 beta 中,我可以通过将 null
作为第二个参数传递并生成我自己的证书来创建 RTCQuicTransport。
当我尝试在 Javascript 上调用 RTCQuicTransport 的构造函数时,它抛出错误:Uncaught TypeError: Failed to construct 'RTCQuicTransport': The provided value cannot be converted to a sequence.
假设构造函数需要两个参数,一个 RTCIceTransport 对象和一个使用 RTCPeerConnection.generateCertificate() 生成的证书,它应该以这种方式工作但不是。
我试过将 'null' 作为证书传递,但仍然抛出相同的错误消息。如果我只是传递 RTCIceTransport 对象,它会抛出该构造需要两个参数。
// Include some helper functions
//import {trace, errorHandler, mySendLocalCandidate,
myIceGathererStateChange,
// myIceTransportStateChange, myDtlsTransportStateChange} from 'helper';
//import 'helper.js';
function initiate(mySignaller) {
// Prepare the IceGatherer
var gatherOptions = {
gatherPolicy: "all",
iceServers: [
{ urls: "stun:stun1.example.net" },
{ urls: "turn:turn.example.org", username: "user", credential:
"myPassword",
credentialType: "password" }
]
};
// Create the IceTransport
var ice = new RTCIceTransport();
ice.onstatechange = function(event) {
myIceGathererStateChange("iceGatherer", event.state);
};
// Handle errors
// Prepare to signal local candidates
ice.onlocalcandidate = function(event) {
mySignaller.mySendLocalCandidate(event.candidate);
};
// Start gathering
ice.gather(gatherOptions);
// Prepare to handle remote ICE candidates
console.log(ice);
mySignaller.onRemoteCandidate = function(remote) {
ice.addRemoteCandidate(remote.candidate);
};
// Create the certificate
var certs = {};
var keygenAlgorithm = { name: "ECDSA", namedCurve: "P-256"};
RTCPeerConnection.generateCertificate(keygenAlgorithm).
then(function(certificate){
certs[0] = certificate;
}, function(){
trace('Certificate could not be created');
});
// Create the DtlsTransport and QuicTransport
var quic = new RTCQuicTransport(ice, certs[0]);
console.log(quic);
mySignaller.sendInitiate({
ice: iceGatherer.getLocalParameters(),
quic: quic.getLocalParameters(),
// ... marshall RtpSender/RtpReceiver capabilities as in Section 6.6
Examples 8 and 9.
}, function(remote) {
// Start the IceTransport, DtlsTransport and QuicTransport
ice.start(iceGatherer, remote.ice, RTCIceRole.controlling);
dtls.start(remote.dtls);
quic.start(remote.quic);
// ... configure RtpSender/RtpReceiver objects as in Section 6.6
Examples 8 and 9.
});}
我正在关注 ORTC 快速示例,我希望获得一个 RTCQuicTransport 对象。
提前致谢
编辑:
我意识到当我在 generateCertificate() 函数中打印我的证书时,它工作正常:
RTCCertificate {expires: 1552505428000}
expires: 1552505428000
但是,从那个函数中,我得到了这个:
console.log(certs);
结果:
{}
[0] RTCCertificate
expires: 1552505951000
那我试试:
console.log(certs[0]);
结果:
undefined
与 RTCIceTransport 和 RTCQuic 传输兼容的网络浏览器是 Chrome 版本 73 Beta,据此:RTCQuicTransport over chrome
虽然我试图在 chrome 72 中使用 --enable-blink-features=RTCQuicTransport,RTCIceTransportExtension
标志 运行 它,但这还不够。
在 chrome 73 beta 中,我可以通过将 null
作为第二个参数传递并生成我自己的证书来创建 RTCQuicTransport。