Skip to content

Commit

Permalink
Add media encryption options.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Dec 9, 2024
1 parent 5a1aa9f commit 3de7bda
Show file tree
Hide file tree
Showing 12 changed files with 1,096 additions and 904 deletions.
6 changes: 6 additions & 0 deletions .changeset/healthy-poets-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@livekit/protocol": minor
"github.com/livekit/protocol": minor
---

Add media encryption options for SIP.
949 changes: 535 additions & 414 deletions livekit/livekit_sip.pb.go

Large diffs are not rendered by default.

307 changes: 156 additions & 151 deletions livekit/livekit_sip.twirp.go

Large diffs are not rendered by default.

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

enum SIPMediaEncryption {
SIP_MEDIA_ENCRYPT_DISABLE = 0; // do not enable encryption
SIP_MEDIA_ENCRYPT_ALLOW = 1; // use encryption if available
SIP_MEDIA_ENCRYPT_REQUIRE = 2; // require encryption
}

message SIPTrunkInfo {
option deprecated = true;

Expand Down Expand Up @@ -154,7 +160,8 @@ message SIPTrunkInfo {
// User-defined metadata for the Trunk.
string metadata = 12;

// NEXT ID: 15
SIPMediaEncryption media_encryption = 15;
// NEXT ID: 16
}

message CreateSIPInboundTrunkRequest {
Expand Down Expand Up @@ -200,8 +207,9 @@ message SIPInboundTrunkInfo {
google.protobuf.Duration max_call_duration = 12;

bool krisp_enabled = 13;
SIPMediaEncryption media_encryption = 15;

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

message CreateSIPOutboundTrunkRequest {
Expand Down Expand Up @@ -372,7 +380,10 @@ message SIPDispatchRuleInfo {
// Participants created by this rule will inherit these attributes.
map<string, string> attributes = 8;

// NEXT ID: 9
bool krisp_enabled = 9;
SIPMediaEncryption media_encryption = 10;

// NEXT ID: 11
}

message ListSIPDispatchRuleRequest {
Expand Down Expand Up @@ -430,8 +441,10 @@ message CreateSIPParticipantRequest {
google.protobuf.Duration max_call_duration = 12;

// Enable voice isolation for the callee.
bool enable_krisp = 14;
// NEXT ID: 16
bool krisp_enabled = 14;
SIPMediaEncryption media_encryption = 16;

// NEXT ID: 17
}

message SIPParticipantInfo {
Expand Down
4 changes: 3 additions & 1 deletion protobufs/rpc/io.proto
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ message EvaluateSIPDispatchRulesResponse {
// Max call duration.
google.protobuf.Duration max_call_duration = 17;

// NEXT ID: 19
livekit.SIPMediaEncryption media_encryption = 19;

// NEXT ID: 20
}

message UpdateSIPCallStateRequest {
Expand Down
4 changes: 3 additions & 1 deletion protobufs/rpc/sip.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ message InternalCreateSIPParticipantRequest {
// Max call duration.
google.protobuf.Duration max_call_duration = 24;

// NEXT ID: 27
livekit.SIPMediaEncryption media_encryption = 27;

// NEXT ID: 28
}

message InternalCreateSIPParticipantResponse {
Expand Down
237 changes: 126 additions & 111 deletions rpc/io.pb.go

Large diffs are not rendered by default.

184 changes: 93 additions & 91 deletions rpc/io.psrpc.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion rpc/sip.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewCreateSIPParticipantRequest(
}

var features []livekit.SIPFeature
if req.EnableKrisp {
if req.KrispEnabled {
features = append(features, livekit.SIPFeature_KRISP_ENABLED)
}

Expand Down Expand Up @@ -80,5 +80,6 @@ func NewCreateSIPParticipantRequest(
EnabledFeatures: features,
RingingTimeout: req.RingingTimeout,
MaxCallDuration: req.MaxCallDuration,
MediaEncryption: req.MediaEncryption,
}, nil
}
153 changes: 84 additions & 69 deletions rpc/sip.pb.go

Large diffs are not rendered by default.

116 changes: 59 additions & 57 deletions rpc/sip.psrpc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions sip/sip.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"strings"

"github.com/twitchtv/twirp"

"golang.org/x/exp/slices"

"github.com/livekit/protocol/livekit"
Expand Down Expand Up @@ -513,15 +512,24 @@ func EvaluateDispatchRule(projectID string, trunk *livekit.SIPInboundTrunkInfo,
ParticipantMetadata: rule.Metadata,
ParticipantAttributes: attrs,
}
krispEnabled := false
if trunk != nil {
resp.Headers = trunk.Headers
resp.HeadersToAttributes = trunk.HeadersToAttributes
resp.AttributesToHeaders = trunk.AttributesToHeaders
resp.RingingTimeout = trunk.RingingTimeout
resp.MaxCallDuration = trunk.MaxCallDuration
if trunk.KrispEnabled {
resp.EnabledFeatures = append(resp.EnabledFeatures, livekit.SIPFeature_KRISP_ENABLED)
resp.MediaEncryption = trunk.MediaEncryption
krispEnabled = krispEnabled || trunk.KrispEnabled
}
if rule != nil {
krispEnabled = krispEnabled || rule.KrispEnabled
if rule.MediaEncryption != 0 {
resp.MediaEncryption = rule.MediaEncryption
}
}
if krispEnabled {
resp.EnabledFeatures = append(resp.EnabledFeatures, livekit.SIPFeature_KRISP_ENABLED)
}
return resp, nil
}

0 comments on commit 3de7bda

Please sign in to comment.