Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,31 @@
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
**/[Ll]ibrary/
**/[Tt]emp/
**/[Oo]bj/
**/[Bb]uild/
**/[Bb]uilds/
**/[Ll]ogs/
**/[Uu]ser[Ss]ettings/

**/[Aa]ssets/Samples/
**/[Aa]ssets/Samples.meta
**/[Aa]ssets/TextMesh Pro/
**/[Aa]ssets/TextMesh Pro.meta

# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/
**/[Mm]emoryCaptures/

# Recordings can get excessive in size
/[Rr]ecordings/
**/[Rr]ecordings/

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*
**/[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/
Expand Down Expand Up @@ -65,11 +70,11 @@ sysinfo.txt
crashlytics-build.properties

# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
**/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*

# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
**/[Aa]ssets/[Ss]treamingAssets/aa.meta
**/[Aa]ssets/[Ss]treamingAssets/aa/*

.DS_Store

Expand All @@ -81,5 +86,5 @@ downloads~
/Runtime/Plugins/ffi-*/livekit_ffi.h.meta

# Ignore temporaries from GameCI
/[Aa]rtifacts/
/[Cc]odeCoverage/
**/[Aa]rtifacts/
**/[Cc]odeCoverage/
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "attach",
"name": "Rust/C++ Unity auto",
"waitFor": true,
"program": "Unity",
"sourceLanguages": ["rust"]
},
{
"type": "lldb",
"request": "attach",
"name": "Rust/C++ Unity manual",
"pid": "${command:pickProcess}", // For manual picking, if there are multiple Unity instances running
"sourceLanguages": ["rust"]
}
]
}
80 changes: 67 additions & 13 deletions BuildScripts~/build_ffi_locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,91 @@ GREEN='\033[0;32m'
RESET='\033[0m'

usage() {
echo "Usage: $0 <platform>"
echo "Usage: $0 <platform> [build_type]"
echo ""
echo "Platforms:"
echo " macos Build for aarch64-apple-darwin"
echo " android Build for aarch64-linux-android"
echo " ios Build for aarch64-apple-ios"
echo ""
echo "Build types (optional, defaults to 'debug'):"
echo " release Optimized release build"
echo " debug Debug build"
exit 1
}

if [ $# -ne 1 ]; then
echo -e "${RED}Error: Expected exactly one argument.${RESET}"
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo -e "${RED}Error: Expected one or two arguments.${RESET}"
usage
fi

PLATFORM="$1"
BUILD_TYPE="${2:-debug}"

case "$BUILD_TYPE" in
release)
BUILD_FLAG="--release"
BUILD_DIR="release"
;;
debug)
BUILD_FLAG=""
BUILD_DIR="debug"
;;
*)
echo -e "${RED}Error: Unknown build type '$BUILD_TYPE'. Expected 'release' or 'debug'.${RESET}"
usage
;;
esac

case "$PLATFORM" in
# MACOS
macos)
echo "Building for macOS (aarch64-apple-darwin)..."
echo "Building for macOS (aarch64-apple-darwin) [$BUILD_TYPE]..."
cargo build \
--manifest-path "$MANIFEST" \
--release \
--workspace \
-p livekit \
$BUILD_FLAG \
-p livekit-ffi \
--target aarch64-apple-darwin
BUILD_STATUS=$?

SRC="$BASE_TARGET/aarch64-apple-darwin/release/liblivekit_ffi.dylib"
SRC="$BASE_TARGET/aarch64-apple-darwin/$BUILD_DIR/liblivekit_ffi.dylib"
DST="$BASE_DST/ffi-macos-arm64/liblivekit_ffi.dylib"
;;
# ANDROID
android)
echo "Building for Android (aarch64-linux-android)..."
echo "Building for Android (aarch64-linux-android) [$BUILD_TYPE]..."
pushd "$ROOT/client-sdk-rust~" > /dev/null
cargo ndk \
--target aarch64-linux-android \
build \
--release \
-p livekit \
--workspace \
$BUILD_FLAG \
-p livekit-ffi \
-v \
--no-default-features \
--features "rustls-tls-webpki-roots"
BUILD_STATUS=$?
popd > /dev/null

SRC="$BASE_TARGET/aarch64-linux-android/release/liblivekit_ffi.so"
SRC="$BASE_TARGET/aarch64-linux-android/$BUILD_DIR/liblivekit_ffi.so"
DST="$BASE_DST/ffi-android-arm64/liblivekit_ffi.so"
JAR_SRC="$BASE_TARGET/aarch64-linux-android/$BUILD_DIR/libwebrtc.jar"
JAR_DST="$BASE_DST/ffi-android-arm64/libwebrtc.jar"
;;
# IOS
ios)
echo "Building for iOS (aarch64-apple-ios) [$BUILD_TYPE]..."
pushd "$ROOT/client-sdk-rust~/livekit-ffi" > /dev/null
cargo rustc \
--crate-type staticlib \
$BUILD_FLAG \
--target aarch64-apple-ios \
--no-default-features \
--features "rustls-tls-webpki-roots"
BUILD_STATUS=$?
popd > /dev/null

SRC="$BASE_TARGET/aarch64-apple-ios/$BUILD_DIR/liblivekit_ffi.a"
DST="$BASE_DST/ffi-ios-arm64/liblivekit_ffi.a"
;;
*)
echo -e "${RED}Error: Unknown platform '$PLATFORM'.${RESET}"
Expand All @@ -70,6 +109,7 @@ if [ $BUILD_STATUS -ne 0 ]; then
exit 1
fi

