WebRTC Kotlin Multiplatform SDK is a comprehensive toolkit for integrating WebRTC functionality into your multiplatform projects. It supports Android, iOS, JS. Other platforms - PRs are welcome.
API | Android | iOS | JS | JVM |
---|---|---|---|---|
Audio/Video | ✅ | ✅ | ✅ | ✅ |
Data channel | ✅ | ✅ | ✅ | ✅ |
Screen Capture | ✅ | ✅ | ✅ |
Current revision: M114
The library is published to Maven Central.
Shared module build.gradle.kts
kotlin {
cocoapods {
version = "1.0.0"
summary = "Shared module"
homepage = "not published"
ios.deploymentTarget = "11.0"
pod("WebRTC-SDK") {
version = "114.5735.02"
linkOnly = true
}
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "shared"
export("com.shepeliev:webrtc-kmp:$webRtcKmpVersion")
transitiveExport = true
}
xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG
xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE
}
android()
ios()
iosSimulatorArm64()
js {
useCommonJs()
browser()
}
jvm()
sourceSets {
val commonMain by getting {
dependencies {
api("com.shepeliev:webrtc-kmp:$webRtcKmpVersion")
}
}
val iosMain by getting
val iosSimulatorArm64Main by getting
iosSimulatorArm64Main.dependsOn(iosMain)
}
}
dependencies {
// Choose the right architecture for your system
// see https://github.com/devopvoid/webrtc-java for supported platforms
val osName = System.getProperty("os.name").lowercase()
val hostOS = if (osName.contains("mac")) {
"macos"
} else if (osName.contains("linux")) {
"linux"
} else if (osName.contains("windows")) {
"windows"
} else {
throw IllegalStateException("Unsupported OS: $osName")
}
val hostArch = when (val arch = System.getProperty("os.arch").lowercase()) {
"amd64" -> "x86_64"
else -> arch
}
jvmMainImplementation(
group = "dev.onvoid.webrtc",
name = "webrtc-java",
version = "0.8.0",
classifier = "$hostOS-$hostArch"
)
}
Also add the following to your Podfile
in the target section:
use_frameworks!
pod 'shared', :path => '../shared'
Please refer to sample.
// Set MediaProjection permission intent using `MediaProjectionIntentHolder`
val mediaProjectionPermissionLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.StartActivityForResult()
) { activityResult ->
activityResult.data?.also {
MediaProjectionIntentHolder.intent = it
}
}