server: fix timeout when reading with Media Foundation (bluenviron/mediamtx#5090) (#932)

This commit is contained in:
Alessandro Ros
2025-11-02 17:03:44 +01:00
committed by GitHub
parent 69481ce0bd
commit 1214bdc17e
3 changed files with 11 additions and 3 deletions

View File

@@ -882,9 +882,14 @@ func (ss *ServerSession) runInner() error {
res.Header = make(base.Header)
}
// Media Foundation-based software, like Windows Media Player,
// send keepalives at an interval equal the timeout value.
// prevent timeouts by subtracting 5 seconds from the value.
timeout := max(int(ss.s.IdleTimeout/time.Second)-5, 1)
res.Header["Session"] = headers.Session{
Session: ss.secretID,
Timeout: ptrOf(uint(ss.s.IdleTimeout / time.Second)),
Timeout: ptrOf(uint(timeout)),
}.Marshal()
}