Skip to content

Commit

Permalink
Add missing createSIPParticipant params (#337)
Browse files Browse the repository at this point in the history
* add missing create sip participant params

* Fixed prettier issue

* Add changeset

* Default ringingTimeout and maxCallDuration to be undefined

* Fix formatting issues
  • Loading branch information
umarniz authored Nov 28, 2024
1 parent 40ca489 commit 1e372ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-forks-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-server-sdk': minor
---

SIP: Add missing params in CreateSIPParticipant
17 changes: 17 additions & 0 deletions packages/livekit-server-sdk/src/SipClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { Duration } from '@bufbuild/protobuf';
import {
CreateSIPDispatchRuleRequest,
CreateSIPInboundTrunkRequest,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -419,6 +423,9 @@ export class SipClient extends ServiceBase {
let playRingtone: boolean = false;
let playDialtone: boolean = false;
let hidePhoneNumber: boolean = false;
let ringingTimeout: number | undefined = undefined;
let maxCallDuration: number | undefined = undefined;
let enableKrisp: boolean | undefined = undefined;

if (opts !== undefined) {
participantIdentity = opts.participantIdentity || '';
Expand All @@ -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 || undefined;
maxCallDuration = opts.maxCallDuration || undefined;
enableKrisp = opts.enableKrisp || undefined;
}

const req = new CreateSIPParticipantRequest({
Expand All @@ -441,6 +451,13 @@ 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,
enableKrisp: enableKrisp,
}).toJson();

const data = await this.rpc.request(
Expand Down

0 comments on commit 1e372ed

Please sign in to comment.