Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mapping all SIP headers to attributes. #920

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may need to add some documentation here, as the interaction of attributes_to_headers and include_headers may not be obvious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Please let me know if there's anything else missing.


// 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
Loading