当我尝试在Javascript上调用RTCQuicTransport的构造函数时,它引发错误:Uncaught TypeError:无法构造'RTCQuicTransport':提供的值无法转换为序列。
假设构造函数需要两个参数,一个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 quic示例,并且希望获得一个RTCQuicTransport对象。
预先感谢
修改:
我已经意识到,当我在generateCertificate()函数中打印证书时,它可以正常工作:
RTCCertificate {expires: 1552505428000}
expires: 1552505428000
但是,从该功能中,我得到了:
console.log(certs);
结果:
{}
[0] RTCCertificate
expires: 1552505951000
然后我尝试:
console.log(certs[0]);
结果:
undefined
答案 0 :(得分:0)
与RTCIceTransport和RTCQuic传输兼容的Web浏览器是版本为73 Beta的Chrome,具体如下:RTCQuicTransport over chrome
尽管我试图在带有--enable-blink-features=RTCQuicTransport,RTCIceTransportExtension
标志的chrome 72中运行它,但这还不够。
在chrome 73 beta中,我可以通过传递null
作为第二个参数并创建自己的证书来创建RTCQuicTransport。