mirror of
https://github.com/Monibuca/plugin-edge.git
synced 2025-10-08 01:00:29 +08:00
🐛 FIX: 调通
This commit is contained in:
29
README.md
29
README.md
@@ -1,2 +1,31 @@
|
||||
# plugin-edge
|
||||
边缘服务器插件——使得m7s实例可作为边缘服务器
|
||||
|
||||
|
||||
## 插件地址
|
||||
|
||||
https://github.com/Monibuca/plugin-edge
|
||||
|
||||
## 插件引入
|
||||
|
||||
```go
|
||||
import (
|
||||
_ "m7s.live/plugin/edge/v4"
|
||||
)
|
||||
```
|
||||
|
||||
## 配置
|
||||
|
||||
```yaml
|
||||
edge:
|
||||
origin: "http://localhost:8080/hdl/"
|
||||
```
|
||||
|
||||
origin代表源服务器拉流地址前缀,可以由如下几种格式:
|
||||
- http://[host]:[port]/hdl/ 使用hdl协议拉流
|
||||
- rtmp://[host]:[port]/ 使用rtmp协议拉流
|
||||
- rtsp://[host]:[port]/ 使用rtsp协议拉流
|
||||
|
||||
## 使用
|
||||
|
||||
当配置了edge后,该实例即可成为边缘服务器,即当收到一个订阅者时将自动向源服务器发送拉流请求,从而实现级联的效果。
|
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