128 lines
3.2 KiB
C#
128 lines
3.2 KiB
C#
|
|
using System.Runtime.InteropServices;
|
||
|
|
|
||
|
|
// Native (blittable) struct layouts mirroring voicecat.h field-for-field. These are the raw
|
||
|
|
// P/Invoke shapes — NativeMethods.cs uses them directly; Marshaling.cs converts them to the
|
||
|
|
// managed record types in Models.cs. const char* fields stay IntPtr here (LibraryImport's
|
||
|
|
// StringMarshalling only auto-converts top-level string parameters/returns, not struct
|
||
|
|
// fields) and must be hand-marshaled — see Marshaling.cs and VoiceCatClient.cs.
|
||
|
|
namespace VoiceCat.Interop;
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcEventNative
|
||
|
|
{
|
||
|
|
public VcEventType Type;
|
||
|
|
public VcConnectionState ConnectionState;
|
||
|
|
public int Result; // vc_result
|
||
|
|
public uint UserId;
|
||
|
|
public uint ChannelId;
|
||
|
|
public uint StreamId;
|
||
|
|
public VcTextScope TextScope;
|
||
|
|
public uint U32a;
|
||
|
|
public IntPtr Text; // owned by core, valid ONLY for the callback's duration
|
||
|
|
public ulong TimestampUnixMs;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcConfigNative
|
||
|
|
{
|
||
|
|
public IntPtr ClientName;
|
||
|
|
public IntPtr ClientVersion;
|
||
|
|
public VcLogLevel LogLevel;
|
||
|
|
public IntPtr TofuStorePath;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcCallbacksNative
|
||
|
|
{
|
||
|
|
public IntPtr OnEvent; // delegate* unmanaged<IntPtr, VcEventNative*, void>
|
||
|
|
public IntPtr OnLevel; // delegate* unmanaged<IntPtr, uint, float, void>
|
||
|
|
public IntPtr User;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcStreamDescNative
|
||
|
|
{
|
||
|
|
public VcStreamKind Kind;
|
||
|
|
public IntPtr DeviceId; // unused by vc_stream_start today — device selection is a
|
||
|
|
// separate vc_set_input_device call; always IntPtr.Zero here.
|
||
|
|
public IntPtr Label;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcAudioConfigNative
|
||
|
|
{
|
||
|
|
public uint Codec;
|
||
|
|
public uint Mode;
|
||
|
|
public uint SampleRate;
|
||
|
|
public uint BitrateBps;
|
||
|
|
public uint FrameMs;
|
||
|
|
public uint Application;
|
||
|
|
public int Fec;
|
||
|
|
public uint ExpectedPacketLoss;
|
||
|
|
public int Dtx;
|
||
|
|
public uint Complexity;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcDeviceNative
|
||
|
|
{
|
||
|
|
public IntPtr Id;
|
||
|
|
public IntPtr Name;
|
||
|
|
public int IsDefault;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcDeviceListNative
|
||
|
|
{
|
||
|
|
public IntPtr Items;
|
||
|
|
public nuint Count;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcChannelNative
|
||
|
|
{
|
||
|
|
public uint Id;
|
||
|
|
public uint ParentId;
|
||
|
|
public IntPtr Name;
|
||
|
|
public int PasswordProtected;
|
||
|
|
public uint MaxUsers;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcChannelListNative
|
||
|
|
{
|
||
|
|
public IntPtr Items;
|
||
|
|
public nuint Count;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcUserNative
|
||
|
|
{
|
||
|
|
public uint Id;
|
||
|
|
public IntPtr Nickname;
|
||
|
|
public int IsGuest;
|
||
|
|
public uint ChannelId;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcUserListNative
|
||
|
|
{
|
||
|
|
public IntPtr Items;
|
||
|
|
public nuint Count;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcStreamSummaryNative
|
||
|
|
{
|
||
|
|
public uint StreamId;
|
||
|
|
public VcStreamKind Kind;
|
||
|
|
public IntPtr Label;
|
||
|
|
}
|
||
|
|
|
||
|
|
[StructLayout(LayoutKind.Sequential)]
|
||
|
|
internal struct VcStreamSummaryListNative
|
||
|
|
{
|
||
|
|
public IntPtr Items;
|
||
|
|
public nuint Count;
|
||
|
|
}
|