mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-09-26 19:51:14 +08:00
对推流可能无法解析的情况进行报错
This commit is contained in:
10
publisher.go
10
publisher.go
@@ -3,6 +3,8 @@ package rtsp
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -18,14 +20,13 @@ type RTSPPublisher struct {
|
||||
RTSPIO
|
||||
}
|
||||
|
||||
func (p *RTSPPublisher) SetTracks() {
|
||||
func (p *RTSPPublisher) SetTracks() error {
|
||||
p.Tracks = make([]common.AVTrack, len(p.tracks))
|
||||
for trackId, track := range p.tracks {
|
||||
md := track.MediaDescription()
|
||||
v, ok := md.Attribute("rtpmap")
|
||||
if !ok {
|
||||
p.Error("rtpmap attribute not found")
|
||||
return
|
||||
return errors.New("rtpmap attribute not found")
|
||||
}
|
||||
v = strings.TrimSpace(v)
|
||||
vals := strings.Split(v, " ")
|
||||
@@ -108,7 +109,10 @@ func (p *RTSPPublisher) SetTracks() {
|
||||
} else {
|
||||
plugin.Warn("aac no config")
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupport codec:%s", keyval[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -91,7 +91,9 @@ func (conf *RTSPConfig) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (*
|
||||
if err := plugin.Publish(ctx.Path, p); err == nil {
|
||||
p.tracks = ctx.Tracks
|
||||
p.stream = gortsplib.NewServerStream(ctx.Tracks)
|
||||
p.SetTracks()
|
||||
if err = p.SetTracks(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conf.Store(ctx.Conn, p)
|
||||
conf.Store(ctx.Session, p)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user