Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ build.log
build/
build-debug/
build-release/
local-install/
release/
vcpkg_installed/
# Generated header
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "client-sdk-rust"]
path = client-sdk-rust
url = https://github.com/livekit/client-sdk-rust
[submodule "cpp-example-collection"]
path = cpp-example-collection
url = https://github.com/livekit-examples/cpp-example-collection.git
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,8 @@ install(FILES
add_subdirectory(bridge)

if(LIVEKIT_BUILD_EXAMPLES)
add_subdirectory(examples)
include(cpp-example-collection)
livekit_configure_cpp_example_collection()
endif()

if(LIVEKIT_BUILD_TESTS)
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,22 @@ lk token create -r test -i your_own_identity --join --valid-for 99999h --dev --

### SimpleRoom

```bash
./build/examples/SimpleRoom --url $URL --token <jwt-token>
```bash`
./build-release/cpp-example-collection-build/simple_room/SimpleRoom --url $URL --token <jwt-token>
```

You can also provide the URL and token via environment variables:
```bash
export LIVEKIT_URL=ws://localhost:7880
export LIVEKIT_TOKEN=<jwt-token>
./build/examples/SimpleRoom
./build-release/cpp-example-collection-build/simple_room/SimpleRoom
```

**End-to-End Encryption (E2EE)**
You can enable E2E encryption for the streams via --enable_e2ee and --e2ee_key flags,
by running the following cmds in two terminals or computers. **Note, jwt_token needs to be different identity**
```bash
./build/examples/SimpleRoom --url $URL --token <jwt-token> --enable_e2ee --e2ee_key="your_key"
./build-release/cpp-example-collection-build/simple_room/SimpleRoom --url $URL --token <jwt-token> --enable_e2ee --e2ee_key="your_key"
```
**Note**, **all participants must use the exact same E2EE configuration and shared key.**
If the E2EE keys do not match between participants:
Expand Down Expand Up @@ -195,7 +195,7 @@ lk token create -r test -i math-genius --join --valid-for 99999h --dev --room=yo
#### ▶ Start Participants
Every participant is run as a separate terminal process, note --role needs to match the token identity.
```bash
./build/examples/SimpleRpc --url $URL --token <jwt-token> --role=math-genius
./build-release/cpp-example-collection-build/simple_rpc/SimpleRpc --url $URL --token <jwt-token> --role=math-genius
```
The caller will automatically:
- Wait for the greeter and math-genius to join
Expand Down Expand Up @@ -223,11 +223,11 @@ lk token create -r test -i greeter --join --valid-for 99999h --dev --room=your_o
#### ▶ Start Participants
Start the receiver first (so it registers stream handlers before messages arrive):
```bash
./build/examples/SimpleDataStream --url $URL --token <jwt-token>
./build-release/cpp-example-collection-build/simple_data_stream/SimpleDataStream --url $URL --token <jwt-token>
```
On another terminal or computer, start the sender
```bash
./build/examples/SimpleDataStream --url $URL --token <jwt-token>
./build-release/cpp-example-collection-build/simple_data_stream/SimpleDataStream --url $URL --token <jwt-token>
```

**Sender** (e.g. greeter)
Expand Down Expand Up @@ -306,7 +306,7 @@ livekit::setLogCallback(
livekit::setLogCallback(nullptr);
```

See [`examples/logging_levels/custom_sinks.cpp`](examples/logging_levels/custom_sinks.cpp)
See [`cpp-example-collection/logging_levels/custom_sinks.cpp`](cpp-example-collection/logging_levels/custom_sinks.cpp)
for three copy-paste-ready patterns: **file logger**, **JSON structured lines**,
and a **ROS2 bridge** that maps `LogLevel` to `RCLCPP_*` macros.

Expand Down
61 changes: 61 additions & 0 deletions cmake/cpp-example-collection.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2026 LiveKit, Inc.
#
# LiveKit examples integration helpers.

include_guard(GLOBAL)

function(livekit_configure_cpp_example_collection)
# Absolute paths so out-of-tree builds and symlinks behave consistently.
get_filename_component(LIVEKIT_CPP_EXAMPLES_SOURCE_DIR
"${CMAKE_SOURCE_DIR}/cpp-example-collection" ABSOLUTE)

get_filename_component(_lk_examples_install_default
"${CMAKE_SOURCE_DIR}/local-install" ABSOLUTE)
set(LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX "${_lk_examples_install_default}"
CACHE PATH "Install prefix used by cpp-example-collection")

get_filename_component(_lk_examples_binary_default
"${CMAKE_BINARY_DIR}/cpp-example-collection-build" ABSOLUTE)
set(LIVEKIT_CPP_EXAMPLES_BINARY_DIR "${_lk_examples_binary_default}"
CACHE PATH "Build directory for cpp-example-collection")

get_filename_component(LIVEKIT_CPP_EXAMPLES_LIVEKIT_DIR
"${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/LiveKit"
ABSOLUTE)

if(NOT EXISTS "${LIVEKIT_CPP_EXAMPLES_SOURCE_DIR}/CMakeLists.txt")
message(FATAL_ERROR
"cpp-example-collection submodule is missing. Run: "
"git submodule sync --recursive && "
"git submodule update --init --recursive --checkout")
endif()

add_custom_target(install_livekit_sdk_for_examples
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}"
--prefix "${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
--config "$<CONFIG>"
DEPENDS livekit
COMMENT "Installing LiveKit SDK for cpp-example-collection"
VERBATIM
)

# cmake --install /Users/sderosa/workspaces/client-sdk-cpp/build-debug --prefix ~/livekit-sdk-local


add_custom_target(cpp_example_collection ALL
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}"
--prefix "${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
COMMAND ${CMAKE_COMMAND} -S "${LIVEKIT_CPP_EXAMPLES_SOURCE_DIR}"
-B "${LIVEKIT_CPP_EXAMPLES_BINARY_DIR}"
"-DCMAKE_PREFIX_PATH=${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DLIVEKIT_LOCAL_SDK_DIR=${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
"-DLiveKit_DIR=${LIVEKIT_CPP_EXAMPLES_LIVEKIT_DIR}"
COMMAND ${CMAKE_COMMAND} --build "${LIVEKIT_CPP_EXAMPLES_BINARY_DIR}"
--config "$<CONFIG>"
DEPENDS install_livekit_sdk_for_examples
COMMENT "Configuring and building cpp-example-collection"
VERBATIM
)
Comment on lines +33 to +60
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both install_livekit_sdk_for_examples and cpp_example_collection are custom targets with no declared OUTPUT/BYPRODUCTS. CMake generators treat these as always-out-of-date, so enabling LIVEKIT_BUILD_EXAMPLES will re-run the install + external configure/build steps on every build invocation. Consider switching to ExternalProject_Add or using stamp files via add_custom_command(OUTPUT ...) so these steps are incremental and only re-run when inputs change.

Copilot uses AI. Check for mistakes.
endfunction()
2 changes: 1 addition & 1 deletion cmake/spdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ FetchContent_Declare(
set(SPDLOG_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE)
set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(SPDLOG_INSTALL OFF CACHE BOOL "" FORCE)
set(SPDLOG_INSTALL ON CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(livekit_spdlog)

Expand Down
1 change: 1 addition & 0 deletions cpp-example-collection
Submodule cpp-example-collection added at a74ca3
4 changes: 0 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,14 @@ WORKDIR /client-sdk-cpp
RUN mkdir -p /client-sdk-cpp
COPY src /client-sdk-cpp/src
COPY include /client-sdk-cpp/include
COPY bridge /client-sdk-cpp/bridge
COPY build.sh /client-sdk-cpp/build.sh
COPY CMakePresets.json /client-sdk-cpp/CMakePresets.json
COPY build.cmd /client-sdk-cpp/build.cmd
COPY client-sdk-rust /client-sdk-cpp/client-sdk-rust
COPY data /client-sdk-cpp/data
COPY examples /client-sdk-cpp/examples
COPY cmake /client-sdk-cpp/cmake
COPY CMakeLists.txt /client-sdk-cpp/CMakeLists.txt
COPY build.h.in /client-sdk-cpp/build.h.in
COPY build.sh /client-sdk-cpp/build.sh
COPY build.cmd /client-sdk-cpp/build.cmd

# Configure Rust linker: use full GCC path so liblto_plugin.so is found (not /home/installs/ which has no plugin)
RUN mkdir -p /client-sdk-cpp/client-sdk-rust/.cargo \
Expand Down
Loading
Loading