diff --git a/main.go b/main.go index f7af82b..9c92360 100644 --- a/main.go +++ b/main.go @@ -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 {