Fix PATCH stream with same name and src

This commit is contained in:
Alexey Khit
2023-07-20 22:29:59 +03:00
parent 870e9c3688
commit 7308652f6e
+12 -2
View File
@@ -57,12 +57,22 @@ func Patch(name string, source string) *Stream {
if u, err := url.Parse(source); err == nil && u.Scheme == "rtsp" && len(u.Path) > 1 {
rtspName := u.Path[1:]
if stream, ok := streams[rtspName]; ok {
// link (alias) stream[name] to stream[rtspName]
streams[name] = stream
if streams[name] != stream {
// link (alias) streams[name] to streams[rtspName]
streams[name] = stream
}
return stream
}
}
if stream, ok := streams[source]; ok {
if name != source {
// link (alias) streams[name] to streams[source]
streams[name] = stream
}
return stream
}
// check if src has supported scheme
if !HasProducer(source) {
return nil