-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathNativeMethods.cs
More file actions
43 lines (37 loc) · 1.96 KB
/
NativeMethods.cs
File metadata and controls
43 lines (37 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Security;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using FfiHandleId = System.IntPtr;
namespace LiveKit.Internal
{
[SuppressUnmanagedCodeSecurity]
internal static class NativeMethods
{
#if UNITY_IOS
const string Lib = "__Internal";
#else
const string Lib = "livekit_ffi";
#endif
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "livekit_ffi_drop_handle")]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal extern static bool FfiDropHandle(FfiHandleId handleId);
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "livekit_ffi_request")]
internal extern static unsafe FfiHandleId FfiNewRequest(byte* data, int len, out byte* dataPtr, out UIntPtr dataLen);
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "livekit_ffi_initialize")]
internal extern static FfiHandleId LiveKitInitialize(FFICallbackDelegate cb, bool captureLogs, string sdk, string sdkVersion);
#if UNITY_ANDROID && !UNITY_EDITOR
/// <summary>
/// Initialize Android WebRTC with the application context.
/// This initializes both the JVM and ContextUtils, which is required for
/// Android audio (microphone/speaker) to work via PlatformAudio.
/// </summary>
/// <param name="javaVmPtr">Pointer to the JavaVM</param>
/// <param name="contextPtr">The Android application context (jobject)</param>
/// <returns>true if context initialization succeeded, false otherwise.
/// Note: JVM initialization happens regardless of return value.</returns>
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "livekit_ffi_initialize_android_context")]
internal extern static bool LiveKitInitializeAndroidContext(IntPtr javaVmPtr, IntPtr contextPtr);
#endif
}
}