refactor: remove some stupid code

This commit is contained in:
langhuihui
2023-05-25 14:15:36 +08:00
parent 0976830607
commit 32e9b7f036

18
main.go
View File

@@ -20,22 +20,20 @@ type HDLConfig struct {
config.Pull config.Pull
} }
func pull(streamPath, url string) {
if err := HDLPlugin.Pull(streamPath, url, NewHDLPuller(), 0); err != nil {
HDLPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
}
}
func (c *HDLConfig) OnEvent(event any) { func (c *HDLConfig) OnEvent(event any) {
switch v := event.(type) { switch v := event.(type) {
case FirstConfig: case FirstConfig:
for streamPath, url := range c.PullOnStart { for streamPath, url := range c.PullOnStart {
if err := HDLPlugin.Pull(streamPath, url, NewHDLPuller(), 0); err != nil { pull(streamPath, url)
HDLPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
}
} }
case *Stream: //按需拉流 case *Stream: //按需拉流
for streamPath, url := range c.PullOnSub { if url, ok := c.PullOnSub[v.Path]; ok {
if streamPath == v.Path { pull(v.Path, url)
if err := HDLPlugin.Pull(streamPath, url, NewHDLPuller(), 0); err != nil {
HDLPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
}
break
}
} }
} }
} }