Skip to content

Commit a045d9b

Browse files
Doc updates
1 parent 4c5b55c commit a045d9b

4 files changed

Lines changed: 80 additions & 76 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2121
# Make "include(LiveKitSDK)" search in ./cmake
2222
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2323

24-
set(LIVEKIT_SDK_VERSION "latest" CACHE STRING "LiveKit C++ SDK version (e.g. 0.2.0 or latest)")
24+
set(LIVEKIT_SDK_VERSION "latest" CACHE STRING "LiveKit C++ SDK version (e.g. 1.3.0 or latest)")
2525
set(LIVEKIT_LOCAL_SDK_DIR "" CACHE PATH "Path to a local LiveKit SDK install prefix (skips download)")
2626

2727
if(LIVEKIT_LOCAL_SDK_DIR)

README.md

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,107 @@
11
# cpp-example-collection
2+
23
This repository contains a collection of small, self-contained examples for the
34
[LiveKit C++ SDK](https://github.com/livekit/client-sdk-cpp).
45

56
The goal of these examples is to demonstrate common usage patterns of the
67
LiveKit C++ SDK (connecting to a room, publishing tracks, RPC, data streams,
78
etc.) without requiring users to build the SDK from source.
89

9-
1010
## How the SDK is provided
1111

1212
These examples **automatically download a prebuilt LiveKit C++ SDK release**
1313
from GitHub at CMake configure time.
1414

15-
This is handled by the cmake helper: [LiveKitSDK.cmake ](https://github.com/livekit-examples/cpp-example-collection/cmake/LiveKitSDK.cmake)
15+
This is handled by the CMake helper:
16+
[`LiveKitSDK.cmake`](https://github.com/livekit-examples/cpp-example-collection/blob/main/cmake/LiveKitSDK.cmake).
1617

17-
## Selecting a LiveKit SDK version
18+
By default, CMake resolves `LIVEKIT_SDK_VERSION=latest` to the newest GitHub
19+
release and downloads the matching archive for your platform. The extracted SDK
20+
lands under **build/_deps/livekit-sdk/**.
1821

19-
By default, the examples download the **latest released** LiveKit C++ SDK.
22+
## Building the examples
2023

21-
You can pin a specific SDK version using the `LIVEKIT_SDK_VERSION` CMake option.
24+
Run these from the repository root. All examples — including
25+
[`token_source/`](token_source/) — build together in one pass.
2226

23-
### Examples
27+
### macOS / Linux
2428

25-
Use the latest release:
2629
```bash
2730
cmake -S . -B build
28-
# Or use a specific version (recommended for reproducibility):
29-
cmake -S . -B build -DLIVEKIT_SDK_VERSION=0.2.0
31+
cmake --build build
3032
```
3133

32-
Reconfigure to change versions:
33-
```bash
34-
rm -rf build
35-
cmake -S . -B build -DLIVEKIT_SDK_VERSION=0.3.1
34+
### Windows (Visual Studio generator)
35+
36+
```powershell
37+
cmake -S . -B build
38+
cmake --build build --config Release
3639
```
3740

38-
Build against a local SDK:
41+
The token source examples require LiveKit C++ SDK **v1.3.0** or newer. If
42+
configure succeeds but those targets fail to compile, pin the SDK version
43+
explicitly:
44+
3945
```bash
4046
rm -rf build
41-
# install the SDK into $HOME/livekit-sdk-install (or any other directory)
42-
cmake --install <sdk-build-dir> --prefix $HOME/livekit-sdk-install
43-
44-
# build the examples against the local SDK
45-
cmake -S . -B build -DLIVEKIT_LOCAL_SDK_DIR=$HOME/livekit-sdk-install
47+
cmake -S . -B build -DLIVEKIT_SDK_VERSION=1.3.0
48+
cmake --build build
4649
```
4750

51+
### Selecting an SDK version
52+
53+
Pin a specific release with `-DLIVEKIT_SDK_VERSION`:
4854

49-
### Building the examples
50-
#### macOS / Linux
5155
```bash
52-
cmake -S . -B build # add -DLIVEKIT_SDK_VERSION=0.2.0 if using a specific version
53-
cmake --build build
56+
cmake -S . -B build -DLIVEKIT_SDK_VERSION=1.3.0
5457
```
5558

56-
#### Windows (Visual Studio generator)
57-
```powershell
58-
cmake -S . -B build # add -DLIVEKIT_SDK_VERSION=0.2.0 if using a specific version
59-
cmake --build build --config Release
59+
When changing versions, remove the build directory first so CMake re-downloads
60+
the SDK:
61+
62+
```bash
63+
rm -rf build
64+
cmake -S . -B build -DLIVEKIT_SDK_VERSION=1.3.0
6065
```
6166

62-
The Livekit Release SDK is downloaded into **build/_deps/livekit-sdk/**
67+
### Build against a local SDK
6368

64-
### Running the examples
69+
Use this when validating an unreleased `client-sdk-cpp` commit, or when a
70+
release tag exists but its prebuilt archives are not yet published:
6571

66-
After building, example binaries are located under:
6772
```bash
68-
build/<example-name>/
73+
git clone --recurse-submodules https://github.com/livekit/client-sdk-cpp.git
74+
cd client-sdk-cpp
75+
./build.sh release --bundle --prefix "$HOME/livekit-sdk-install"
76+
77+
cd /path/to/cpp-example-collection
78+
rm -rf build
79+
cmake -S . -B build -DLIVEKIT_LOCAL_SDK_DIR="$HOME/livekit-sdk-install"
80+
cmake --build build
6981
```
7082

83+
### Troubleshooting configure
84+
85+
- **Start from a clean build directory** after a failed configure or download:
86+
`rm -rf build`
87+
- **GitHub API rate limits** when resolving `latest`: pin
88+
`-DLIVEKIT_SDK_VERSION=1.3.0`, or export `GITHUB_TOKEN` and re-run configure.
89+
- **404 on SDK download**: the release may not have platform archives yet. Pin
90+
an older release that does, or use `-DLIVEKIT_LOCAL_SDK_DIR` as above.
91+
92+
## Running the examples
93+
94+
After building, example binaries are located under `build/<example-name>/`.
95+
7196
For example:
97+
7298
```bash
7399
./build/basic_room/basic_room --url <ws-url> --token <token>
74100
```
75101

102+
See [`token_source/README.md`](token_source/README.md) for the token-source
103+
examples.
104+
76105
### PlatformAudio
77106

78107
The `platform_audio` examples show microphone capture and speaker playout using
@@ -86,8 +115,9 @@ WebRTC's platform Audio Device Module:
86115
### Supported platforms
87116

88117
Prebuilt SDKs are downloaded automatically for:
89-
* Windows: x64
90-
* macOS: x64, arm64 (Apple Silicon)
91-
* Linux: x64
118+
119+
- Windows: x64
120+
- macOS: x64, arm64 (Apple Silicon)
121+
- Linux: x64
92122

93123
If no matching SDK is available for your platform, CMake configuration will fail with a clear error.

token_source/README.md

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Token sources
1+
# Token Source Examples
22

33
These examples show the different ways to obtain the credentials
44
(**WebSocket URL** + **participant JWT**) the SDK needs to join a room. Each
@@ -12,28 +12,27 @@ disconnects.
1212
> not called again unless you connect again. See the SDK's
1313
> [authentication docs](https://github.com/livekit/client-sdk-cpp/blob/main/docs/authentication.md).
1414
15-
## The types
15+
## Types
1616

17-
| Example | Type | When to use |
18-
|---|---|---|
19-
| `token_source_literal.cpp` | `LiteralTokenSource` | You already have a URL + JWT (minted out of band, e.g. `lk token create`). The SDK consumes them as-is. |
20-
| `token_source_endpoint.cpp` | `EndpointTokenSource` | Recommended for production. The SDK POSTs request options to your backend token endpoint, which returns the URL + a fresh JWT. API keys stay server-side. |
21-
| `token_source_sandbox.cpp` | `SandboxTokenSource` | Local development only. Uses LiveKit Cloud's sandbox token server. Not for production. |
22-
| `token_source_custom.cpp` | `CustomTokenSource` | You have an internal auth/token system. Plug in your own async callback that returns credentials. |
23-
| `token_source_caching.cpp` | `CachingTokenSource` | A decorator that adds JWT-aware caching around any configurable source (endpoint/sandbox/custom) to cut down on fetch calls. |
17+
| Type | Example | When to use |
18+
| --- | --- | --- |
19+
| `LiteralTokenSource` | `token_source_literal.cpp` | You already have a URL + JWT (minted out of band, e.g. `lk token create`). The SDK consumes them as-is. |
20+
| `EndpointTokenSource` | `token_source_endpoint.cpp` | Recommended for production. The SDK POSTs request options to your backend token endpoint, which returns the URL + a fresh JWT. API keys stay server-side. |
21+
| `SandboxTokenSource` | `token_source_sandbox.cpp` | Local development only. Uses LiveKit Cloud's sandbox token server. Not for production. |
22+
| `CustomTokenSource` | `token_source_custom.cpp` | You have an internal auth/token system. Plug in your own async callback that returns credentials. |
23+
| `CachingTokenSource` | `token_source_caching.cpp` | A decorator that adds JWT-aware caching around any configurable source (endpoint/sandbox/custom) to cut down on fetch calls. |
2424

2525
`LiteralTokenSource` is *fixed* (no per-call options); the others are
2626
*configurable* and accept
2727
[`TokenRequestOptions`](https://github.com/livekit/client-sdk-cpp/blob/main/include/livekit/token_source.h)
2828
(room name, participant identity, agent dispatch, ...).
2929

30-
## Configuration
30+
## Configuring the Examples
3131

32-
All inputs come from environment variables, so no secrets or sandbox IDs are
33-
committed to source.
32+
All inputs come from environment variables, so no secrets or sandbox IDs are committed to source.
3433

3534
| Variable | Used by | Notes |
36-
|---|---|---|
35+
| --- | --- | --- |
3736
| `LIVEKIT_URL` | literal, custom | WebSocket URL, e.g. `ws://localhost:7880`. |
3837
| `LIVEKIT_TOKEN` | literal, custom | Participant JWT. |
3938
| `LIVEKIT_TOKEN_ENDPOINT` | endpoint, caching | Token endpoint URL. Default `http://127.0.0.1:3000/createToken`. |
@@ -43,33 +42,8 @@ committed to source.
4342
| `LIVEKIT_AGENT_NAME` | sandbox | Optional agent to dispatch into the room. |
4443
| `LIVEKIT_AGENT_METADATA` | sandbox | Optional metadata for the dispatched agent. |
4544

46-
## Building
47-
48-
The token source API is newer than the latest published SDK release, so build
49-
these examples against a **local SDK build** of the
50-
[`feature/token_source_api`](https://github.com/livekit/client-sdk-cpp/tree/feature/token_source_api)
51-
branch rather than a downloaded release. The commands below pin the branch to
52-
commit [`bbf6a41`](https://github.com/livekit/client-sdk-cpp/commit/bbf6a41fae42607ee19ff44ccddac786767b34e3)
53-
so the examples build against a known-good API; drop the `git checkout` of the
54-
hash to track the branch tip instead.
55-
56-
```bash
57-
# 1. Build and install the SDK from the feature branch.
58-
git clone https://github.com/livekit/client-sdk-cpp.git
59-
cd client-sdk-cpp
60-
git checkout bbf6a41fae42607ee19ff44ccddac786767b34e3
61-
git submodule update --init --recursive
62-
./build.sh release --bundle --prefix "$HOME/livekit-sdk-install"
63-
64-
# 2. Configure the examples against that local install.
65-
cd /path/to/cpp-example-collection
66-
cmake -S . -B build -DLIVEKIT_LOCAL_SDK_DIR="$HOME/livekit-sdk-install"
67-
cmake --build build
68-
```
69-
70-
Once the token source API ships in a release, you can drop
71-
`-DLIVEKIT_LOCAL_SDK_DIR` and use the normal download flow (optionally pinning
72-
`-DLIVEKIT_SDK_VERSION`).
45+
These examples require LiveKit C++ SDK **v1.3.0** or newer. Build them with the
46+
rest of the repo — see the root [README](../README.md#building-the-examples).
7347

7448
## Running
7549

user_timestamped_video/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Requirements:
2323
`VideoFrameMetadata` and `setOnVideoFrameEventCallback`, which are not
2424
available in older SDK releases.
2525
- To pin the SDK version when configuring the examples, pass
26-
`-DLIVEKIT_SDK_VERSION=0.3.4` to CMake.
26+
`-DLIVEKIT_SDK_VERSION=1.3.0` to CMake.
2727

2828
Flags:
2929

0 commit comments

Comments
 (0)