diff --git a/main.go b/main.go index 6817017..b2550c7 100644 --- a/main.go +++ b/main.go @@ -31,9 +31,9 @@ func (c *HDLConfig) OnEvent(event any) { for streamPath, url := range c.PullOnStart { pull(streamPath, url) } - case *Stream: //按需拉流 - if url, ok := c.PullOnSub[v.Path]; ok { - pull(v.Path, url) + case InvitePublish: //按需拉流 + if url, ok := c.PullOnSub[v.Target]; ok { + pull(v.Target, url) } } } @@ -59,7 +59,7 @@ func (c *HDLConfig) API_Pull(rw http.ResponseWriter, r *http.Request) { } func (*HDLConfig) API_List(rw http.ResponseWriter, r *http.Request) { - util.ReturnJson(FilterStreams[*HDLPuller], time.Second, rw, r) + util.ReturnFetchValue(FilterStreams[*HDLPuller], rw, r) } // 确保HDLConfig实现了PullPlugin接口 diff --git a/pull.go b/pull.go index 8f69a05..b31d76a 100644 --- a/pull.go +++ b/pull.go @@ -27,7 +27,11 @@ func NewHDLPuller() *HDLPuller { pool: make(util.BytesPool, 17), } } - +func (puller *HDLPuller) Disconnect() { + if puller.Closer != nil { + puller.Closer.Close() + } +} func (puller *HDLPuller) Connect() (err error) { HDLPlugin.Info("connect", zap.String("remoteURL", puller.RemoteURL)) if strings.HasPrefix(puller.RemoteURL, "http") {