mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-09-26 19:51:14 +08:00
解决rtsp推流无视频时的报错
This commit is contained in:
2
go.sum
2
go.sum
@@ -10,6 +10,7 @@ github.com/Monibuca/engine/v2 v2.2.0 h1:A4SyWwzVLegd8Oa6LfSW3LpNfBmWq+MHJJLO55gv
|
||||
github.com/Monibuca/engine/v2 v2.2.0/go.mod h1:34EYjjV15G6myuHOKaJkO7y5tJ1Arq/NfC9Weacr2mc=
|
||||
github.com/Monibuca/plugin-rtp v0.0.0-20200531014802-504413c0dfcb h1:CnmoQ8XsWxs/6mulbQfTGUa8cPr6c/3bkkTsNozRBwE=
|
||||
github.com/Monibuca/plugin-rtp v0.0.0-20200531014802-504413c0dfcb/go.mod h1:8HxBilkF835Lepe/DLUCjaw1mRiu3MxTDsG7g9UcfZA=
|
||||
github.com/Monibuca/plugin-rtp v1.0.0 h1:yksNsIIGxoKX8UZirkAUK+mGZ/XoEeS2vqbIqtqXyCg=
|
||||
github.com/Monibuca/plugin-rtp v1.0.0/go.mod h1:0xkNm23a/BjVnEMz1zXyOqfEjoVmGe3PJqPNF1KyFGc=
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
|
||||
@@ -25,6 +26,7 @@ github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRn
|
||||
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/mask-pp/rtp-ps v1.0.0 h1:JFxuJL9N+gD1ldgJlAy3b7rYfY8wAVHi9ODNmdP4+EE=
|
||||
github.com/mask-pp/rtp-ps v1.0.0/go.mod h1:jCxsZ2G7z/jX+aqFypEWMePnhNrfnUiXUEKm6Xp0vgU=
|
||||
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
|
60
session.go
60
session.go
@@ -319,9 +319,9 @@ func (session *RTSP) handleRequest(req *Request) {
|
||||
session.SDPMap = ParseSDP(req.Body)
|
||||
if session.Publish(streamPath) {
|
||||
if session.ASdp, session.HasAudio = session.SDPMap["audio"]; session.HasAudio {
|
||||
if len(session.ASdp.Control) >0 {
|
||||
if len(session.ASdp.Control) > 0 {
|
||||
session.WriteASC(session.ASdp.Config)
|
||||
}else{
|
||||
} else {
|
||||
session.setAudioFormat()
|
||||
}
|
||||
Printf("audio codec[%s]\n", session.ASdp.Codec)
|
||||
@@ -379,36 +379,38 @@ func (session *RTSP) handleRequest(req *Request) {
|
||||
// res.Status = "Error Status"
|
||||
// return
|
||||
//}
|
||||
vPath := ""
|
||||
if strings.Index(strings.ToLower(session.VSdp.Control), "rtsp://") == 0 {
|
||||
vControlUrl, err := url.Parse(session.VSdp.Control)
|
||||
if err != nil {
|
||||
res.StatusCode = 500
|
||||
res.Status = "Invalid VControl"
|
||||
return
|
||||
var vPath, aPath string
|
||||
if session.HasVideo {
|
||||
if strings.Index(strings.ToLower(session.VSdp.Control), "rtsp://") == 0 {
|
||||
vControlUrl, err := url.Parse(session.VSdp.Control)
|
||||
if err != nil {
|
||||
res.StatusCode = 500
|
||||
res.Status = "Invalid VControl"
|
||||
return
|
||||
}
|
||||
if vControlUrl.Port() == "" {
|
||||
vControlUrl.Host = fmt.Sprintf("%s:554", vControlUrl.Host)
|
||||
}
|
||||
vPath = vControlUrl.String()
|
||||
} else {
|
||||
vPath = session.VSdp.Control
|
||||
}
|
||||
if vControlUrl.Port() == "" {
|
||||
vControlUrl.Host = fmt.Sprintf("%s:554", vControlUrl.Host)
|
||||
}
|
||||
vPath = vControlUrl.String()
|
||||
} else {
|
||||
vPath = session.VSdp.Control
|
||||
}
|
||||
|
||||
aPath := ""
|
||||
if strings.Index(strings.ToLower(session.ASdp.Control), "rtsp://") == 0 {
|
||||
aControlUrl, err := url.Parse(session.ASdp.Control)
|
||||
if err != nil {
|
||||
res.StatusCode = 500
|
||||
res.Status = "Invalid AControl"
|
||||
return
|
||||
if session.HasAudio {
|
||||
if strings.Index(strings.ToLower(session.ASdp.Control), "rtsp://") == 0 {
|
||||
aControlUrl, err := url.Parse(session.ASdp.Control)
|
||||
if err != nil {
|
||||
res.StatusCode = 500
|
||||
res.Status = "Invalid AControl"
|
||||
return
|
||||
}
|
||||
if aControlUrl.Port() == "" {
|
||||
aControlUrl.Host = fmt.Sprintf("%s:554", aControlUrl.Host)
|
||||
}
|
||||
aPath = aControlUrl.String()
|
||||
} else {
|
||||
aPath = session.ASdp.Control
|
||||
}
|
||||
if aControlUrl.Port() == "" {
|
||||
aControlUrl.Host = fmt.Sprintf("%s:554", aControlUrl.Host)
|
||||
}
|
||||
aPath = aControlUrl.String()
|
||||
} else {
|
||||
aPath = session.ASdp.Control
|
||||
}
|
||||
|
||||
mtcp := regexp.MustCompile("interleaved=(\\d+)(-(\\d+))?")
|
||||
|
Reference in New Issue
Block a user