Merge pull request #15 from yangchao2015/v4

增加RTMP流的查询接口
This commit is contained in:
dexter
2022-12-12 16:23:22 +08:00
committed by GitHub

18
main.go
View File

@@ -3,10 +3,12 @@ package rtmp
import (
"context"
"net/http"
"time"
"go.uber.org/zap"
. "m7s.live/engine/v4"
"m7s.live/engine/v4/config"
"m7s.live/engine/v4/util"
)
type RTMPConfig struct {
@@ -68,6 +70,22 @@ var conf = &RTMPConfig{
}
var RTMPPlugin = InstallPlugin(conf)
func filterStreams() (ss []*Stream) {
Streams.RLock()
defer Streams.RUnlock()
for _, s := range Streams.Map {
switch s.Publisher.(type) {
case *RTMPReceiver, *RTMPPuller:
ss = append(ss, s)
}
}
return
}
func (*RTMPConfig) API_list(w http.ResponseWriter, r *http.Request) {
util.ReturnJson(filterStreams, time.Second, w, r)
}
func (*RTMPConfig) API_Pull(rw http.ResponseWriter, r *http.Request) {
err := RTMPPlugin.Pull(r.URL.Query().Get("streamPath"), r.URL.Query().Get("target"), new(RTMPPuller), r.URL.Query().Has("save"))
if err != nil {