Skip to content

Commit df39089

Browse files
committed
fixing turn config
1 parent 7a742cd commit df39089

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

src/inference-api.ts

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ export interface WebRTCWorkerConfig {
88
*/
99
workflowsParameters?: Record<string, any>;
1010
/**
11-
* WebRTC configuration to pass to the server API
12-
* This is passed to the /initialise_webrtc_worker endpoint's webrtc_turn_config field.
11+
* ICE servers for WebRTC connections (used for both client and server)
1312
*/
14-
webrtcConfig?: {
15-
iceServers?: RTCIceServerConfig[];
16-
};
13+
iceServers?: RTCIceServerConfig[];
1714
/**
1815
* Processing timeout in seconds (serverless only)
1916
* @default 600
@@ -38,7 +35,7 @@ export interface WebRTCWorkerConfig {
3835
* symmetric NAT or restrictive firewalls.
3936
*/
4037
export interface RTCIceServerConfig {
41-
urls: string | string[];
38+
urls: string[];
4239
username?: string;
4340
credential?: string;
4441
}
@@ -73,29 +70,22 @@ export interface WebRTCParams {
7370
*/
7471
workflowsParameters?: Record<string, any>;
7572
/**
76-
* Custom ICE servers for RTCPeerConnection (client-side)
73+
* ICE servers for WebRTC connections (used for both client and server)
7774
*
7875
* Use this to specify custom STUN/TURN servers for users behind
79-
* symmetric NAT or restrictive firewalls.
76+
* symmetric NAT or restrictive firewalls. The same configuration is
77+
* used for both the client-side RTCPeerConnection and sent to the
78+
* server via webrtc_config.
8079
*
8180
* @example
8281
* ```typescript
8382
* iceServers: [
8483
* { urls: ["stun:stun.l.google.com:19302"] },
85-
* { urls: "turn:turn.example.com:3478", username: "user", credential: "pass" }
84+
* { urls: ["turn:turn.example.com:3478"], username: "user", credential: "pass" }
8685
* ]
8786
* ```
8887
*/
8988
iceServers?: RTCIceServerConfig[];
90-
/**
91-
* WebRTC configuration to pass to the server API
92-
*
93-
* This is passed to the /initialise_webrtc_worker endpoint's webrtc_turn_config field.
94-
* Use this when the server needs to know about your TURN configuration.
95-
*/
96-
webrtcConfig?: {
97-
iceServers?: RTCIceServerConfig[];
98-
};
9989
/**
10090
* Processing timeout in seconds (serverless only)
10191
* @default 600
@@ -198,7 +188,7 @@ export class InferenceHTTPClient {
198188
dataOutputNames = ["string"],
199189
threadPoolWorkers = 4,
200190
workflowsParameters = {},
201-
webrtcConfig,
191+
iceServers,
202192
processingTimeout,
203193
requestedPlan,
204194
requestedRegion
@@ -229,7 +219,7 @@ export class InferenceHTTPClient {
229219
sdp: offer.sdp,
230220
type: offer.type
231221
},
232-
webrtc_turn_config: webrtcConfig ?? null,
222+
webrtc_config: iceServers ? { iceServers } : null,
233223
stream_output: streamOutputNames,
234224
data_output: dataOutputNames
235225
};
@@ -244,7 +234,7 @@ export class InferenceHTTPClient {
244234
if (requestedRegion !== undefined) {
245235
payload.requested_region = requestedRegion;
246236
}
247-
237+
console.trace("payload", payload);
248238
const response = await fetch(`${this.serverUrl}/initialise_webrtc_worker`, {
249239
method: "POST",
250240
headers: { "Content-Type": "application/json" },
@@ -313,7 +303,7 @@ export const connectors = {
313303
return {
314304
connectWrtc: async (offer: WebRTCOffer, wrtcParams: WebRTCParams): Promise<WebRTCWorkerResponse> => {
315305
const client = InferenceHTTPClient.init({ apiKey, serverUrl });
316-
306+
console.log("wrtcParams", wrtcParams);
317307
const answer = await client.initializeWebrtcWorker({
318308
offer,
319309
workflowSpec: wrtcParams.workflowSpec,
@@ -325,7 +315,7 @@ export const connectors = {
325315
dataOutputNames: wrtcParams.dataOutputNames,
326316
threadPoolWorkers: wrtcParams.threadPoolWorkers,
327317
workflowsParameters: wrtcParams.workflowsParameters,
328-
webrtcConfig: wrtcParams.webrtcConfig,
318+
iceServers: wrtcParams.iceServers,
329319
processingTimeout: wrtcParams.processingTimeout,
330320
requestedPlan: wrtcParams.requestedPlan,
331321
requestedRegion: wrtcParams.requestedRegion
@@ -376,7 +366,7 @@ export const connectors = {
376366
* dataOutputNames: wrtcParams.dataOutputNames,
377367
* threadPoolWorkers: wrtcParams.threadPoolWorkers,
378368
* workflowsParameters: wrtcParams.workflowsParameters,
379-
* webrtcConfig: wrtcParams.webrtcConfig,
369+
* iceServers: wrtcParams.iceServers,
380370
* processingTimeout: wrtcParams.processingTimeout,
381371
* requestedPlan: wrtcParams.requestedPlan,
382372
* requestedRegion: wrtcParams.requestedRegion

0 commit comments

Comments
 (0)