examples: fix memory leak in server-h264-save-to-disk

This commit is contained in:
aler9
2022-11-20 22:15:49 +01:00
parent 91e15d6e1a
commit ed8665762a

View File

@@ -46,8 +46,8 @@ func (sh *serverHandler) OnSessionClose(ctx *gortsplib.ServerHandlerOnSessionClo
sh.mutex.Lock() sh.mutex.Lock()
defer sh.mutex.Unlock() defer sh.mutex.Unlock()
// allow someone else to publish
sh.publisher = nil sh.publisher = nil
sh.mpegtsMuxer.close()
} }
// called after receiving an ANNOUNCE request. // called after receiving an ANNOUNCE request.
@@ -58,9 +58,8 @@ func (sh *serverHandler) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (
defer sh.mutex.Unlock() defer sh.mutex.Unlock()
if sh.publisher != nil { if sh.publisher != nil {
return &base.Response{ sh.publisher.Close()
StatusCode: base.StatusBadRequest, sh.mpegtsMuxer.close()
}, fmt.Errorf("someone is already publishing")
} }
// find the H264 track // find the H264 track