mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 06:46:42 +08:00
@@ -29,7 +29,7 @@ const (
|
||||
)
|
||||
|
||||
type serverHandler struct {
|
||||
s *gortsplib.Server
|
||||
server *gortsplib.Server
|
||||
mutex sync.RWMutex
|
||||
stream *gortsplib.ServerStream
|
||||
publisher *gortsplib.ServerSession
|
||||
@@ -54,8 +54,8 @@ func (sh *serverHandler) OnSessionOpen(ctx *gortsplib.ServerHandlerOnSessionOpen
|
||||
func (sh *serverHandler) OnSessionClose(ctx *gortsplib.ServerHandlerOnSessionCloseCtx) {
|
||||
log.Printf("session closed")
|
||||
|
||||
sh.mutex.Lock()
|
||||
defer sh.mutex.Unlock()
|
||||
sh.mutex.RLock()
|
||||
defer sh.mutex.RUnlock()
|
||||
|
||||
// if the session is the publisher,
|
||||
// close the stream and disconnect any reader.
|
||||
@@ -118,7 +118,7 @@ func (sh *serverHandler) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (
|
||||
|
||||
// create the stream and save the publisher
|
||||
sh.stream = &gortsplib.ServerStream{
|
||||
Server: sh.s,
|
||||
Server: sh.server,
|
||||
Desc: ctx.Description,
|
||||
}
|
||||
err := sh.stream.Initialize()
|
||||
@@ -194,7 +194,7 @@ func (sh *serverHandler) OnRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*bas
|
||||
func main() {
|
||||
// configure the server
|
||||
h := &serverHandler{}
|
||||
h.s = &gortsplib.Server{
|
||||
h.server = &gortsplib.Server{
|
||||
Handler: h,
|
||||
RTSPAddress: ":8554",
|
||||
UDPRTPAddress: ":8000",
|
||||
@@ -205,6 +205,6 @@ func main() {
|
||||
}
|
||||
|
||||
// start server and wait until a fatal error
|
||||
log.Printf("server is ready")
|
||||
panic(h.s.StartAndWait())
|
||||
log.Printf("server is ready on %s", h.server.RTSPAddress)
|
||||
panic(h.server.StartAndWait())
|
||||
}
|
||||
|
Reference in New Issue
Block a user