mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-04 23:32:44 +08:00
This commit is contained in:
@@ -491,6 +491,22 @@ func (co *PeerConnection) addAdditionalCandidates(firstMedia *sdp.MediaDescripti
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, host := range co.AdditionalHosts {
|
for _, host := range co.AdditionalHosts {
|
||||||
|
var ips []string
|
||||||
|
if net.ParseIP(host) != nil {
|
||||||
|
ips = []string{host}
|
||||||
|
} else {
|
||||||
|
tmp, err := net.LookupIP(host)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ips = make([]string, len(tmp))
|
||||||
|
for i, e := range tmp {
|
||||||
|
ips[i] = e.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ip := range ips {
|
||||||
newAttrs := append([]sdp.Attribute(nil), firstMedia.Attributes[:i]...)
|
newAttrs := append([]sdp.Attribute(nil), firstMedia.Attributes[:i]...)
|
||||||
|
|
||||||
if co.ICEUDPMux != nil {
|
if co.ICEUDPMux != nil {
|
||||||
@@ -504,11 +520,11 @@ func (co *PeerConnection) addAdditionalCandidates(firstMedia *sdp.MediaDescripti
|
|||||||
|
|
||||||
newAttrs = append(newAttrs, sdp.Attribute{
|
newAttrs = append(newAttrs, sdp.Attribute{
|
||||||
Key: "candidate",
|
Key: "candidate",
|
||||||
Value: id + " 1 udp 2130706431 " + host + " " + port + " typ host",
|
Value: id + " 1 udp 2130706431 " + ip + " " + port + " typ host",
|
||||||
})
|
})
|
||||||
newAttrs = append(newAttrs, sdp.Attribute{
|
newAttrs = append(newAttrs, sdp.Attribute{
|
||||||
Key: "candidate",
|
Key: "candidate",
|
||||||
Value: id + " 2 udp 2130706431 " + host + " " + port + " typ host",
|
Value: id + " 2 udp 2130706431 " + ip + " " + port + " typ host",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,17 +539,18 @@ func (co *PeerConnection) addAdditionalCandidates(firstMedia *sdp.MediaDescripti
|
|||||||
|
|
||||||
newAttrs = append(newAttrs, sdp.Attribute{
|
newAttrs = append(newAttrs, sdp.Attribute{
|
||||||
Key: "candidate",
|
Key: "candidate",
|
||||||
Value: id + " 1 tcp 1671430143 " + host + " " + port + " typ host tcptype passive",
|
Value: id + " 1 tcp 1671430143 " + ip + " " + port + " typ host tcptype passive",
|
||||||
})
|
})
|
||||||
newAttrs = append(newAttrs, sdp.Attribute{
|
newAttrs = append(newAttrs, sdp.Attribute{
|
||||||
Key: "candidate",
|
Key: "candidate",
|
||||||
Value: id + " 2 tcp 1671430143 " + host + " " + port + " typ host tcptype passive",
|
Value: id + " 2 tcp 1671430143 " + ip + " " + port + " typ host tcptype passive",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
newAttrs = append(newAttrs, firstMedia.Attributes[i:]...)
|
newAttrs = append(newAttrs, firstMedia.Attributes[i:]...)
|
||||||
firstMedia.Attributes = newAttrs
|
firstMedia.Attributes = newAttrs
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user