examples: prevent redundant checks in OnSetup when recording (#731)

This commit is contained in:
Alessandro Ros
2025-03-23 16:33:46 +01:00
committed by GitHub
parent 87d3720f48
commit 304c38bb60
4 changed files with 33 additions and 7 deletions

View File

@@ -107,6 +107,13 @@ func (sh *serverHandler) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (
func (sh *serverHandler) OnSetup(ctx *gortsplib.ServerHandlerOnSetupCtx) (*base.Response, *gortsplib.ServerStream, error) {
log.Printf("setup request")
// SETUP is used by both readers and publishers. In case of publishers, just return StatusOK.
if ctx.Session.State() == gortsplib.ServerSessionStatePreRecord {
return &base.Response{
StatusCode: base.StatusOK,
}, nil, nil
}
sh.mutex.RLock()
defer sh.mutex.RUnlock()