feat: add STUN candidates for screen sharing

This commit is contained in:
illusia committed 2026-09-21 22:24:24 +08:00
1 parent de8f6a11c9
commit 8ed3e788be
10 files changed
+174 -8

No files matched your search

+9 -1
View File
@@ -17,7 +17,7 @@ import { isRecoverable, reconnectDelayMs, reconnectWindowOpen } from "./reconnec
import { WebRtcAudioSession, type WebRtcAudioOptions, type WebRtcAudioStats, type WebRtcSessionDescription } from "./webrtc-audio.js";
import { pingTeamSpeakSession } from "./network-probe.js";
import type { AccelerationRelayOptions, ConfiguredAccelerationRelay } from "./acceleration-relay.js";
import { parseScreenShareMessage, type ScreenShareClientMessage, type ScreenSharePeerSignal, type ScreenShareStreamDescription, type ScreenShareViewerDescription } from "./screen-share.js";
import { normalizeScreenShareIceServers, parseScreenShareMessage, type ScreenShareClientMessage, type ScreenShareIceServer, type ScreenSharePeerSignal, type ScreenShareStreamDescription, type ScreenShareViewerDescription } from "./screen-share.js";
const require = createRequire(import.meta.url);
const { OpusEncoder } = require("@discordjs/opus") as {
@@ -46,6 +46,7 @@ function publicFailureDetail(error: ReturnType<typeof normalizeTeamSpeakError>):
export interface VoiceBridgeOptions {
joinTickets: JoinTicketStore;
webRtc?: WebRtcAudioOptions | (() => WebRtcAudioOptions);
screenShareIceServers?: ScreenShareIceServer[] | (() => ScreenShareIceServer[]);
acceleration?: ConfiguredAccelerationRelay[] | (() => ConfiguredAccelerationRelay[]);
accelerationName?: string | (() => string | undefined);
}
@@ -462,6 +463,7 @@ export class VoiceBridge {
whisperTargetIds: [...entry!.whisperTargetIds],
whisperActive: entry!.whisperActive,
webrtcAvailable: this.getWebRtcOptions()?.enabled === true,
screenShareIceServers: this.getScreenShareIceServers(),
accelerated: Boolean(entry!.acceleration),
canMoveClients: entry!.canMoveClients,
...(entry!.rememberIdentity ? { identity: tsClient.getIdentityString() } : {}),
@@ -1053,6 +1055,12 @@ export class VoiceBridge {
return typeof configured === "function" ? configured() : configured;
}
private getScreenShareIceServers(): ScreenShareIceServer[] {
const configured = this.options.screenShareIceServers;
const servers = typeof configured === "function" ? configured() : configured;
return normalizeScreenShareIceServers(servers);
}
private getAccelerationOptions(relayId = ""): ConfiguredAccelerationRelay | undefined {
const configured = this.options.acceleration;
const relays = typeof configured === "function" ? configured() : configured;