From 401930e3530448a709930446f11633fc3c33a94e Mon Sep 17 00:00:00 2001 From: Umar Nizamani Date: Wed, 20 Nov 2024 20:05:54 +0100 Subject: [PATCH 1/5] add missing create sip participant params --- packages/livekit-server-sdk/src/SipClient.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/livekit-server-sdk/src/SipClient.ts b/packages/livekit-server-sdk/src/SipClient.ts index 074f3210..197051b6 100644 --- a/packages/livekit-server-sdk/src/SipClient.ts +++ b/packages/livekit-server-sdk/src/SipClient.ts @@ -31,6 +31,7 @@ import { import ServiceBase from './ServiceBase.js'; import type { Rpc } from './TwirpRPC.js'; import { TwirpRpc, livekitPackage } from './TwirpRPC.js'; +import { Duration } from '@bufbuild/protobuf'; const svc = 'SIP'; @@ -94,6 +95,9 @@ export interface CreateSipParticipantOptions { playRingtone?: boolean; // Deprecated, use playDialtone instead playDialtone?: boolean; hidePhoneNumber?: boolean; + ringingTimeout?: number; // Duration in seconds + maxCallDuration?: number; // Duration in seconds + enableKrisp?: boolean; } export interface TransferSipParticipantOptions { @@ -419,6 +423,9 @@ export class SipClient extends ServiceBase { let playRingtone: boolean = false; let playDialtone: boolean = false; let hidePhoneNumber: boolean = false; + let ringingTimeout: number = 0; + let maxCallDuration: number = 0; + let enableKrisp: boolean = false; if (opts !== undefined) { participantIdentity = opts.participantIdentity || ''; @@ -428,6 +435,9 @@ export class SipClient extends ServiceBase { playRingtone = opts.playRingtone || false; playDialtone = opts.playDialtone || playRingtone; // Enable PlayDialtone if either PlayDialtone or playRingtone is set hidePhoneNumber = opts.hidePhoneNumber || false; + ringingTimeout = opts.ringingTimeout || 0; + maxCallDuration = opts.maxCallDuration || 0; + enableKrisp = opts.enableKrisp || false; } const req = new CreateSIPParticipantRequest({ @@ -441,6 +451,9 @@ export class SipClient extends ServiceBase { playRingtone: playDialtone, playDialtone: playDialtone, hidePhoneNumber: hidePhoneNumber, + ringingTimeout: new Duration({ seconds: BigInt(ringingTimeout) }), + maxCallDuration: new Duration({ seconds: BigInt(maxCallDuration) }), + enableKrisp: enableKrisp, }).toJson(); const data = await this.rpc.request( From b9bb2119c0d46b46a069831a73da685c852d3e0d Mon Sep 17 00:00:00 2001 From: Umar Nizamani Date: Wed, 20 Nov 2024 20:11:37 +0100 Subject: [PATCH 2/5] Fixed prettier issue --- packages/livekit-server-sdk/src/SipClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/livekit-server-sdk/src/SipClient.ts b/packages/livekit-server-sdk/src/SipClient.ts index 197051b6..a15b1656 100644 --- a/packages/livekit-server-sdk/src/SipClient.ts +++ b/packages/livekit-server-sdk/src/SipClient.ts @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2024 LiveKit, Inc. // // SPDX-License-Identifier: Apache-2.0 +import { Duration } from '@bufbuild/protobuf'; import { CreateSIPDispatchRuleRequest, CreateSIPInboundTrunkRequest, @@ -31,7 +32,6 @@ import { import ServiceBase from './ServiceBase.js'; import type { Rpc } from './TwirpRPC.js'; import { TwirpRpc, livekitPackage } from './TwirpRPC.js'; -import { Duration } from '@bufbuild/protobuf'; const svc = 'SIP'; From 8da0535c8db3bffb435e958b7de165883ccaef04 Mon Sep 17 00:00:00 2001 From: Umar Nizamani Date: Wed, 20 Nov 2024 20:15:17 +0100 Subject: [PATCH 3/5] Add changeset --- .changeset/early-forks-sin.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/early-forks-sin.md diff --git a/.changeset/early-forks-sin.md b/.changeset/early-forks-sin.md new file mode 100644 index 00000000..20a5daf0 --- /dev/null +++ b/.changeset/early-forks-sin.md @@ -0,0 +1,5 @@ +--- +'livekit-server-sdk': minor +--- + +SIP: Add missing params in CreateSIPParticipant From 3af97e5c099ee3d32e9d6c7bd3e8d27f3daa6dbe Mon Sep 17 00:00:00 2001 From: Umar Nizamani Date: Thu, 28 Nov 2024 06:57:51 +0100 Subject: [PATCH 4/5] Default ringingTimeout and maxCallDuration to be undefined --- packages/livekit-server-sdk/src/SipClient.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/livekit-server-sdk/src/SipClient.ts b/packages/livekit-server-sdk/src/SipClient.ts index a15b1656..a2636094 100644 --- a/packages/livekit-server-sdk/src/SipClient.ts +++ b/packages/livekit-server-sdk/src/SipClient.ts @@ -423,9 +423,9 @@ export class SipClient extends ServiceBase { let playRingtone: boolean = false; let playDialtone: boolean = false; let hidePhoneNumber: boolean = false; - let ringingTimeout: number = 0; - let maxCallDuration: number = 0; - let enableKrisp: boolean = false; + let ringingTimeout: number | undefined = undefined; + let maxCallDuration: number | undefined = undefined; + let enableKrisp: boolean | undefined = undefined; if (opts !== undefined) { participantIdentity = opts.participantIdentity || ''; @@ -435,9 +435,9 @@ export class SipClient extends ServiceBase { playRingtone = opts.playRingtone || false; playDialtone = opts.playDialtone || playRingtone; // Enable PlayDialtone if either PlayDialtone or playRingtone is set hidePhoneNumber = opts.hidePhoneNumber || false; - ringingTimeout = opts.ringingTimeout || 0; - maxCallDuration = opts.maxCallDuration || 0; - enableKrisp = opts.enableKrisp || false; + ringingTimeout = opts.ringingTimeout || undefined; + maxCallDuration = opts.maxCallDuration || undefined; + enableKrisp = opts.enableKrisp || undefined; } const req = new CreateSIPParticipantRequest({ @@ -451,8 +451,8 @@ export class SipClient extends ServiceBase { playRingtone: playDialtone, playDialtone: playDialtone, hidePhoneNumber: hidePhoneNumber, - ringingTimeout: new Duration({ seconds: BigInt(ringingTimeout) }), - maxCallDuration: new Duration({ seconds: BigInt(maxCallDuration) }), + ringingTimeout: ringingTimeout ? new Duration({ seconds: BigInt(ringingTimeout) }) : undefined, + maxCallDuration: maxCallDuration ? new Duration({ seconds: BigInt(maxCallDuration) }) : undefined, enableKrisp: enableKrisp, }).toJson(); From 45a93905d01361bb9e7f9046a78d52453a731394 Mon Sep 17 00:00:00 2001 From: Umar Nizamani Date: Thu, 28 Nov 2024 06:59:13 +0100 Subject: [PATCH 5/5] Fix formatting issues --- packages/livekit-server-sdk/src/SipClient.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/livekit-server-sdk/src/SipClient.ts b/packages/livekit-server-sdk/src/SipClient.ts index a2636094..50428231 100644 --- a/packages/livekit-server-sdk/src/SipClient.ts +++ b/packages/livekit-server-sdk/src/SipClient.ts @@ -451,8 +451,12 @@ export class SipClient extends ServiceBase { playRingtone: playDialtone, playDialtone: playDialtone, hidePhoneNumber: hidePhoneNumber, - ringingTimeout: ringingTimeout ? new Duration({ seconds: BigInt(ringingTimeout) }) : undefined, - maxCallDuration: maxCallDuration ? new Duration({ seconds: BigInt(maxCallDuration) }) : undefined, + ringingTimeout: ringingTimeout + ? new Duration({ seconds: BigInt(ringingTimeout) }) + : undefined, + maxCallDuration: maxCallDuration + ? new Duration({ seconds: BigInt(maxCallDuration) }) + : undefined, enableKrisp: enableKrisp, }).toJson();