Browse Source

perform frame readings and writings in separate routines, in order to increase UDP throughput and avoid freezes caused by a single laggy reader (#125) (#162)

pull/181/head
aler9 5 years ago
parent
commit
e5364b1fc6
  1. 2
      go.mod
  2. 4
      go.sum
  3. 1
      internal/serverplain/server.go
  4. 7
      internal/servertls/server.go
  5. 2
      internal/sourcertsp/source.go

2
go.mod

@ -5,7 +5,7 @@ go 1.15
require ( require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/aler9/gortsplib v0.0.0-20210107121652-0680ffa9a343 github.com/aler9/gortsplib v0.0.0-20210109215941-7d91c139729d
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 github.com/fsnotify/fsnotify v1.4.9
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51

4
go.sum

@ -2,8 +2,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/aler9/gortsplib v0.0.0-20210107121652-0680ffa9a343 h1:U6C+dTroqLhd/SfDowiSwt7QNJB0Ow09uv3SAQzqug8= github.com/aler9/gortsplib v0.0.0-20210109215941-7d91c139729d h1:hMNcEEry/jZNXrtPyIijXemRRwbT1oP1SzrPSp/r8j8=
github.com/aler9/gortsplib v0.0.0-20210107121652-0680ffa9a343/go.mod h1:8P09VjpiPJFyfkVosyF5/TY82jNwkMN165NS/7sc32I= github.com/aler9/gortsplib v0.0.0-20210109215941-7d91c139729d/go.mod h1:8P09VjpiPJFyfkVosyF5/TY82jNwkMN165NS/7sc32I=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

1
internal/serverplain/server.go

@ -36,7 +36,6 @@ func New(port int,
conf := gortsplib.ServerConf{ conf := gortsplib.ServerConf{
ReadTimeout: readTimeout, ReadTimeout: readTimeout,
WriteTimeout: writeTimeout, WriteTimeout: writeTimeout,
ReadBufferCount: 1,
UDPRTPListener: udpRTPListener, UDPRTPListener: udpRTPListener,
UDPRTCPListener: udpRTCPListener, UDPRTCPListener: udpRTCPListener,
} }

7
internal/servertls/server.go

@ -40,10 +40,9 @@ func New(port int,
} }
conf := gortsplib.ServerConf{ conf := gortsplib.ServerConf{
TLSConfig: &tls.Config{Certificates: []tls.Certificate{cert}}, TLSConfig: &tls.Config{Certificates: []tls.Certificate{cert}},
ReadTimeout: readTimeout, ReadTimeout: readTimeout,
WriteTimeout: writeTimeout, WriteTimeout: writeTimeout,
ReadBufferCount: 1,
} }
srv, err := conf.Serve(":" + strconv.FormatInt(int64(port), 10)) srv, err := conf.Serve(":" + strconv.FormatInt(int64(port), 10))

2
internal/sourcertsp/source.go

@ -121,7 +121,7 @@ func (s *Source) runInner() bool {
StreamProtocol: s.proto, StreamProtocol: s.proto,
ReadTimeout: s.readTimeout, ReadTimeout: s.readTimeout,
WriteTimeout: s.writeTimeout, WriteTimeout: s.writeTimeout,
ReadBufferCount: 2, ReadBufferCount: 1024,
OnRequest: func(req *base.Request) { OnRequest: func(req *base.Request) {
s.log(logger.Debug, "c->s %v", req) s.log(logger.Debug, "c->s %v", req)
}, },

Loading…
Cancel
Save