Skip to content

Commit c3c005b

Browse files
authored
Allow mapping all SIP headers to attributes. (#920)
1 parent 933b7ff commit c3c005b

File tree

13 files changed

+1303
-1088
lines changed

13 files changed

+1303
-1088
lines changed

.changeset/thick-pens-sit.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@livekit/protocol": minor
3+
"github.com/livekit/protocol": minor
4+
---
5+
6+
Allow mapping all SIP headers to attributes.

livekit/attrs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ const (
2020
//
2121
// SIP participant is ready when it reaches "active" status.
2222
AttrSIPCallStatus = AttrSIPPrefix + "callStatus"
23+
// AttrSIPHeaderPrefix is a prefix for automatically mapped SIP header attributes.
24+
AttrSIPHeaderPrefix = AttrSIPPrefix + "h."
2325
)

livekit/livekit_sip.pb.go

Lines changed: 673 additions & 561 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: 158 additions & 154 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protobufs/livekit_sip.proto

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ enum SIPTransport {
111111
SIP_TRANSPORT_TLS = 3;
112112
}
113113

114+
enum SIPHeaderOptions {
115+
SIP_NO_HEADERS = 0; // do not map any headers, except ones mapped explicitly
116+
SIP_X_HEADERS = 1; // map all X-* headers to sip.h.x-* attributes
117+
SIP_ALL_HEADERS = 2; // map all headers to sip.h.* attributes
118+
}
119+
114120
message SIPTrunkInfo {
115121
option deprecated = true;
116122

@@ -194,6 +200,13 @@ message SIPInboundTrunkInfo {
194200
// Map LiveKit attributes to SIP X-* headers when sending BYE or REFER requests.
195201
// Keys are the names of attributes and values are the names of X-* headers they will be mapped to.
196202
map<string, string> attributes_to_headers = 14;
203+
// Map SIP headers from INVITE to sip.h.* participant attributes automatically.
204+
//
205+
// When the names of required headers is known, using headers_to_attributes is strongly recommended.
206+
//
207+
// When mapping INVITE headers to response headers with attributes_to_headers map,
208+
// lowercase header names should be used, for example: sip.h.x-custom-header.
209+
SIPHeaderOptions include_headers = 15;
197210

198211
// Max time for the caller to wait for track subscription.
199212
google.protobuf.Duration ringing_timeout = 11;
@@ -202,7 +215,7 @@ message SIPInboundTrunkInfo {
202215

203216
bool krisp_enabled = 13;
204217

205-
// NEXT ID: 15
218+
// NEXT ID: 16
206219
}
207220

208221
message CreateSIPOutboundTrunkRequest {
@@ -241,8 +254,15 @@ message SIPOutboundTrunkInfo {
241254
// Map LiveKit attributes to SIP X-* headers when sending BYE or REFER requests.
242255
// Keys are the names of attributes and values are the names of X-* headers they will be mapped to.
243256
map<string, string> attributes_to_headers = 11;
257+
// Map SIP headers from 200 OK to sip.h.* participant attributes automatically.
258+
//
259+
// When the names of required headers is known, using headers_to_attributes is strongly recommended.
260+
//
261+
// When mapping 200 OK headers to follow-up request headers with attributes_to_headers map,
262+
// lowercase header names should be used, for example: sip.h.x-custom-header.
263+
SIPHeaderOptions include_headers = 12;
244264

245-
// NEXT ID: 12
265+
// NEXT ID: 13
246266
}
247267

248268
message GetSIPInboundTrunkRequest {
@@ -445,6 +465,13 @@ message CreateSIPParticipantRequest {
445465

446466
// These headers are sent as-is and may help identify this call as coming from LiveKit for the other SIP endpoint.
447467
map<string, string> headers = 16;
468+
// Map SIP headers from 200 OK to sip.h.* participant attributes automatically.
469+
//
470+
// When the names of required headers is known, using headers_to_attributes is strongly recommended.
471+
//
472+
// When mapping 200 OK headers to follow-up request headers with attributes_to_headers map,
473+
// lowercase header names should be used, for example: sip.h.x-custom-header.
474+
SIPHeaderOptions include_headers = 17;
448475

449476
// Max time for the callee to answer the call.
450477
google.protobuf.Duration ringing_timeout = 11;
@@ -453,7 +480,7 @@ message CreateSIPParticipantRequest {
453480

454481
// Enable voice isolation for the callee.
455482
bool enable_krisp = 14;
456-
// NEXT ID: 17
483+
// NEXT ID: 18
457484
}
458485

459486
message SIPParticipantInfo {

protobufs/rpc/io.proto

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ message EvaluateSIPDispatchRulesResponse {
171171
// Map LiveKit attributes to SIP X-* headers when sending BYE or REFER requests.
172172
// Keys are the names of attributes and values are the names of X-* headers they will be mapped to.
173173
map<string, string> attributes_to_headers = 18;
174+
// Map SIP headers from INVITE to sip.h.* participant attributes automatically.
175+
//
176+
// When the names of required headers is known, using headers_to_attributes is strongly recommended.
177+
//
178+
// When mapping INVITE headers to response headers with attributes_to_headers map,
179+
// lowercase header names should be used, for example: sip.h.x-custom-header.
180+
livekit.SIPHeaderOptions include_headers = 19;
174181

175182
repeated livekit.SIPFeature enabled_features = 15;
176183

@@ -179,7 +186,7 @@ message EvaluateSIPDispatchRulesResponse {
179186
// Max call duration.
180187
google.protobuf.Duration max_call_duration = 17;
181188

182-
// NEXT ID: 19
189+
// NEXT ID: 20
183190
}
184191

185192
message UpdateSIPCallStateRequest {

protobufs/rpc/sip.proto

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ message InternalCreateSIPParticipantRequest {
8484
// Map LiveKit attributes to SIP X-* headers when sending BYE or REFER requests.
8585
// Keys are the names of attributes and values are the names of X-* headers they will be mapped to.
8686
map<string, string> attributes_to_headers = 26;
87+
// Map SIP headers from 200 OK to sip.h.* participant attributes automatically.
88+
//
89+
// When the names of required headers is known, using headers_to_attributes is strongly recommended.
90+
//
91+
// When mapping 200 OK headers to follow-up request headers with attributes_to_headers map,
92+
// lowercase header names should be used, for example: sip.h.x-custom-header.
93+
livekit.SIPHeaderOptions include_headers = 27;
8794

8895
repeated livekit.SIPFeature enabled_features = 25;
8996

@@ -92,7 +99,7 @@ message InternalCreateSIPParticipantRequest {
9299
// Max call duration.
93100
google.protobuf.Duration max_call_duration = 24;
94101

95-
// NEXT ID: 27
102+
// NEXT ID: 28
96103
}
97104

98105
message InternalCreateSIPParticipantResponse {

0 commit comments

Comments
 (0)