android, desktop: workaround of missing stuns support in calls (#4033)

* android, desktop: workaround of missing stuns support in calls

* const
This commit is contained in:
Stanislav Dmitrenko
2024-04-16 14:38:46 +07:00
committed by GitHub
parent c2169f7813
commit 5e71d00ace
2 changed files with 22 additions and 2 deletions
@@ -111,7 +111,17 @@ const processCommand = (function () {
});
}
async function initializeCall(config, mediaType, aesKey) {
const pc = new RTCPeerConnection(config.peerConnectionConfig);
var _a;
let pc;
try {
pc = new RTCPeerConnection(config.peerConnectionConfig);
}
catch (e) {
console.log("Error while constructing RTCPeerConnection, will try without 'stuns' specified: " + e);
const withoutStuns = (_a = config.peerConnectionConfig.iceServers) === null || _a === void 0 ? void 0 : _a.filter((elem) => typeof elem.urls === "string" ? !elem.urls.startsWith("stuns:") : !elem.urls.some((url) => url.startsWith("stuns:")));
config.peerConnectionConfig.iceServers = withoutStuns;
pc = new RTCPeerConnection(config.peerConnectionConfig);
}
const remoteStream = new MediaStream();
const localCamera = VideoCamera.User;
const localStream = await getLocalMediaStream(mediaType, localCamera);
+11 -1
View File
@@ -321,7 +321,17 @@ const processCommand = (function () {
}
async function initializeCall(config: CallConfig, mediaType: CallMediaType, aesKey?: string): Promise<Call> {
const pc = new RTCPeerConnection(config.peerConnectionConfig)
let pc: RTCPeerConnection
try {
pc = new RTCPeerConnection(config.peerConnectionConfig)
} catch (e) {
console.log("Error while constructing RTCPeerConnection, will try without 'stuns' specified: " + e)
const withoutStuns = config.peerConnectionConfig.iceServers?.filter((elem) =>
typeof elem.urls === "string" ? !elem.urls.startsWith("stuns:") : !elem.urls.some((url) => url.startsWith("stuns:"))
)
config.peerConnectionConfig.iceServers = withoutStuns
pc = new RTCPeerConnection(config.peerConnectionConfig)
}
const remoteStream = new MediaStream()
const localCamera = VideoCamera.User
const localStream = await getLocalMediaStream(mediaType, localCamera)