export type AdvertisedCandidate = {ipAddress: string, port: number, transport: string, type: string}; export type WebRTCConfig = {udpBindAddress: string, enablePlay: boolean, preferredCodecsAudio: string, preferredCodecsVideo: string, enableQuery: boolean, debugLog: boolean, serverName: string, saveFieldList?: Array | undefined, iceCandidateIpAddresses: string, version: string, enablePublish: boolean, advertisedCandidates: Array, advertisedCandidatesTimestamp: number, enableDataChannels: boolean, enableIceCandidateHarvesting: boolean, enableRemb: boolean, enableSimulcast: boolean, enableTransportCC: boolean, enableWebRTC: boolean, enableWebSocket: boolean, firMessageInterval: number, firMessageScheme: string, idleTimeout: number, nackDelayMs: number, nackEnable: boolean, pliInterval: number, renditionDowngradeDebounceMs: number, renditionDowngradeMarginPercent: number, renditionInitialRendition: string, renditionSelector: string, renditionSwitchRequestKeyframe: boolean, renditionUpgradeMarginPercent: number, rtxCacheSize: number, rtxEnable: boolean, stunServer: string, turnRelay: string, turnRelayPassword: string, turnRelayTrustStore: string, turnRelayTrustStorePassword: string, turnRelayTrustStoreType: string, turnRelayUsername: string, whepBearerToken: string, whipBearerToken: string}; export type UpdateApiV2ServersServerNameVhostsVhostNameApplicationsAppNameWebrtcArgs = {serverName: string, vhostName: string, appName: string, body: WebRTCConfig}; export type UpdateApiV2ServersServerNameVhostsVhostNameApplicationsAppNameWebrtcOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Update WebRTC config * * PUT /v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/webrtc */ export const updateApiV2ServersServerNameVhostsVhostNameApplicationsAppNameWebrtc = async (args: UpdateApiV2ServersServerNameVhostsVhostNameApplicationsAppNameWebrtcArgs, options?: UpdateApiV2ServersServerNameVhostsVhostNameApplicationsAppNameWebrtcOptions) => { const {baseUrl = "http://localhost:8087", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/servers/${encodeURIComponent(String(args.serverName))}/vhosts/${encodeURIComponent(String(args.vhostName))}/applications/${encodeURIComponent(String(args.appName))}/webrtc${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };