With javascript we pass into PeerConnection an Js Object that does the job of listing our servers and credentials as well... like this:
var configuration = { iceServers: [{ urls: "stun:stun.services.mozilla.com", username: "louis@mozilla.com", credential: "webrtcdemo" }, { urls: [ "stun:stun.example.com", "stun:stun-1.example.com" ] }] };
A online example for better understanding: RTCIceServer - Web APIs | MDN
But how we do it with web_sys::RtcConfiguration::ice_servers?
Link to function docs: RtcConfiguration in web_sys - Rust ?
I'm Trying this way:
`
let mut rtc = web_sys::RtcConfiguration::new();
let config = web_sys::RtcConfiguration::ice_servers(
&mut rtc,
&r#"{ iceServers: [{
urls: "stun:stun.services.mozilla.com",
username: "louis@mozilla.com",
credential: "webrtcdemo"
}, {
urls: [
"stun:stun.example.com",
"stun:stun-1.example.com"
]
}]
};"#.into(),
);
let pc2 = RtcPeerConnection::new_with_configuration(&config)?;
`
It compiles but on my web-browser console it returns:
JsValue(TypeError: Failed to construct 'RTCPeerConnection': The provided value cannot be converted to a sequence. TypeError: Failed to construct 'RTCPeerConnection': The provided value cannot be converted to a sequence. at new WrappedRTCPeerConnection (<anonymous>:275:28) at Module.eval (webpack:///./pkg/index_bg.js?:381:15) at Module.eval (webpack:///./pkg/index_bg.js?:309:22) at __wbg_newwithconfiguration_049486145e56aba2 (http://localhost:8081/index.js:98:115) at web_sys::features::gen_RtcPeerConnection::RtcPeerConnection::new_with_configuration::hc078b64217307571 (http://localhost:8081/5ba58cfd45492289eaff.module.wasm:wasm-function[132]:0xf5a5)