forked from cowkeys/livego
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,016 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package configure | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"log" | ||
) | ||
|
||
/* | ||
{ | ||
[ | ||
{ | ||
"application":"live", | ||
"live":"on", | ||
"hls":"on", | ||
"static_push":["rtmp://xx/live"] | ||
} | ||
] | ||
} | ||
*/ | ||
type Application struct { | ||
Appname string | ||
Liveon string | ||
Hlson string | ||
Static_push []string | ||
} | ||
|
||
type ServerCfg struct { | ||
Server []Application | ||
} | ||
|
||
var RtmpServercfg ServerCfg | ||
|
||
func LoadConfig(configfilename string) error { | ||
log.Printf("starting load configure file(%s)......", configfilename) | ||
data, err := ioutil.ReadFile(configfilename) | ||
if err != nil { | ||
log.Printf("ReadFile %s error:%v", configfilename, err) | ||
return err | ||
} | ||
|
||
log.Printf("loadconfig: \r\n%s", string(data)) | ||
|
||
err = json.Unmarshal(data, &RtmpServercfg) | ||
if err != nil { | ||
log.Printf("json.Unmarshal error:%v", err) | ||
return err | ||
} | ||
log.Printf("get config json data:%v", RtmpServercfg) | ||
return nil | ||
} | ||
|
||
func CheckAppName(appname string) bool { | ||
for _, app := range RtmpServercfg.Server { | ||
if (app.Appname == appname) && (app.Liveon == "on") { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func GetStaticPushUrlList(appname string) ([]string, bool) { | ||
for _, app := range RtmpServercfg.Server { | ||
if (app.Appname == appname) && (app.Liveon == "on") { | ||
if len(app.Static_push) > 0 { | ||
return app.Static_push, true | ||
} else { | ||
return nil, false | ||
} | ||
} | ||
|
||
} | ||
return nil, false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"server": [ | ||
{ | ||
"appname":"live", | ||
"liveon":"on", | ||
"hlson":"on" | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.