Browse Source

rewrite client to use the new gortsplib ServerConn

pull/169/head
aler9 5 years ago
parent
commit
f9e6cdcb7b
  1. 2
      go.mod
  2. 4
      go.sum
  3. 1030
      internal/client/client.go
  4. 2
      internal/servertcp/server.go
  5. 6
      internal/sourcertsp/source.go
  6. 2
      rtsp-simple-server.yml

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-20201208105438-07aefbcd5d11 github.com/aler9/gortsplib v0.0.0-20201212222949-4c942d33fed8
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-20201208105438-07aefbcd5d11 h1:as97tV7XyNJurmD1e3iT0AcgxeIwRa+nwMm10gi0vO0= github.com/aler9/gortsplib v0.0.0-20201212222949-4c942d33fed8 h1:nDEZtoFBPDPgu9wxujoTEmMXFNTg+d0ATYKSgGHtsgE=
github.com/aler9/gortsplib v0.0.0-20201208105438-07aefbcd5d11/go.mod h1:8P09VjpiPJFyfkVosyF5/TY82jNwkMN165NS/7sc32I= github.com/aler9/gortsplib v0.0.0-20201212222949-4c942d33fed8/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=

1030
internal/client/client.go

File diff suppressed because it is too large Load Diff

2
internal/servertcp/server.go

@ -37,7 +37,7 @@ func New(port int,
ReadBufferCount: 1, ReadBufferCount: 1,
} }
srv, err := conf.Serve(":"+strconv.FormatInt(int64(port), 10), nil) srv, err := conf.Serve(":" + strconv.FormatInt(int64(port), 10))
if err != nil { if err != nil {
return nil, err return nil, err
} }

6
internal/sourcertsp/source.go

@ -149,7 +149,7 @@ func (s *Source) runInner() bool {
s.parent.OnSourceSetReady(tracks) s.parent.OnSourceSetReady(tracks)
defer s.parent.OnSourceSetNotReady() defer s.parent.OnSourceSetNotReady()
readerDone := conn.OnFrame(func(trackID int, streamType gortsplib.StreamType, content []byte) { done := conn.ReadFrames(func(trackID int, streamType gortsplib.StreamType, content []byte) {
s.parent.OnFrame(trackID, streamType, content) s.parent.OnFrame(trackID, streamType, content)
}) })
@ -157,10 +157,10 @@ func (s *Source) runInner() bool {
select { select {
case <-s.terminate: case <-s.terminate:
conn.Close() conn.Close()
<-readerDone <-done
return false return false
case err := <-readerDone: case err := <-done:
conn.Close() conn.Close()
s.log(logger.Info, "ERR: %s", err) s.log(logger.Info, "ERR: %s", err)
return true return true

2
rtsp-simple-server.yml

@ -51,7 +51,7 @@ paths:
# if the source is an RTSP url, this is the protocol that will be used to # if the source is an RTSP url, this is the protocol that will be used to
# pull the stream. available options are "automatic", "udp", "tcp". # pull the stream. available options are "automatic", "udp", "tcp".
# the tcp protocol can help to overcome the error "no packets received recently". # the tcp protocol can help to overcome the error "no UDP packets received recently".
sourceProtocol: automatic sourceProtocol: automatic
# if the source is an RTSP or RTMP url, it will be pulled only when at least # if the source is an RTSP or RTMP url, it will be pulled only when at least

Loading…
Cancel
Save