mirror of
https://github.com/Monibuca/plugin-rtmp.git
synced 2025-10-04 23:23:34 +08:00
18
main.go
18
main.go
@@ -3,10 +3,12 @@ package rtmp
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
. "m7s.live/engine/v4"
|
. "m7s.live/engine/v4"
|
||||||
"m7s.live/engine/v4/config"
|
"m7s.live/engine/v4/config"
|
||||||
|
"m7s.live/engine/v4/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RTMPConfig struct {
|
type RTMPConfig struct {
|
||||||
@@ -68,6 +70,22 @@ var conf = &RTMPConfig{
|
|||||||
}
|
}
|
||||||
var RTMPPlugin = InstallPlugin(conf)
|
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) {
|
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"))
|
err := RTMPPlugin.Pull(r.URL.Query().Get("streamPath"), r.URL.Query().Get("target"), new(RTMPPuller), r.URL.Query().Has("save"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user