mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-25 12:32:01 -08:00
new option streamDeadAfter
This commit is contained in:
parent
d9411321e7
commit
f01bb9685f
4 changed files with 10 additions and 6 deletions
4
conf.go
4
conf.go
|
|
@ -34,6 +34,7 @@ type conf struct {
|
|||
PostScript string `yaml:"postScript"`
|
||||
ReadTimeout time.Duration `yaml:"readTimeout"`
|
||||
WriteTimeout time.Duration `yaml:"writeTimeout"`
|
||||
StreamDeadAfter time.Duration `yaml:"streamDeadAfter"`
|
||||
AuthMethods []string `yaml:"authMethods"`
|
||||
authMethodsParsed []gortsplib.AuthMethod
|
||||
Pprof bool `yaml:"pprof"`
|
||||
|
|
@ -120,6 +121,9 @@ func loadConf(fpath string, stdin io.Reader) (*conf, error) {
|
|||
if conf.WriteTimeout == 0 {
|
||||
conf.WriteTimeout = 5 * time.Second
|
||||
}
|
||||
if conf.StreamDeadAfter == 0 {
|
||||
conf.StreamDeadAfter = 15 * time.Second
|
||||
}
|
||||
|
||||
if len(conf.AuthMethods) == 0 {
|
||||
conf.AuthMethods = []string{"basic", "digest"}
|
||||
|
|
|
|||
2
conf.yml
2
conf.yml
|
|
@ -15,6 +15,8 @@ postScript:
|
|||
readTimeout: 5s
|
||||
# timeout of write operations
|
||||
writeTimeout: 5s
|
||||
# time after which a stream is considered dead
|
||||
streamDeadAfter: 15s
|
||||
# supported authentication methods
|
||||
authMethods: [basic, digest]
|
||||
# enable pprof on port 9999 to monitor performance
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import (
|
|||
|
||||
const (
|
||||
_CLIENT_CHECK_STREAM_INTERVAL = 5 * time.Second
|
||||
_CLIENT_STREAM_DEAD_AFTER = 15 * time.Second
|
||||
_CLIENT_RECEIVER_REPORT_INTERVAL = 10 * time.Second
|
||||
)
|
||||
|
||||
|
|
@ -332,7 +331,7 @@ func (c *serverClient) runRecord() bool {
|
|||
|
||||
case <-checkStreamTicker.C:
|
||||
for trackId := range c.streamTracks {
|
||||
if time.Since(c.rtcpReceivers[trackId].lastFrameTime()) >= _CLIENT_STREAM_DEAD_AFTER {
|
||||
if time.Since(c.rtcpReceivers[trackId].lastFrameTime()) >= c.p.conf.StreamDeadAfter {
|
||||
c.log("ERR: stream is dead")
|
||||
c.conn.NetConn().Close()
|
||||
<-readDone
|
||||
|
|
@ -388,7 +387,7 @@ func (c *serverClient) runRecord() bool {
|
|||
|
||||
case <-checkStreamTicker.C:
|
||||
for trackId := range c.streamTracks {
|
||||
if time.Since(c.rtcpReceivers[trackId].lastFrameTime()) >= _CLIENT_STREAM_DEAD_AFTER {
|
||||
if time.Since(c.rtcpReceivers[trackId].lastFrameTime()) >= c.p.conf.StreamDeadAfter {
|
||||
c.log("ERR: stream is dead")
|
||||
c.conn.NetConn().Close()
|
||||
<-readDone
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import (
|
|||
const (
|
||||
_STREAMER_RETRY_INTERVAL = 5 * time.Second
|
||||
_STREAMER_CHECK_STREAM_INTERVAL = 5 * time.Second
|
||||
_STREAMER_STREAM_DEAD_AFTER = 15 * time.Second
|
||||
_STREAMER_KEEPALIVE_INTERVAL = 60 * time.Second
|
||||
_STREAMER_RECEIVER_REPORT_INTERVAL = 10 * time.Second
|
||||
)
|
||||
|
|
@ -431,7 +430,7 @@ outer:
|
|||
|
||||
case <-checkStreamTicker.C:
|
||||
for trackId := range s.clientSdpParsed.Medias {
|
||||
if time.Since(s.rtcpReceivers[trackId].lastFrameTime()) >= _STREAMER_STREAM_DEAD_AFTER {
|
||||
if time.Since(s.rtcpReceivers[trackId].lastFrameTime()) >= s.p.conf.StreamDeadAfter {
|
||||
s.log("ERR: stream is dead")
|
||||
ret = true
|
||||
break outer
|
||||
|
|
@ -634,7 +633,7 @@ outer2:
|
|||
|
||||
case <-checkStreamTicker.C:
|
||||
for trackId := range s.clientSdpParsed.Medias {
|
||||
if time.Since(s.rtcpReceivers[trackId].lastFrameTime()) >= _STREAMER_STREAM_DEAD_AFTER {
|
||||
if time.Since(s.rtcpReceivers[trackId].lastFrameTime()) >= s.p.conf.StreamDeadAfter {
|
||||
s.log("ERR: stream is dead")
|
||||
ret = true
|
||||
break outer2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue