Skip to content

Commit a2ccfaf

Browse files
authored
Merge pull request #5253 from ktorio/zibet27/fix-webrtc-ice-server-urls
WebRTC Client. Make `IceServer.urls` a list
2 parents 2fb8596 + 2f76634 commit a2ccfaf

File tree

17 files changed

+761
-2128
lines changed

17 files changed

+761
-2128
lines changed

gradle/artifacts/publishJvmAndCommonPublications.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ io.ktor:ktor-client-serialization/sources.jar
179179
io.ktor:ktor-client-webrtc-android/.aar
180180
io.ktor:ktor-client-webrtc-android/javadoc.jar
181181
io.ktor:ktor-client-webrtc-android/sources.jar
182+
io.ktor:ktor-client-webrtc-jvm/.jar
183+
io.ktor:ktor-client-webrtc-jvm/javadoc.jar
184+
io.ktor:ktor-client-webrtc-jvm/sources.jar
182185
io.ktor:ktor-client-webrtc/.jar
183186
io.ktor:ktor-client-webrtc/javadoc.jar
184187
io.ktor:ktor-client-webrtc/kotlin-tooling-metadata.json

ktor-client/ktor-client-webrtc/api/android/ktor-client-webrtc.api

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,16 @@ public final class io/ktor/client/webrtc/WebRtc$IceGatheringState : java/lang/En
357357
public final class io/ktor/client/webrtc/WebRtc$IceServer {
358358
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
359359
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
360-
public final fun component1 ()Ljava/lang/String;
360+
public fun <init> (Ljava/util/List;Ljava/lang/String;Ljava/lang/String;)V
361+
public synthetic fun <init> (Ljava/util/List;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
362+
public final fun component1 ()Ljava/util/List;
361363
public final fun component2 ()Ljava/lang/String;
362364
public final fun component3 ()Ljava/lang/String;
363-
public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/ktor/client/webrtc/WebRtc$IceServer;
364-
public static synthetic fun copy$default (Lio/ktor/client/webrtc/WebRtc$IceServer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/ktor/client/webrtc/WebRtc$IceServer;
365+
public final fun copy (Ljava/util/List;Ljava/lang/String;Ljava/lang/String;)Lio/ktor/client/webrtc/WebRtc$IceServer;
366+
public static synthetic fun copy$default (Lio/ktor/client/webrtc/WebRtc$IceServer;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/ktor/client/webrtc/WebRtc$IceServer;
365367
public fun equals (Ljava/lang/Object;)Z
366368
public final fun getCredential ()Ljava/lang/String;
367-
public final fun getUrls ()Ljava/lang/String;
369+
public final fun getUrls ()Ljava/util/List;
368370
public final fun getUsername ()Ljava/lang/String;
369371
public fun hashCode ()I
370372
public fun toString ()Ljava/lang/String;
@@ -788,6 +790,7 @@ public abstract class io/ktor/client/webrtc/WebRtcPeerConnection : io/ktor/clien
788790
public abstract fun removeTrack (Lio/ktor/client/webrtc/WebRtc$RtpSender;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
789791
public abstract fun removeTrack (Lio/ktor/client/webrtc/WebRtcMedia$Track;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
790792
public abstract fun restartIce ()V
793+
protected final fun runInConnectionScope (Lkotlin/jvm/functions/Function0;)V
791794
public abstract fun setLocalDescription (Lio/ktor/client/webrtc/WebRtc$SessionDescription;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
792795
public abstract fun setRemoteDescription (Lio/ktor/client/webrtc/WebRtc$SessionDescription;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
793796
}

ktor-client/ktor-client-webrtc/api/jvm/ktor-client-webrtc.api

Lines changed: 692 additions & 0 deletions
Large diffs are not rendered by default.

ktor-client/ktor-client-webrtc/api/ktor-client-webrtc.api

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,16 +355,16 @@ public final class io/ktor/client/webrtc/WebRtc$IceGatheringState : java/lang/En
355355
}
356356

357357
public final class io/ktor/client/webrtc/WebRtc$IceServer {
358-
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
359-
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
360-
public final fun component1 ()Ljava/lang/String;
358+
public fun <init> (Ljava/util/List;Ljava/lang/String;Ljava/lang/String;)V
359+
public synthetic fun <init> (Ljava/util/List;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
360+
public final fun component1 ()Ljava/util/List;
361361
public final fun component2 ()Ljava/lang/String;
362362
public final fun component3 ()Ljava/lang/String;
363-
public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/ktor/client/webrtc/WebRtc$IceServer;
364-
public static synthetic fun copy$default (Lio/ktor/client/webrtc/WebRtc$IceServer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/ktor/client/webrtc/WebRtc$IceServer;
363+
public final fun copy (Ljava/util/List;Ljava/lang/String;Ljava/lang/String;)Lio/ktor/client/webrtc/WebRtc$IceServer;
364+
public static synthetic fun copy$default (Lio/ktor/client/webrtc/WebRtc$IceServer;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/ktor/client/webrtc/WebRtc$IceServer;
365365
public fun equals (Ljava/lang/Object;)Z
366366
public final fun getCredential ()Ljava/lang/String;
367-
public final fun getUrls ()Ljava/lang/String;
367+
public final fun getUrls ()Ljava/util/List;
368368
public final fun getUsername ()Ljava/lang/String;
369369
public fun hashCode ()I
370370
public fun toString ()Ljava/lang/String;

ktor-client/ktor-client-webrtc/api/ktor-client-webrtc.klib.api

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ abstract class io.ktor.client.webrtc/WebRtcPeerConnection : io.ktor.client.webrt
172172
abstract suspend fun removeTrack(io.ktor.client.webrtc/WebRtcMedia.Track) // io.ktor.client.webrtc/WebRtcPeerConnection.removeTrack|removeTrack(io.ktor.client.webrtc.WebRtcMedia.Track){}[0]
173173
abstract suspend fun setLocalDescription(io.ktor.client.webrtc/WebRtc.SessionDescription) // io.ktor.client.webrtc/WebRtcPeerConnection.setLocalDescription|setLocalDescription(io.ktor.client.webrtc.WebRtc.SessionDescription){}[0]
174174
abstract suspend fun setRemoteDescription(io.ktor.client.webrtc/WebRtc.SessionDescription) // io.ktor.client.webrtc/WebRtcPeerConnection.setRemoteDescription|setRemoteDescription(io.ktor.client.webrtc.WebRtc.SessionDescription){}[0]
175+
final inline fun runInConnectionScope(crossinline kotlin/Function0<kotlin/Unit>) // io.ktor.client.webrtc/WebRtcPeerConnection.runInConnectionScope|runInConnectionScope(kotlin.Function0<kotlin.Unit>){}[0]
175176
final suspend fun awaitIceGatheringComplete() // io.ktor.client.webrtc/WebRtcPeerConnection.awaitIceGatheringComplete|awaitIceGatheringComplete(){}[0]
176177
open fun close() // io.ktor.client.webrtc/WebRtcPeerConnection.close|close(){}[0]
177178
}
@@ -594,19 +595,20 @@ final object io.ktor.client.webrtc/WebRtc { // io.ktor.client.webrtc/WebRtc|null
594595
}
595596

596597
final class IceServer { // io.ktor.client.webrtc/WebRtc.IceServer|null[0]
598+
constructor <init>(kotlin.collections/List<kotlin/String>, kotlin/String? = ..., kotlin/String? = ...) // io.ktor.client.webrtc/WebRtc.IceServer.<init>|<init>(kotlin.collections.List<kotlin.String>;kotlin.String?;kotlin.String?){}[0]
597599
constructor <init>(kotlin/String, kotlin/String? = ..., kotlin/String? = ...) // io.ktor.client.webrtc/WebRtc.IceServer.<init>|<init>(kotlin.String;kotlin.String?;kotlin.String?){}[0]
598600

599601
final val credential // io.ktor.client.webrtc/WebRtc.IceServer.credential|{}credential[0]
600602
final fun <get-credential>(): kotlin/String? // io.ktor.client.webrtc/WebRtc.IceServer.credential.<get-credential>|<get-credential>(){}[0]
601603
final val urls // io.ktor.client.webrtc/WebRtc.IceServer.urls|{}urls[0]
602-
final fun <get-urls>(): kotlin/String // io.ktor.client.webrtc/WebRtc.IceServer.urls.<get-urls>|<get-urls>(){}[0]
604+
final fun <get-urls>(): kotlin.collections/List<kotlin/String> // io.ktor.client.webrtc/WebRtc.IceServer.urls.<get-urls>|<get-urls>(){}[0]
603605
final val username // io.ktor.client.webrtc/WebRtc.IceServer.username|{}username[0]
604606
final fun <get-username>(): kotlin/String? // io.ktor.client.webrtc/WebRtc.IceServer.username.<get-username>|<get-username>(){}[0]
605607

606-
final fun component1(): kotlin/String // io.ktor.client.webrtc/WebRtc.IceServer.component1|component1(){}[0]
608+
final fun component1(): kotlin.collections/List<kotlin/String> // io.ktor.client.webrtc/WebRtc.IceServer.component1|component1(){}[0]
607609
final fun component2(): kotlin/String? // io.ktor.client.webrtc/WebRtc.IceServer.component2|component2(){}[0]
608610
final fun component3(): kotlin/String? // io.ktor.client.webrtc/WebRtc.IceServer.component3|component3(){}[0]
609-
final fun copy(kotlin/String = ..., kotlin/String? = ..., kotlin/String? = ...): io.ktor.client.webrtc/WebRtc.IceServer // io.ktor.client.webrtc/WebRtc.IceServer.copy|copy(kotlin.String;kotlin.String?;kotlin.String?){}[0]
611+
final fun copy(kotlin.collections/List<kotlin/String> = ..., kotlin/String? = ..., kotlin/String? = ...): io.ktor.client.webrtc/WebRtc.IceServer // io.ktor.client.webrtc/WebRtc.IceServer.copy|copy(kotlin.collections.List<kotlin.String>;kotlin.String?;kotlin.String?){}[0]
610612
final fun equals(kotlin/Any?): kotlin/Boolean // io.ktor.client.webrtc/WebRtc.IceServer.equals|equals(kotlin.Any?){}[0]
611613
final fun hashCode(): kotlin/Int // io.ktor.client.webrtc/WebRtc.IceServer.hashCode|hashCode(){}[0]
612614
final fun toString(): kotlin/String // io.ktor.client.webrtc/WebRtc.IceServer.toString|toString(){}[0]

ktor-client/ktor-client-webrtc/common/src/io/ktor/client/webrtc/WebRtc.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,23 @@ public object WebRtc {
8989
/**
9090
* Represents an ICE server configuration for WebRtc connections.
9191
*
92-
* @property urls The URL(s) of the ICE server.
92+
* @property urls The URLs of the ICE server.
9393
* @property username Optional username for the ICE server.
9494
* @property credential Optional credential for the ICE server.
9595
*
9696
* @see [MDN RTCIceServer](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer)
9797
*/
9898
public data class IceServer(
99-
val urls: String,
99+
val urls: List<String>,
100100
val username: String? = null,
101101
val credential: String? = null
102-
)
102+
) {
103+
public constructor(url: String, username: String? = null, credential: String? = null) : this(
104+
urls = listOf(url),
105+
username,
106+
credential
107+
)
108+
}
103109

104110
/**
105111
* Represents the bundle policy for media negotiation.

ktor-client/ktor-client-webrtc/common/src/io/ktor/client/webrtc/WebRtcPeerConnection.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public abstract class WebRtcPeerConnection private constructor(
130130
* Runs a [block] in the coroutine scope of the peer connection without extra dispatching.
131131
* This should be used to run some background tasks without losing thrown exceptions.
132132
*/
133-
internal inline fun runInConnectionScope(crossinline block: () -> Unit) {
133+
protected inline fun runInConnectionScope(crossinline block: () -> Unit) {
134134
coroutineScope.launch(start = CoroutineStart.UNDISPATCHED) { block() }
135135
}
136136

ktor-client/ktor-client-webrtc/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ target.android.unitTest=false
77
target.androidNative=true
88
target.desktop=false
99
target.darwin=false
10-
target.jvm=false
10+
# jvm "dummy" srcset is needed for `ktor-client-webrtc-rs`
11+
target.jvm=true
1112
target.ios=true

ktor-client/ktor-client-webrtc/ios/src/io/ktor/client/webrtc/Engine.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class IosWebRtcEngine(
4444
?: error("Please specify custom rtcFactory for custom MediaTrackFactory")
4545

4646
private fun WebRtc.IceServer.toIos(): RTCIceServer {
47-
return RTCIceServer(listOf(urls), username, credential)
47+
return RTCIceServer(urls, username, credential)
4848
}
4949

5050
override suspend fun createPeerConnection(config: WebRtcConnectionConfig): WebRtcPeerConnection {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright 2014-2026 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package io.ktor.client.webrtc.utils
6+
7+
import io.ktor.client.webrtc.WebRtcClient
8+
import io.ktor.utils.io.ExperimentalKtorApi
9+
10+
@OptIn(markerClass = [ExperimentalKtorApi::class])
11+
actual fun createTestWebRtcClient(): WebRtcClient {
12+
TODO("Not yet implemented")
13+
}
14+
15+
actual fun grantPermissions(audio: Boolean, video: Boolean) {
16+
}

0 commit comments

Comments
 (0)