mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-10-03 14:56:38 +08:00
refactor: remove some stupid code
This commit is contained in:
19
main.go
19
main.go
@@ -43,7 +43,7 @@ func (conf *RTSPConfig) OnEvent(event any) {
|
|||||||
}
|
}
|
||||||
if err := s.Start(); err != nil {
|
if err := s.Start(); err != nil {
|
||||||
RTSPPlugin.Error("server start", zap.Error(err))
|
RTSPPlugin.Error("server start", zap.Error(err))
|
||||||
v["enable"] = false
|
RTSPPlugin.Disabled = true
|
||||||
}
|
}
|
||||||
for streamPath, url := range conf.PullOnStart {
|
for streamPath, url := range conf.PullOnStart {
|
||||||
if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), 0); err != nil {
|
if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), 0); err != nil {
|
||||||
@@ -51,20 +51,15 @@ func (conf *RTSPConfig) OnEvent(event any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case SEpublish:
|
case SEpublish:
|
||||||
for streamPath, url := range conf.PushList {
|
if url, ok := conf.PushList[v.Target.Path]; ok {
|
||||||
if streamPath == v.Target.Path {
|
if err := RTSPPlugin.Push(v.Target.Path, url, new(RTSPPusher), false); err != nil {
|
||||||
if err := RTSPPlugin.Push(streamPath, url, new(RTSPPusher), false); err != nil {
|
RTSPPlugin.Error("push", zap.String("streamPath", v.Target.Path), zap.String("url", url), zap.Error(err))
|
||||||
RTSPPlugin.Error("push", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case *Stream: //按需拉流
|
case *Stream: //按需拉流
|
||||||
for streamPath, url := range conf.PullOnSub {
|
if url, ok := conf.PullOnSub[v.Path]; ok {
|
||||||
if streamPath == v.Path {
|
if err := RTSPPlugin.Pull(v.Path, url, new(RTSPPuller), 0); err != nil {
|
||||||
if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), 0); err != nil {
|
RTSPPlugin.Error("pull", zap.String("streamPath", v.Path), zap.String("url", url), zap.Error(err))
|
||||||
RTSPPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -77,7 +77,6 @@ func (p *RTSPPublisher) SetTracks() error {
|
|||||||
at := p.AudioTrack
|
at := p.AudioTrack
|
||||||
if at == nil {
|
if at == nil {
|
||||||
at := NewG711(p.Stream, !f.MULaw, f.PayloadType(), uint32(f.ClockRate()))
|
at := NewG711(p.Stream, !f.MULaw, f.PayloadType(), uint32(f.ClockRate()))
|
||||||
at.AVCCHead = []byte{(byte(at.CodecID) << 4) | (1 << 1)}
|
|
||||||
p.AudioTrack = at
|
p.AudioTrack = at
|
||||||
}
|
}
|
||||||
p.Tracks[track] = p.AudioTrack
|
p.Tracks[track] = p.AudioTrack
|
||||||
|
Reference in New Issue
Block a user