Skip to content

Commit

Permalink
fix a panic risk
Browse files Browse the repository at this point in the history
  • Loading branch information
macbookpro committed Jan 22, 2019
1 parent 565aaff commit 223d53a
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions rtsp/rtsp-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 223d53a

Please sign in to comment.