Adds the full voice pipeline: 14-byte binary frame header, ChaCha20-Poly1305 AEAD keyed from the TLS exporter, libopus encode/decode with FEC/PLC/DTX, an adaptive per-ssrc jitter buffer, a miniaudio capture/playback engine, an APM passthrough stub, and the UdpBinding/StreamAnnounce signaling chain wired through ConnSession/SessionRegistry into a new server-side SFU (MediaRelay) that decrypts and re-encrypts frames per channel member. Exit criterion verified: test_m2_voice — two headless clients relay 50 encrypted Opus frames through the server; ctest --preset m1-dev is 9/9 green. Also corrects protocol.md's UdpBinding diagram, which described the UDP-side binding packet as AEAD-sealed when it is in fact a plaintext bootstrap frame (separate from the TCP/TLS UdpBinding ack). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
68 lines
2.7 KiB
CMake
68 lines
2.7 KiB
CMake
# libvoicecat — the shared C++ core (docs/architecture.md).
|
|
# Sources are globbed so adding a stub under src/<subsystem>/ needs no CMake edit.
|
|
file(GLOB_RECURSE VOICECAT_SOURCES CONFIGURE_DEPENDS
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
|
|
|
if(VOICECAT_BUILD_SHARED)
|
|
add_library(voicecat SHARED ${VOICECAT_SOURCES})
|
|
else()
|
|
add_library(voicecat STATIC ${VOICECAT_SOURCES})
|
|
# Static consumers must see VC_API as empty (no dllimport).
|
|
target_compile_definitions(voicecat PUBLIC VOICECAT_STATIC)
|
|
endif()
|
|
add_library(voicecat::voicecat ALIAS voicecat)
|
|
|
|
target_include_directories(voicecat
|
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
|
|
target_compile_definitions(voicecat PRIVATE VOICECAT_BUILDING)
|
|
target_compile_features(voicecat PUBLIC cxx_std_20)
|
|
|
|
set_target_properties(voicecat PROPERTIES
|
|
C_VISIBILITY_PRESET hidden
|
|
CXX_VISIBILITY_PRESET hidden
|
|
VISIBILITY_INLINES_HIDDEN ON)
|
|
|
|
if(VOICECAT_USE_VCPKG_DEPS)
|
|
find_package(protobuf CONFIG REQUIRED)
|
|
find_package(unofficial-sodium CONFIG REQUIRED)
|
|
find_package(MbedTLS CONFIG REQUIRED)
|
|
find_package(asio CONFIG REQUIRED)
|
|
find_package(unofficial-sqlite3 CONFIG REQUIRED)
|
|
find_package(spdlog CONFIG REQUIRED)
|
|
find_package(Opus CONFIG REQUIRED)
|
|
# miniaudio is header-only; vcpkg does not install a CMake config for it.
|
|
find_path(MINIAUDIO_INCLUDE_DIR "miniaudio.h" REQUIRED)
|
|
|
|
# Generate C++ from voicecat.proto into the build tree.
|
|
protobuf_generate(
|
|
TARGET voicecat
|
|
PROTOS proto/voicecat.proto
|
|
LANGUAGE cpp
|
|
IMPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/proto
|
|
PROTOC_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated/proto)
|
|
# Generated .pb.h files are included by protocol/envelope.h (consumed by tests and server),
|
|
# so the generated dir and protobuf itself must be PUBLIC.
|
|
target_include_directories(voicecat PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/generated)
|
|
|
|
target_link_libraries(voicecat
|
|
PUBLIC protobuf::libprotobuf
|
|
PRIVATE unofficial-sodium::sodium
|
|
MbedTLS::mbedtls MbedTLS::mbedcrypto MbedTLS::mbedx509
|
|
asio::asio unofficial::sqlite3::sqlite3 spdlog::spdlog
|
|
Opus::opus)
|
|
|
|
target_include_directories(voicecat PRIVATE ${MINIAUDIO_INCLUDE_DIR})
|
|
|
|
target_compile_definitions(voicecat PUBLIC VOICECAT_HAS_OPUS VOICECAT_HAS_AUDIO)
|
|
|
|
if(WIN32)
|
|
# AcceptEx / GetAcceptExSockaddrs live in mswsock; ws2_32 covers the base Winsock API.
|
|
target_link_libraries(voicecat PRIVATE ws2_32 mswsock)
|
|
endif()
|
|
|
|
# Signal to C++ code that the real networking/crypto stack is available.
|
|
target_compile_definitions(voicecat PUBLIC VOICECAT_HAS_NET)
|
|
endif()
|