Skip to content
Open
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
31 changes: 16 additions & 15 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,22 @@ type Config struct {
ApiSecret string `yaml:"api_secret"` // required (env LIVEKIT_API_SECRET)
WsUrl string `yaml:"ws_url"` // required (env LIVEKIT_WS_URL)

HealthPort int `yaml:"health_port"`
PrometheusPort int `yaml:"prometheus_port"`
PProfPort int `yaml:"pprof_port"`
SIPPort int `yaml:"sip_port"` // announced SIP signaling port
SIPPortListen int `yaml:"sip_port_listen"` // SIP signaling port to listen on
SIPHostname string `yaml:"sip_hostname"`
SIPRingingInterval time.Duration `yaml:"sip_ringing_interval"` // from 1 sec up to 60 (default '1s')
TCP *TCPConfig `yaml:"tcp"`
TLS *TLSConfig `yaml:"tls"`
RTPPort rtcconfig.PortRange `yaml:"rtp_port"`
Logging logger.Config `yaml:"logging"`
ClusterID string `yaml:"cluster_id"` // cluster this instance belongs to
MaxCpuUtilization float64 `yaml:"max_cpu_utilization"`
MaxActiveCalls int `yaml:"max_active_calls"` // if set, used for affinity-based routing
SIPTrunkIds []string `yaml:"sip_trunk_ids"` // if set, only accept calls for these trunk IDs
HealthPort int `yaml:"health_port"`
PrometheusPort int `yaml:"prometheus_port"`
PProfPort int `yaml:"pprof_port"`
SIPPort int `yaml:"sip_port"` // announced SIP signaling port
SIPPortListen int `yaml:"sip_port_listen"` // SIP signaling port to listen on
SIPHostname string `yaml:"sip_hostname"`
OutboundRouteHeaders []string `yaml:"outbound_route_headers"` // Route headers prepended to outbound requests, e.g. "<sip:proxy:5060;transport=tcp;lr>"
SIPRingingInterval time.Duration `yaml:"sip_ringing_interval"` // from 1 sec up to 60 (default '1s')
TCP *TCPConfig `yaml:"tcp"`
TLS *TLSConfig `yaml:"tls"`
RTPPort rtcconfig.PortRange `yaml:"rtp_port"`
Logging logger.Config `yaml:"logging"`
ClusterID string `yaml:"cluster_id"` // cluster this instance belongs to
MaxCpuUtilization float64 `yaml:"max_cpu_utilization"`
MaxActiveCalls int `yaml:"max_active_calls"` // if set, used for affinity-based routing
SIPTrunkIds []string `yaml:"sip_trunk_ids"` // if set, only accept calls for these trunk IDs

UseExternalIP bool `yaml:"use_external_ip"`
LocalNet string `yaml:"local_net"` // local IP net to use, e.g. 192.168.0.0/24
Expand Down
5 changes: 4 additions & 1 deletion pkg/sip/features.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package sip

const signalLoggingFeatureFlag = "sip.signal_logging"
const (
signalLoggingFeatureFlag = "sip.signal_logging"
outboundRouteHeadersFeatureFlag = "sip.outbound_route_headers"
)
2 changes: 1 addition & 1 deletion pkg/sip/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ func (c *inboundCall) runMediaConn(tid traceid.ID, offerData []byte, enc livekit
c.mon.SDPSize(len(answerData), false)
c.log().Debugw("SDP answer", "sdp", string(answerData))

mconf.Processor = c.s.handler.GetMediaProcessor(features, featureFlags, c.call.LkCallId)
mconf.Processor = c.s.handler.GetMediaProcessor(features, featureFlags, string(c.cc.ID()))
if err = c.media.SetConfig(mconf); err != nil {
return nil, err
}
Expand Down
18 changes: 13 additions & 5 deletions pkg/sip/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ func (c *Client) newCall(ctx context.Context, tid traceid.ID, conf *config.Confi
}
return AttrsToHeaders(r.LocalParticipant.Attributes(), c.sipConf.attrsToHeaders, headers)
})
if sipConf.featureFlags[outboundRouteHeadersFeatureFlag] == "true" {
call.cc.routeHeaders = conf.OutboundRouteHeaders
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should consider putting these URIs to the CreateSIPParticipant request instead? This would allow the user to add any external proxies to the path, as we as Cloud who will inject it's own set of URIs. In that case we won't need a feature flag here even.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea, and I think it'll be helpful to do percentage traffic migration there. That being said, feature flag is still useful here if we only want to enable it for UHG, which is our plan. We may need both..

}

call.mon = c.mon.NewCall(stats.Outbound, sipConf.host, sipConf.address)
var err error
Expand Down Expand Up @@ -769,11 +772,12 @@ func (c *Client) newOutbound(log logger.Logger, id LocalTag, from, contact URI,
}

type sipOutbound struct {
log logger.Logger
c *Client
id LocalTag
from *sip.FromHeader
contact *sip.ContactHeader
log logger.Logger
c *Client
id LocalTag
from *sip.FromHeader
contact *sip.ContactHeader
routeHeaders []string

mu sync.RWMutex
tag RemoteTag
Expand Down Expand Up @@ -1038,6 +1042,10 @@ func (c *sipOutbound) attemptInvite(ctx context.Context, callID sip.CallIDHeader
req.AppendHeader(h)
}

for _, route := range c.routeHeaders {
req.PrependHeader(sip.NewHeader("Route", route))
}

tx, err := c.c.sipCli.TransactionRequest(req)
if err != nil {
return nil, nil, err
Expand Down
Loading