examples: disconnect allow overriding publishers in server

This commit is contained in:
aler9
2022-11-20 22:16:16 +01:00
parent ed8665762a
commit be93b242a5
2 changed files with 6 additions and 8 deletions

View File

@@ -2,7 +2,6 @@ package main
import (
"crypto/tls"
"fmt"
"log"
"sync"
@@ -78,10 +77,10 @@ func (sh *serverHandler) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (
sh.mutex.Lock()
defer sh.mutex.Unlock()
// disconnect existing publisher
if sh.stream != nil {
return &base.Response{
StatusCode: base.StatusBadRequest,
}, fmt.Errorf("someone is already publishing")
sh.stream.Close()
sh.publisher.Close()
}
// create the stream and save the publisher

View File

@@ -1,7 +1,6 @@
package main
import (
"fmt"
"log"
"sync"
@@ -77,10 +76,10 @@ func (sh *serverHandler) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (
sh.mutex.Lock()
defer sh.mutex.Unlock()
// disconnect existing publisher
if sh.stream != nil {
return &base.Response{
StatusCode: base.StatusBadRequest,
}, fmt.Errorf("someone is already publishing")
sh.stream.Close()
sh.publisher.Close()
}
// create the stream and save the publisher