Skip to content

Commit f01bb96

Browse files
committed
new option streamDeadAfter
1 parent d941132 commit f01bb96

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

conf.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type conf struct {
3434
PostScript string `yaml:"postScript"`
3535
ReadTimeout time.Duration `yaml:"readTimeout"`
3636
WriteTimeout time.Duration `yaml:"writeTimeout"`
37+
StreamDeadAfter time.Duration `yaml:"streamDeadAfter"`
3738
AuthMethods []string `yaml:"authMethods"`
3839
authMethodsParsed []gortsplib.AuthMethod
3940
Pprof bool `yaml:"pprof"`
@@ -120,6 +121,9 @@ func loadConf(fpath string, stdin io.Reader) (*conf, error) {
120121
if conf.WriteTimeout == 0 {
121122
conf.WriteTimeout = 5 * time.Second
122123
}
124+
if conf.StreamDeadAfter == 0 {
125+
conf.StreamDeadAfter = 15 * time.Second
126+
}
123127

124128
if len(conf.AuthMethods) == 0 {
125129
conf.AuthMethods = []string{"basic", "digest"}

conf.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ postScript:
1515
readTimeout: 5s
1616
# timeout of write operations
1717
writeTimeout: 5s
18+
# time after which a stream is considered dead
19+
streamDeadAfter: 15s
1820
# supported authentication methods
1921
authMethods: [basic, digest]
2022
# enable pprof on port 9999 to monitor performance

server-client.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515

1616
const (
1717
_CLIENT_CHECK_STREAM_INTERVAL = 5 * time.Second
18-
_CLIENT_STREAM_DEAD_AFTER = 15 * time.Second
1918
_CLIENT_RECEIVER_REPORT_INTERVAL = 10 * time.Second
2019
)
2120

@@ -332,7 +331,7 @@ func (c *serverClient) runRecord() bool {
332331

333332
case <-checkStreamTicker.C:
334333
for trackId := range c.streamTracks {
335-
if time.Since(c.rtcpReceivers[trackId].lastFrameTime()) >= _CLIENT_STREAM_DEAD_AFTER {
334+
if time.Since(c.rtcpReceivers[trackId].lastFrameTime()) >= c.p.conf.StreamDeadAfter {
336335
c.log("ERR: stream is dead")
337336
c.conn.NetConn().Close()
338337
<-readDone
@@ -388,7 +387,7 @@ func (c *serverClient) runRecord() bool {
388387

389388
case <-checkStreamTicker.C:
390389
for trackId := range c.streamTracks {
391-
if time.Since(c.rtcpReceivers[trackId].lastFrameTime()) >= _CLIENT_STREAM_DEAD_AFTER {
390+
if time.Since(c.rtcpReceivers[trackId].lastFrameTime()) >= c.p.conf.StreamDeadAfter {
392391
c.log("ERR: stream is dead")
393392
c.conn.NetConn().Close()
394393
<-readDone

streamer.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
const (
1717
_STREAMER_RETRY_INTERVAL = 5 * time.Second
1818
_STREAMER_CHECK_STREAM_INTERVAL = 5 * time.Second
19-
_STREAMER_STREAM_DEAD_AFTER = 15 * time.Second
2019
_STREAMER_KEEPALIVE_INTERVAL = 60 * time.Second
2120
_STREAMER_RECEIVER_REPORT_INTERVAL = 10 * time.Second
2221
)
@@ -431,7 +430,7 @@ outer:
431430

432431
case <-checkStreamTicker.C:
433432
for trackId := range s.clientSdpParsed.Medias {
434-
if time.Since(s.rtcpReceivers[trackId].lastFrameTime()) >= _STREAMER_STREAM_DEAD_AFTER {
433+
if time.Since(s.rtcpReceivers[trackId].lastFrameTime()) >= s.p.conf.StreamDeadAfter {
435434
s.log("ERR: stream is dead")
436435
ret = true
437436
break outer
@@ -634,7 +633,7 @@ outer2:
634633

635634
case <-checkStreamTicker.C:
636635
for trackId := range s.clientSdpParsed.Medias {
637-
if time.Since(s.rtcpReceivers[trackId].lastFrameTime()) >= _STREAMER_STREAM_DEAD_AFTER {
636+
if time.Since(s.rtcpReceivers[trackId].lastFrameTime()) >= s.p.conf.StreamDeadAfter {
638637
s.log("ERR: stream is dead")
639638
ret = true
640639
break outer2

0 commit comments

Comments
 (0)