remove ServerHandler.Server

This commit is contained in:
aler9
2023-08-14 17:26:42 +02:00
parent 779ad4e3ca
commit e2c526b3b8
6 changed files with 18 additions and 16 deletions

View File

@@ -18,6 +18,7 @@ import (
// 3. allow multiple clients to read that stream with TCP, UDP or UDP-multicast
type serverHandler struct {
s *gortsplib.Server
mutex sync.Mutex
stream *gortsplib.ServerStream
publisher *gortsplib.ServerSession
@@ -87,7 +88,7 @@ func (sh *serverHandler) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (
}
// create the stream and save the publisher
sh.stream = gortsplib.NewServerStream(ctx.Server, ctx.Medias)
sh.stream = gortsplib.NewServerStream(sh.s, ctx.Medias)
sh.publisher = ctx.Session
return &base.Response{
@@ -137,8 +138,9 @@ func (sh *serverHandler) OnRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*bas
func main() {
// configure the server
s := &gortsplib.Server{
Handler: &serverHandler{},
h := &serverHandler{}
h.s = &gortsplib.Server{
Handler: h,
RTSPAddress: ":8554",
UDPRTPAddress: ":8000",
UDPRTCPAddress: ":8001",
@@ -149,5 +151,5 @@ func main() {
// start server and wait until a fatal error
log.Printf("server is ready")
panic(s.StartAndWait())
panic(h.s.StartAndWait())
}