Skip to content

Commit

Permalink
client: prevent switching protocol when protocol is fixed to UDP
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Aug 25, 2024
1 parent 7df898a commit 687e359
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 979 in client.go

View check run for this annotation

Codecov / codecov/patch

client.go#L979

Added line #L979 was not covered by tests
}
}
return true
return false
}

func (c *Client) isInUDPTimeout() bool {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client_play_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 687e359

Please sign in to comment.