client: prevent switching protocol when protocol is fixed to UDP (#607)

This commit is contained in:
Alessandro Ros
2024-08-25 20:40:56 +02:00
committed by GitHub
parent 5865d7b7ac
commit ff5bda0e67
2 changed files with 6 additions and 6 deletions

View File

@@ -971,15 +971,15 @@ func (c *Client) atLeastOneUDPPacketHasBeenReceived() bool {
for _, ct := range c.medias {
lft := atomic.LoadInt64(ct.udpRTPListener.lastPacketTime)
if lft != 0 {
return false
return true
}
lft = atomic.LoadInt64(ct.udpRTCPListener.lastPacketTime)
if lft != 0 {
return false
return true
}
}
return true
return false
}
func (c *Client) isInUDPTimeout() bool {
@@ -1007,10 +1007,10 @@ func (c *Client) isInTCPTimeout() bool {
func (c *Client) doCheckTimeout() error {
if *c.effectiveTransport == TransportUDP ||
*c.effectiveTransport == TransportUDPMulticast {
if c.checkTimeoutInitial && !c.backChannelSetupped {
if c.checkTimeoutInitial && !c.backChannelSetupped && c.Transport == nil {
c.checkTimeoutInitial = false
if c.atLeastOneUDPPacketHasBeenReceived() {
if !c.atLeastOneUDPPacketHasBeenReceived() {
err := c.trySwitchingProtocol()
if err != nil {
return err

View File

@@ -2278,7 +2278,7 @@ func TestClientPlayErrorTimeout(t *testing.T) {
})
require.NoError(t, err2)
if transport == "udp" || transport == "auto" {
if transport == "auto" {
// write a packet to skip the protocol autodetection feature
_, err2 = l1.WriteTo(testRTPPacketMarshaled, &net.UDPAddr{
IP: net.ParseIP("127.0.0.1"),