feat: add card examples and speed up rtc connect
This commit is contained in:
parent
04afead5af
commit
23fd806e6d
41 changed files with 3327 additions and 3 deletions
|
|
@ -11,6 +11,8 @@ import type {
|
|||
} from "../types";
|
||||
|
||||
const BACKEND_URL = import.meta.env.VITE_BACKEND_URL ?? "";
|
||||
const WEBRTC_STUN_URL = import.meta.env.VITE_WEBRTC_STUN_URL?.trim() ?? "";
|
||||
const LOCAL_ICE_GATHER_TIMEOUT_MS = 350;
|
||||
|
||||
let cardIdCounter = 0;
|
||||
let logIdCounter = 0;
|
||||
|
|
@ -235,7 +237,10 @@ function waitForIceComplete(pc: RTCPeerConnection): Promise<void> {
|
|||
}
|
||||
};
|
||||
pc.addEventListener("icegatheringstatechange", check);
|
||||
setTimeout(resolve, 5000);
|
||||
setTimeout(() => {
|
||||
pc.removeEventListener("icegatheringstatechange", check);
|
||||
resolve();
|
||||
}, LOCAL_ICE_GATHER_TIMEOUT_MS);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -277,7 +282,11 @@ async function runConnect(
|
|||
refs.localTracksRef.current = audioTracks;
|
||||
}
|
||||
|
||||
const pc = new RTCPeerConnection({ iceServers: [{ urls: "stun:stun.l.google.com:19302" }] });
|
||||
// Local-only deployments do not need a public STUN server; host candidates are enough
|
||||
// and avoiding external ICE gathering removes several seconds from startup latency.
|
||||
const pc = new RTCPeerConnection(
|
||||
WEBRTC_STUN_URL ? { iceServers: [{ urls: WEBRTC_STUN_URL }] } : undefined,
|
||||
);
|
||||
refs.pcRef.current = pc;
|
||||
|
||||
const newRemoteStream = new MediaStream();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue