Files
voice-cat/tests/CMakeLists.txt

248 lines
15 KiB
CMake
Raw Normal View History

2026-06-15 23:48:44 +02:00
# Tests use plain asserts + exit codes (no framework dep needed).
# Behavior tests — not just "it compiles" — are how milestones are judged (AGENTS.md).
add_executable(test_smoke test_smoke.cpp)
target_link_libraries(test_smoke PRIVATE voicecat::voicecat)
target_compile_features(test_smoke PRIVATE cxx_std_20)
add_test(NAME smoke COMMAND test_smoke)
2026-06-15 23:48:44 +02:00
# Needs core/src on the include path to reach internal headers (protocol/, session/, etc.).
add_executable(test_frame_codec test_frame_codec.cpp)
target_link_libraries(test_frame_codec PRIVATE voicecat::voicecat)
target_compile_features(test_frame_codec PRIVATE cxx_std_20)
target_include_directories(test_frame_codec PRIVATE ${CMAKE_SOURCE_DIR}/core/src)
add_test(NAME frame_codec COMMAND test_frame_codec)
set(VC_TEST_INTERNAL_INCLUDES
2026-06-15 23:48:44 +02:00
${CMAKE_SOURCE_DIR}/core/src
${CMAKE_SOURCE_DIR}/server/src
${CMAKE_BINARY_DIR}/core/generated) # protobuf-generated headers
add_executable(test_envelope test_envelope.cpp)
target_link_libraries(test_envelope PRIVATE voicecat::voicecat)
target_compile_features(test_envelope PRIVATE cxx_std_20)
target_include_directories(test_envelope PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME envelope COMMAND test_envelope)
add_executable(test_tls_loopback test_tls_loopback.cpp)
target_link_libraries(test_tls_loopback PRIVATE voicecat::voicecat)
target_compile_features(test_tls_loopback PRIVATE cxx_std_20)
target_include_directories(test_tls_loopback PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME tls_loopback COMMAND test_tls_loopback)
# Links voicecat::server (which pulls in voicecat::voicecat + all deps transitively).
add_executable(test_m1_integration test_m1_integration.cpp)
target_link_libraries(test_m1_integration PRIVATE voicecat::server)
target_compile_features(test_m1_integration PRIVATE cxx_std_20)
target_include_directories(test_m1_integration PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME m1_integration COMMAND test_m1_integration)
set_tests_properties(m1_integration PROPERTIES TIMEOUT 60)
# ── M2 unit tests ──────────────────────────────────────────────────────────
add_executable(test_voice_frame test_voice_frame.cpp)
target_link_libraries(test_voice_frame PRIVATE voicecat::voicecat)
target_compile_features(test_voice_frame PRIVATE cxx_std_20)
target_include_directories(test_voice_frame PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME voice_frame COMMAND test_voice_frame)
add_executable(test_media_aead test_media_aead.cpp)
target_link_libraries(test_media_aead PRIVATE voicecat::voicecat)
target_compile_features(test_media_aead PRIVATE cxx_std_20)
target_include_directories(test_media_aead PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME media_aead COMMAND test_media_aead)
add_executable(test_opus_codec test_opus_codec.cpp)
target_link_libraries(test_opus_codec PRIVATE voicecat::voicecat)
target_compile_features(test_opus_codec PRIVATE cxx_std_20)
target_include_directories(test_opus_codec PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME opus_codec COMMAND test_opus_codec)
fix(net): broadcast LEFT on disconnect, add keepalive/reaper, cap PLC hiss Three reported bugs traced to one root cause plus two missing designed features: 1. Stale users + eternal PLC hiss (root cause): ConnSession::close() silently erased dropped users without broadcasting UserEvent::LEFT, so peers never learned the user left and their audio engines never called remove_stream — Opus PLC synthesized comfort noise forever. Fix: broadcast_left() helper + close() broadcasts LEFT before erasing. 2. PLC cap (defense-in-depth): on_playback now caps pure PLC at ~2s, then emits digital silence so a stale stream can never hiss forever even if remove_stream is skipped. Resets automatically on fresh packets. 3. No timeout / no ping: client never sent Ping, server had no last_seen / reaper, so half-open connections (NAT timeout, wifi loss, sleep) left ghost users forever. Fix: client Ping every 15s with RTT measurement, ConnSession::last_seen bumped on every inbound TCP/UDP frame, steady_timer reaper sweeps every 15s and drops sessions older than 45s (configurable via server::Config). 4. UDP KEEPALIVE: client sends plaintext kFrameKeepalive every 5s; server bumps last_seen + echoes back. Keeps NAT bindings alive and lets media activity defer the reaper independently of TCP. 5. Graceful client disconnect: vc_disconnect() sends Disconnect{code=0} via a flag-based io-thread exit (no double-close race); server handles client-sent Disconnect with immediate close() + LEFT broadcast. 3 new tests: disconnect_left, plc_cap, reaper_timeout. 21/21 ctest green. Docs: protocol.md §6/§7, voice.md §6, architecture.md §5, PROGRESS.md.
2026-06-18 01:18:33 +02:00
# PLC cap: after ~2s of pure PLC (no real packets), the mixer emits silence instead of
# comfort noise — bounds the eternal-hiss failure mode (defense-in-depth for the
# disconnect/LEFT fix). White-box AudioEngine test, no server needed.
add_executable(test_plc_cap test_plc_cap.cpp)
target_link_libraries(test_plc_cap PRIVATE voicecat::voicecat)
target_compile_features(test_plc_cap PRIVATE cxx_std_20)
target_include_directories(test_plc_cap PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME plc_cap COMMAND test_plc_cap)
# Jitter-buffer bounded depth: across many talkspurt/silence cycles with a compressed sender
# timeline + reordered stragglers, playout latency must stay bounded (no backward drift /
# ratchet). White-box AudioEngine test, no server needed.
add_executable(test_jitter_depth test_jitter_depth.cpp)
target_link_libraries(test_jitter_depth PRIVATE voicecat::voicecat)
target_compile_features(test_jitter_depth PRIVATE cxx_std_20)
target_include_directories(test_jitter_depth PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME jitter_depth COMMAND test_jitter_depth)
# External playback (iOS VPIO): the mixer-timer thread drives decode+mix with NO hardware
# device and delivers the final mix to the mixed-output sink. White-box AudioEngine test.
add_executable(test_external_playback test_external_playback.cpp)
target_link_libraries(test_external_playback PRIVATE voicecat::voicecat)
target_compile_features(test_external_playback PRIVATE cxx_std_20)
target_include_directories(test_external_playback PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME external_playback COMMAND test_external_playback)
# M2 exit criterion: two headless clients relay encrypted Opus frames via the SFU.
add_executable(test_m2_voice test_m2_voice.cpp)
target_link_libraries(test_m2_voice PRIVATE voicecat::server)
target_compile_features(test_m2_voice PRIVATE cxx_std_20)
target_include_directories(test_m2_voice PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME m2_voice COMMAND test_m2_voice)
set_tests_properties(m2_voice PROPERTIES TIMEOUT 120)
# Same exit criterion, but through the real C ABI (vc_client), not raw sockets —
# proves stream_start/stop/UDP-binding in core/src/core/client.cpp actually work.
add_executable(test_voice_client_abi test_voice_client_abi.cpp)
target_link_libraries(test_voice_client_abi PRIVATE voicecat::server)
target_compile_features(test_voice_client_abi PRIVATE cxx_std_20)
target_include_directories(test_voice_client_abi PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME voice_client_abi COMMAND test_voice_client_abi)
set_tests_properties(voice_client_abi PROPERTIES TIMEOUT 60)
feat(M3): multi-stream & per-channel tuning Implements docs/roadmap.md M3: multiple concurrent streams per user (MIC + SCREEN_AUDIO + AUX_DEVICE), independent per-stream receiver gain/mute/noise- reduction, talk indicators, and enforced per-channel Opus configurability (mono/stereo, bitrate, frame size, FEC/DTX, application). Bugs fixed along the way (found while implementing, not pre-existing scope): - Server hard-coded stream_id=1 for every announce, so a second stream from the same user silently overwrote the first in SessionRegistry::set_user_stream. Now a per-session counter (ConnSession::next_stream_id_); handle_stream_stop validates against announced_stream_ids_ before clearing. - Client dropped mode/dtx/complexity/application from effective_audio even for the single M2 stream -- only sample_rate/bitrate_bps/frame_ms/fec were ever applied to OpusParams. Fixed on both the send (handle_stream_announce_result) and receive (sync_remote_streams) paths via a shared opus_params_from_audio_config() helper. - OpusEncoder always used OPUS_APPLICATION_VOIP; added OpusParams::application and wired it through. - on_playback's per-stream decode passed the wrong frame_size to opus_decode (total samples instead of samples-per-channel), which would have overflowed the decode buffer for any stereo stream. - teardown_voice() raced when called concurrently from run_io()'s own cleanup and from disconnect() on a different thread -- both could see udp_thread_/talk_timer_thread_ as joinable() at once and race to join() the same std::thread (intermittent std::system_error under ctest). Fixed with a teardown_mu_ guard instead of carrying the flake forward. New: - Per-channel AudioConfig: SessionRegistry now seeds Lobby (mono/24kbps/VOIP/ FEC+DTX) and a new "Music Room" channel (stereo/128kbps/AUDIO/no DTX); handle_stream_announce enforces the channel's config, clamping (not overriding) bitrate_bps to its ceiling. - core/src/core/client.h/.cpp: local-stream state is now a std::unordered_map<int, LocalStream> keyed by vc_stream_kind, with request_id-correlated announce/result handling (request_id already round-tripped on the wire; just wasn't read before). on_capture_frame is kind-aware and upmixes mono capture to stereo when a stream's config calls for it. set_self_mute's mic_muted now only gates the MIC kind. NS is wired through set_remote_stream. New run_talk_timer() thread emits VC_EVENT_TALK_STATE from both remote and local edge detection. - core/src/audio/audio_engine.h/.cpp: kind-keyed injection taps (inject_capture), stereo-to-mono downmix at the decode/mix boundary, RemoteStream gains recv_ns (lazy ApmProcessor) + noise_reduction_enabled and last_voice_ms/talking; new set_stream_noise_reduction() and poll_talk_transitions(). - core/src/session/session.h/.cpp: Stream now carries the full AudioConfig, not just sample_rate/frame_ms. - New additive C ABI (core/include/voicecat.h): vc_audio_config + vc_get_stream_audio_config (effective Opus config for any stream you own or a peer's); vc_test_inject_capture (test-only synthetic PCM injection, clearly marked, mirrors AudioEngine::inject_capture). - tests/test_m3_multistream.cpp: the M3 exit criterion through the real ABI (mirrors test_voice_client_abi.cpp's approach, not raw sockets) -- two concurrent local streams, independent gain/mute/NS control, per-channel config divergence via vc_get_stream_audio_config, talk indicators. Explicitly out of scope for this pass (tracked in PROGRESS.md, not silently dropped): VAD/PTT input gate + device enumeration; real WASAPI loopback capture for SCREEN_AUDIO (synthetic injection only); true stereo playback output (AudioEngine's mixer/output device stays mono -- Opus itself is fully stereo-correct on the wire). ctest --test-dir build/m1-dev: 11/11 green, verified across 3 consecutive full-suite runs plus 8 standalone runs of the new test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 14:12:37 +02:00
# M3 exit criterion: multi-stream (mic + desktop audio), independent per-stream
# gain/mute/NS, per-channel Opus configurability, talk indicators -- all through the
# real C ABI (vc_client), not raw sockets.
add_executable(test_m3_multistream test_m3_multistream.cpp)
target_link_libraries(test_m3_multistream PRIVATE voicecat::server)
target_compile_features(test_m3_multistream PRIVATE cxx_std_20)
target_include_directories(test_m3_multistream PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME m3_multistream COMMAND test_m3_multistream)
set_tests_properties(m3_multistream PROPERTIES TIMEOUT 60)
feat: device enumeration, VAD/PTT input gate, stereo playback, WASAPI loopback Closes the three items PROGRESS.md's M3 section explicitly carried forward as out of scope: - Device enumeration (vc_list_devices) + input device selection (vc_set_input_device), backed by AudioEngine::enumerate_devices() via miniaudio's ma_context_get_devices. Device ids are opaque hex-encoded ma_device_id strings. - VAD/PTT send-side input gate (vc_set_input_mode, vc_set_push_to_talk). webrtc-audio-processing (the originally-planned APM) has no working Windows/MSVC build upstream (GCC-only Meson, unfinished MinGW support, hard abseil-cpp dependency), so VAD is a new lightweight, dependency-free energy/RMS processor (EnergyVadProcessor) behind the existing ApmProcessor interface. Gating is MIC-only; SCREEN_AUDIO/AUX_DEVICE always bypass it. - True stereo playback: AudioEngine's mixer and output device now carry stereo end-to-end (mono streams upmix L=R) instead of downmixing decoded stereo streams to mono before mixing. - Real WASAPI loopback capture for SCREEN_AUDIO (Windows-only, via miniaudio's loopback device type), replacing test-only injection as the production capture path. Also: vccli gains --list-devices, --input-device, --input-mode, and --share-screen-audio flags, plus a stdin command loop (ptt on/off, mode vad/ptt) for manual verification. New test_vad_ptt_devices.cpp covers all four items (ABI-level + a white-box AudioEngine stereo-mix check). Docs updated to match: voice.md, roadmap.md (decision-log entry superseding the original webrtc-audio-processing choice), tech-stack.md, README.md, architecture.md, CLAUDE.md, PROGRESS.md. Still explicitly out of scope, documented not silently dropped: real webrtc-audio-processing/AEC (no AEC/NS/AGC exists at all yet), macOS/iOS SCREEN_AUDIO capture, process-specific loopback, and a pre-existing RT-thread rule violation in the capture path that predates this work. Verified: ctest 12/12 green across 3 consecutive full-suite runs (both dev and m1-dev presets build clean); test_vad_ptt_devices passed 5 consecutive standalone runs; manually verified live (vccli --list-devices against real hardware, vccli --voice --input-mode vad streaming without incident). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 16:11:52 +02:00
# Post-M3 follow-up: device enumeration, VAD/PTT input gate, true stereo playback mixing —
# the items PROGRESS.md's M3 section explicitly carried forward as out of scope.
add_executable(test_vad_ptt_devices test_vad_ptt_devices.cpp)
target_link_libraries(test_vad_ptt_devices PRIVATE voicecat::server)
target_compile_features(test_vad_ptt_devices PRIVATE cxx_std_20)
target_include_directories(test_vad_ptt_devices PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME vad_ptt_devices COMMAND test_vad_ptt_devices)
set_tests_properties(vad_ptt_devices PROPERTIES TIMEOUT 60)
feat(M4): Windows WinForms client, TOFU identity pinning, VAD threshold + always-on mode Core ABI extensions (voicecat.h): - vc_list_channels / vc_list_users / vc_list_user_streams — pull-based snapshot getters for the channel-tree and user-list UI; session_model_mu_ guards cross-thread reads - VC_EVENT_JOIN_RESULT / vc_join_channel — channel join with optional password - VC_EVENT_SERVER_IDENTITY + vc_confirm_server_identity — TOFU gate that blocks io_thread_ until the UI approves or rejects; pins TLS leaf-cert SHA-256 (not declared Ed25519) - vc_get_server_identity_display — Ed25519 fingerprint for human-readable display only - VC_INPUT_ALWAYS_ON = 2 in vc_input_mode — transmit unconditionally, no VAD gate - vc_set_vad_threshold — live RMS threshold update (0.0–1.0); EnergyVadProcessor stores it atomically so the audio RT path reads without a lock C++ implementation: - SessionModel::apply_snapshot / apply_channel_event fixed to populate parent_id, password_protected, and max_users (were permanently zeroed) - TlsContext::peer_cert_fingerprint — SHA-256 of peer leaf cert DER via mbedTLS - TofuStore split into peek (read-only) + pin (write) so first-connect only persists after user approval; tofu_store_path in vc_config for per-user pin file location - TcpAcceptor uses dual-stack IPv6+IPv4 fallback (fixes localhost → ::1 on Windows) - windows-client CMake preset: Release shared DLL, static MinGW runtime, no tools/tests - New C++ tests: test_channel_user_list_abi, test_tofu_flow (14/14 green) Windows client (clients/windows/ — .NET 10 WinForms): - VoiceCat.Interop: LibraryImport P/Invoke surface, UnmanagedCallersOnly callbacks, Channel<VoiceCatEvent> event delivery drained by 30ms WinForms Timer - VoiceCat.App: ConnectDialog (saved servers, DPAPI password storage), ServerIdentity- Dialog (TOFU first-connect / mismatch warning), MainForm (channel TreeView, user ListBox, RichTextBox chat, voice controls, device pickers, VAD/PTT/always-on mode, per-user gain/mute/NR tuning, VAD sensitivity TrackBar, level meter ProgressBar) - PttKeyCaptureDialog — focus-scoped PTT key capture (documented limitation) - PerUserTuningDialog — real-time gain/mute/NR applied to all of a user's streams - Accessibility: explicit AccessibleName/Description on every control, & mnemonics, Activity log ListBox as durable screen-reader record, AutomationNotification for curated live announcements Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-17 00:35:16 +02:00
# M4: channel/user/stream snapshot getters (vc_list_channels/vc_list_users/
# vc_list_user_streams) — through the real C ABI against a real in-process server.
add_executable(test_channel_user_list_abi test_channel_user_list_abi.cpp)
target_link_libraries(test_channel_user_list_abi PRIVATE voicecat::server)
target_compile_features(test_channel_user_list_abi PRIVATE cxx_std_20)
target_include_directories(test_channel_user_list_abi PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME channel_user_list_abi COMMAND test_channel_user_list_abi)
set_tests_properties(channel_user_list_abi PROPERTIES TIMEOUT 60)
# M4: TOFU server-identity gate (VC_EVENT_SERVER_IDENTITY / vc_confirm_server_identity /
# vc_get_server_identity_display) — real TLS handshakes against real in-process servers.
add_executable(test_tofu_flow test_tofu_flow.cpp)
target_link_libraries(test_tofu_flow PRIVATE voicecat::server)
target_compile_features(test_tofu_flow PRIVATE cxx_std_20)
target_include_directories(test_tofu_flow PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME tofu_flow COMMAND test_tofu_flow)
set_tests_properties(tofu_flow PROPERTIES TIMEOUT 90)
# M5 Phase 1: permission enforcement + SetPermissionRequest + channel create.
add_executable(test_m5_permissions test_m5_permissions.cpp)
target_link_libraries(test_m5_permissions PRIVATE voicecat::server)
target_compile_features(test_m5_permissions PRIVATE cxx_std_20)
target_include_directories(test_m5_permissions PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME m5_permissions COMMAND test_m5_permissions)
set_tests_properties(m5_permissions PROPERTIES TIMEOUT 60)
# M5 Phase 2: kick/ban/move/server-mute.
add_executable(test_m5_kick_ban_move_mute test_m5_kick_ban_move_mute.cpp)
target_link_libraries(test_m5_kick_ban_move_mute PRIVATE voicecat::server)
target_compile_features(test_m5_kick_ban_move_mute PRIVATE cxx_std_20)
target_include_directories(test_m5_kick_ban_move_mute PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME m5_kick_ban_move_mute COMMAND test_m5_kick_ban_move_mute)
set_tests_properties(m5_kick_ban_move_mute PROPERTIES TIMEOUT 90)
# M5 Phase 3: in-app admin account management.
add_executable(test_m5_admin_accounts test_m5_admin_accounts.cpp)
target_link_libraries(test_m5_admin_accounts PRIVATE voicecat::server)
target_compile_features(test_m5_admin_accounts PRIVATE cxx_std_20)
target_include_directories(test_m5_admin_accounts PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME m5_admin_accounts COMMAND test_m5_admin_accounts)
set_tests_properties(m5_admin_accounts PROPERTIES TIMEOUT 90)
# M5 Phase 4: channel CRUD & password enforcement.
add_executable(test_m5_channel_crud test_m5_channel_crud.cpp)
target_link_libraries(test_m5_channel_crud PRIVATE voicecat::server)
target_compile_features(test_m5_channel_crud PRIVATE cxx_std_20)
target_include_directories(test_m5_channel_crud PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME m5_channel_crud COMMAND test_m5_channel_crud)
set_tests_properties(m5_channel_crud PROPERTIES TIMEOUT 90)
fix(net): broadcast LEFT on disconnect, add keepalive/reaper, cap PLC hiss Three reported bugs traced to one root cause plus two missing designed features: 1. Stale users + eternal PLC hiss (root cause): ConnSession::close() silently erased dropped users without broadcasting UserEvent::LEFT, so peers never learned the user left and their audio engines never called remove_stream — Opus PLC synthesized comfort noise forever. Fix: broadcast_left() helper + close() broadcasts LEFT before erasing. 2. PLC cap (defense-in-depth): on_playback now caps pure PLC at ~2s, then emits digital silence so a stale stream can never hiss forever even if remove_stream is skipped. Resets automatically on fresh packets. 3. No timeout / no ping: client never sent Ping, server had no last_seen / reaper, so half-open connections (NAT timeout, wifi loss, sleep) left ghost users forever. Fix: client Ping every 15s with RTT measurement, ConnSession::last_seen bumped on every inbound TCP/UDP frame, steady_timer reaper sweeps every 15s and drops sessions older than 45s (configurable via server::Config). 4. UDP KEEPALIVE: client sends plaintext kFrameKeepalive every 5s; server bumps last_seen + echoes back. Keeps NAT bindings alive and lets media activity defer the reaper independently of TCP. 5. Graceful client disconnect: vc_disconnect() sends Disconnect{code=0} via a flag-based io-thread exit (no double-close race); server handles client-sent Disconnect with immediate close() + LEFT broadcast. 3 new tests: disconnect_left, plc_cap, reaper_timeout. 21/21 ctest green. Docs: protocol.md §6/§7, voice.md §6, architecture.md §5, PROGRESS.md.
2026-06-18 01:18:33 +02:00
# Disconnect/timeout: server broadcasts UserEvent::LEFT on TCP drop (no more ghost
# users or eternal PLC hiss on peers). Also covers the keepalive/reaper paths added
# alongside the LEFT-broadcast fix.
add_executable(test_disconnect_left test_disconnect_left.cpp)
target_link_libraries(test_disconnect_left PRIVATE voicecat::server)
target_compile_features(test_disconnect_left PRIVATE cxx_std_20)
target_include_directories(test_disconnect_left PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME disconnect_left COMMAND test_disconnect_left)
set_tests_properties(disconnect_left PROPERTIES TIMEOUT 90)
# Reaper: half-open connections (no TCP EOF) are dropped after the configurable timeout,
# peers get UserEvent::LEFT, the stale client gets disconnected. Uses a 2s timeout for
# fast test turnaround (production default is 45s).
add_executable(test_reaper_timeout test_reaper_timeout.cpp)
target_link_libraries(test_reaper_timeout PRIVATE voicecat::server)
target_compile_features(test_reaper_timeout PRIVATE cxx_std_20)
target_include_directories(test_reaper_timeout PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME reaper_timeout COMMAND test_reaper_timeout)
set_tests_properties(reaper_timeout PROPERTIES TIMEOUT 30)
# DRED toggle: per-channel dred flag round-trips through protocol; encoder initialises
# with DRED; PCM injection through DRED-enabled encode path runs without crash.
add_executable(test_dred_toggle test_dred_toggle.cpp)
target_link_libraries(test_dred_toggle PRIVATE voicecat::server)
target_compile_features(test_dred_toggle PRIVATE cxx_std_20)
target_include_directories(test_dred_toggle PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME dred_toggle COMMAND test_dred_toggle)
set_tests_properties(dred_toggle PROPERTIES TIMEOUT 60)
feat: external PCM feed/tap API (vc_stream_feed_pcm + vc_set_pcm_sink) Promotes vc_test_inject_capture (mono-only, TEST-ONLY) to a public, stereo-capable production API and adds a symmetric PCM tap on the receive side. Enables ReplayKit (iOS), ScreenCaptureKit (macOS), bots, soundboards, and custom clients — all without a hardware audio device. Core C++: - voicecat.h: new vc_stream_feed_pcm, vc_pcm_sink_cb typedef, vc_set_pcm_sink; vc_test_inject_capture kept as deprecated alias - audio_engine: stereo-aware inject_capture (channels param + ring reset on channel-count change); atomic pcm_sink_ fired per decoded frame in on_playback; RemoteStream carries user_id/stream_id for RT-safe sink metadata; init_recv_stream takes user_id+stream_id - client.cpp: stream_feed_pcm / set_pcm_sink implementations; sync_remote_streams passes user_id/stream_id to init_recv_stream - voicecat.cpp: trampolines + channels=1/2 validation Tests: test_external_pcm (headless, 3 sub-tests: mono round-trip, stereo feed L≠R, sink metadata+disable). ctest 23/23. Swift: feedPcm / setPcmSink in VoiceCatClient.swift + 4 XCTest smoke tests (ExternalPcmTests.swift). C#: StreamFeedPcm / SetPcmSink in VoiceCatClient.cs + NativeMethods.cs (vc_stream_feed_pcm unsafe P/Invoke, VcPcmSinkCallback delegate, vc_set_pcm_sink via nint) + 4 xUnit smoke tests (ExternalPcmTests.cs). Docs: architecture.md §4 new subsection, voice.md §9 updated (macOS/iOS now reference vc_stream_feed_pcm), protocol.md §8 explicit no-protocol-change note, roadmap.md M5 entry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-20 17:52:09 +02:00
# External PCM feed/tap API:
# test_feed_pcm_round_trip — vc_stream_feed_pcm (mono), verified via pcm_sink.
# test_feed_pcm_stereo — vc_stream_feed_pcm (stereo, Music Room), L != R assertion.
# test_pcm_sink — vc_set_pcm_sink metadata (user_id / stream_id / sr) + disable.
add_executable(test_external_pcm test_external_pcm.cpp)
target_link_libraries(test_external_pcm PRIVATE voicecat::server)
target_compile_features(test_external_pcm PRIVATE cxx_std_20)
target_include_directories(test_external_pcm PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME external_pcm COMMAND test_external_pcm)
set_tests_properties(external_pcm PROPERTIES TIMEOUT 90)
# Non-20ms channel frame_ms: the fixed 48k/20ms engine clock is reframed to the channel's
# Opus window before encoding. 40ms (accumulate) and 10ms (split) feed->sink round trips.
add_executable(test_frame_ms_reframe test_frame_ms_reframe.cpp)
target_link_libraries(test_frame_ms_reframe PRIVATE voicecat::server)
target_compile_features(test_frame_ms_reframe PRIVATE cxx_std_20)
target_include_directories(test_frame_ms_reframe PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME frame_ms_reframe COMMAND test_frame_ms_reframe)
set_tests_properties(frame_ms_reframe PROPERTIES TIMEOUT 90)
# Per-channel sample_rate as an Opus bandwidth cap (OPUS_SET_MAX_BANDWIDTH): a 7 kHz tone is
# attenuated on an 8 kHz (narrowband) channel vs a 48 kHz (full-band) channel.
add_executable(test_channel_samplerate test_channel_samplerate.cpp)
target_link_libraries(test_channel_samplerate PRIVATE voicecat::server)
target_compile_features(test_channel_samplerate PRIVATE cxx_std_20)
target_include_directories(test_channel_samplerate PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME channel_samplerate COMMAND test_channel_samplerate)
set_tests_properties(channel_samplerate PROPERTIES TIMEOUT 90)
feat(audio): real noise suppression via vendored RNNoise (send + receive) The two-sided NR plumbing (RemoteStream::recv_ns + the per-listener vc_set_remote_stream noise_reduction toggle) was wired but inert: ApmProcessor::create() returned a no-op passthrough, because the originally-planned webrtc-audio-processing has no working Windows/macOS build. Drop in RNNoise as the real backend behind the same ApmProcessor interface, lighting up both NR paths. - Vendor RNNoise (BSD-3 + CC0) at third_party/rnnoise/ — the vcpkg port is !windows !arm, so it can't cover our primary targets. Shrunk int8 model (78MB -> 11.7MB via upstream scripts/shrink_model.sh), built as a standalone C static lib with no RTCD (portable scalar path on x86, auto-NEON on arm64) under -DDISABLE_DEBUG_FLOAT. Model is baked in (rnnoise_create(NULL)); no runtime file. - New RnnoiseProcessor (core/src/audio/apm_processor.cpp) selected by ApmProcessor::create() when VOICECAT_HAS_NS. Mono/48kHz/480-sample; our clock is fixed 48kHz and Opus frame sizes are multiples of 480, so no resampling. RT-safe: allocates at construction, lock-free in the capture/playback callbacks. - Receive-side: lit up via the factory; gated to mono streams (a stereo stream is a screen-audio share, not voice). - Send-side (new): vc_set_input_noise_reduction(client, enable) ABI + vc_client::mic_ns_, run before input gain/VAD in on_capture_frame. A stereo mic is downmixed to mono ONLY when NR is on — with NR off a stereo mic keeps full stereo (never collapse mic quality unasked). - Enable C as a project language for the vendored lib. - New noise_suppression test: white noise through ApmProcessor::create() drops ~99.9% RMS. ctest --preset dev green, 28/28. windows-client DLL builds clean with vc_set_input_noise_reduction exported, system-only deps. - Docs synced: voice.md §10, tech-stack.md §1/§5, third_party/README.md, vcpkg.json note, PROGRESS.md, CLAUDE.md. Client on/off UI toggles (Windows/macOS/iOS) are the remaining follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 13:30:54 +02:00
# Noise suppression: the RNNoise backend behind ApmProcessor actually denoises (docs/voice.md
# §10-11). Links core only; reaches the internal audio/ headers for ApmProcessor::create().
add_executable(test_noise_suppression test_noise_suppression.cpp)
target_link_libraries(test_noise_suppression PRIVATE voicecat::voicecat)
target_compile_features(test_noise_suppression PRIVATE cxx_std_20)
target_include_directories(test_noise_suppression PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME noise_suppression COMMAND test_noise_suppression)
# Receive-side NR through the decode loop: a stereo VOICE stream is actually denoised
# (regression for the stereo-mic bypass), and a screen-audio share is left untouched.
# White-box AudioEngine test; paced realtime feed, so it needs a generous timeout.
add_executable(test_recv_noise_reduction test_recv_noise_reduction.cpp)
target_link_libraries(test_recv_noise_reduction PRIVATE voicecat::voicecat)
target_compile_features(test_recv_noise_reduction PRIVATE cxx_std_20)
target_include_directories(test_recv_noise_reduction PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
add_test(NAME recv_noise_reduction COMMAND test_recv_noise_reduction)
set_tests_properties(recv_noise_reduction PROPERTIES TIMEOUT 90)