Skip to content

Commit 7012dfc

Browse files
authored
configurable ringing interval (#328)
* configurable ringing interval * change parameter type
1 parent bd7330e commit 7012dfc

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

pkg/config/config.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,18 @@ type Config struct {
6161
ApiSecret string `yaml:"api_secret"` // required (env LIVEKIT_API_SECRET)
6262
WsUrl string `yaml:"ws_url"` // required (env LIVEKIT_WS_URL)
6363

64-
HealthPort int `yaml:"health_port"`
65-
PrometheusPort int `yaml:"prometheus_port"`
66-
PProfPort int `yaml:"pprof_port"`
67-
SIPPort int `yaml:"sip_port"` // announced SIP signaling port
68-
SIPPortListen int `yaml:"sip_port_listen"` // SIP signaling port to listen on
69-
SIPHostname string `yaml:"sip_hostname"`
70-
TLS *TLSConfig `yaml:"tls"`
71-
RTPPort rtcconfig.PortRange `yaml:"rtp_port"`
72-
Logging logger.Config `yaml:"logging"`
73-
ClusterID string `yaml:"cluster_id"` // cluster this instance belongs to
74-
MaxCpuUtilization float64 `yaml:"max_cpu_utilization"`
64+
HealthPort int `yaml:"health_port"`
65+
PrometheusPort int `yaml:"prometheus_port"`
66+
PProfPort int `yaml:"pprof_port"`
67+
SIPPort int `yaml:"sip_port"` // announced SIP signaling port
68+
SIPPortListen int `yaml:"sip_port_listen"` // SIP signaling port to listen on
69+
SIPHostname string `yaml:"sip_hostname"`
70+
SIPRingingInterval time.Duration `yaml:"sip_ringing_interval"` // from 1 sec up to 60 (default '1s')
71+
TLS *TLSConfig `yaml:"tls"`
72+
RTPPort rtcconfig.PortRange `yaml:"rtp_port"`
73+
Logging logger.Config `yaml:"logging"`
74+
ClusterID string `yaml:"cluster_id"` // cluster this instance belongs to
75+
MaxCpuUtilization float64 `yaml:"max_cpu_utilization"`
7576

7677
UseExternalIP bool `yaml:"use_external_ip"`
7778
LocalNet string `yaml:"local_net"` // local IP net to use, e.g. 192.168.0.0/24

pkg/sip/inbound.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,7 @@ func (c *sipInbound) StartRinging() {
10881088
tx := c.inviteTx
10891089
cancels := tx.Cancels()
10901090
go func() {
1091-
// TODO: check spec for the exact interval
1092-
ticker := time.NewTicker(time.Second)
1091+
ticker := time.NewTicker(c.s.conf.SIPRingingInterval)
10931092
defer ticker.Stop()
10941093
for {
10951094
select {

pkg/sip/service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ func NewService(region string, conf *config.Config, mon *stats.Monitor, log logg
9393
if s.conf.SIPHostname != "" {
9494
log.Infow("using hostname", "hostname", s.conf.SIPHostname)
9595
}
96+
if s.conf.SIPRingingInterval < 1*time.Second || s.conf.SIPRingingInterval > 60*time.Second {
97+
s.conf.SIPRingingInterval = 1 * time.Second
98+
log.Infow("ringing interval", "seconds", s.conf.SIPRingingInterval)
99+
}
96100
return s, nil
97101
}
98102

0 commit comments

Comments
 (0)