🐛 FIX: 调通

This commit is contained in:
dexter
2022-10-03 16:19:49 +08:00
parent 3ab5e3b868
commit f9ef840213
2 changed files with 45 additions and 14 deletions

30
main.go
View File

@@ -9,27 +9,29 @@ import (
"m7s.live/plugin/rtsp/v4"
)
type EdgePlugin struct {
type EdgeConfig struct {
Origin string //源服务器地址
config.Pull
puller IPuller
}
func (p *EdgePlugin) OnEvent(event any) {
func (p *EdgeConfig) OnEvent(event any) {
switch v := event.(type) {
case FirstConfig:
if len(p.Origin) < 4 {
plugin.Panic("origin config error")
}
switch p.Origin[:4] {
case "http":
p.puller = new(hdl.HDLPuller)
case "rtmp":
p.puller = new(rtmp.RTMPPuller)
case "rtsp":
p.puller = new(rtsp.RTSPPuller)
default:
plugin.Panic("origin config not support")
plugin.Warn("origin config error plugin disabled")
plugin.RawConfig["enabled"] = false
} else {
switch p.Origin[:4] {
case "http":
p.puller = new(hdl.HDLPuller)
case "rtmp":
p.puller = new(rtmp.RTMPPuller)
case "rtsp":
p.puller = new(rtsp.RTSPPuller)
default:
plugin.Panic("origin config not support")
}
}
case *Stream:
err := plugin.Pull(v.Path, p.Origin+v.Path, p.puller, false)
@@ -39,4 +41,4 @@ func (p *EdgePlugin) OnEvent(event any) {
}
}
var plugin = InstallPlugin(new(EdgePlugin))
var plugin = InstallPlugin(new(EdgeConfig))