mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-19 17:50:03 -08:00
rtsp: fix crash when setupping tracks between stream changes (#5253) (#5257)
Some checks are pending
code_lint / go (push) Waiting to run
code_lint / go_mod (push) Waiting to run
code_lint / docs (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
Some checks are pending
code_lint / go (push) Waiting to run
code_lint / go_mod (push) Waiting to run
code_lint / docs (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
This commit is contained in:
parent
fc8012d3c7
commit
834b079b78
1 changed files with 14 additions and 9 deletions
|
|
@ -194,6 +194,13 @@ func (s *session) onAnnounce(c *conn, ctx *gortsplib.ServerHandlerOnAnnounceCtx)
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (s *session) rtspStream() *gortsplib.ServerStream {
|
||||
if !s.isTLS {
|
||||
return s.stream.RTSPStream(s.rserver)
|
||||
}
|
||||
return s.stream.RTSPSStream(s.rserver)
|
||||
}
|
||||
|
||||
// onSetup is called by rtspServer.
|
||||
func (s *session) onSetup(c *conn, ctx *gortsplib.ServerHandlerOnSetupCtx,
|
||||
) (*base.Response, *gortsplib.ServerStream, error) {
|
||||
|
|
@ -226,7 +233,7 @@ func (s *session) onSetup(c *conn, ctx *gortsplib.ServerHandlerOnSetupCtx,
|
|||
}
|
||||
|
||||
switch s.rsession.State() {
|
||||
case gortsplib.ServerSessionStateInitial, gortsplib.ServerSessionStatePrePlay: // play
|
||||
case gortsplib.ServerSessionStateInitial: // play
|
||||
path, stream, err := s.pathManager.AddReader(defs.PathAddReaderReq{
|
||||
Author: s,
|
||||
AccessRequest: defs.PathAccessRequest{
|
||||
|
|
@ -261,16 +268,14 @@ func (s *session) onSetup(c *conn, ctx *gortsplib.ServerHandlerOnSetupCtx,
|
|||
s.path = path
|
||||
s.stream = stream
|
||||
|
||||
var rstream *gortsplib.ServerStream
|
||||
if !s.isTLS {
|
||||
rstream = stream.RTSPStream(s.rserver)
|
||||
} else {
|
||||
rstream = stream.RTSPSStream(s.rserver)
|
||||
}
|
||||
|
||||
return &base.Response{
|
||||
StatusCode: base.StatusOK,
|
||||
}, rstream, nil
|
||||
}, s.rtspStream(), nil
|
||||
|
||||
case gortsplib.ServerSessionStatePrePlay: // play, subsequent calls
|
||||
return &base.Response{
|
||||
StatusCode: base.StatusOK,
|
||||
}, s.rtspStream(), nil
|
||||
|
||||
default: // record
|
||||
return &base.Response{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue