diff --git a/client.go b/client.go index 8c3235eb..e7d75157 100644 --- a/client.go +++ b/client.go @@ -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 diff --git a/client_play_test.go b/client_play_test.go index 9b5ece83..f505598f 100644 --- a/client_play_test.go +++ b/client_play_test.go @@ -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"),