-
Notifications
You must be signed in to change notification settings - Fork 60
FFI v0.12.2 & RPC #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cd546e5
3d5364b
70cd1d1
b2b1e0e
8d4a862
16c861d
c3d496d
955553d
77ee701
e931916
f4245f8
25113a4
dcea5d0
7e649d4
86903e0
c893730
d572d43
0a058cf
0142e71
1f7094a
9763f9a
f06f0c7
228d88f
72ae518
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,9 @@ | |
|
|
||
| namespace LiveKit.Internal | ||
| { | ||
| #if UNITY_EDITOR | ||
| #if UNITY_EDITOR | ||
| [InitializeOnLoad] | ||
| #endif | ||
| #endif | ||
| internal sealed class FfiClient : IFFIClient | ||
| { | ||
| private static bool initialized = false; | ||
|
|
@@ -37,10 +37,14 @@ internal sealed class FfiClient : IFFIClient | |
| public event DisconnectReceivedDelegate? DisconnectReceived; | ||
| public event RoomEventReceivedDelegate? RoomEventReceived; | ||
| public event TrackEventReceivedDelegate? TrackEventReceived; | ||
| public event RpcMethodInvocationReceivedDelegate? RpcMethodInvocationReceived; | ||
|
|
||
| // participant events are not allowed in the fii protocol public event ParticipantEventReceivedDelegate ParticipantEventReceived; | ||
| public event VideoStreamEventReceivedDelegate? VideoStreamEventReceived; | ||
| public event AudioStreamEventReceivedDelegate? AudioStreamEventReceived; | ||
|
|
||
| public event PerformRpcReceivedDelegate? PerformRpcReceived; | ||
|
|
||
| public FfiClient() : this(Pools.NewFfiResponsePool(), new ArrayMemoryPool()) | ||
| { | ||
| } | ||
|
|
@@ -65,7 +69,7 @@ IMemoryPool memoryPool | |
| this.ffiResponsePool = ffiResponsePool; | ||
| } | ||
|
|
||
| #if UNITY_EDITOR | ||
| #if UNITY_EDITOR | ||
| static FfiClient() | ||
| { | ||
| AssemblyReloadEvents.beforeAssemblyReload += OnBeforeAssemblyReload; | ||
|
|
@@ -94,12 +98,12 @@ static void Init() | |
|
|
||
| private static void Quit() | ||
| { | ||
| #if UNITY_EDITOR | ||
| #if UNITY_EDITOR | ||
| AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload; | ||
| AssemblyReloadEvents.afterAssemblyReload -= OnAfterAssemblyReload; | ||
| #endif | ||
| Instance.Dispose(); | ||
| #endif | ||
| Instance.Dispose(); | ||
|
|
||
| } | ||
|
|
||
| [RuntimeInitializeOnLoadMethod] | ||
|
|
@@ -122,7 +126,7 @@ private static void InitializeSdk() | |
| const bool captureLogs = false; | ||
| #endif | ||
|
|
||
| NativeMethods.LiveKitInitialize(FFICallback, captureLogs); | ||
| NativeMethods.LiveKitInitialize(FFICallback, captureLogs, "unity", ""); // TODO: Get SDK version | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I verified this works for now but I'd love to get SDK version in. it's just not clear where to get it from at runtime? Might need to inject it into a script like we do for the node SDK. any ideas @cloudwebrtc @theomonnom ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found this but don't know if it works as expected using UnityEngine;
using System.Linq;
using UnityEditor.PackageManager;
// ... within some class ...
private PackageInfo GetPackageInfo(string packageName)
{
return UnityEditor.AssetDatabase.FindAssets("package")
.Select(UnityEditor.AssetDatabase.GUIDToAssetPath)
.Where(x => UnityEditor.AssetDatabase.LoadAssetAtPath<TextAsset>(x) != null)
.Select(PackageInfo.FindForAssetPath)
.Where(x => x != null)
.First(x => x.name == packageName);
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I saw online,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gonna just punt on this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, you are right, maybe we can add a version.cs, but we must check that the version number in version.cs is consistent with package.json before releasing a new version
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the node sdk we dynamically generate a version.js file as part of the build process, but i'm not sure there's a clean way to pull that off here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the Unity build process can generate version.cs, I think it is a good idea. |
||
|
|
||
| Utils.Debug("FFIServer - Initialized"); | ||
| initialized = true; | ||
|
|
@@ -198,7 +202,7 @@ out UIntPtr dataLen | |
|
|
||
| [AOT.MonoPInvokeCallback(typeof(FFICallbackDelegate))] | ||
| static unsafe void FFICallback(UIntPtr data, UIntPtr size) | ||
| { | ||
| { | ||
| #if NO_LIVEKIT_MODE | ||
| return; | ||
| #endif | ||
|
|
@@ -238,6 +242,9 @@ static unsafe void FFICallback(UIntPtr data, UIntPtr size) | |
| case FfiEvent.MessageOneofCase.TrackEvent: | ||
| Instance.TrackEventReceived?.Invoke(r.TrackEvent!); | ||
| break; | ||
| case FfiEvent.MessageOneofCase.RpcMethodInvocation: | ||
| Instance.RpcMethodInvocationReceived?.Invoke(r.RpcMethodInvocation); | ||
| break; | ||
| case FfiEvent.MessageOneofCase.Disconnect: | ||
| Instance.DisconnectReceived?.Invoke(r.Disconnect!); | ||
| break; | ||
|
|
@@ -251,6 +258,9 @@ static unsafe void FFICallback(UIntPtr data, UIntPtr size) | |
| break; | ||
| case FfiEvent.MessageOneofCase.CaptureAudioFrame: | ||
| break; | ||
| case FfiEvent.MessageOneofCase.PerformRpc: | ||
| Instance.PerformRpcReceived?.Invoke(r.PerformRpc!); | ||
| break; | ||
| case FfiEvent.MessageOneofCase.GetStats: | ||
| case FfiEvent.MessageOneofCase.Panic: | ||
| break; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.