|
1 | 1 | # AGENTS.md — LiveKit C++ Client SDK |
2 | 2 |
|
| 3 | +## Shared C++ Baseline |
| 4 | + |
| 5 | +Follow `cpp-tools/AGENTS.md` for shared C++ rules and this file for SDK-specific |
| 6 | +guidance. |
| 7 | + |
| 8 | +Before C++ work, verify the shared guidance and root `.clang-format` / |
| 9 | +`.clang-tidy` symlinks are present. If not, flag it and recommend |
| 10 | +`git submodule update --init cpp-tools` or `./cpp-tools/install.sh` as |
| 11 | +appropriate. Never use `--force` without approval or claim tooling verification |
| 12 | +while these prerequisites are missing. Project-specific commands are documented |
| 13 | +in `docs/tools.md`. |
| 14 | + |
3 | 15 | ## Project Overview |
4 | 16 |
|
5 | 17 | This is **client-sdk-cpp**, the official LiveKit C++ client SDK. It wraps a Rust core (`client-sdk-rust/`) via a protobuf-based FFI bridge. All WebRTC, networking, and media logic lives in Rust; the C++ layer provides an ergonomic API for C++ consumers. |
@@ -76,7 +88,7 @@ Be sure to update the directory layout in this file if the directory layout chan |
76 | 88 | | `src/tests/` | Google Test integration and stress tests | |
77 | 89 | | `examples/` | In-tree example applications | |
78 | 90 | | `client-sdk-rust/` | Git submodule holding the Rust core of the SDK| |
79 | | -| `cpp-tools/` | Git submodule holding shared LiveKit C++ clang-format / clang-tidy configs, scripts, docs, and CI workflow | |
| 91 | +| `cpp-tools/` | Git submodule holding shared LiveKit C++ engineering guidance, clang-format / clang-tidy configs, scripts, docs, and CI workflow | |
80 | 92 | | `client-sdk-rust/livekit-ffi/protocol/*.proto` | FFI contract (protobuf definitions, read-only reference) | |
81 | 93 | | `cmake/` | Build helpers (`protobuf.cmake`, `spdlog.cmake`, `nlohmann_json.cmake`, `LiveKitConfig.cmake.in`) | |
82 | 94 | | `docker/` | Dockerfile for CI and SDK distribution images | |
@@ -306,33 +318,12 @@ internal symbols are too noisy to enforce) and `WARN_AS_ERROR = FAIL_ON_WARNINGS |
306 | 318 | so any other warning (broken `@ref`, unknown `@command`, unsupported HTML tag, |
307 | 319 | malformed table, missing `@param` on a documented function, …) fails the build. |
308 | 320 |
|
309 | | -### Integer Types |
310 | | - |
311 | | -- Prefer fixed-width integer types from `<cstdint>` (`std::int32_t`, `std::uint64_t`, etc.) over raw primitive integer types when size or signedness matters. |
312 | | -- This applies in public APIs, FFI/protobuf-facing code, serialized payloads, handles, timestamps, IDs, and any cross-platform boundary where integer width must be explicit. |
313 | | -- Use raw primitive integer types only when the value is intentionally platform-sized or when preserving an existing public API is necessary for backwards compatibility. |
314 | | -- Do not change an existing public API from a raw primitive integer type to a fixed-width type for style consistency alone unless the compatibility impact has been reviewed. |
315 | | - |
316 | | -### Git Practices |
317 | | - |
318 | | -- Use `git mv` when moving or renaming files. |
319 | | - |
320 | 321 | ### CMake |
321 | 322 |
|
322 | 323 | - spdlog is linked **PRIVATE** to the `livekit` target. It must not appear in exported/installed dependencies. |
323 | 324 | - protobuf is vendored via FetchContent on non-Windows platforms; Windows uses vcpkg. |
324 | 325 | - The CMake install produces a `find_package(LiveKit CONFIG)`-compatible package with `LiveKitConfig.cmake`, `LiveKitTargets.cmake`, and `LiveKitConfigVersion.cmake`. |
325 | 326 |
|
326 | | -### Readability and Performance |
327 | | - |
328 | | -Code should be easy to read and understand. If a sacrifice is made for performance or readability, it should be documented. |
329 | | - |
330 | | -Adhere to clang-format checks configured in `.clang-format`, which is installed as a symlink to `cpp-tools/.clang-format`. Run `./cpp-tools/clang-format.sh --path src --path include --path benchmarks` to confirm code styling, or add `--fix` to rewrite files. |
331 | | - |
332 | | -### Static Analysis |
333 | | - |
334 | | -Adhere to clang-tidy checks configured in `.clang-tidy`, which is installed as a symlink to `cpp-tools/.clang-tidy`. Run `./cpp-tools/clang-tidy.sh` with the repository-specific build directory and filters documented in `docs/tools.md`. |
335 | | - |
336 | 327 | ## Dependencies |
337 | 328 |
|
338 | 329 | | Dependency | Scope | Notes | |
@@ -374,13 +365,6 @@ Integration tests (`src/tests/integration/`) cover: room connections, callbacks, |
374 | 365 | When adding new client facing functionality, add a new test case to the existing test suite. |
375 | 366 | When adding new client facing functionality, add benchmarking to understand the limitations of the new functionality. |
376 | 367 |
|
377 | | -## General C++ Development |
378 | | - |
379 | | -- Do not use dynamic memory allocation after initialization |
380 | | -- Keep each function short (roughly ≤ 60 lines) |
381 | | -- Declare all data objects at the smallest possible level of scope |
382 | | -- Each calling function must check the return value of nonvoid functions, and each called function must check the validity of all parameters provided by the caller |
383 | | - |
384 | 368 | ## Common Pitfalls |
385 | 369 |
|
386 | 370 | - A `Room` with `auto_subscribe = false` will never receive remote audio/video frames — this is almost never what you want. |
|
0 commit comments