mirror of
https://github.com/aler9/gortsplib
synced 2025-09-27 11:32:08 +08:00
examples: disconnect allow overriding publishers in server
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user