Skip to content

Commit 7768e1d

Browse files
examples -> cpp-examples-collection, CI to build collection in docker
1 parent a9b271f commit 7768e1d

54 files changed

Lines changed: 99 additions & 7916 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/builds.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,18 @@ jobs:
266266
submodules: recursive
267267
fetch-depth: 0
268268

269+
# Default ubuntu-latest images are tight on disk; this Dockerfile builds GCC
270+
# from source plus Rust — BuildKit export/import needs several extra GB.
271+
- name: Free disk space
272+
uses: jlumbroso/free-disk-space@v1.3.1
273+
with:
274+
tool-cache: false
275+
android: true
276+
dotnet: true
277+
haskell: true
278+
large-packages: true
279+
swap-storage: true
280+
269281
- name: Set up Docker Buildx
270282
uses: docker/setup-buildx-action@v3
271283

@@ -305,6 +317,16 @@ jobs:
305317
submodules: recursive
306318
fetch-depth: 0
307319

320+
- name: Free disk space
321+
uses: jlumbroso/free-disk-space@v1.3.1
322+
with:
323+
tool-cache: false
324+
android: true
325+
dotnet: true
326+
haskell: true
327+
large-packages: true
328+
swap-storage: true
329+
308330
- name: Set up Docker Buildx
309331
uses: docker/setup-buildx-action@v3
310332

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ build.log
99
build/
1010
build-debug/
1111
build-release/
12+
local-install/
1213
release/
1314
vcpkg_installed/
1415
# Generated header

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "client-sdk-rust"]
22
path = client-sdk-rust
33
url = https://github.com/livekit/client-sdk-rust
4+
[submodule "cpp-example-collection"]
5+
path = cpp-example-collection
6+
url = https://github.com/livekit-examples/cpp-example-collection.git

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,8 @@ install(FILES
689689
add_subdirectory(bridge)
690690

691691
if(LIVEKIT_BUILD_EXAMPLES)
692-
add_subdirectory(examples)
692+
include(cpp-example-collection)
693+
livekit_configure_cpp_example_collection()
693694
endif()
694695

695696
if(LIVEKIT_BUILD_TESTS)

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,22 @@ lk token create -r test -i your_own_identity --join --valid-for 99999h --dev --
150150

151151
### SimpleRoom
152152

153-
```bash
154-
./build/examples/SimpleRoom --url $URL --token <jwt-token>
153+
```bash`
154+
./build-release/cpp-example-collection-build/simple_room/SimpleRoom --url $URL --token <jwt-token>
155155
```
156156
157157
You can also provide the URL and token via environment variables:
158158
```bash
159159
export LIVEKIT_URL=ws://localhost:7880
160160
export LIVEKIT_TOKEN=<jwt-token>
161-
./build/examples/SimpleRoom
161+
./build-release/cpp-example-collection-build/simple_room/SimpleRoom
162162
```
163163

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

233233
**Sender** (e.g. greeter)
@@ -306,7 +306,7 @@ livekit::setLogCallback(
306306
livekit::setLogCallback(nullptr);
307307
```
308308

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

cmake/cpp-example-collection.cmake

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Copyright 2026 LiveKit, Inc.
2+
#
3+
# LiveKit examples integration helpers.
4+
5+
include_guard(GLOBAL)
6+
7+
function(livekit_configure_cpp_example_collection)
8+
# Absolute paths so out-of-tree builds and symlinks behave consistently.
9+
get_filename_component(LIVEKIT_CPP_EXAMPLES_SOURCE_DIR
10+
"${CMAKE_SOURCE_DIR}/cpp-example-collection" ABSOLUTE)
11+
12+
get_filename_component(_lk_examples_install_default
13+
"${CMAKE_SOURCE_DIR}/local-install" ABSOLUTE)
14+
set(LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX "${_lk_examples_install_default}"
15+
CACHE PATH "Install prefix used by cpp-example-collection")
16+
17+
get_filename_component(_lk_examples_binary_default
18+
"${CMAKE_BINARY_DIR}/cpp-example-collection-build" ABSOLUTE)
19+
set(LIVEKIT_CPP_EXAMPLES_BINARY_DIR "${_lk_examples_binary_default}"
20+
CACHE PATH "Build directory for cpp-example-collection")
21+
22+
get_filename_component(LIVEKIT_CPP_EXAMPLES_LIVEKIT_DIR
23+
"${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/LiveKit"
24+
ABSOLUTE)
25+
26+
if(NOT EXISTS "${LIVEKIT_CPP_EXAMPLES_SOURCE_DIR}/CMakeLists.txt")
27+
message(FATAL_ERROR
28+
"cpp-example-collection submodule is missing. Run: "
29+
"git submodule sync --recursive && "
30+
"git submodule update --init --recursive --checkout")
31+
endif()
32+
33+
add_custom_target(install_livekit_sdk_for_examples
34+
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
35+
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}"
36+
--prefix "${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
37+
--config "$<CONFIG>"
38+
DEPENDS livekit
39+
COMMENT "Installing LiveKit SDK for cpp-example-collection"
40+
VERBATIM
41+
)
42+
43+
# cmake --install /Users/sderosa/workspaces/client-sdk-cpp/build-debug --prefix ~/livekit-sdk-local
44+
45+
46+
add_custom_target(cpp_example_collection ALL
47+
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}"
48+
--prefix "${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
49+
COMMAND ${CMAKE_COMMAND} -S "${LIVEKIT_CPP_EXAMPLES_SOURCE_DIR}"
50+
-B "${LIVEKIT_CPP_EXAMPLES_BINARY_DIR}"
51+
"-DCMAKE_PREFIX_PATH=${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
52+
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
53+
"-DLIVEKIT_LOCAL_SDK_DIR=${LIVEKIT_CPP_EXAMPLES_INSTALL_PREFIX}"
54+
"-DLiveKit_DIR=${LIVEKIT_CPP_EXAMPLES_LIVEKIT_DIR}"
55+
COMMAND ${CMAKE_COMMAND} --build "${LIVEKIT_CPP_EXAMPLES_BINARY_DIR}"
56+
--config "$<CONFIG>"
57+
DEPENDS install_livekit_sdk_for_examples
58+
COMMENT "Configuring and building cpp-example-collection"
59+
VERBATIM
60+
)
61+
endfunction()

cmake/spdlog.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ FetchContent_Declare(
7171
set(SPDLOG_BUILD_SHARED OFF CACHE BOOL "" FORCE)
7272
set(SPDLOG_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE)
7373
set(SPDLOG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
74-
set(SPDLOG_INSTALL OFF CACHE BOOL "" FORCE)
74+
set(SPDLOG_INSTALL ON CACHE BOOL "" FORCE)
7575

7676
FetchContent_MakeAvailable(livekit_spdlog)
7777

cpp-example-collection

Submodule cpp-example-collection added at 5b440d5

docker/Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,14 @@ WORKDIR /client-sdk-cpp
112112
RUN mkdir -p /client-sdk-cpp
113113
COPY src /client-sdk-cpp/src
114114
COPY include /client-sdk-cpp/include
115-
COPY bridge /client-sdk-cpp/bridge
116115
COPY build.sh /client-sdk-cpp/build.sh
117116
COPY CMakePresets.json /client-sdk-cpp/CMakePresets.json
118117
COPY build.cmd /client-sdk-cpp/build.cmd
119118
COPY client-sdk-rust /client-sdk-cpp/client-sdk-rust
120119
COPY data /client-sdk-cpp/data
121-
COPY examples /client-sdk-cpp/examples
122120
COPY cmake /client-sdk-cpp/cmake
123121
COPY CMakeLists.txt /client-sdk-cpp/CMakeLists.txt
124122
COPY build.h.in /client-sdk-cpp/build.h.in
125-
COPY build.sh /client-sdk-cpp/build.sh
126-
COPY build.cmd /client-sdk-cpp/build.cmd
127123

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

0 commit comments

Comments
 (0)