Skip to content

HackWebRTC/kmp-webrtc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

kmp-webrtc

KMP wrapper for WebRTC.

Maven Central Version Main branch status

Supported platforms

Platform ๐Ÿ› Builds๐Ÿ›  + ๐Ÿ”ฌTests๐Ÿ”ฌ
Android ๐Ÿš€
iOS ๐Ÿš€
macOS ๐Ÿš€
Windows X64 ๐Ÿš€
JS (Chrome) ๐Ÿš€
Linux X64 ๐Ÿš€

Dependency

You only need to add gradle dependency:

// add common source set dependency
kotlin {
  sourceSets {
    val commonMain by getting {
      dependencies {
        implementation("com.piasy:kmp-webrtc:$version")
      }
    }
  }
}

Usage

Env Setup

Download and extract the libs dir:

wget https://github.com/HackWebRTC/kmp-webrtc/releases/latest/download/libs.zip
unzip -o libs.zip

macOS

You need to install RVM to manage your ruby version, and install gems. You need to use homebrew to install the following tools:

brew install cocoapods xcodegen
# if you have installed them earlier, you need to remove them at first,
# or run brew link --overwrite xcodegen cocoapods

You may need to restart your system so that Android Studio could use the correct ruby.

Windows

Follow this guide to install Visual Studio 2022 and necessary tools.

Example

Android

Open the project (the repo root dir) in Android studio, and run the example.androidApp target.

iOS

./scripts/setup_apple.sh
# open example/iosApp/iosApp.xcworkspace in Xcode, and run it.

macOS

./scripts/setup_apple.sh
# open example/macApp/macApp.xcworkspace in Xcode, and run it.

Windows

.\scripts\setup_windows.bat
# open example\winApp\winApp.sln in Visual Studio 2022, and run it.

Linux

./scripts/build_linux_demo.sh
./example/linuxApp/build/loopback <path to video file>

JS

./gradlew :example:webApp:jsBrowserRun

Build WebRTC

hack_webrtc_43659 branch of HackWebRTC/webrtc, which is based on m133.

File structure for macOS:

- webrtc_apple
    - src
- kmp-webrtc

File structure for Windows:

- webrtc_windows
    - src
- kmp-webrtc

File structure for Linux:

- webrtc_android
    - src
- kmp-webrtc

Android

CPP code need to be built on Linux.

# on Linux
./sdk/build_android_libs.sh <output path> --skip-build-ffmpeg

# on macOS, copy prebuilt_libs into sdk/android_gradle/webrtc/
# then build aar like this:
pushd ../webrtc_apple/src/sdk/android_gradle/ && \
./gradlew :webrtc:assembleRelease && \
cp webrtc/build/outputs/aar/webrtc-release.aar \
  ../../../../kmp-webrtc/libs/android/webrtc.aar && \
popd

Apple

pushd ../webrtc_apple/src/ && \
./sdk/build_apple_framework.sh ../../kmp-webrtc/libs --skip-build-ffmpeg && \
popd

Windows

In x64 Native Tools Command Prompt for VS 2022:

.\sdk\build_windows_libs.bat ..\..\kmp-webrtc

Linux

pushd ../webrtc_android/src/ && \
./sdk/build_linux_libs.sh ../../kmp-webrtc/libs --skip-build-ffmpeg && \
popd

Upload libs zip

zip -ry build/libs.zip libs

Then upload build/libs.zip to GitHub releases.

Publish

Maven central portal credentials and signing configs are set in ~/.gradle/gradle.properties.

Login to https://central.sonatype.com/publishing/deployments, and release them manually.

Other projects