From b6f606b156bb55156f500b4417fecfd71f996add Mon Sep 17 00:00:00 2001 From: Billy Lindeman Date: Mon, 1 Mar 2021 17:07:50 -0800 Subject: [PATCH 1/3] Upgrade to ion-sfu 1.9.1 (fixed nacks) --- cfgs/config.toml | 4 ++-- cfgs/local.toml | 4 ++-- go.mod | 2 +- go.sum | 2 ++ pkg/coordinator.go | 26 ++++++++++++++++---------- pkg/coordinator_etcd.go | 9 ++++++++- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/cfgs/config.toml b/cfgs/config.toml index beb8299..27d612d 100644 --- a/cfgs/config.toml +++ b/cfgs/config.toml @@ -22,8 +22,8 @@ key = "1q2dGu5pzikcrECJgW3ADfXX3EsmoD99SYvSVCpDsJrAqxou5tUNbHPvkEFI4bTS" # Limit the remb bandwidth in kbps # zero means no limits maxbandwidth = 1500 -# max buffer time by ms for video tracks -maxbuffertime = 1000 +# max number of video tracks packets the SFU will keep track +maxpackettrack = 500 # Sets the audio level volume threshold. # Values from [0-127] where 0 is the loudest. # Audio levels are read from rtp extension header according to: diff --git a/cfgs/local.toml b/cfgs/local.toml index 39261b0..29c394a 100644 --- a/cfgs/local.toml +++ b/cfgs/local.toml @@ -26,8 +26,8 @@ withstats = true # Limit the remb bandwidth in kbps # zero means no limits maxbandwidth = 1500 -# max buffer time by ms for video tracks -maxbuffertime = 1000 +# max number of video tracks packets the SFU will keep track +maxpackettrack = 500 # Sets the audio level volume threshold. # Values from [0-127] where 0 is the loudest. # Audio levels are read from rtp extension header according to: diff --git a/go.mod b/go.mod index e75dbf6..c7b1c1e 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/pborman/uuid v1.2.1 github.com/pion/interceptor v0.0.9 github.com/pion/ion-log v1.0.0 - github.com/pion/ion-sfu v1.9.1-0.20210220020230-c52b1cd81c3a + github.com/pion/ion-sfu v1.9.1 github.com/pion/quic v0.1.4 // indirect github.com/pion/sdp/v2 v2.4.0 github.com/pion/srtp v1.5.2 // indirect diff --git a/go.sum b/go.sum index 5c97099..9960ede 100644 --- a/go.sum +++ b/go.sum @@ -454,6 +454,8 @@ github.com/pion/ion-sfu v1.9.0 h1:3bgaTS1AyGvBmrU8R8nt/qQRguhOv3aGgaTEKUFAoUQ= github.com/pion/ion-sfu v1.9.0/go.mod h1:MKDh4JSLpBA/hFeYAYALb6nYpe6Ruknd3pmxPMbdpM8= github.com/pion/ion-sfu v1.9.1-0.20210220020230-c52b1cd81c3a h1:xSbhYqYknmm97himQ7o4gBL/2bmBKvBwGMBDsTqXBBM= github.com/pion/ion-sfu v1.9.1-0.20210220020230-c52b1cd81c3a/go.mod h1:eRGTRVxYYvW7mhxcBByROYvZdm2aUqDSG499rje2Jh8= +github.com/pion/ion-sfu v1.9.1 h1:EqTLTw2j2DUKc5qw2l6tvUnDRaEZy899NjXkEEEjoC4= +github.com/pion/ion-sfu v1.9.1/go.mod h1:eRGTRVxYYvW7mhxcBByROYvZdm2aUqDSG499rje2Jh8= github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= github.com/pion/mdns v0.0.4 h1:O4vvVqr4DGX63vzmO6Fw9vpy3lfztVWHGCQfyw0ZLSY= diff --git a/pkg/coordinator.go b/pkg/coordinator.go index b76e337..c663b2e 100644 --- a/pkg/coordinator.go +++ b/pkg/coordinator.go @@ -7,6 +7,7 @@ import ( "github.com/pborman/uuid" log "github.com/pion/ion-log" + "github.com/pion/ion-sfu/pkg/buffer" "github.com/pion/ion-sfu/pkg/middlewares/datachannel" "github.com/pion/ion-sfu/pkg/sfu" ) @@ -44,23 +45,28 @@ type localCoordinator struct { nodeID string nodeEndpoint string - mu sync.Mutex - w sfu.WebRTCTransportConfig - sessions map[string]*sfu.Session - datachannels []*sfu.Datachannel + mu sync.Mutex + w sfu.WebRTCTransportConfig + bufferFactory *buffer.Factory + sessions map[string]*sfu.Session + datachannels []*sfu.Datachannel } func newCoordinatorLocal(conf RootConfig) (coordinator, error) { + if conf.SFU.BufferFactory == nil { + conf.SFU.BufferFactory = buffer.NewBufferFactory(conf.SFU.Router.MaxPacketTrack) + } w := sfu.NewWebRTCTransportConfig(conf.SFU) dc := &sfu.Datachannel{Label: sfu.APIChannelLabel} dc.Use(datachannel.SubscriberAPI) return &localCoordinator{ - nodeID: uuid.New(), - nodeEndpoint: conf.Endpoint(), - datachannels: []*sfu.Datachannel{dc}, - sessions: make(map[string]*sfu.Session), - w: w, + nodeID: uuid.New(), + nodeEndpoint: conf.Endpoint(), + datachannels: []*sfu.Datachannel{dc}, + sessions: make(map[string]*sfu.Session), + w: w, + bufferFactory: conf.SFU.BufferFactory, }, nil } @@ -72,7 +78,7 @@ func (c *localCoordinator) ensureSession(sessionID string) *sfu.Session { return s } - s := sfu.NewSession(sessionID, c.datachannels, c.w) + s := sfu.NewSession(sessionID, c.bufferFactory, c.datachannels, c.w) s.OnClose(func() { c.onSessionClosed(sessionID) }) diff --git a/pkg/coordinator_etcd.go b/pkg/coordinator_etcd.go index 60ae47a..dee9024 100644 --- a/pkg/coordinator_etcd.go +++ b/pkg/coordinator_etcd.go @@ -9,6 +9,7 @@ import ( "github.com/pborman/uuid" log "github.com/pion/ion-log" + "github.com/pion/ion-sfu/pkg/buffer" "github.com/pion/ion-sfu/pkg/middlewares/datachannel" "github.com/pion/ion-sfu/pkg/sfu" "google.golang.org/grpc" @@ -24,6 +25,7 @@ type etcdCoordinator struct { client *clientv3.Client w sfu.WebRTCTransportConfig + bufferFactory *buffer.Factory datachannels []*sfu.Datachannel localSessions map[string]*sfu.Session sessionLeases map[string]context.CancelFunc @@ -39,6 +41,10 @@ func newCoordinatorEtcd(conf RootConfig) (*etcdCoordinator, error) { if err != nil { return nil, err } + + if conf.SFU.BufferFactory == nil { + conf.SFU.BufferFactory = buffer.NewBufferFactory(conf.SFU.Router.MaxPacketTrack) + } w := sfu.NewWebRTCTransportConfig(conf.SFU) dc := &sfu.Datachannel{Label: sfu.APIChannelLabel} dc.Use(datachannel.SubscriberAPI) @@ -49,6 +55,7 @@ func newCoordinatorEtcd(conf RootConfig) (*etcdCoordinator, error) { nodeID: uuid.New(), nodeEndpoint: conf.Endpoint(), w: w, + bufferFactory: conf.SFU.BufferFactory, datachannels: []*sfu.Datachannel{dc}, sessionLeases: make(map[string]context.CancelFunc), localSessions: make(map[string]*sfu.Session), @@ -141,7 +148,7 @@ func (e *etcdCoordinator) ensureSession(sessionID string) *sfu.Session { return s } - s := sfu.NewSession(sessionID, e.datachannels, e.w) + s := sfu.NewSession(sessionID, e.bufferFactory, e.datachannels, e.w) s.OnClose(func() { e.onSessionClosed(sessionID) }) From 96c789a6ce8176e75059766b6bc32f71d1182438 Mon Sep 17 00:00:00 2001 From: Billy Lindeman Date: Mon, 1 Mar 2021 17:09:19 -0800 Subject: [PATCH 2/3] fix / cleanup example configs --- cfgs/config-docker.toml | 28 ++++++++++++++++++++++++++-- cfgs/config.toml | 4 ++++ cfgs/config2.toml | 23 +++++++++++++++++++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/cfgs/config-docker.toml b/cfgs/config-docker.toml index e715af0..8bd7bac 100644 --- a/cfgs/config-docker.toml +++ b/cfgs/config-docker.toml @@ -13,12 +13,36 @@ httpaddr = ":7000" key = "" cert = "" +[signal.auth] +enabled = false +keytype = "HMAC" +key = "1q2dGu5pzikcrECJgW3ADfXX3EsmoD99SYvSVCpDsJrAqxou5tUNbHPvkEFI4bTS" + +[sfu.sfu] +ballast = 1024 +withstats = true + [sfu.router] # Limit the remb bandwidth in kbps # zero means no limits maxbandwidth = 1500 -# max buffer time by ms for video tracks -maxbuffertime = 1000 +# max number of video tracks packets the SFU will keep track +maxpackettrack = 500 +# Sets the audio level volume threshold. +# Values from [0-127] where 0 is the loudest. +# Audio levels are read from rtp extension header according to: +# https://tools.ietf.org/html/rfc6464 +audiolevelthreshold = 40 +# Sets the interval in which the SFU will check the audio level +# in [ms]. If the active speaker has changed, the sfu will +# emit an event to clients. +audiolevelinterval=1000 +# Sets minimum percentage of events required to fire an audio level +# according to the expected events from the audiolevelinterval, +# calculated as audiolevelinterval/packetization time (20ms for 8kHz) +# Values from [0-100] +audiolevelfilter = 20 + [sfu.router.simulcast] # Prefer best quality initially diff --git a/cfgs/config.toml b/cfgs/config.toml index 27d612d..a1b4c80 100644 --- a/cfgs/config.toml +++ b/cfgs/config.toml @@ -18,6 +18,10 @@ enabled = false keytype = "HMAC" key = "1q2dGu5pzikcrECJgW3ADfXX3EsmoD99SYvSVCpDsJrAqxou5tUNbHPvkEFI4bTS" +[sfu.sfu] +ballast = 1024 +withstats = true + [sfu.router] # Limit the remb bandwidth in kbps # zero means no limits diff --git a/cfgs/config2.toml b/cfgs/config2.toml index 16142bf..9065726 100644 --- a/cfgs/config2.toml +++ b/cfgs/config2.toml @@ -18,12 +18,31 @@ enabled = true keytype = "HMAC" key = "1q2dGu5pzikcrECJgW3ADfXX3EsmoD99SYvSVCpDsJrAqxou5tUNbHPvkEFI4bTS" +[sfu.sfu] +ballast = 1024 +withstats = true + [sfu.router] # Limit the remb bandwidth in kbps # zero means no limits maxbandwidth = 1500 -# max buffer time by ms for video tracks -maxbuffertime = 1000 +# max number of video tracks packets the SFU will keep track +maxpackettrack = 500 +# Sets the audio level volume threshold. +# Values from [0-127] where 0 is the loudest. +# Audio levels are read from rtp extension header according to: +# https://tools.ietf.org/html/rfc6464 +audiolevelthreshold = 40 +# Sets the interval in which the SFU will check the audio level +# in [ms]. If the active speaker has changed, the sfu will +# emit an event to clients. +audiolevelinterval=1000 +# Sets minimum percentage of events required to fire an audio level +# according to the expected events from the audiolevelinterval, +# calculated as audiolevelinterval/packetization time (20ms for 8kHz) +# Values from [0-100] +audiolevelfilter = 20 + [sfu.router.simulcast] # Prefer best quality initially From 128070d2b8d3d3eaee4738eb8532f58e35dddce5 Mon Sep 17 00:00:00 2001 From: Billy Lindeman Date: Tue, 2 Mar 2021 18:22:51 -0800 Subject: [PATCH 3/3] Bump v1.9.3 fix nack publisher --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index c7b1c1e..8bb00bc 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/pborman/uuid v1.2.1 github.com/pion/interceptor v0.0.9 github.com/pion/ion-log v1.0.0 - github.com/pion/ion-sfu v1.9.1 + github.com/pion/ion-sfu v1.9.3 github.com/pion/quic v0.1.4 // indirect github.com/pion/sdp/v2 v2.4.0 github.com/pion/srtp v1.5.2 // indirect diff --git a/go.sum b/go.sum index 9960ede..7564b1f 100644 --- a/go.sum +++ b/go.sum @@ -456,6 +456,8 @@ github.com/pion/ion-sfu v1.9.1-0.20210220020230-c52b1cd81c3a h1:xSbhYqYknmm97him github.com/pion/ion-sfu v1.9.1-0.20210220020230-c52b1cd81c3a/go.mod h1:eRGTRVxYYvW7mhxcBByROYvZdm2aUqDSG499rje2Jh8= github.com/pion/ion-sfu v1.9.1 h1:EqTLTw2j2DUKc5qw2l6tvUnDRaEZy899NjXkEEEjoC4= github.com/pion/ion-sfu v1.9.1/go.mod h1:eRGTRVxYYvW7mhxcBByROYvZdm2aUqDSG499rje2Jh8= +github.com/pion/ion-sfu v1.9.3 h1:7p6He3bPIoJcgo+CaGA+ulOYvOSaYUxk9Yd06jrE+5o= +github.com/pion/ion-sfu v1.9.3/go.mod h1:eRGTRVxYYvW7mhxcBByROYvZdm2aUqDSG499rje2Jh8= github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= github.com/pion/mdns v0.0.4 h1:O4vvVqr4DGX63vzmO6Fw9vpy3lfztVWHGCQfyw0ZLSY=