Skip to content

Commit

Permalink
Allow mapping all SIP headers to attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Dec 12, 2024
1 parent a55d5a0 commit 72ab163
Show file tree
Hide file tree
Showing 13 changed files with 1,303 additions and 1,088 deletions.
6 changes: 6 additions & 0 deletions .changeset/thick-pens-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@livekit/protocol": minor
"github.com/livekit/protocol": minor
---

Allow mapping all SIP headers to attributes.
2 changes: 2 additions & 0 deletions livekit/attrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ const (
//
// SIP participant is ready when it reaches "active" status.
AttrSIPCallStatus = AttrSIPPrefix + "callStatus"
// AttrSIPHeaderPrefix is a prefix for automatically mapped SIP header attributes.
AttrSIPHeaderPrefix = AttrSIPPrefix + "h."
)
1,234 changes: 673 additions & 561 deletions livekit/livekit_sip.pb.go

Large diffs are not rendered by default.

312 changes: 158 additions & 154 deletions livekit/livekit_sip.twirp.go

Large diffs are not rendered by default.

33 changes: 30 additions & 3 deletions protobufs/livekit_sip.proto
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ enum SIPTransport {
SIP_TRANSPORT_TLS = 3;
}

enum SIPHeaderOptions {
SIP_NO_HEADERS = 0; // do not map any headers, except ones mapped explicitly
SIP_X_HEADERS = 1; // map all X-* headers to sip.h.x-* attributes
SIP_ALL_HEADERS = 2; // map all headers to sip.h.* attributes
}

message SIPTrunkInfo {
option deprecated = true;

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

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

bool krisp_enabled = 13;

// NEXT ID: 15
// NEXT ID: 16
}

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

// NEXT ID: 12
// NEXT ID: 13
}

message GetSIPInboundTrunkRequest {
Expand Down Expand Up @@ -445,6 +465,13 @@ message CreateSIPParticipantRequest {

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

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

// Enable voice isolation for the callee.
bool enable_krisp = 14;
// NEXT ID: 17
// NEXT ID: 18
}

message SIPParticipantInfo {
Expand Down
9 changes: 8 additions & 1 deletion protobufs/rpc/io.proto
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ message EvaluateSIPDispatchRulesResponse {
// Map LiveKit attributes to SIP X-* headers when sending BYE or REFER requests.
// Keys are the names of attributes and values are the names of X-* headers they will be mapped to.
map<string, string> attributes_to_headers = 18;
// Map SIP headers from INVITE to sip.h.* participant attributes automatically.
//
// When the names of required headers is known, using headers_to_attributes is strongly recommended.
//
// When mapping INVITE headers to response headers with attributes_to_headers map,
// lowercase header names should be used, for example: sip.h.x-custom-header.
livekit.SIPHeaderOptions include_headers = 19;

repeated livekit.SIPFeature enabled_features = 15;

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

// NEXT ID: 19
// NEXT ID: 20
}

message UpdateSIPCallStateRequest {
Expand Down
9 changes: 8 additions & 1 deletion protobufs/rpc/sip.proto
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ message InternalCreateSIPParticipantRequest {
// Map LiveKit attributes to SIP X-* headers when sending BYE or REFER requests.
// Keys are the names of attributes and values are the names of X-* headers they will be mapped to.
map<string, string> attributes_to_headers = 26;
// Map SIP headers from 200 OK to sip.h.* participant attributes automatically.
//
// When the names of required headers is known, using headers_to_attributes is strongly recommended.
//
// When mapping 200 OK headers to follow-up request headers with attributes_to_headers map,
// lowercase header names should be used, for example: sip.h.x-custom-header.
livekit.SIPHeaderOptions include_headers = 27;

repeated livekit.SIPFeature enabled_features = 25;

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

// NEXT ID: 27
// NEXT ID: 28
}

message InternalCreateSIPParticipantResponse {
Expand Down
Loading

0 comments on commit 72ab163

Please sign in to comment.