Browse Source

RTSP source: add option sourceAnyPortEnable to support cameras that don't provide server ports (#407)

pull/429/head
aler9 4 years ago
parent
commit
d21841c1b7
  1. 2
      go.mod
  2. 4
      go.sum
  3. 1
      internal/conf/path.go
  4. 1
      internal/path/path.go
  5. 4
      internal/rtspsource/source.go
  6. 5
      rtsp-simple-server.yml

2
go.mod

@ -5,7 +5,7 @@ go 1.15 @@ -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-20210530105246-d07e93f2453e
github.com/aler9/gortsplib v0.0.0-20210603214139-363871d65898
github.com/asticode/go-astits v0.0.0-00010101000000-000000000000
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9

4
go.sum

@ -4,8 +4,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2c @@ -4,8 +4,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2c
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/aler9/go-astits v0.0.0-20210423195926-582b09ed7c04 h1:CXgQLsU4uxWAmsXNOjGLbj0A+0IlRcpZpMgI13fmVwo=
github.com/aler9/go-astits v0.0.0-20210423195926-582b09ed7c04/go.mod h1:DkOWmBNQpnr9mv24KfZjq4JawCFX1FCqjLVGvO0DygQ=
github.com/aler9/gortsplib v0.0.0-20210530105246-d07e93f2453e h1:RlEDgRKJHw0Z07FfsUnuZiqk2lwFwxONXlmiSQCjJrU=
github.com/aler9/gortsplib v0.0.0-20210530105246-d07e93f2453e/go.mod h1:zVCg+TQX445hh1pC5QgAuuBvvXZMWLY1XYz626dGFqY=
github.com/aler9/gortsplib v0.0.0-20210603214139-363871d65898 h1:Qw3xa+fdWVF0eHhZ/ntET1q24y5uynLFIllYAWbkeTU=
github.com/aler9/gortsplib v0.0.0-20210603214139-363871d65898/go.mod h1:zVCg+TQX445hh1pC5QgAuuBvvXZMWLY1XYz626dGFqY=
github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927 h1:95mXJ5fUCYpBRdSOnLAQAdJHHKxxxJrVCiaqDi965YQ=
github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927/go.mod h1:vzuE21rowz+lT1NGsWbreIvYulgBpCGnQyeTyFblUHc=
github.com/asticode/go-astikit v0.20.0 h1:+7N+J4E4lWx2QOkRdOf6DafWJMv6O4RRfgClwQokrH8=

1
internal/conf/path.go

@ -72,6 +72,7 @@ type PathConf struct { @@ -72,6 +72,7 @@ type PathConf struct {
Source string `yaml:"source"`
SourceProtocol string `yaml:"sourceProtocol"`
SourceProtocolParsed *gortsplib.StreamProtocol `yaml:"-" json:"-"`
SourceAnyPortEnable bool `yaml:"sourceAnyPortEnable"`
SourceFingerprint string `yaml:"sourceFingerprint" json:"sourceFingerprint"`
SourceOnDemand bool `yaml:"sourceOnDemand"`
SourceOnDemandStartTimeout time.Duration `yaml:"sourceOnDemandStartTimeout"`

1
internal/path/path.go

@ -329,6 +329,7 @@ func (pa *Path) startExternalSource() { @@ -329,6 +329,7 @@ func (pa *Path) startExternalSource() {
pa.ctx,
pa.conf.Source,
pa.conf.SourceProtocolParsed,
pa.conf.SourceAnyPortEnable,
pa.conf.SourceFingerprint,
pa.readTimeout,
pa.writeTimeout,

4
internal/rtspsource/source.go

@ -34,6 +34,7 @@ type Parent interface { @@ -34,6 +34,7 @@ type Parent interface {
type Source struct {
ur string
proto *gortsplib.StreamProtocol
anyPortEnable bool
fingerprint string
readTimeout time.Duration
writeTimeout time.Duration
@ -52,6 +53,7 @@ func New( @@ -52,6 +53,7 @@ func New(
ctxParent context.Context,
ur string,
proto *gortsplib.StreamProtocol,
anyPortEnable bool,
fingerprint string,
readTimeout time.Duration,
writeTimeout time.Duration,
@ -65,6 +67,7 @@ func New( @@ -65,6 +67,7 @@ func New(
s := &Source{
ur: ur,
proto: proto,
anyPortEnable: anyPortEnable,
fingerprint: fingerprint,
readTimeout: readTimeout,
writeTimeout: writeTimeout,
@ -153,6 +156,7 @@ func (s *Source) runInner() bool { @@ -153,6 +156,7 @@ func (s *Source) runInner() bool {
WriteTimeout: s.writeTimeout,
ReadBufferCount: s.readBufferCount,
ReadBufferSize: s.readBufferSize,
AnyPortEnable: s.anyPortEnable,
OnRequest: func(req *base.Request) {
s.log(logger.Debug, "c->s %v", req)
},

5
rtsp-simple-server.yml

@ -119,6 +119,11 @@ paths: @@ -119,6 +119,11 @@ paths:
# the tcp protocol can help to overcome the error "no UDP packets received recently".
sourceProtocol: automatic
# if the source is an RTSP or RTSPS URL, this allows to support cameras that
# don't provide server ports. This is a security issue and must be enabled only
# when interacting with old cameras that require it.
sourceAnyPortEnable: no
# if the source is an RTSPS URL, the fingerprint of the certificate of the source
# must be provided in order to prevent man-in-the-middle attacks.
# it can be obtained from the source by running:

Loading…
Cancel
Save