Skip to content

Commit

Permalink
Add script to download ffi binaries. (#39)
Browse files Browse the repository at this point in the history
* Add script to download ffi binaries.

* Remove built-in binaries.

* Added installation reminder for iOS.
  • Loading branch information
cloudwebrtc authored Jun 27, 2024
1 parent de68f2c commit 5f19cb0
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 30 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,31 @@ We plan to support all Unity platforms with this SDK. WebGL is currently support

## Installation

Follow this [unity tutorial](https://docs.unity3d.com/Manual/upm-ui-giturl.html) using the `https://github.com/livekit/client-sdk-unity.git` link.
You can then directly import the samples into the package manager.
Follow this [unity tutorial](https://docs.unity3d.com/Manual/upm-ui-giturl.html),

This repo uses [Git LFS](https://git-lfs.com/), please ensure it's installed when cloning the repo.
clone this repo and download the ffi binaries.

```sh
git clone https://github.com/livekit/client-sdk-unity.git
cd client-sdk-unity
python3 install.py
```

You can use the package manager to import `client-sdk-unity` into your Unity project.

### iOS

Add dependent frameworks to your Unity project

select `Unity-iPhone` -> `TARGETS` -> `UnityFramework` -> `General` -> `Frameworks and Libraries` -> `+`

add the following frameworks:

`OpenGLES.framework` `MetalKit.framework`

Since `libiPhone-lib.a` has built-in old versions of `celt` and `libvpx` (This will cause the opus and vp8/vp9 codecs to not be called correctly and cause a crash.), so you need to adjust the link order to ensure that it is linked to `liblivekit_ffi.a` first.

The fix is ​​to remove and re-add `libiPhone-lib.a` from `Frameworks and Libraries`, making sure to link after `liblivekit_ffi.a`.

## Examples

Expand Down
3 changes: 0 additions & 3 deletions Runtime/Plugins/ffi-android-arm64/liblivekit_ffi.so

This file was deleted.

3 changes: 0 additions & 3 deletions Runtime/Plugins/ffi-android-armv7/liblivekit_ffi.so

This file was deleted.

3 changes: 0 additions & 3 deletions Runtime/Plugins/ffi-android-x86_64/liblivekit_ffi.so

This file was deleted.

3 changes: 0 additions & 3 deletions Runtime/Plugins/ffi-linux-arm64/liblivekit_ffi.so

This file was deleted.

3 changes: 0 additions & 3 deletions Runtime/Plugins/ffi-linux-x86_64/liblivekit_ffi.so

This file was deleted.

3 changes: 0 additions & 3 deletions Runtime/Plugins/ffi-macos-arm64/liblivekit_ffi.dylib

This file was deleted.

3 changes: 0 additions & 3 deletions Runtime/Plugins/ffi-macos-x86_64/liblivekit_ffi.dylib

This file was deleted.

3 changes: 0 additions & 3 deletions Runtime/Plugins/ffi-windows-arm64/livekit_ffi.dll

This file was deleted.

3 changes: 0 additions & 3 deletions Runtime/Plugins/ffi-windows-x86_64/livekit_ffi.dll

This file was deleted.

51 changes: 51 additions & 0 deletions install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import os
import urllib.request
import configparser
import zipfile

# prepare progressbar
def show_progress(block_num, block_size, total_size):
print(round(block_num * block_size / total_size *100,2), end="\r")

platforms = ['android', 'ios', 'macos', 'linux', 'windows']
download_dir = 'downloads~'

def main():
config = configparser.ConfigParser()
config.read('version.ini')
version = config['ffi']['version']

for platform in platforms:
archs = ['arm64', 'x86_64']
if platform == 'android':
archs = [ 'armv7', 'arm64', 'x86_64']
elif platform == 'ios':
archs = ['arm64', 'sim-arm64']

for arch in archs:
filename = 'ffi-' + platform + '-' + arch + '.zip'
url = config['ffi']['url'] + '/ffi-' + version + '/' + filename
file_to_download = download_dir + '/' + filename
if download_file_if_not_exists(url, file_to_download) :
dest = 'Runtime/Plugins' + '/ffi-' + platform + '-' + arch
unzip_file(file_to_download, filename, dest)

def download_file_if_not_exists(url, filename):
if os.path.isdir(download_dir) == False:
print( download_dir + " directory not exists, creating one...")
os.makedirs(download_dir)
if os.path.isfile(filename):
print("file " + filename + " exists, skipping download")
return False
print("downloading file " + url)
urllib.request.urlretrieve(url, filename, show_progress)
return True

def unzip_file(srcfile, filename, dest):
print("unzipping " + filename + " to " + dest)
with zipfile.ZipFile(srcfile, 'r') as zip_ref:
zip_ref.extractall(dest)
print("unzipped " + srcfile)

if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions version.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ffi]
version = v0.5.0
url = https://github.com/livekit/rust-sdks/releases/download

0 comments on commit 5f19cb0

Please sign in to comment.