Browse Source

Merge pull request #224 from KylinMountain/bugfix/initconfig

FIX utils.Conf() would not read easy-darwin.ini configuration
pull/282/head
Babosa 1 year ago committed by GitHub
parent
commit
f9545f46d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      routers/stats.go
  2. 4
      routers/sys.go
  3. 24
      rtsp/rtsp-server.go

4
routers/stats.go

@ -49,7 +49,7 @@ func (h *APIHandler) Pushers(c *gin.Context) {
}
hostname := utils.GetRequestHostname(c.Request)
pushers := make([]interface{}, 0)
for _, pusher := range rtsp.Instance.GetPushers() {
for _, pusher := range rtsp.GetServer().GetPushers() {
port := pusher.Server().TCPPort
rtsp := fmt.Sprintf("rtsp://%s:%d%s", hostname, port, pusher.Path())
if port == 554 {
@ -102,7 +102,7 @@ func (h *APIHandler) Players(c *gin.Context) {
return
}
players := make([]*rtsp.Player, 0)
for _, pusher := range rtsp.Instance.GetPushers() {
for _, pusher := range rtsp.GetServer().GetPushers() {
for _, player := range pusher.GetPlayers() {
players = append(players, player)
}

4
routers/sys.go

@ -50,9 +50,9 @@ func init() {
now := utils.DateTime(time.Now())
memData = append(memData, PercentData{Time: now, Used: mem.UsedPercent / 100})
cpuData = append(cpuData, PercentData{Time: now, Used: cpu[0] / 100})
pusherData = append(pusherData, CountData{Time: now, Total: uint(rtsp.Instance.GetPusherSize())})
pusherData = append(pusherData, CountData{Time: now, Total: uint(rtsp.GetServer().GetPusherSize())})
playerCnt := 0
for _, pusher := range rtsp.Instance.GetPushers() {
for _, pusher := range rtsp.GetServer().GetPushers() {
playerCnt += len(pusher.GetPlayers())
}
playerData = append(playerData, CountData{Time: now, Total: uint(playerCnt)})

24
rtsp/rtsp-server.go

@ -27,17 +27,23 @@ type Server struct {
removePusherCh chan *Pusher
}
var Instance *Server = &Server{
SessionLogger: SessionLogger{log.New(os.Stdout, "[RTSPServer]", log.LstdFlags|log.Lshortfile)},
Stoped: true,
TCPPort: utils.Conf().Section("rtsp").Key("port").MustInt(554),
pushers: make(map[string]*Pusher),
addPusherCh: make(chan *Pusher),
removePusherCh: make(chan *Pusher),
}
var (
instance *Server
once sync.Once
)
func GetServer() *Server {
return Instance
once.Do(func() {
instance = &Server{
SessionLogger: SessionLogger{log.New(os.Stdout, "[RTSPServer]", log.LstdFlags|log.Lshortfile)},
Stoped: true,
TCPPort: utils.Conf().Section("rtsp").Key("port").MustInt(554),
pushers: make(map[string]*Pusher),
addPusherCh: make(chan *Pusher),
removePusherCh: make(chan *Pusher),
}
})
return instance
}
func (server *Server) Start() (err error) {

Loading…
Cancel
Save