# Copy the built lib
echo ""
echo "Copying to $DST..."
cp -f "$SRC" "$DST"
Expand All @@ -83,4 +123,18 @@ if [ $? -eq 0 ]; then
else
echo -e "${RED}Failed to copy $(basename "$DST"). Check that the source file exists and the destination directory is writable.${RESET}"
exit 1
fi

# For android, also copy the built libwebrtc.jar
if [ "$PLATFORM" = "android" ]; then
echo ""
echo "Copying to $JAR_DST..."
cp -f "$JAR_SRC" "$JAR_DST"

if [ $? -eq 0 ]; then
echo -e "${GREEN}Copied $(basename "$JAR_DST") successfully.${RESET}"
else
echo -e "${RED}Failed to copy $(basename "$JAR_DST"). Check that the source file exists and the destination directory is writable.${RESET}"
exit 1
fi
fi
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,40 @@ You can use the package manager to import local `client-sdk-unity` into your Uni

Or you can import the git url `https://github.com/livekit/client-sdk-unity.git` from the package manager.

## Local development

### Building Livekit plugins locally

For local development, initialize the git submodule containing the Rust code for the LiveKit plugin libraries.

There is a [helper script](https://github.com/livekit/client-sdk-unity/blob/main/BuildScripts~/build_ffi_locally.sh) to build the libraries locally and exchange the downloaded libraries with the build artifacts.
There is a [helper script](https://github.com/livekit/client-sdk-unity/blob/main/BuildScripts~/build_ffi_locally.sh) to build the libraries locally and exchange the downloaded libraries with the local build artifacts in the correct `Runtime/Plugins` folder.

Currently, the build script supports the following arguments:
- macos
- android
- ios

In the following options:
- debug (default)
- release

So a build command is for example:
`./BuildScripts~/build_ffi_locally.sh macos release`

### VSCode setup

Look at the Unity-SDK.code-workspace setup for VSCode. This will use the Meet Sample as the Unity project and the Unity SDK package as two roots in a multi-root workspace and the Meet.sln as the `dotnet.defaultSolution`, enabling Rust and C# IDE support.

### Debugging

For C# debugging, there is a simple attach launch option called `C# Unity`, for example in the `Meet/.vscode/launch.json`.

For Rust / C++ debugging on MacOS, you need to install the [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) extension. The debug attach is defined in `.vscode/launch.json`.

1. Build the livekit-ffi lib locally in debug mode with `./BuildScripts~/build_ffi_locally.sh macos debug`
2. Start the Unity Editor
3. Attach to the Unity Editor process (either auto or manual process picker)
4. Start the Scene in Editor

### iOS

Expand Down
2 changes: 1 addition & 1 deletion Runtime/Scripts/Internal/FFIClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private static void InitializeSdk()
#endif

var sdkVersion = PackageVersion.Get();
NativeMethods.LiveKitInitialize(FFICallback, captureLogs, "unity", sdkVersion); // TODO: Get SDK version
NativeMethods.LiveKitInitialize(FFICallback, captureLogs, "unity", sdkVersion);

Utils.Debug("FFIServer - Initialized");
initialized = true;
Expand Down
11 changes: 10 additions & 1 deletion Runtime/Scripts/Video/YuvToRgbConverter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Samples~/Meet/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"visualstudiotoolsforunity.vstuc"
]
}
10 changes: 10 additions & 0 deletions Samples~/Meet/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C# Unity",
"type": "vstuc",
"request": "attach"
}
]
}
60 changes: 60 additions & 0 deletions Samples~/Meet/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.vs": true,
"**/.gitmodules": true,
"**/.vsconfig": true,
"**/*.booproj": true,
"**/*.pidb": true,
"**/*.suo": true,
"**/*.user": true,
"**/*.userprefs": true,
"**/*.unityproj": true,
"**/*.dll": true,
"**/*.exe": true,
"**/*.pdf": true,
"**/*.mid": true,
"**/*.midi": true,
"**/*.wav": true,
"**/*.gif": true,
"**/*.ico": true,
"**/*.jpg": true,
"**/*.jpeg": true,
"**/*.png": true,
"**/*.psd": true,
"**/*.tga": true,
"**/*.tif": true,
"**/*.tiff": true,
"**/*.3ds": true,
"**/*.3DS": true,
"**/*.fbx": true,
"**/*.FBX": true,
"**/*.lxo": true,
"**/*.LXO": true,
"**/*.ma": true,
"**/*.MA": true,
"**/*.obj": true,
"**/*.OBJ": true,
"**/*.asset": true,
"**/*.cubemap": true,
"**/*.flare": true,
"**/*.mat": true,
"**/*.meta": true,
"**/*.prefab": true,
"**/*.unity": true,
"build/": true,
"Build/": true,
"Library/": true,
"library/": true,
"obj/": true,
"Obj/": true,
"Logs/": true,
"logs/": true,
"ProjectSettings/": true,
"UserSettings/": true,
"temp/": true,
"Temp/": true
},
"dotnet.defaultSolution": "Meet.sln"
}
8 changes: 8 additions & 0 deletions Samples~/Meet/Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading