Committed by
GitHub
Force relay client configuration (#155)
* Update protocol submodule * Force relay configuration * tests
正在显示
5 个修改的文件
包含
32 行增加
和
4 行删除
| @@ -201,6 +201,14 @@ internal constructor( | @@ -201,6 +201,14 @@ internal constructor( | ||
| 201 | PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY | 201 | PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | + if (joinResponse.hasClientConfiguration()) { | ||
| 205 | + val clientConfig = joinResponse.clientConfiguration | ||
| 206 | + | ||
| 207 | + if (clientConfig.forceRelay == LivekitModels.ClientConfigSetting.ENABLED) { | ||
| 208 | + rtcConfig.iceTransportsType = PeerConnection.IceTransportsType.RELAY | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | + | ||
| 204 | _publisher?.close() | 212 | _publisher?.close() |
| 205 | _publisher = pctFactory.create( | 213 | _publisher = pctFactory.create( |
| 206 | rtcConfig, | 214 | rtcConfig, |
| @@ -7,7 +7,8 @@ private class MockNativePeerConnectionFactory : NativePeerConnectionFactory { | @@ -7,7 +7,8 @@ private class MockNativePeerConnectionFactory : NativePeerConnectionFactory { | ||
| 7 | } | 7 | } |
| 8 | 8 | ||
| 9 | class MockPeerConnection( | 9 | class MockPeerConnection( |
| 10 | - val observer: PeerConnection.Observer? | 10 | + val rtcConfig: RTCConfiguration, |
| 11 | + val observer: Observer? | ||
| 11 | ) : PeerConnection(MockNativePeerConnectionFactory()) { | 12 | ) : PeerConnection(MockNativePeerConnectionFactory()) { |
| 12 | 13 | ||
| 13 | private var closed = false | 14 | private var closed = false |
| @@ -5,8 +5,10 @@ import io.livekit.android.mock.MockPeerConnection | @@ -5,8 +5,10 @@ import io.livekit.android.mock.MockPeerConnection | ||
| 5 | import io.livekit.android.util.toOkioByteString | 5 | import io.livekit.android.util.toOkioByteString |
| 6 | import io.livekit.android.util.toPBByteString | 6 | import io.livekit.android.util.toPBByteString |
| 7 | import kotlinx.coroutines.ExperimentalCoroutinesApi | 7 | import kotlinx.coroutines.ExperimentalCoroutinesApi |
| 8 | +import livekit.LivekitModels | ||
| 8 | import livekit.LivekitRtc | 9 | import livekit.LivekitRtc |
| 9 | import org.junit.Assert | 10 | import org.junit.Assert |
| 11 | +import org.junit.Assert.assertEquals | ||
| 10 | import org.junit.Before | 12 | import org.junit.Before |
| 11 | import org.junit.Test | 13 | import org.junit.Test |
| 12 | import org.junit.runner.RunWith | 14 | import org.junit.runner.RunWith |
| @@ -95,4 +97,21 @@ class RTCEngineMockE2ETest : MockE2ETest() { | @@ -95,4 +97,21 @@ class RTCEngineMockE2ETest : MockE2ETest() { | ||
| 95 | Assert.assertNotEquals(oldToken, newToken) | 97 | Assert.assertNotEquals(oldToken, newToken) |
| 96 | Assert.assertEquals(SignalClientTest.REFRESH_TOKEN.refreshToken, newToken) | 98 | Assert.assertEquals(SignalClientTest.REFRESH_TOKEN.refreshToken, newToken) |
| 97 | } | 99 | } |
| 100 | + | ||
| 101 | + @Test | ||
| 102 | + fun relayConfiguration() = runTest { | ||
| 103 | + connect(with(SignalClientTest.JOIN.toBuilder()) { | ||
| 104 | + join = with(join.toBuilder()) { | ||
| 105 | + clientConfiguration = with(LivekitModels.ClientConfiguration.newBuilder()) { | ||
| 106 | + forceRelay = LivekitModels.ClientConfigSetting.ENABLED | ||
| 107 | + build() | ||
| 108 | + } | ||
| 109 | + build() | ||
| 110 | + } | ||
| 111 | + build() | ||
| 112 | + }) | ||
| 113 | + | ||
| 114 | + val pubPeerConnection = rtcEngine.subscriber.peerConnection as MockPeerConnection | ||
| 115 | + assertEquals(PeerConnection.IceTransportsType.RELAY, pubPeerConnection.rtcConfig.iceTransportsType) | ||
| 116 | + } | ||
| 98 | } | 117 | } |
| @@ -4,11 +4,11 @@ import io.livekit.android.mock.MockPeerConnection | @@ -4,11 +4,11 @@ import io.livekit.android.mock.MockPeerConnection | ||
| 4 | 4 | ||
| 5 | class MockPeerConnectionFactory : PeerConnectionFactory(1L) { | 5 | class MockPeerConnectionFactory : PeerConnectionFactory(1L) { |
| 6 | override fun createPeerConnectionInternal( | 6 | override fun createPeerConnectionInternal( |
| 7 | - rtcConfig: PeerConnection.RTCConfiguration?, | 7 | + rtcConfig: PeerConnection.RTCConfiguration, |
| 8 | constraints: MediaConstraints?, | 8 | constraints: MediaConstraints?, |
| 9 | observer: PeerConnection.Observer?, | 9 | observer: PeerConnection.Observer?, |
| 10 | sslCertificateVerifier: SSLCertificateVerifier? | 10 | sslCertificateVerifier: SSLCertificateVerifier? |
| 11 | ): PeerConnection { | 11 | ): PeerConnection { |
| 12 | - return MockPeerConnection(observer) | 12 | + return MockPeerConnection(rtcConfig, observer) |
| 13 | } | 13 | } |
| 14 | } | 14 | } |
-
请 注册 或 登录 后发表评论