RTSP: automatically remux oversized RTP/H264 packets; drop parameter ReadBufferSize
This commit is contained in:
@@ -705,7 +705,7 @@ paths:
|
||||
|
||||
In some scenarios, when reading RTSP from the server, decoded frames can be corrupted or incomplete. This can be caused by multiple reasons:
|
||||
|
||||
* the packet buffer of the server is too small and can't handle the stream throughput. A solution consists in increasing its size:
|
||||
* the packet buffer of the server is too small and can't keep up with the stream throughput. A solution consists in increasing its size:
|
||||
|
||||
```yml
|
||||
readBufferCount: 1024
|
||||
@@ -726,12 +726,6 @@ In some scenarios, when reading RTSP from the server, decoded frames can be corr
|
||||
sourceProtocol: tcp
|
||||
```
|
||||
|
||||
* the software that is generating the stream (a camera or FFmpeg) is generating non-conformant RTP packets, with a payload bigger than the maximum allowed (that is 1460 due to the UDP MTU). A solution consists in increasing the buffer size:
|
||||
|
||||
```yml
|
||||
readBufferSize: 8192
|
||||
```
|
||||
|
||||
## RTMP protocol
|
||||
|
||||
### RTMP general usage
|
||||
|
||||
@@ -81,8 +81,6 @@ components:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
readBufferSize:
|
||||
type: integer
|
||||
|
||||
# RTMP
|
||||
rtmpDisable:
|
||||
|
||||
@@ -4,7 +4,7 @@ go 1.17
|
||||
|
||||
require (
|
||||
code.cloudfoundry.org/bytefmt v0.0.0-20211005130812-5bb3c17173e5
|
||||
github.com/aler9/gortsplib v0.0.0-20220409092623-b1a4b5209088
|
||||
github.com/aler9/gortsplib v0.0.0-20220409181614-bfe4e8cdaa9b
|
||||
github.com/asticode/go-astits v1.10.0
|
||||
github.com/fsnotify/fsnotify v1.4.9
|
||||
github.com/gin-gonic/gin v1.7.2
|
||||
|
||||
@@ -4,8 +4,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-20220409092623-b1a4b5209088 h1:LxlbSskpLz+7GvAyId2GGPRQ1aAUQ547H3mTfTBVw9Q=
|
||||
github.com/aler9/gortsplib v0.0.0-20220409092623-b1a4b5209088/go.mod h1:Mezkz7Jb5zrIWP6MxJ2uBgt5xwywZkcdmuQZ2QrFYsM=
|
||||
github.com/aler9/gortsplib v0.0.0-20220409181614-bfe4e8cdaa9b h1:4MiZp+d15pIQKVjJdJK5PRnhpLNsOoU5LizzPbg8Cxo=
|
||||
github.com/aler9/gortsplib v0.0.0-20220409181614-bfe4e8cdaa9b/go.mod h1:Mezkz7Jb5zrIWP6MxJ2uBgt5xwywZkcdmuQZ2QrFYsM=
|
||||
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=
|
||||
|
||||
@@ -198,7 +198,6 @@ type Conf struct {
|
||||
ServerKey string `json:"serverKey"`
|
||||
ServerCert string `json:"serverCert"`
|
||||
AuthMethods AuthMethods `json:"authMethods"`
|
||||
ReadBufferSize int `json:"readBufferSize"`
|
||||
|
||||
// RTMP
|
||||
RTMPDisable bool `json:"rtmpDisable"`
|
||||
|
||||
@@ -74,7 +74,6 @@ func loadConfData(ctx *gin.Context) (interface{}, error) {
|
||||
ServerKey *string `json:"serverKey"`
|
||||
ServerCert *string `json:"serverCert"`
|
||||
AuthMethods *conf.AuthMethods `json:"authMethods"`
|
||||
ReadBufferSize *int `json:"readBufferSize"`
|
||||
|
||||
// RTMP
|
||||
RTMPDisable *bool `json:"rtmpDisable"`
|
||||
|
||||
@@ -224,7 +224,6 @@ func (p *Core) createResources(initial bool) error {
|
||||
p.conf.ReadTimeout,
|
||||
p.conf.WriteTimeout,
|
||||
p.conf.ReadBufferCount,
|
||||
p.conf.ReadBufferSize,
|
||||
p.conf.Paths,
|
||||
p.externalCmdPool,
|
||||
p.metrics,
|
||||
@@ -245,7 +244,6 @@ func (p *Core) createResources(initial bool) error {
|
||||
p.conf.ReadTimeout,
|
||||
p.conf.WriteTimeout,
|
||||
p.conf.ReadBufferCount,
|
||||
p.conf.ReadBufferSize,
|
||||
useUDP,
|
||||
useMulticast,
|
||||
p.conf.RTPAddress,
|
||||
@@ -282,7 +280,6 @@ func (p *Core) createResources(initial bool) error {
|
||||
p.conf.ReadTimeout,
|
||||
p.conf.WriteTimeout,
|
||||
p.conf.ReadBufferCount,
|
||||
p.conf.ReadBufferSize,
|
||||
false,
|
||||
false,
|
||||
"",
|
||||
@@ -405,7 +402,6 @@ func (p *Core) closeResources(newConf *conf.Conf, calledByAPI bool) {
|
||||
newConf.ReadTimeout != p.conf.ReadTimeout ||
|
||||
newConf.WriteTimeout != p.conf.WriteTimeout ||
|
||||
newConf.ReadBufferCount != p.conf.ReadBufferCount ||
|
||||
newConf.ReadBufferSize != p.conf.ReadBufferSize ||
|
||||
closeMetrics {
|
||||
closePathManager = true
|
||||
} else if !reflect.DeepEqual(newConf.Paths, p.conf.Paths) {
|
||||
|
||||
@@ -216,7 +216,6 @@ type path struct {
|
||||
readTimeout conf.StringDuration
|
||||
writeTimeout conf.StringDuration
|
||||
readBufferCount int
|
||||
readBufferSize int
|
||||
confName string
|
||||
conf *conf.PathConf
|
||||
name string
|
||||
@@ -261,7 +260,6 @@ func newPath(
|
||||
readTimeout conf.StringDuration,
|
||||
writeTimeout conf.StringDuration,
|
||||
readBufferCount int,
|
||||
readBufferSize int,
|
||||
confName string,
|
||||
conf *conf.PathConf,
|
||||
name string,
|
||||
@@ -277,7 +275,6 @@ func newPath(
|
||||
readTimeout: readTimeout,
|
||||
writeTimeout: writeTimeout,
|
||||
readBufferCount: readBufferCount,
|
||||
readBufferSize: readBufferSize,
|
||||
confName: confName,
|
||||
conf: conf,
|
||||
name: name,
|
||||
@@ -670,7 +667,6 @@ func (pa *path) staticSourceCreate() {
|
||||
pa.readTimeout,
|
||||
pa.writeTimeout,
|
||||
pa.readBufferCount,
|
||||
pa.readBufferSize,
|
||||
&pa.sourceStaticWg,
|
||||
pa)
|
||||
case strings.HasPrefix(pa.conf.Source, "rtmp://"):
|
||||
|
||||
@@ -23,7 +23,6 @@ type pathManager struct {
|
||||
readTimeout conf.StringDuration
|
||||
writeTimeout conf.StringDuration
|
||||
readBufferCount int
|
||||
readBufferSize int
|
||||
pathConfs map[string]*conf.PathConf
|
||||
externalCmdPool *externalcmd.Pool
|
||||
metrics *metrics
|
||||
@@ -52,7 +51,6 @@ func newPathManager(
|
||||
readTimeout conf.StringDuration,
|
||||
writeTimeout conf.StringDuration,
|
||||
readBufferCount int,
|
||||
readBufferSize int,
|
||||
pathConfs map[string]*conf.PathConf,
|
||||
externalCmdPool *externalcmd.Pool,
|
||||
metrics *metrics,
|
||||
@@ -65,7 +63,6 @@ func newPathManager(
|
||||
readTimeout: readTimeout,
|
||||
writeTimeout: writeTimeout,
|
||||
readBufferCount: readBufferCount,
|
||||
readBufferSize: readBufferSize,
|
||||
pathConfs: pathConfs,
|
||||
externalCmdPool: externalCmdPool,
|
||||
metrics: metrics,
|
||||
@@ -277,7 +274,6 @@ func (pm *pathManager) createPath(
|
||||
pm.readTimeout,
|
||||
pm.writeTimeout,
|
||||
pm.readBufferCount,
|
||||
pm.readBufferSize,
|
||||
pathConfName,
|
||||
pathConf,
|
||||
name,
|
||||
|
||||
@@ -80,7 +80,6 @@ func newRTSPServer(
|
||||
readTimeout conf.StringDuration,
|
||||
writeTimeout conf.StringDuration,
|
||||
readBufferCount int,
|
||||
readBufferSize int,
|
||||
useUDP bool,
|
||||
useMulticast bool,
|
||||
rtpAddress string,
|
||||
@@ -124,7 +123,6 @@ func newRTSPServer(
|
||||
ReadTimeout: time.Duration(readTimeout),
|
||||
WriteTimeout: time.Duration(writeTimeout),
|
||||
ReadBufferCount: readBufferCount,
|
||||
ReadBufferSize: readBufferSize,
|
||||
WriteBufferCount: readBufferCount,
|
||||
RTSPAddress: address,
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ type rtspSource struct {
|
||||
readTimeout conf.StringDuration
|
||||
writeTimeout conf.StringDuration
|
||||
readBufferCount int
|
||||
readBufferSize int
|
||||
wg *sync.WaitGroup
|
||||
parent rtspSourceParent
|
||||
|
||||
@@ -52,7 +51,6 @@ func newRTSPSource(
|
||||
readTimeout conf.StringDuration,
|
||||
writeTimeout conf.StringDuration,
|
||||
readBufferCount int,
|
||||
readBufferSize int,
|
||||
wg *sync.WaitGroup,
|
||||
parent rtspSourceParent,
|
||||
) *rtspSource {
|
||||
@@ -66,7 +64,6 @@ func newRTSPSource(
|
||||
readTimeout: readTimeout,
|
||||
writeTimeout: writeTimeout,
|
||||
readBufferCount: readBufferCount,
|
||||
readBufferSize: readBufferSize,
|
||||
wg: wg,
|
||||
parent: parent,
|
||||
ctx: ctx,
|
||||
@@ -145,7 +142,6 @@ func (s *rtspSource) runInner() bool {
|
||||
ReadTimeout: time.Duration(s.readTimeout),
|
||||
WriteTimeout: time.Duration(s.writeTimeout),
|
||||
ReadBufferCount: s.readBufferCount,
|
||||
ReadBufferSize: s.readBufferSize,
|
||||
AnyPortEnable: s.anyPortEnable,
|
||||
OnRequest: func(req *base.Request) {
|
||||
s.log(logger.Debug, "c->s %v", req)
|
||||
|
||||
@@ -93,10 +93,6 @@ serverKey: server.key
|
||||
serverCert: server.crt
|
||||
# Authentication methods.
|
||||
authMethods: [basic, digest]
|
||||
# Read buffer size.
|
||||
# This doesn't influence throughput and shouldn't be touched unless the server
|
||||
# reports errors about the buffer size.
|
||||
readBufferSize: 2048
|
||||
|
||||
###############################################
|
||||
# RTMP parameters
|
||||
|
||||
Reference in New Issue
Block a user