Skip to content

Commit db2b85a

Browse files
Add SIPDialtone enum and deprecate play_dialtone (#1892)
* Add SIPDialtone enum and deprecate play_dialtone Lets callers pick a regional dial tone preset on CreateSIPParticipant and TransferSIPParticipant. play_dialtone still maps to the ETSI tone when the enum is unset, and is kept populated for older sip services. * generated protobuf --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 211df6b commit db2b85a

10 files changed

Lines changed: 1020 additions & 769 deletions

File tree

‎.changeset/sip-dialtone-preset.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"github.com/livekit/protocol": patch
3+
"@livekit/protocol": patch
4+
---
5+
6+
Add `SIPDialtone` to select a regional dial tone on CreateSIPParticipant and TransferSIPParticipant; deprecate `play_dialtone`

‎livekit/livekit_sip.pb.go‎

Lines changed: 341 additions & 242 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎livekit/livekit_sip.twirp.go‎

Lines changed: 380 additions & 375 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎livekit/sip.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,22 @@ func (p *CreateSIPParticipantRequest) Upgrade() {
13251325
return
13261326
}
13271327
p.Media = p.Media.UpgradeWith(p.MediaEncryption)
1328+
p.Dialtone = UpgradeSIPDialtone(p.Dialtone, p.PlayRingtone || p.PlayDialtone)
1329+
}
1330+
1331+
func (p *TransferSIPParticipantRequest) Upgrade() {
1332+
if p == nil {
1333+
return
1334+
}
1335+
p.Dialtone = UpgradeSIPDialtone(p.Dialtone, p.PlayDialtone)
1336+
}
1337+
1338+
// UpgradeSIPDialtone maps the deprecated play_dialtone flag to SIP_DIALTONE_ETSI when dialtone is unset.
1339+
func UpgradeSIPDialtone(tone SIPDialtone, playDialtone bool) SIPDialtone {
1340+
if tone == SIPDialtone_SIP_DIALTONE_DISABLED && playDialtone {
1341+
return SIPDialtone_SIP_DIALTONE_ETSI
1342+
}
1343+
return tone
13281344
}
13291345

