mirror of
https://github.com/Monibuca/plugin-edge.git
synced 2025-10-08 09:10:15 +08:00
🐛 FIX: 调通
This commit is contained in:
29
README.md
29
README.md
@@ -1,2 +1,31 @@
|
|||||||
# plugin-edge
|
# plugin-edge
|
||||||
边缘服务器插件——使得m7s实例可作为边缘服务器
|
边缘服务器插件——使得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后,该实例即可成为边缘服务器,即当收到一个订阅者时将自动向源服务器发送拉流请求,从而实现级联的效果。
|
12
main.go
12
main.go
@@ -9,18 +9,19 @@ import (
|
|||||||
"m7s.live/plugin/rtsp/v4"
|
"m7s.live/plugin/rtsp/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EdgePlugin struct {
|
type EdgeConfig struct {
|
||||||
Origin string //源服务器地址
|
Origin string //源服务器地址
|
||||||
config.Pull
|
config.Pull
|
||||||
puller IPuller
|
puller IPuller
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *EdgePlugin) OnEvent(event any) {
|
func (p *EdgeConfig) OnEvent(event any) {
|
||||||
switch v := event.(type) {
|
switch v := event.(type) {
|
||||||
case FirstConfig:
|
case FirstConfig:
|
||||||
if len(p.Origin) < 4 {
|
if len(p.Origin) < 4 {
|
||||||
plugin.Panic("origin config error")
|
plugin.Warn("origin config error plugin disabled")
|
||||||
}
|
plugin.RawConfig["enabled"] = false
|
||||||
|
} else {
|
||||||
switch p.Origin[:4] {
|
switch p.Origin[:4] {
|
||||||
case "http":
|
case "http":
|
||||||
p.puller = new(hdl.HDLPuller)
|
p.puller = new(hdl.HDLPuller)
|
||||||
@@ -31,6 +32,7 @@ func (p *EdgePlugin) OnEvent(event any) {
|
|||||||
default:
|
default:
|
||||||
plugin.Panic("origin config not support")
|
plugin.Panic("origin config not support")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case *Stream:
|
case *Stream:
|
||||||
err := plugin.Pull(v.Path, p.Origin+v.Path, p.puller, false)
|
err := plugin.Pull(v.Path, p.Origin+v.Path, p.puller, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -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