fix a panic risk

pull/132/head
macbookpro 2019-01-22 21:36:05 +08:00
parent 565aafffce
commit 223d53a315
1 changed files with 8 additions and 11 deletions

View File

@ -27,19 +27,16 @@ type Server struct {
removePusherCh chan *Pusher
}
var Instance *Server = nil
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),
}
func GetServer() *Server {
if Instance == nil {
Instance = &Server{
Stoped: true,
TCPPort: utils.Conf().Section("rtsp").Key("port").MustInt(554),
pushers: make(map[string]*Pusher),
addPusherCh: make(chan *Pusher),
removePusherCh: make(chan *Pusher),
}
Instance.logger = log.New(os.Stdout, "[RTSPServer]", log.LstdFlags|log.Lshortfile)
}
return Instance
}