Fix extra slash for RTSP SETUP #1236

This commit is contained in:
Alex X
2025-03-09 17:08:25 +03:00
parent b6934922fa
commit 3954a555f8
2 changed files with 3 additions and 4 deletions

View File

@@ -237,13 +237,11 @@ func (c *Conn) SetupMedia(media *core.Media) (byte, error) {
rawURL := media.ID // control
if !strings.Contains(rawURL, "://") {
rawURL = c.URL.String()
if !strings.HasSuffix(rawURL, "/") {
// prefix check for https://github.com/AlexxIT/go2rtc/issues/1236
if !strings.HasSuffix(rawURL, "/") && !strings.HasPrefix(media.ID, "/") {
rawURL += "/"
}
rawURL += media.ID
} else if strings.HasPrefix(rawURL, "rtsp://rtsp://") {
// fix https://github.com/AlexxIT/go2rtc/issues/830
rawURL = rawURL[7:]
}
trackURL, err := urlParse(rawURL)
if err != nil {

View File

@@ -117,6 +117,7 @@ func findFmtpLine(payloadType uint8, descriptions []*sdp.MediaDescription) strin
// 1. Content-Base: rtsp://::ffff:192.168.1.123/onvif/profile.1/
// 2. Content-Base: rtsp://rtsp://turret2-cam.lan:554/stream1/
func urlParse(rawURL string) (*url.URL, error) {
// fix https://github.com/AlexxIT/go2rtc/issues/830
if strings.HasPrefix(rawURL, "rtsp://rtsp://") {
rawURL = rawURL[7:]
}