mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
fix: improve voice playback, diagnostics and workspace controls
This commit is contained in:
1 parent
72d7e6e013
commit
e82116239a
34 files changed
+502
-147
No files matched your search
@@ -0,0 +1,45 @@
|
||||
/** Add Opus channel negotiation parameters to audio payloads in an SDP document. */
|
||||
export function addOpusFmtpParameters(sdp: string, parameters: readonly string[]): string {
|
||||
if (!sdp || parameters.length === 0) return sdp;
|
||||
const lines = sdp.split(/\r?\n/);
|
||||
const output: string[] = [];
|
||||
let section: string[] = [];
|
||||
const flush = () => {
|
||||
if (section[0]?.startsWith("m=audio ")) patchAudioSection(section, parameters);
|
||||
output.push(...section);
|
||||
section = [];
|
||||
};
|
||||
for (const line of lines) {
|
||||
if (line.startsWith("m=")) {
|
||||
if (section.length) flush();
|
||||
}
|
||||
section.push(line);
|
||||
}
|
||||
if (section.length) flush();
|
||||
return output.join("\r\n");
|
||||
}
|
||||
|
||||
function patchAudioSection(section: string[], parameters: readonly string[]): void {
|
||||
const payloads = new Set(section[0]!.trim().split(/\s+/).slice(3));
|
||||
const opusPayloads = section.flatMap(line => {
|
||||
const match = /^a=rtpmap:(\d+)\s+opus\/48000(?:\/\d+)?\s*$/i.exec(line);
|
||||
return match && payloads.has(match[1]!) ? [match[1]!] : [];
|
||||
});
|
||||
for (const payload of opusPayloads) {
|
||||
const prefix = `a=fmtp:${payload}`;
|
||||
const index = section.findIndex(line => new RegExp(`^${prefix}(?:\\s|$)`).test(line));
|
||||
if (index < 0) {
|
||||
const rtpmap = section.findIndex(line => line.startsWith(`a=rtpmap:${payload} `));
|
||||
if (rtpmap >= 0) section.splice(rtpmap + 1, 0, `${prefix} ${parameters.join(";")}`);
|
||||
continue;
|
||||
}
|
||||
const parts = section[index]!.slice(prefix.length).trim().split(";").filter(Boolean);
|
||||
for (const parameter of parameters) {
|
||||
const name = parameter.split("=", 1)[0]!.trim().toLowerCase();
|
||||
const existing = parts.findIndex(part => part.split("=", 1)[0]!.trim().toLowerCase() === name);
|
||||
if (existing < 0) parts.push(parameter);
|
||||
else parts[existing] = parameter;
|
||||
}
|
||||
section[index] = `${prefix} ${parts.join(";")}`;
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,9 @@ export interface PluginManifest {
|
||||
}
|
||||
export interface PluginFile { encoding: "utf8" | "base64"; data: string }
|
||||
export interface PluginPackage { manifest: PluginManifest; files: Record<string, PluginFile> }
|
||||
export interface PluginSettings { enabled: boolean; trusted: boolean; scope: PluginScope; targets: string[]; config: JsonValue; hasServerConfig: boolean }
|
||||
export interface PluginSettings { enabled: boolean; trusted: boolean; toolbarPinned: boolean; scope: PluginScope; targets: string[]; config: JsonValue; hasServerConfig: boolean }
|
||||
export interface PluginSettingsInput {
|
||||
enabled: boolean; trusted: boolean; scope: PluginScope; targets: string[]; config: JsonValue;
|
||||
enabled: boolean; trusted: boolean; toolbarPinned?: boolean; scope: PluginScope; targets: string[]; config: JsonValue;
|
||||
serverConfigAction?: "keep" | "replace" | "remove"; serverConfig?: JsonValue;
|
||||
}
|
||||
export interface PluginRuntimeStatus { state: "disabled" | "client" | "stopped" | "starting" | "running" | "failed"; error?: string }
|
||||
@@ -95,8 +95,8 @@ export function parsePluginJson(v: unknown, maxBytes = 64 * 1024): JsonValue {
|
||||
export function readInstalledPlugin(v: unknown): InstalledPlugin {
|
||||
pluginAssert(pluginRecord(v) && pluginRecord(v.settings) && typeof v.revision === "string" && /^[a-f0-9]{64}$/.test(v.revision) && typeof v.installedAt === "number" && Number.isFinite(v.installedAt));
|
||||
const manifest=parsePluginManifest(v.manifest),s=v.settings;
|
||||
pluginAssert(typeof s.enabled === "boolean" && typeof s.trusted === "boolean" && typeof s.hasServerConfig === "boolean" && manifest.scopes.includes(s.scope as PluginScope) && Array.isArray(s.targets) && s.targets.length <= 50 && s.targets.every(t=>typeof t === "string" && t.length <= 300));
|
||||
const result: InstalledPlugin={manifest,revision:v.revision,installedAt:v.installedAt,settings:{enabled:s.enabled,trusted:s.trusted,scope:s.scope as PluginScope,targets:[...s.targets],config:parsePluginJson(s.config),hasServerConfig:s.hasServerConfig}};
|
||||
pluginAssert(typeof s.enabled === "boolean" && typeof s.trusted === "boolean" && (s.toolbarPinned === undefined || typeof s.toolbarPinned === "boolean") && typeof s.hasServerConfig === "boolean" && manifest.scopes.includes(s.scope as PluginScope) && Array.isArray(s.targets) && s.targets.length <= 50 && s.targets.every(t=>typeof t === "string" && t.length <= 300));
|
||||
const result: InstalledPlugin={manifest,revision:v.revision,installedAt:v.installedAt,settings:{enabled:s.enabled,trusted:s.trusted,toolbarPinned:s.toolbarPinned===true,scope:s.scope as PluginScope,targets:[...s.targets],config:parsePluginJson(s.config),hasServerConfig:s.hasServerConfig}};
|
||||
if(v.runtime!==undefined){pluginAssert(pluginRecord(v.runtime) && ["disabled","client","stopped","starting","running","failed"].includes(String(v.runtime.state)) && (v.runtime.error===undefined||typeof v.runtime.error==="string"));result.runtime={state:v.runtime.state as PluginRuntimeStatus["state"],...(v.runtime.error?{error:v.runtime.error as string}:{})};}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -278,6 +278,7 @@ const PUBLIC_PART_IDS = new Set<string>([
|
||||
"voice.favorite-servers.tooltip",
|
||||
"voice.header",
|
||||
"voice.header-actions",
|
||||
"voice.plugin-toolbar",
|
||||
"voice.member",
|
||||
"voice.member-panel",
|
||||
"voice.member-panel.channels",
|
||||
|
||||
Reference in new issue
Block a user