Channel create/edit UIs only surfaced a subset of the core's vc_audio_config, and DRED was exposed nowhere. While adding it, found a latent ABI mismatch: both Swift AudioConfig and the C# VcAudioConfigNative blittable struct were one int short of the native vc_audio_config (missing the trailing `dred`), so native read past the managed struct in vc_create_channel/vc_edit_channel. - core marshaling: thread `dred` through Swift (Models/Marshaling/toNative) and C# (Structs/Models/Marshaling/VoiceCatClient) -- fixes the ABI gap + enables it - windows: add the one missing DRED checkbox to ChannelEditDialog - macos: ChannelEditSheet now exposes application, sample rate, packet loss, complexity, and DRED (was stereo/bitrate/frame/FEC/DTX only) - ios: rebuild ChannelEditView into a full create+edit form (all params); add SessionState.editChannel + an admin Edit swipe action (iOS had no edit UI) - guest nickname: add a dedicated `nickname` to SavedServer on macOS+iOS (backward-compatible Codable), shown in Guest mode, wired into the guest auth path -- guests could not set a display name on either before (only Windows) Verified: macOS + iOS (sim, arm64) xcodebuild BUILD SUCCEEDED; core ctest 22/23 (only external_pcm aborts on a pre-existing shutdown mutex race; no C++ changed).
183 lines
4.4 KiB
C#
183 lines
4.4 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;
|
|
public int Dred;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
internal struct VcPermissionsNative
|
|
{
|
|
public int CanCreateTempChannel;
|
|
public int CanKick;
|
|
public int CanBan;
|
|
public int CanMoveUsers;
|
|
public int CanAdminAccounts;
|
|
public int IsAdmin;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
internal struct VcChannelInfoNative
|
|
{
|
|
public uint Id;
|
|
public uint ParentId;
|
|
public IntPtr Name;
|
|
public IntPtr Topic;
|
|
public int PasswordProtected;
|
|
public IntPtr Password;
|
|
public uint MaxUsers;
|
|
public uint SortOrder;
|
|
public VcAudioConfigNative Audio;
|
|
}
|
|
|
|
[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 IntPtr Topic;
|
|
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;
|
|
public int SelfMicMuted;
|
|
public int SelfDeafened;
|
|
public int ServerMuted;
|
|
public int ServerDeafened;
|
|
}
|
|
|
|
[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;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
internal struct VcRemoteStreamStateNative
|
|
{
|
|
public float Gain;
|
|
public int Muted;
|
|
public int NoiseReduction;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
internal struct VcAccountNative
|
|
{
|
|
public IntPtr Username;
|
|
public int IsAdmin;
|
|
public ulong CreatedAtUnixMs;
|
|
public ulong LastLoginUnixMs;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
internal struct VcAccountListNative
|
|
{
|
|
public IntPtr Items;
|
|
public nuint Count;
|
|
}
|