mirror of
https://github.com/Monibuca/plugin-edge.git
synced 2025-10-07 16:50:59 +08:00
🐛 FIX: 调通
This commit is contained in:
30
main.go
30
main.go
@@ -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))
|
||||
|
Reference in New Issue
Block a user