13301346
func (p *SIPMediaEncryption) Deref() SIPMediaEncryption {

‎protobufs/livekit_sip.proto‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,18 @@ enum SIPMediaEncryption {
223223
SIP_MEDIA_ENCRYPT_REQUIRE = 2; // require encryption
224224
}
225225

226+
// Dial tone (ringback) played while a call is being placed or transferred.
227+
// Receivers treat unknown values as SIP_DIALTONE_ETSI.
228+
enum SIPDialtone {
229+
SIP_DIALTONE_DISABLED = 0; // no tone
230+
SIP_DIALTONE_ETSI = 1; // 425 Hz, 1s on / 4s off; the tone play_dialtone used
231+
SIP_DIALTONE_AUTO = 2; // pick by the country of the called number, ETSI if unknown
232+
SIP_DIALTONE_US = 3; // North America (NANP)
233+
SIP_DIALTONE_UK = 4;
234+
SIP_DIALTONE_JP = 5;
235+
SIP_DIALTONE_AU = 6;
236+
}
237+
226238
message SIPCodec {
227239
string name = 1;
228240
uint32 rate = 2;
@@ -802,9 +814,11 @@ message CreateSIPParticipantRequest {
802814
// Character 'w' can be used to add a 0.5 sec delay.
803815
string dtmf = 5;
804816

805-
// Optionally play dialtone in the room as an audible indicator for existing participants. The `play_ringtone` option is deprectated but has the same effect.
817+
// Deprecated: use dialtone. Setting play_dialtone (or play_ringtone) is equivalent to SIP_DIALTONE_ETSI when dialtone is unset.
806818
bool play_ringtone = 6 [deprecated = true];
807-
bool play_dialtone = 13;
819+
bool play_dialtone = 13 [deprecated = true];
820+
// Optionally play dialtone in the room as an audible indicator for existing participants.
821+
SIPDialtone dialtone = 28;
808822

809823
// By default the From value (Phone number) is used for participant name/identity (if not set) and added to attributes.
810824
// If true, a random value for identity will be used and numbers will be omitted from attributes.
@@ -848,7 +862,7 @@ message CreateSIPParticipantRequest {
848862
(logger.redact_format) = "<redacted ({{ .Size }} bytes)>"
849863
];
850864
optional Destination destination = 22;
851-
// NEXT ID: 28
865+
// NEXT ID: 29
852866
}
853867

854868
message SIPParticipantInfo {
@@ -863,8 +877,10 @@ message TransferSIPParticipantRequest {
863877
string room_name = 2;
864878
string transfer_to = 3;
865879

866-
// Optionally play dialtone to the SIP participant as an audible indicator of being transferred
867-
bool play_dialtone = 4;
880+
// Deprecated: use dialtone. Setting play_dialtone is equivalent to SIP_DIALTONE_ETSI when dialtone is unset.
881+
bool play_dialtone = 4 [deprecated = true];
882+
// Optionally play dialtone to the SIP participant as an audible indicator of being transferred.
883+
SIPDialtone dialtone = 7;
868884

869885
// Add the following headers to the REFER SIP request.
870886
map<string, string> headers = 5 [

‎protobufs/rpc/sip.proto‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ message InternalCreateSIPParticipantRequest {
103103
// Character 'w' can be used to add a 0.5 sec delay.
104104
string dtmf = 11;
105105

106+
// Deprecated: set for older sip services, which only read this field. Read dialtone after Upgrade() instead.
107+
bool play_dialtone = 12 [deprecated = true];
106108
// Optionally play dialtone in the room as an audible indicator for existing participants
107-
bool play_dialtone = 12;
109+
livekit.SIPDialtone dialtone = 41;
108110

109111
map<string, string> headers = 21 [
110112
(logger.sensitivity) = SENSITIVITY_PII,
@@ -157,7 +159,7 @@ message InternalCreateSIPParticipantRequest {
157159
// Provider of the caller number, when the call does not use a customer trunk.
158160
livekit.ProviderInfo provider_info = 40;
159161

160-
// NEXT ID: 41
162+
// NEXT ID: 42
161163
}
162164

163165
message InternalCreateSIPParticipantResponse {
@@ -170,8 +172,10 @@ message InternalTransferSIPParticipantRequest {
170172
string sip_call_id = 1 [(logger.name) = "sipCallID"];
171173
string transfer_to = 2;
172174

175+
// Deprecated: set for older sip services, which only read this field. Read dialtone after Upgrade() instead.
176+
bool play_dialtone = 3 [deprecated = true];
173177
// Optionally play dialtone to the SIP participant as an audible indicator of being transferred
174-
bool play_dialtone = 3;
178+
livekit.SIPDialtone dialtone = 7;
175179

176180
// Add the following headers to the REFER SIP request.
177181
map<string, string> headers = 4 [

‎rpc/sip.go‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ func NewCreateSIPParticipantRequestResult(
207207
ParticipantMetadata: req.ParticipantMetadata,
208208
ParticipantAttributes: attrs,
209209
Dtmf: req.Dtmf,
210-
PlayDialtone: req.PlayRingtone || req.PlayDialtone,
210+
Dialtone: req.Dialtone,
211+
PlayDialtone: req.Dialtone != livekit.SIPDialtone_SIP_DIALTONE_DISABLED,
211212
Headers: headers,
212213
HeadersToAttributes: hdrToAttr,
213214
AttributesToHeaders: attrToHdr,
@@ -229,17 +230,27 @@ func NewTransferSIPParticipantRequest(
229230
callID string,
230231
req *livekit.TransferSIPParticipantRequest,
231232
) (*InternalTransferSIPParticipantRequest, error) {
233+
req.Upgrade()
232234
return &InternalTransferSIPParticipantRequest{
233235
SipCallId: callID,
234236
TransferTo: req.TransferTo,
235-
PlayDialtone: req.PlayDialtone,
237+
Dialtone: req.Dialtone,
238+
PlayDialtone: req.Dialtone != livekit.SIPDialtone_SIP_DIALTONE_DISABLED,
236239
Headers: req.Headers,
237240
RingingTimeout: req.RingingTimeout,
238241
}, nil
239242
}
240243

241244
func (p *InternalCreateSIPParticipantRequest) Upgrade() {
242245
p.Media = p.Media.UpgradeWith(p.MediaEncryption)
246+
p.Dialtone = livekit.UpgradeSIPDialtone(p.Dialtone, p.PlayDialtone)
247+
}
248+
249+
func (p *InternalTransferSIPParticipantRequest) Upgrade() {
250+
if p == nil {
251+
return
252+
}
253+
p.Dialtone = livekit.UpgradeSIPDialtone(p.Dialtone, p.PlayDialtone)
243254
}
244255

245256
func (p *EvaluateSIPDispatchRulesResponse) Upgrade() {

0 commit comments

Comments
 (0)