mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-10-03 23:06:36 +08:00
修复获取rtsp列表信息
This commit is contained in:
17
main.go
17
main.go
@@ -22,6 +22,14 @@ var config = struct {
|
|||||||
AutoPushList map[string]string
|
AutoPushList map[string]string
|
||||||
}{":554", ":8000", ":8001", 0, false, nil, nil}
|
}{":554", ":8000", ":8001", 0, false, nil, nil}
|
||||||
|
|
||||||
|
type RTSPStreamInfo struct {
|
||||||
|
StreamPath string
|
||||||
|
Type string //流类型,来自发布者
|
||||||
|
StartTime time.Time
|
||||||
|
URL string
|
||||||
|
SubscriberCount int
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
InstallPlugin(&PluginConfig{
|
InstallPlugin(&PluginConfig{
|
||||||
Name: "RTSP",
|
Name: "RTSP",
|
||||||
@@ -29,10 +37,13 @@ func init() {
|
|||||||
Run: runPlugin,
|
Run: runPlugin,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func getRtspList() (info []*RTSPublisher) {
|
func getRtspList() (info []*RTSPStreamInfo) {
|
||||||
for _, s := range Streams.ToList() {
|
for _, s := range Streams.ToList() {
|
||||||
if rtsp, ok := s.ExtraProp.(*RTSPublisher); ok {
|
switch rtsp := s.ExtraProp.(type) {
|
||||||
info = append(info, rtsp)
|
case *RTSPublisher:
|
||||||
|
info = append(info, rtsp.GetInfo())
|
||||||
|
case *RTSPClient:
|
||||||
|
info = append(info, rtsp.GetInfo())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
10
publisher.go
10
publisher.go
@@ -18,6 +18,16 @@ type RTSPublisher struct {
|
|||||||
processFunc []func([]byte)
|
processFunc []func([]byte)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *RTSPublisher) GetInfo() (info *RTSPStreamInfo) {
|
||||||
|
info = &RTSPStreamInfo{
|
||||||
|
URL: p.URL,
|
||||||
|
StreamPath: p.StreamPath,
|
||||||
|
Type: p.Type,
|
||||||
|
StartTime: p.StartTime,
|
||||||
|
SubscriberCount: len(p.Subscribers),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
func (p *RTSPublisher) setTracks(tracks gortsplib.Tracks) {
|
func (p *RTSPublisher) setTracks(tracks gortsplib.Tracks) {
|
||||||
if p.processFunc != nil {
|
if p.processFunc != nil {
|
||||||
p.processFunc = p.processFunc[:len(tracks)]
|
p.processFunc = p.processFunc[:len(tracks)]
|
||||||
|
@@ -177,6 +177,7 @@ func (sh *RTSPServer) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (*ba
|
|||||||
Type: "RTSP push",
|
Type: "RTSP push",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
p.ExtraProp = p
|
||||||
p.URL = ctx.Req.URL.String()
|
p.URL = ctx.Req.URL.String()
|
||||||
if p.Publish() {
|
if p.Publish() {
|
||||||
p.setTracks(ctx.Tracks)
|
p.setTracks(ctx.Tracks)
|
||||||
|
Reference in New Issue
Block a user