Three bugs fixed across the full stack (proto/server/core/ABI/Win/macOS/iOS): 1. Join/Leave Voice now truly subscribes/unsubscribes from the voice plane. Previously the button only toggled the local mic — receiving was always on (gated by channel membership alone). Added a protocol-level voice subscription concept: new SubscribeVoiceRequest/UnsubscribeVoiceRequest/VoiceSubscriptionResult proto messages, User.voice_subscribed field, vc_join_voice/vc_leave_voice C ABI functions, VC_EVENT_VOICE_STATE event, server-side voice_subscribed flag checked by the SFU relay recipient filter, and core-client gating of remote-stream decoder setup. All three clients rewired to subscribe+mic on Join / unsubscribe on Leave. Text chat works regardless of voice subscription. 2. Channel edit dialog now shows the channel's actual current settings. The read struct vc_channel was missing sort_order and audio fields — only the write struct vc_channel_info had them. Extended vc_channel with both (additive, no ABI break), updated the session model and list_channels marshaling to populate them, and updated all three clients' edit callers to use actual channel info instead of hardcoded defaults. 3. Channel parameter updates now automatically restart everyone's streams. Previously editing a channel's audio config persisted and broadcast a ChannelEvent::UPDATED, but no layer restarted streams — encoders/decoders are frozen at announce time. handle_channel_event now detects audio-config changes on the user's current channel and stop->starts each active local stream. The server reads the updated config on re-announce; peers wire up fresh decoders at the new ssrc. All 29 CTest tests pass; Windows DLL + C# client build clean. Apple clients not yet compile-verified (Windows environment).
189 lines
4.7 KiB
C#
189 lines
4.7 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;
|
|
// Mirrors vc_stream_desc::external_feed. When 1, the core skips its own WASAPI loopback
|
|
// and the caller feeds PCM via StreamFeedPcm (per-app capture path on Windows).
|
|
public int ExternalFeed;
|
|
}
|
|
|
|
[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;
|
|
public uint SortOrder;
|
|
public VcAudioConfigNative Audio;
|
|
}
|
|
|
|
[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;
|
|
public int VoiceSubscribed;
|
|
}
|
|
|
|
[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;
|
|
}
|