Skip to content

Commit

Permalink
Merge branch 'v0.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
asdftu committed Nov 4, 2022
2 parents 301440f + a96648d commit b368a30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 4 additions & 1 deletion configure/liveconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type ServerCfg struct {
FLVDir string `mapstructure:"flv_dir"`
RTMPAddr string `mapstructure:"rtmp_addr"`
HTTPFLVAddr string `mapstructure:"httpflv_addr"`
HTTPFLVDisable bool `mapstructure:"httpflv_disable"`
HLSAddr string `mapstructure:"hls_addr"`
HLSKeepAfterEnd bool `mapstructure:"hls_keep_after_end"`
APIAddr string `mapstructure:"api_addr"`
Expand All @@ -58,8 +59,9 @@ type ServerCfg struct {
// default config
var defaultConf = ServerCfg{
ConfigFile: "livego.yaml",
RTMPAddr: ":19080",
RTMPAddr: ":19035",
HTTPFLVAddr: ":19080",
HTTPFLVDisable: false,
HLSAddr: ":7002",
HLSKeepAfterEnd: false,
APIAddr: ":8090",
Expand Down Expand Up @@ -87,6 +89,7 @@ func init() {
// Flags
pflag.String("rtmp_addr", ":19080", "RTMP server listen address")
pflag.String("httpflv_addr", ":19080", "HTTP-FLV server listen address")
pflag.Bool("httpflv_disable", false, " disable http-flv")
pflag.String("hls_addr", ":7002", "HLS server listen address")
pflag.String("api_addr", ":8090", "HTTP manage interface server listen address")
pflag.String("config_file", "livego.yaml", "configure filename")
Expand Down
20 changes: 13 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func startRtmp(stream *rtmp.RtmpStream, hlsServer *hls.Server) {
}

func startHTTPFlv(stream *rtmp.RtmpStream) {
httpflvDisable := configure.Config.GetBool("httpflv_disable")
if httpflvDisable {
log.Info("httpflv is disabled.")
return
}

httpflvAddr := configure.Config.GetString("httpflv_addr")

flvListen, err := net.Listen("tcp", httpflvAddr)
Expand Down Expand Up @@ -104,7 +110,7 @@ func startAPI(stream *rtmp.RtmpStream) {
log.Info("HTTP-API listen On ", apiAddr)
opServer.Serve(opListen)
}()
go func () {
go func() {
LogStaticsTickerLaunch(opServer)
}()
}
Expand All @@ -114,8 +120,8 @@ func LogStaticsTickerLaunch(opServer *api.Server) {
ticker := time.NewTicker(1 * time.Minute)

for range ticker.C {
msgs := opServer.SimpleLiveStaticsData();
log.Info("statics:", *msgs);
msgs := opServer.SimpleLiveStaticsData()
log.Info("statics:", *msgs)
}
}

Expand All @@ -124,8 +130,8 @@ func init() {
logrus_mate.ConfigFile("mate.conf"),
)
mate.Hijack(
log.StandardLogger(),
"mike",
log.StandardLogger(),
"mike",
)

// log.SetFormatter(&log.TextFormatter{
Expand All @@ -138,7 +144,7 @@ func init() {
// current := time.Now()
// yyyymmdd := current.Format("20060102")
// file, err := os.OpenFile("livego_"+ yyyymmdd + ".log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
// if err != nil {
// if err != nil {
// fmt.Println("Could Not Open Log File : " + err.Error())
// }

Expand All @@ -165,7 +171,7 @@ func main() {
stream := rtmp.NewRtmpStream()
// hlsServer := startHls()
startHTTPFlv(stream)
startAPI(stream)
// startAPI(stream)

startRtmp(stream, nil)

Expand Down

0 comments on commit b368a30

Please sign in to comment.