update gortsplib
This commit is contained in:
@@ -5,7 +5,7 @@ go 1.15
|
||||
require (
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
|
||||
github.com/aler9/gortsplib v0.0.0-20201112104820-ad96344f01fe
|
||||
github.com/aler9/gortsplib v0.0.0-20201115164941-3f45d21f1132
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
|
||||
|
||||
@@ -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/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/aler9/gortsplib v0.0.0-20201112104820-ad96344f01fe h1:se/lGBXWvJzIhUCKfvH/FDJQ4aFzbC/782fnIOcXK8A=
|
||||
github.com/aler9/gortsplib v0.0.0-20201112104820-ad96344f01fe/go.mod h1:6yKsTNIrCapRz90WHQtyFV/rKK0TT+QapxUXNqSJi9M=
|
||||
github.com/aler9/gortsplib v0.0.0-20201115164941-3f45d21f1132 h1:yPtvZE/tfSPkQn7R2TkBv0I9t318yKDgCwynHzuCK5E=
|
||||
github.com/aler9/gortsplib v0.0.0-20201115164941-3f45d21f1132/go.mod h1:6yKsTNIrCapRz90WHQtyFV/rKK0TT+QapxUXNqSJi9M=
|
||||
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.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
|
||||
+13
-18
@@ -12,10 +12,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/auth"
|
||||
"github.com/aler9/gortsplib/base"
|
||||
"github.com/aler9/gortsplib/headers"
|
||||
"github.com/aler9/gortsplib/rtcpreceiver"
|
||||
"github.com/aler9/gortsplib/pkg/auth"
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
"github.com/aler9/gortsplib/pkg/headers"
|
||||
"github.com/aler9/gortsplib/pkg/rtcpreceiver"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/conf"
|
||||
"github.com/aler9/rtsp-simple-server/internal/externalcmd"
|
||||
@@ -56,27 +56,22 @@ const (
|
||||
stateRecord
|
||||
)
|
||||
|
||||
func (cs state) String() string {
|
||||
switch cs {
|
||||
func (s state) String() string {
|
||||
switch s {
|
||||
case stateInitial:
|
||||
return "Initial"
|
||||
|
||||
return "initial"
|
||||
case stateWaitingDescribe:
|
||||
return "WaitingDescribe"
|
||||
|
||||
return "waitingDescribe"
|
||||
case statePrePlay:
|
||||
return "PrePlay"
|
||||
|
||||
return "prePlay"
|
||||
case statePlay:
|
||||
return "Play"
|
||||
|
||||
return "play"
|
||||
case statePreRecord:
|
||||
return "PreRecord"
|
||||
|
||||
return "preRecord"
|
||||
case stateRecord:
|
||||
return "Record"
|
||||
return "record"
|
||||
}
|
||||
return "Invalid"
|
||||
return "invalid"
|
||||
}
|
||||
|
||||
// Path is implemented by path.Path.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/base"
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/client"
|
||||
"github.com/aler9/rtsp-simple-server/internal/pathman"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/headers"
|
||||
"github.com/aler9/gortsplib/pkg/headers"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/confenv"
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/base"
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
)
|
||||
|
||||
var reUserPass = regexp.MustCompile("^[a-zA-Z0-9!\\$\\(\\)\\*\\+\\.;<=>\\[\\]\\^_\\-\\{\\}]+$")
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/base"
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/client"
|
||||
"github.com/aler9/rtsp-simple-server/internal/conf"
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/base"
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
)
|
||||
|
||||
type reader interface {
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/base"
|
||||
"github.com/aler9/gortsplib/headers"
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
"github.com/aler9/gortsplib/pkg/headers"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/client"
|
||||
"github.com/aler9/rtsp-simple-server/internal/conf"
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/base"
|
||||
"github.com/aler9/gortsplib/multibuffer"
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
"github.com/aler9/gortsplib/pkg/multibuffer"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/aler9/gortsplib"
|
||||
"github.com/aler9/gortsplib/rtpaac"
|
||||
"github.com/aler9/gortsplib/rtph264"
|
||||
"github.com/aler9/gortsplib/pkg/rtpaac"
|
||||
"github.com/aler9/gortsplib/pkg/rtph264"
|
||||
"github.com/notedit/rtmp/av"
|
||||
"github.com/notedit/rtmp/codec/h264"
|
||||
"github.com/notedit/rtmp/format/rtmp"
|
||||
|
||||
@@ -113,11 +113,14 @@ func (s *Source) runInner() bool {
|
||||
dialDone := make(chan struct{}, 1)
|
||||
go func() {
|
||||
defer close(dialDone)
|
||||
conn, err = gortsplib.Dialer{
|
||||
|
||||
dialer := gortsplib.Dialer{
|
||||
StreamProtocol: s.proto,
|
||||
ReadTimeout: s.readTimeout,
|
||||
WriteTimeout: s.writeTimeout,
|
||||
ReadBufferCount: 2,
|
||||
}.DialRead(s.ur, s.proto)
|
||||
}
|
||||
conn, err = dialer.DialRead(s.ur)
|
||||
}()
|
||||
|
||||
select {
|
||||
@@ -136,89 +139,12 @@ func (s *Source) runInner() bool {
|
||||
s.parent.Log("rtsp source ready")
|
||||
s.parent.OnSourceSetReady(tracks)
|
||||
|
||||
var ret bool
|
||||
if s.proto == gortsplib.StreamProtocolUDP {
|
||||
ret = s.runUDP(conn, tracks)
|
||||
} else {
|
||||
ret = s.runTCP(conn, tracks)
|
||||
}
|
||||
|
||||
s.parent.OnSourceSetNotReady()
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *Source) runUDP(conn *gortsplib.ConnClient, tracks gortsplib.Tracks) bool {
|
||||
var wg sync.WaitGroup
|
||||
|
||||
// receive RTP packets
|
||||
for trackId := range tracks {
|
||||
wg.Add(1)
|
||||
go func(trackId int) {
|
||||
defer wg.Done()
|
||||
|
||||
for {
|
||||
buf, err := conn.ReadFrameUDP(trackId, gortsplib.StreamTypeRtp)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
s.parent.OnFrame(trackId, gortsplib.StreamTypeRtp, buf)
|
||||
}
|
||||
}(trackId)
|
||||
}
|
||||
|
||||
// receive RTCP packets
|
||||
for trackId := range tracks {
|
||||
wg.Add(1)
|
||||
go func(trackId int) {
|
||||
defer wg.Done()
|
||||
|
||||
for {
|
||||
buf, err := conn.ReadFrameUDP(trackId, gortsplib.StreamTypeRtcp)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
s.parent.OnFrame(trackId, gortsplib.StreamTypeRtcp, buf)
|
||||
}
|
||||
}(trackId)
|
||||
}
|
||||
|
||||
tcpConnDone := make(chan error)
|
||||
go func() {
|
||||
tcpConnDone <- conn.LoopUDP()
|
||||
}()
|
||||
|
||||
var ret bool
|
||||
|
||||
outer:
|
||||
for {
|
||||
select {
|
||||
case <-s.terminate:
|
||||
conn.Close()
|
||||
<-tcpConnDone
|
||||
ret = false
|
||||
break outer
|
||||
|
||||
case err := <-tcpConnDone:
|
||||
conn.Close()
|
||||
s.parent.Log("rtsp source ERR: %s", err)
|
||||
ret = true
|
||||
break outer
|
||||
}
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *Source) runTCP(conn *gortsplib.ConnClient, tracks gortsplib.Tracks) bool {
|
||||
tcpConnDone := make(chan error)
|
||||
readDone := make(chan error)
|
||||
go func() {
|
||||
for {
|
||||
trackId, streamType, content, err := conn.ReadFrameTCP()
|
||||
trackId, streamType, content, err := conn.ReadFrame()
|
||||
if err != nil {
|
||||
tcpConnDone <- err
|
||||
readDone <- err
|
||||
return
|
||||
}
|
||||
|
||||
@@ -233,11 +159,11 @@ outer:
|
||||
select {
|
||||
case <-s.terminate:
|
||||
conn.Close()
|
||||
<-tcpConnDone
|
||||
<-readDone
|
||||
ret = false
|
||||
break outer
|
||||
|
||||
case err := <-tcpConnDone:
|
||||
case err := <-readDone:
|
||||
conn.Close()
|
||||
s.parent.Log("rtsp source ERR: %s", err)
|
||||
ret = true
|
||||
@@ -245,5 +171,6 @@ outer:
|
||||
}
|
||||
}
|
||||
|
||||
s.parent.OnSourceSetNotReady()
|
||||
return ret
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user