Committed by
GitHub
treat completed as connected for ice connection state (#21)
正在显示
2 个修改的文件
包含
18 行增加
和
2 行删除
| @@ -11,6 +11,7 @@ import io.livekit.android.room.util.* | @@ -11,6 +11,7 @@ import io.livekit.android.room.util.* | ||
| 11 | import io.livekit.android.util.CloseableCoroutineScope | 11 | import io.livekit.android.util.CloseableCoroutineScope |
| 12 | import io.livekit.android.util.Either | 12 | import io.livekit.android.util.Either |
| 13 | import io.livekit.android.util.LKLog | 13 | import io.livekit.android.util.LKLog |
| 14 | +import io.livekit.android.webrtc.isConnected | ||
| 14 | import kotlinx.coroutines.CoroutineDispatcher | 15 | import kotlinx.coroutines.CoroutineDispatcher |
| 15 | import kotlinx.coroutines.SupervisorJob | 16 | import kotlinx.coroutines.SupervisorJob |
| 16 | import kotlinx.coroutines.delay | 17 | import kotlinx.coroutines.delay |
| @@ -324,7 +325,7 @@ internal constructor( | @@ -324,7 +325,7 @@ internal constructor( | ||
| 324 | return | 325 | return |
| 325 | } | 326 | } |
| 326 | 327 | ||
| 327 | - if (this.publisher.peerConnection.iceConnectionState() == PeerConnection.IceConnectionState.CONNECTED) { | 328 | + if (this.publisher.peerConnection.isConnected()) { |
| 328 | return | 329 | return |
| 329 | } | 330 | } |
| 330 | 331 | ||
| @@ -334,7 +335,7 @@ internal constructor( | @@ -334,7 +335,7 @@ internal constructor( | ||
| 334 | // wait until publisher ICE connected | 335 | // wait until publisher ICE connected |
| 335 | val endTime = SystemClock.elapsedRealtime() + MAX_ICE_CONNECT_TIMEOUT_MS; | 336 | val endTime = SystemClock.elapsedRealtime() + MAX_ICE_CONNECT_TIMEOUT_MS; |
| 336 | while (SystemClock.elapsedRealtime() < endTime) { | 337 | while (SystemClock.elapsedRealtime() < endTime) { |
| 337 | - if (this.publisher.peerConnection.iceConnectionState() == PeerConnection.IceConnectionState.CONNECTED) { | 338 | + if (this.publisher.peerConnection.isConnected()) { |
| 338 | return | 339 | return |
| 339 | } | 340 | } |
| 340 | delay(50) | 341 | delay(50) |
| 1 | +package io.livekit.android.webrtc | ||
| 2 | + | ||
| 3 | +import org.webrtc.PeerConnection | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Completed state is a valid state for a connected connection, so this should be used | ||
| 7 | + * when checking for a connected state | ||
| 8 | + */ | ||
| 9 | +internal fun PeerConnection.isConnected(): Boolean { | ||
| 10 | + return when (iceConnectionState()) { | ||
| 11 | + PeerConnection.IceConnectionState.CONNECTED, | ||
| 12 | + PeerConnection.IceConnectionState.COMPLETED -> true | ||
| 13 | + else -> false | ||
| 14 | + } | ||
| 15 | +} |
-
请 注册 或 登录 后发表评论