Skip to content

Commit bad05f0

Browse files
authored
Fix custom RTCConfigurations not picking up server-provided ice servers when needed (#993)
1 parent 7323be5 commit bad05f0

3 files changed

Lines changed: 42 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"client-sdk-android": patch
3+
---
4+
5+
Fix custom RTCConfigurations not picking up server-provided ice servers when user-provided list is empty

livekit-android-sdk/src/main/java/io/livekit/android/room/RTCEngine.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -998,14 +998,13 @@ internal constructor(
998998

999999
// Only use server-provided servers if user doesn't provide any.
10001000
if (mergedServers.isEmpty()) {
1001-
iceServers.forEach { server ->
1002-
if (!mergedServers.contains(server)) {
1003-
mergedServers.add(server)
1004-
}
1005-
}
1001+
mergedServers.addAll(serverIceServers)
10061002
}
10071003

10081004
iceServers = mergedServers
1005+
sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN
1006+
continualGatheringPolicy =
1007+
PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY
10091008
}
10101009
?: RTCConfiguration(serverIceServers).apply {
10111010
sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN

livekit-android-test/src/test/java/io/livekit/android/room/RTCEngineMockE2ETest.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.livekit.android.room
1818

1919
import com.google.protobuf.ByteString
20+
import io.livekit.android.ConnectOptions
2021
import io.livekit.android.room.track.TrackException
2122
import io.livekit.android.test.MockE2ETest
2223
import io.livekit.android.test.events.FlowCollector
@@ -84,6 +85,38 @@ class RTCEngineMockE2ETest : MockE2ETest() {
8485
assertEquals(sentIceServers, subPeerConnection.rtcConfig.iceServers)
8586
}
8687

88+
@Test
89+
fun customRtcConfigWithEmptyIceServersUsesServerIceServers() = runTest {
90+
val connectJob = async {
91+
room.connect(
92+
url = TestData.EXAMPLE_URL,
93+
token = "token",
94+
options = ConnectOptions(
95+
rtcConfig = PeerConnection.RTCConfiguration(emptyList()).apply {
96+
iceTransportsType = PeerConnection.IceTransportsType.RELAY
97+
},
98+
),
99+
)
100+
}
101+
prepareSignal(TestData.JOIN)
102+
connectJob.await()
103+
connectPeerConnection()
104+
105+
val subPeerConnection = getSubscriberPeerConnection()
106+
assertEquals(PeerConnection.IceTransportsType.RELAY, subPeerConnection.rtcConfig.iceTransportsType)
107+
val sentIceServers = TestData.JOIN.join.iceServersList
108+
.map { it.toWebrtc() }
109+
assertEquals(sentIceServers, subPeerConnection.rtcConfig.iceServers)
110+
assertEquals(
111+
PeerConnection.SdpSemantics.UNIFIED_PLAN,
112+
subPeerConnection.rtcConfig.sdpSemantics,
113+
)
114+
assertEquals(
115+
PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY,
116+
subPeerConnection.rtcConfig.continualGatheringPolicy,
117+
)
118+
}
119+
87120
@Test
88121
fun roomConnectDoesNotHangOnWebSocketFailure() = runTest {
89122
val connectJob = async {

0 commit comments

Comments
 (0)