server: send session timeout to clients through the session header (https://github.com/aler9/rtsp-simple-server/issues/702)

This commit is contained in:
aler9
2022-01-19 23:07:53 +01:00
parent 12b14491c2
commit f6a86b8789
5 changed files with 201 additions and 92 deletions

View File

@@ -283,7 +283,13 @@ func (ss *ServerSession) run() {
if res.Header == nil {
res.Header = make(base.Header)
}
res.Header["Session"] = base.HeaderValue{ss.secretID}
res.Header["Session"] = headers.Session{
Session: ss.secretID,
Timeout: func() *uint {
v := uint(ss.s.sessionTimeout / time.Second)
return &v
}(),
}.Write()
}
if _, ok := err.(liberrors.ErrServerSessionTeardown); ok {
@@ -337,7 +343,7 @@ func (ss *ServerSession) run() {
}
// in case of PLAY and UDP, timeout happens when no RTSP request arrives
} else if now.Sub(ss.lastRequestTime) >= ss.s.closeSessionAfterNoRequestsFor {
} else if now.Sub(ss.lastRequestTime) >= ss.s.sessionTimeout {
return liberrors.ErrServerNoRTSPRequestsInAWhile{}
}