From 5f19cb08cb6b0e85ba819e943078a2d24ec6d120 Mon Sep 17 00:00:00 2001 From: CloudWebRTC Date: Thu, 27 Jun 2024 19:03:38 +0800 Subject: [PATCH] Add script to download ffi binaries. (#39) * Add script to download ffi binaries. * Remove built-in binaries. * Added installation reminder for iOS. --- README.md | 27 ++++++++-- .../ffi-android-arm64/liblivekit_ffi.so | 3 -- .../ffi-android-armv7/liblivekit_ffi.so | 3 -- .../ffi-android-x86_64/liblivekit_ffi.so | 3 -- .../Plugins/ffi-linux-arm64/liblivekit_ffi.so | 3 -- .../ffi-linux-x86_64/liblivekit_ffi.so | 3 -- .../ffi-macos-arm64/liblivekit_ffi.dylib | 3 -- .../ffi-macos-x86_64/liblivekit_ffi.dylib | 3 -- .../Plugins/ffi-windows-arm64/livekit_ffi.dll | 3 -- .../ffi-windows-x86_64/livekit_ffi.dll | 3 -- install.py | 51 +++++++++++++++++++ version.ini | 3 ++ 12 files changed, 78 insertions(+), 30 deletions(-) delete mode 100755 Runtime/Plugins/ffi-android-arm64/liblivekit_ffi.so delete mode 100755 Runtime/Plugins/ffi-android-armv7/liblivekit_ffi.so delete mode 100755 Runtime/Plugins/ffi-android-x86_64/liblivekit_ffi.so delete mode 100755 Runtime/Plugins/ffi-linux-arm64/liblivekit_ffi.so delete mode 100755 Runtime/Plugins/ffi-linux-x86_64/liblivekit_ffi.so delete mode 100755 Runtime/Plugins/ffi-macos-arm64/liblivekit_ffi.dylib delete mode 100755 Runtime/Plugins/ffi-macos-x86_64/liblivekit_ffi.dylib delete mode 100644 Runtime/Plugins/ffi-windows-arm64/livekit_ffi.dll delete mode 100644 Runtime/Plugins/ffi-windows-x86_64/livekit_ffi.dll create mode 100644 install.py create mode 100644 version.ini diff --git a/README.md b/README.md index 1086bee..3596d71 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Runtime/Plugins/ffi-android-arm64/liblivekit_ffi.so b/Runtime/Plugins/ffi-android-arm64/liblivekit_ffi.so deleted file mode 100755 index b21fc4d..0000000 --- a/Runtime/Plugins/ffi-android-arm64/liblivekit_ffi.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b32cef2ae5f01481d5ac195946c0c3b464278fc9cc63fbb6307a7e3223c49386 -size 19400648 diff --git a/Runtime/Plugins/ffi-android-armv7/liblivekit_ffi.so b/Runtime/Plugins/ffi-android-armv7/liblivekit_ffi.so deleted file mode 100755 index 9453f4c..0000000 --- a/Runtime/Plugins/ffi-android-armv7/liblivekit_ffi.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6dc5e8fbe700573721038cceef05aec9001150526f5f0ff09a713416f4866ff5 -size 11856156 diff --git a/Runtime/Plugins/ffi-android-x86_64/liblivekit_ffi.so b/Runtime/Plugins/ffi-android-x86_64/liblivekit_ffi.so deleted file mode 100755 index f6021ad..0000000 --- a/Runtime/Plugins/ffi-android-x86_64/liblivekit_ffi.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:40319cc86da7ab8f528ddcd25db6071c24abe63244c2910154425209a8502a4c -size 22770824 diff --git a/Runtime/Plugins/ffi-linux-arm64/liblivekit_ffi.so b/Runtime/Plugins/ffi-linux-arm64/liblivekit_ffi.so deleted file mode 100755 index d3db137..0000000 --- a/Runtime/Plugins/ffi-linux-arm64/liblivekit_ffi.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f7d9672aee862749734cf5ef1844cac731fec01e32e03d19d4310ca64d367168 -size 22565440 diff --git a/Runtime/Plugins/ffi-linux-x86_64/liblivekit_ffi.so b/Runtime/Plugins/ffi-linux-x86_64/liblivekit_ffi.so deleted file mode 100755 index b6cd671..0000000 --- a/Runtime/Plugins/ffi-linux-x86_64/liblivekit_ffi.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:26989365e0d812baabaa6c25843a78c5e2f20ca1bf1feb8c1697ae8283ccbf59 -size 28320320 diff --git a/Runtime/Plugins/ffi-macos-arm64/liblivekit_ffi.dylib b/Runtime/Plugins/ffi-macos-arm64/liblivekit_ffi.dylib deleted file mode 100755 index 8133da2..0000000 --- a/Runtime/Plugins/ffi-macos-arm64/liblivekit_ffi.dylib +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ea1ebc2657412af9a9910806620e115b05a00bef0541fd0788be699ba9041079 -size 19446760 diff --git a/Runtime/Plugins/ffi-macos-x86_64/liblivekit_ffi.dylib b/Runtime/Plugins/ffi-macos-x86_64/liblivekit_ffi.dylib deleted file mode 100755 index e86657b..0000000 --- a/Runtime/Plugins/ffi-macos-x86_64/liblivekit_ffi.dylib +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4acc3d1273ae3a9bedcb310f03b235496f96230d9711f8d6aefc79c93d3ee826 -size 24330544 diff --git a/Runtime/Plugins/ffi-windows-arm64/livekit_ffi.dll b/Runtime/Plugins/ffi-windows-arm64/livekit_ffi.dll deleted file mode 100644 index 901099d..0000000 --- a/Runtime/Plugins/ffi-windows-arm64/livekit_ffi.dll +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c2e1bc120c790e0f28ccc13382243cf4d9d210f01a36a9481600788b211bf505 -size 19587072 diff --git a/Runtime/Plugins/ffi-windows-x86_64/livekit_ffi.dll b/Runtime/Plugins/ffi-windows-x86_64/livekit_ffi.dll deleted file mode 100644 index fed6b10..0000000 --- a/Runtime/Plugins/ffi-windows-x86_64/livekit_ffi.dll +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8122d4c9f6d0ada61e19ea62b3694c8662aa6ad30c904cb3006730fb3f814e00 -size 24363520 diff --git a/install.py b/install.py new file mode 100644 index 0000000..b26fc5b --- /dev/null +++ b/install.py @@ -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() \ No newline at end of file diff --git a/version.ini b/version.ini new file mode 100644 index 0000000..8ea1d37 --- /dev/null +++ b/version.ini @@ -0,0 +1,3 @@ +[ffi] +version = v0.5.0 +url = https://github.com/livekit/rust-sdks/releases/download \ No newline at end of file