webrtc-kmp

Comprehensive toolkit for integrating WebRTC functionality into projects. Supports audio/video, data channels, and screen capture. Compatible with Android, iOS, and JS/WasmJS. Detailed installation and usage instructions provided.

Android JVMKotlin/NativeWasmJS
GitHub stars310
Authorsshepeliev
Open issues19
LicenseApache License 2.0
Creation dateover 5 years ago

Last activity9 months ago
Latest release0.125.11 (9 months ago)

WebRTC KMP Maven Central

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 implementation map

API Android iOS JS/WasmJS
Audio/Video
Data channel
Screen Capture

WebRTC revision

Current revision: M125

Installation

The library is published to Maven Central.

Add dependency to your common source set:

commonMain.dependencies {
  dependencies {
    implementation("com.shepeliev:webrtc-kmp:$webRtcKmpVersion")
  }
}

Running on iOS

On iOS, the WebRTC SDK is not linked as a transitive dependency, so you need to add it to your iOS project manually. This can be done using CocoaPods or SPM, depending on your project setup. Here is an example of how to link the WebRTC SDK using CocoaPods in build.gradle.kts:

kotlin {
  cocoapods {
    version = "1.0.0"
    summary = "Shared module"
    homepage = "not published"
    ios.deploymentTarget = "13.0"
   
    pod("WebRTC-SDK") { 
      version = "125.6422.05"
      moduleName = "WebRTC"
    }
  
    podfile = project.file("../iosApp/Podfile")
  
    framework {
      baseName = "shared"
      isStatic = true  
    }
  
    xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG
    xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE
  }

    iosX64()
    iosArm64()
    iosSimulatorArm64()
}

Also add the following to your Podfile in the target section:

use_frameworks!
pod 'shared', :path => '../shared'

Usage

Please refer to sample.

Screen Share in Android

// Set MediaProjection permission intent using `MediaProjectionIntentHolder`
val mediaProjectionPermissionLauncher = rememberLauncherForActivityResult(
    contract = ActivityResultContracts.StartActivityForResult()
) { activityResult ->
    activityResult.data?.also {
        MediaProjectionIntentHolder.intent = it
    }
}
Android JVMKotlin/NativeWasmJS
GitHub stars310
Authorsshepeliev
Open issues19
LicenseApache License 2.0
Creation dateover 5 years ago

Last activity9 months ago
Latest release0.125.11 (9 months ago)

WebRTC KMP Maven Central

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 implementation map

API Android iOS JS/WasmJS
Audio/Video
Data channel
Screen Capture

WebRTC revision

Current revision: M125

Installation

The library is published to Maven Central.

Add dependency to your common source set:

commonMain.dependencies {
  dependencies {
    implementation("com.shepeliev:webrtc-kmp:$webRtcKmpVersion")
  }
}

Running on iOS

On iOS, the WebRTC SDK is not linked as a transitive dependency, so you need to add it to your iOS project manually. This can be done using CocoaPods or SPM, depending on your project setup. Here is an example of how to link the WebRTC SDK using CocoaPods in build.gradle.kts:

kotlin {
  cocoapods {
    version = "1.0.0"
    summary = "Shared module"
    homepage = "not published"
    ios.deploymentTarget = "13.0"
   
    pod("WebRTC-SDK") { 
      version = "125.6422.05"
      moduleName = "WebRTC"
    }
  
    podfile = project.file("../iosApp/Podfile")
  
    framework {
      baseName = "shared"
      isStatic = true  
    }
  
    xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG
    xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE
  }

    iosX64()
    iosArm64()
    iosSimulatorArm64()
}

Also add the following to your Podfile in the target section:

use_frameworks!
pod 'shared', :path => '../shared'

Usage

Please refer to sample.

Screen Share in Android

// Set MediaProjection permission intent using `MediaProjectionIntentHolder`
val mediaProjectionPermissionLauncher = rememberLauncherForActivityResult(
    contract = ActivityResultContracts.StartActivityForResult()
) { activityResult ->
    activityResult.data?.also {
        MediaProjectionIntentHolder.intent = it
    }
}