Skip to content

Commit 9db8cd0

Browse files
smoghe-bwclaude
andcommitted
feat: add autoOpenEgressGate to RtcOptions and pass via setMediaPreferences
Defaults to true. When true the gateway immediately re-opens the egress gate after each call ends, so the next call's audio flows without any round-trip delay. Pass false to restore legacy behaviour (gate stays closed until streamAvailable is processed by the gateway). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 903a1d5 commit 9db8cd0

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ export interface RtcOptions {
3535
websocketUrl?: string;
3636
iceServers?: RTCIceServer[];
3737
iceTransportPolicy?: RTCIceTransportPolicy;
38+
/**
39+
* When true (default), the gateway re-opens the egress gate immediately after
40+
* each call ends so the next call's audio flows without any round-trip delay.
41+
* Set to false to restore the legacy behaviour where the gate stays closed
42+
* between calls until the gateway processes streamAvailable.
43+
*/
44+
autoOpenEgressGate?: boolean;
3845
}
3946

4047
export interface RtcStream {

src/v1/signaling.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Signaling extends EventEmitter {
1515
private isReady: boolean = false;
1616
private readyMetadata: ReadyMetadata | null = null;
1717
private diagnosticsBatcher?: DiagnosticsBatcher;
18+
private rtcOptions?: RtcOptions;
1819

1920
constructor(diagnosticsBatcher?: DiagnosticsBatcher) {
2021
super();
@@ -35,6 +36,7 @@ class Signaling extends EventEmitter {
3536
if (options) {
3637
rtcOptions = { ...rtcOptions, ...options };
3738
}
39+
this.rtcOptions = rtcOptions;
3840
const websocketUrl = `${rtcOptions.websocketUrl}?client=node&sdkVersion=${sdkVersion}&uniqueId=${this.uniqueDeviceId}&endpointToken=${authParams.endpointToken}`;
3941
logger.debug(`Connecting to ${websocketUrl}`);
4042
console.log(`Connecting to ${websocketUrl}`);
@@ -122,9 +124,11 @@ class Signaling extends EventEmitter {
122124
}
123125

124126
private setMediaPreferences(): Promise<{}> {
125-
logger.debug(`Calling "setMediaPreferences"`, { protocol: "WEBRTC" });
127+
const autoOpenEgressGate = this.rtcOptions?.autoOpenEgressGate ?? true;
128+
logger.debug(`Calling "setMediaPreferences"`, { protocol: "WEBRTC", autoOpenEgressGate });
126129
return this.ws?.call("setMediaPreferences", {
127130
protocol: "WEBRTC",
131+
autoOpenEgressGate,
128132
}) as Promise<SetMediaPreferencesWebRtcResponse>;
129133
}
130134

0 commit comments

Comments
 (0)