mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-20 02:00:05 -08:00
hls: fix toggling hlsAlwaysRemux after server is started (#4503)
Some checks are pending
code_lint / golangci_lint (push) Waiting to run
code_lint / mod_tidy (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
Some checks are pending
code_lint / golangci_lint (push) Waiting to run
code_lint / mod_tidy (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
When hlsAlwaysRemux was switched from false to true, through API or hot reloading, muxers of existing paths were not created. This fixes the issue.
This commit is contained in:
parent
84ed7a5f3b
commit
defee1eed9
12 changed files with 380 additions and 182 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"reflect"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
|
|
@ -24,6 +25,10 @@ import (
|
|||
// ErrConnNotFound is returned when a connection is not found.
|
||||
var ErrConnNotFound = errors.New("connection not found")
|
||||
|
||||
func interfaceIsEmpty(i interface{}) bool {
|
||||
return reflect.ValueOf(i).Kind() != reflect.Ptr || reflect.ValueOf(i).IsNil()
|
||||
}
|
||||
|
||||
type serverAPIConnsListRes struct {
|
||||
data *defs.APIRTMPConnList
|
||||
err error
|
||||
|
|
@ -52,6 +57,11 @@ type serverAPIConnsKickReq struct {
|
|||
res chan serverAPIConnsKickRes
|
||||
}
|
||||
|
||||
type serverMetrics interface {
|
||||
SetRTMPSServer(defs.APIRTMPServer)
|
||||
SetRTMPServer(defs.APIRTMPServer)
|
||||
}
|
||||
|
||||
type serverPathManager interface {
|
||||
AddPublisher(req defs.PathAddPublisherReq) (defs.Path, error)
|
||||
AddReader(req defs.PathAddReaderReq) (defs.Path, *stream.Stream, error)
|
||||
|
|
@ -74,6 +84,7 @@ type Server struct {
|
|||
RunOnConnectRestart bool
|
||||
RunOnDisconnect string
|
||||
ExternalCmdPool *externalcmd.Pool
|
||||
Metrics serverMetrics
|
||||
PathManager serverPathManager
|
||||
Parent serverParent
|
||||
|
||||
|
|
@ -140,6 +151,14 @@ func (s *Server) Initialize() error {
|
|||
s.wg.Add(1)
|
||||
go s.run()
|
||||
|
||||
if !interfaceIsEmpty(s.Metrics) {
|
||||
if s.IsTLS {
|
||||
s.Metrics.SetRTMPSServer(s)
|
||||
} else {
|
||||
s.Metrics.SetRTMPServer(s)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -157,8 +176,18 @@ func (s *Server) Log(level logger.Level, format string, args ...interface{}) {
|
|||
// Close closes the server.
|
||||
func (s *Server) Close() {
|
||||
s.Log(logger.Info, "listener is closing")
|
||||
|
||||
if !interfaceIsEmpty((s.Metrics)) {
|
||||
if s.IsTLS {
|
||||
s.Metrics.SetRTMPSServer(nil)
|
||||
} else {
|
||||
s.Metrics.SetRTMPServer(nil)
|
||||
}
|
||||
}
|
||||
|
||||
s.ctxCancel()
|
||||
s.wg.Wait()
|
||||
|
||||
if s.loader != nil {
|
||||
s.loader.Close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue