Optimize RTSP URL generation: eliminate duplicate streams
Changes: - RTSP now generates single URL based on credentials availability * With credentials: only rtsp://user:pass@host/path * Without credentials: only rtsp://host/path - HTTP/HTTPS unchanged: still generates 4 auth variants - Improved deduplication efficiency from 66% to 100% for RTSP - Added comprehensive test coverage for protocol auth behavior This reduces unnecessary stream testing and improves discovery speed
This commit is contained in:
@@ -323,15 +323,17 @@ func (b *Builder) BuildURLsFromEntry(entry models.CameraEntry, ctx BuildContext)
|
||||
}
|
||||
|
||||
case "rtsp", "rtsps":
|
||||
// For RTSP: generate with and without credentials
|
||||
// For RTSP: generate ONLY with credentials if provided, otherwise without
|
||||
if ctx.Username != "" && ctx.Password != "" {
|
||||
// Credentials provided - generate ONLY URL with auth
|
||||
addURL(b.BuildURL(entry, ctx))
|
||||
} else {
|
||||
// No credentials - generate ONLY URL without auth
|
||||
ctxNoAuth := ctx
|
||||
ctxNoAuth.Username = ""
|
||||
ctxNoAuth.Password = ""
|
||||
addURL(b.BuildURL(entry, ctxNoAuth))
|
||||
}
|
||||
// Without credentials (for open cameras)
|
||||
ctxNoAuth := ctx
|
||||
ctxNoAuth.Username = ""
|
||||
ctxNoAuth.Password = ""
|
||||
addURL(b.BuildURL(entry, ctxNoAuth))
|
||||
|
||||
case "http", "https":
|
||||
// For HTTP/HTTPS: ALWAYS generate 4 authentication variants
|
||||
|
||||
Reference in New Issue
Block a user