mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-09-27 20:12:14 +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 {
|
||||
RTSPPlugin.Error("server start", zap.Error(err))
|
||||
v["enable"] = false
|
||||
RTSPPlugin.Disabled = true
|
||||
}
|
||||
for streamPath, url := range conf.PullOnStart {
|
||||
if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), 0); err != nil {
|
||||
@@ -51,20 +51,15 @@ func (conf *RTSPConfig) OnEvent(event any) {
|
||||
}
|
||||
}
|
||||
case SEpublish:
|
||||
for streamPath, url := range conf.PushList {
|
||||
if streamPath == v.Target.Path {
|
||||
if err := RTSPPlugin.Push(streamPath, url, new(RTSPPusher), false); err != nil {
|
||||
RTSPPlugin.Error("push", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
|
||||
}
|
||||
if url, ok := conf.PushList[v.Target.Path]; ok {
|
||||
if err := RTSPPlugin.Push(v.Target.Path, url, new(RTSPPusher), false); err != nil {
|
||||
RTSPPlugin.Error("push", zap.String("streamPath", v.Target.Path), zap.String("url", url), zap.Error(err))
|
||||
}
|
||||
}
|
||||
case *Stream: //按需拉流
|
||||
for streamPath, url := range conf.PullOnSub {
|
||||
if streamPath == v.Path {
|
||||
if err := RTSPPlugin.Pull(streamPath, url, new(RTSPPuller), 0); err != nil {
|
||||
RTSPPlugin.Error("pull", zap.String("streamPath", streamPath), zap.String("url", url), zap.Error(err))
|
||||
}
|
||||
break
|
||||
if url, ok := conf.PullOnSub[v.Path]; ok {
|
||||
if err := RTSPPlugin.Pull(v.Path, url, new(RTSPPuller), 0); err != nil {
|
||||
RTSPPlugin.Error("pull", zap.String("streamPath", v.Path), zap.String("url", url), zap.Error(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -77,7 +77,6 @@ func (p *RTSPPublisher) SetTracks() error {
|
||||
at := p.AudioTrack
|
||||
if at == nil {
|
||||
at := NewG711(p.Stream, !f.MULaw, f.PayloadType(), uint32(f.ClockRate()))
|
||||
at.AVCCHead = []byte{(byte(at.CodecID) << 4) | (1 << 1)}
|
||||
p.AudioTrack = at
|
||||
}
|
||||
p.Tracks[track] = p.AudioTrack
|
||||
|
Reference in New Issue
Block a user