mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
feat: optional TURN relay for screen streams
TURN_URLS on the gateway is handed to the browser in "hello" and added to the STUN defaults for both watching and publishing. With TURN_SECRET (coturn's use-auth-secret) each socket gets its own credential valid for 24 h; static TURN_USERNAME/TURN_CREDENTIAL work too but are public to every visitor. Also moves GATEWAY_FEATURES above the runtime-config comment it had split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
d67053f2dd
commit
23e61c86b3
5 files changed
+30
-14
No files matched your search
+6
-1
@@ -34,7 +34,7 @@ import {
|
||||
type PublishState,
|
||||
type StreamPublishOptions,
|
||||
} from "./publish";
|
||||
import { StreamViewer, parseStreamInfo, type StreamEvent, type StreamInfo } from "./stream";
|
||||
import { DEFAULT_ICE_SERVERS, StreamViewer, parseStreamInfo, type StreamEvent, type StreamInfo } from "./stream";
|
||||
import { DEMO_HOST, DEMO_MODE, DemoSocket } from "./demoMode";
|
||||
import {
|
||||
SOUND_EVENTS,
|
||||
@@ -6424,6 +6424,8 @@ function AppInner() {
|
||||
// What the gateway announced in its "hello" (gateway/src/index.ts). Empty for
|
||||
// a gateway older than the handshake, so a feature newer than it stays hidden.
|
||||
const [gatewayFeatures, setGatewayFeatures] = useState<ReadonlySet<string>>(new Set());
|
||||
// TURN relay the gateway offers for screen streams (TURN_URLS), if any.
|
||||
const [turnServers, setTurnServers] = useState<RTCIceServer[]>([]);
|
||||
// Terms of use, own-hosted instance only (see IS_OWN_HOSTED_INSTANCE): shown
|
||||
// mandatorily on first visit, reopenable any time from the menu afterwards.
|
||||
const [tosOpen, setTosOpen] = useState(false);
|
||||
@@ -7290,6 +7292,7 @@ function AppInner() {
|
||||
}
|
||||
if (data.type === "hello") {
|
||||
setGatewayFeatures(new Set(Array.isArray(data.features) ? data.features : []));
|
||||
setTurnServers(Array.isArray(data.iceServers) ? data.iceServers : []);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8989,6 +8992,7 @@ function AppInner() {
|
||||
const viewer = new StreamViewer(info.id, info.clientId, {
|
||||
send: (message) => socketRef.current?.send(JSON.stringify(message)),
|
||||
onTrack: setStreamMedia,
|
||||
iceServers: [...DEFAULT_ICE_SERVERS, ...turnServers],
|
||||
onStateChange: setStreamState,
|
||||
onError: setStreamError,
|
||||
onClosed: () => {
|
||||
@@ -9042,6 +9046,7 @@ function AppInner() {
|
||||
onViewersChange: setPublishViewers,
|
||||
onPendingChange: setPublishPending,
|
||||
onError: setPublishError,
|
||||
iceServers: [...DEFAULT_ICE_SERVERS, ...turnServers],
|
||||
});
|
||||
publisherRef.current = publisher;
|
||||
void publisher.start(options);
|
||||
|
||||
Reference in new issue
Block a user