Skip to content

Commit 00f73ec

Browse files
ladvocstephen-derosa
authored andcommitted
Allow choosing specific backends
1 parent 063a2ce commit 00f73ec

11 files changed

Lines changed: 103 additions & 43 deletions

File tree

‎.github/actions/build-sdk/action.yml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ inputs:
1919
description: Build script command, such as release-examples or debug-tests.
2020
required: true
2121
capture:
22-
description: Whether to enable capture (ON or OFF).
22+
description: Capture sources (ON/all, OFF/none, or gstreamer,pattern,clock).
2323
default: 'OFF'
2424
bundle-dir:
2525
description: Optional installation directory for an SDK bundle.
@@ -45,9 +45,9 @@ runs:
4545
run: |
4646
args=(./build.sh "$SDK_PRESET")
4747
case "$SDK_CAPTURE" in
48-
ON) args+=(--capture) ;;
49-
OFF) args+=(--no-capture) ;;
50-
*) echo "Invalid capture setting: $SDK_CAPTURE" >&2; exit 1 ;;
48+
ON|all) args+=(--capture) ;;
49+
OFF|none|"") args+=(--no-capture) ;;
50+
*) args+=(--capture="$SDK_CAPTURE") ;;
5151
esac
5252
if [[ -n "$SDK_BUNDLE_DIR" ]]; then args+=(--bundle --prefix "$SDK_BUNDLE_DIR"); fi
5353
if [[ -n "$SDK_VERSION" ]]; then args+=(--version "$SDK_VERSION"); fi
@@ -64,9 +64,9 @@ runs:
6464
run: |
6565
$buildArgs = @($env:SDK_PRESET)
6666
switch ($env:SDK_CAPTURE) {
67-
'ON' { $buildArgs += '--capture' }
68-
'OFF' { $buildArgs += '--no-capture' }
69-
default { throw "Invalid capture setting: $env:SDK_CAPTURE" }
67+
'ON'; 'all' { $buildArgs += '--capture' }
68+
'OFF'; 'none'; '' { $buildArgs += '--no-capture' }
69+
default { $buildArgs += "--capture=$($env:SDK_CAPTURE)" }
7070
}
7171
if ($env:SDK_BUNDLE_DIR) { $buildArgs += @('--bundle', '--prefix', $env:SDK_BUNDLE_DIR) }
7272
if ($env:SDK_VERSION) { $buildArgs += @('--version', $env:SDK_VERSION) }

‎.github/workflows/tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ jobs:
539539
- name: Configure (linux-debug-tests preset + coverage flags)
540540
run: |
541541
cmake --preset linux-debug-tests \
542-
-DLIVEKIT_BUILD_CAPTURE=ON \
542+
-DLIVEKIT_CAPTURE=all \
543543
-DCMAKE_C_FLAGS="-Wno-deprecated-declarations --coverage" \
544544
-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations --coverage" \
545545
-DCMAKE_EXE_LINKER_FLAGS="--coverage" \

‎AGENTS.md‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,10 @@ To create an installable SDK bundle, use the same build command with
128128
`./build.sh release --bundle --prefix sdk-out/livekit-sdk`). On Windows, use
129129
`build.cmd release --bundle --prefix C:\path\to\livekit-sdk`.
130130

131-
The build scripts set `LIVEKIT_BUILD_CAPTURE`. The generated
132-
`LIVEKIT_CAPTURE_ENABLED` macro is 0 or 1 and supports `#if` checks in consumers.
133-
134-
Both build scripts accept `--capture` to enable GStreamer, pattern, and clock
135-
sources, and `--no-capture` to disable them explicitly. Capture is disabled by
136-
default for every preset. Capture-enabled builds need GStreamer development and
137-
runtime libraries. Release workflows publish separate
138-
`-capture` bundles and validate creation through the installed SDK using the standalone CTest project in
139-
`src/tests/packaging/`.
131+
Capture sources are selected with `LIVEKIT_CAPTURE` / `--capture[=list]`:
132+
`none`, `all`, or a comma-separated subset of `gstreamer`, `pattern`, `clock`.
133+
`LIVEKIT_CAPTURE_ENABLED` is 0 or 1. Release workflows publish separate
134+
`-capture` bundles (all sources) and validate them via `src/tests/packaging/`.
140135

141136
Rust FFI outputs live under `client-sdk-rust/target/cpp-<feature-hash>/` to isolate
142137
Cargo feature configurations. Set `CARGO_TARGET_DIR` to override the root;

‎CMakeLists.txt‎

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ include(warnings)
1818

1919
option(LIVEKIT_BUILD_EXAMPLES "Build LiveKit examples" OFF)
2020
option(LIVEKIT_BUILD_TESTS "Build LiveKit tests" OFF)
21-
option(LIVEKIT_BUILD_CAPTURE "Build the Rust FFI with the capture feature (livekit-capture sources; links system GStreamer)" OFF)
21+
# Capture sources for the Rust FFI. Comma-separated subset of gstreamer,
22+
# pattern, clock; or all / none / ON / OFF (aliases). Empty means none.
23+
set(LIVEKIT_CAPTURE "" CACHE STRING
24+
"Capture sources: none, all, or comma-separated gstreamer,pattern,clock")
25+
set_property(CACHE LIVEKIT_CAPTURE PROPERTY STRINGS
26+
"" none all gstreamer pattern clock ON OFF)
2227

2328
# vcpkg is only used on Windows; Linux/macOS use system package managers
2429
if(WIN32)
@@ -169,13 +174,44 @@ set(GENERATED_BUILD_H "${LIVEKIT_GENERATED_INCLUDE_DIR}/livekit/build.h")
169174
set(GENERATED_BUILD_INFO_JSON "${LIVEKIT_BINARY_DIR}/build-info.json")
170175
set(RUST_ROOT ${LIVEKIT_ROOT_DIR}/client-sdk-rust)
171176

172-
# Cargo features for the Rust FFI build.
177+
# Map LIVEKIT_CAPTURE to livekit-ffi Cargo features (sorted for stable hashing).
173178
set(LIVEKIT_CARGO_FEATURES "")
174179
set(LIVEKIT_CAPTURE_ENABLED 0)
175-
if(LIVEKIT_BUILD_CAPTURE)
176-
set(LIVEKIT_CARGO_FEATURES "capture-gstreamer,capture-pattern,capture-clock")
180+
string(STRIP "${LIVEKIT_CAPTURE}" _lk_capture)
181+
string(TOLOWER "${_lk_capture}" _lk_capture_lower)
182+
set(_lk_capture_tokens "")
183+
if(_lk_capture_lower STREQUAL "" OR _lk_capture_lower STREQUAL "none" OR _lk_capture_lower STREQUAL "off")
184+
# Capture disabled.
185+
elseif(_lk_capture_lower STREQUAL "all" OR _lk_capture_lower STREQUAL "on")
186+
set(_lk_capture_tokens "clock;gstreamer;pattern")
187+
else()
188+
string(REPLACE "," ";" _lk_capture_tokens "${_lk_capture_lower}")
189+
endif()
190+
set(_lk_capture_features "")
191+
foreach(_token IN LISTS _lk_capture_tokens)
192+
string(STRIP "${_token}" _token)
193+
if(_token STREQUAL "")
194+
continue()
195+
endif()
196+
if(_token STREQUAL "gstreamer")
197+
list(APPEND _lk_capture_features "capture-gstreamer")
198+
elseif(_token STREQUAL "pattern")
199+
list(APPEND _lk_capture_features "capture-pattern")
200+
elseif(_token STREQUAL "clock")
201+
list(APPEND _lk_capture_features "capture-clock")
202+
else()
203+
message(FATAL_ERROR
204+
"Unknown LIVEKIT_CAPTURE source '${_token}'. "
205+
"Expected: gstreamer, pattern, clock, all, none, ON, or OFF.")
206+
endif()
207+
endforeach()
208+
if(_lk_capture_features)
209+
list(REMOVE_DUPLICATES _lk_capture_features)
210+
list(SORT _lk_capture_features)
211+
list(JOIN _lk_capture_features "," LIVEKIT_CARGO_FEATURES)
177212
set(LIVEKIT_CAPTURE_ENABLED 1)
178213
endif()
214+
message(STATUS "LIVEKIT_CAPTURE='${LIVEKIT_CAPTURE}' -> cargo features: '${LIVEKIT_CARGO_FEATURES}'")
179215

180216
set(GIT_COMMIT "unknown")
181217
set(RUST_GIT_COMMIT "unknown")

‎CMakePresets.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"name": "sdk-defaults",
1111
"hidden": true,
1212
"cacheVariables": {
13-
"LIVEKIT_BUILD_CAPTURE": "OFF"
13+
"LIVEKIT_CAPTURE": ""
1414
}
1515
},
1616
{

‎build.cmd‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set "BUILD_TYPE=Release"
88
set "PRESET=windows-release"
99
set "LIVEKIT_VERSION="
1010
set "CMAKE_EXTRA_ARGS="
11-
set "CAPTURE_OVERRIDE=OFF"
11+
set "CAPTURE_OVERRIDE=none"
1212
set "BUILD_PARALLEL_JOBS="
1313
set "DO_BUNDLE="
1414
set "PREFIX="
@@ -90,13 +90,23 @@ if /I "%~1"=="--version" (
9090
goto :get_version_value
9191
)
9292

93+
set "ARG=%~1"
94+
if /I "!ARG:~0,10!"=="--capture=" (
95+
set "CAPTURE_OVERRIDE=!ARG:~10!"
96+
if "!CAPTURE_OVERRIDE!"=="" (
97+
echo ERROR: --capture= requires a value ^(gstreamer, pattern, clock, or all^)
98+
exit /b 1
99+
)
100+
shift
101+
goto parse_all
102+
)
93103
if /I "%~1"=="--capture" (
94-
set "CAPTURE_OVERRIDE=ON"
104+
set "CAPTURE_OVERRIDE=all"
95105
shift
96106
goto parse_all
97107
)
98108
if /I "%~1"=="--no-capture" (
99-
set "CAPTURE_OVERRIDE=OFF"
109+
set "CAPTURE_OVERRIDE=none"
100110
shift
101111
goto parse_all
102112
)
@@ -144,7 +154,7 @@ if defined LIVEKIT_VERSION (
144154
set "CMAKE_EXTRA_ARGS=-DLIVEKIT_VERSION=%LIVEKIT_VERSION%"
145155
echo ==^> Injecting LIVEKIT_VERSION=%LIVEKIT_VERSION%
146156
)
147-
set "CMAKE_EXTRA_ARGS=%CMAKE_EXTRA_ARGS% -DLIVEKIT_BUILD_CAPTURE=%CAPTURE_OVERRIDE%"
157+
set "CMAKE_EXTRA_ARGS=%CMAKE_EXTRA_ARGS% -DLIVEKIT_CAPTURE=%CAPTURE_OVERRIDE%"
148158
goto dispatch
149159

150160
:dispatch
@@ -228,7 +238,8 @@ echo clean-all Full clean (build dirs + local-install + Rust targets)
228238
echo help Show this help
229239
echo.
230240
echo Options (for debug / release):
231-
echo --capture Enable all capture sources ^(requires GStreamer^)
241+
echo --capture[=list] Enable capture sources ^(default: all^).
242+
echo list: gstreamer, pattern, clock ^(comma-separated^)
232243
echo --no-capture Explicitly disable capture sources ^(the default^)
233244
echo --bundle Install the SDK bundle using cmake --install
234245
echo --prefix ^<dir^> Install prefix for --bundle ^(default: .\sdk-out\livekit-sdk^)

‎build.h.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define LIVEKIT_BUILD_VERSION "@LIVEKIT_VERSION@"
99
#define LIVEKIT_BUILD_FLAVOR "cpp"
1010

11-
/// @brief Whether the Rust FFI was built with capture-source support (0 or 1).
11+
/// @brief Whether the Rust FFI was built with any capture source (0 or 1).
1212
#define LIVEKIT_CAPTURE_ENABLED @LIVEKIT_CAPTURE_ENABLED@
1313

1414
#ifdef DEBUG

‎build.sh‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ARCHIVE_NAME=""
1414
GENERATOR=""
1515
MACOS_ARCH=""
1616
LIVEKIT_VERSION=""
17-
CAPTURE_OVERRIDE="OFF"
17+
CAPTURE_OVERRIDE="none"
1818

1919
# Detect OS for preset selection
2020
detect_os() {
@@ -47,7 +47,8 @@ Commands:
4747
help Show this help message
4848
4949
Options (for debug / release):
50-
--capture Enable all capture sources (requires GStreamer)
50+
--capture[=list] Enable capture sources (default: all).
51+
list: gstreamer, pattern, clock (comma-separated)
5152
--no-capture Explicitly disable capture sources (the default)
5253
--bundle Install the SDK bundle using 'cmake --install'
5354
--prefix <dir> Install prefix for --bundle
@@ -79,11 +80,19 @@ parse_opts() {
7980
while [[ $# -gt 0 ]]; do
8081
case "$1" in
8182
--capture)
82-
CAPTURE_OVERRIDE="ON"
83+
CAPTURE_OVERRIDE="all"
84+
shift
85+
;;
86+
--capture=*)
87+
CAPTURE_OVERRIDE="${1#*=}"
88+
if [[ -z "${CAPTURE_OVERRIDE}" ]]; then
89+
echo "ERROR: --capture= requires a value (gstreamer, pattern, clock, or all)"
90+
exit 1
91+
fi
8392
shift
8493
;;
8594
--no-capture)
86-
CAPTURE_OVERRIDE="OFF"
95+
CAPTURE_OVERRIDE="none"
8796
shift
8897
;;
8998
--bundle)
@@ -146,7 +155,7 @@ parse_opts() {
146155

147156
configure() {
148157
echo "==> Configuring CMake (${BUILD_TYPE}) using preset ${PRESET}..."
149-
local -a extra_args=("-DLIVEKIT_BUILD_CAPTURE=${CAPTURE_OVERRIDE}")
158+
local -a extra_args=("-DLIVEKIT_CAPTURE=${CAPTURE_OVERRIDE}")
150159
if [[ -n "${LIVEKIT_VERSION}" ]]; then
151160
echo "==> Injecting LIVEKIT_VERSION=${LIVEKIT_VERSION}"
152161
extra_args+=("-DLIVEKIT_VERSION=${LIVEKIT_VERSION}")

‎docs/building.md‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ cmake --build build
244244
| `LIVEKIT_USE_SYSTEM_PROTOBUF` | OFF | Use system Protobuf instead of vcpkg's |
245245
| `LIVEKIT_LOG_LEVEL` | `TRACE` | Compile-time log threshold (see [logging.md](logging.md)) |
246246
| `LIVEKIT_VERSION` | repo-derived | SDK version string baked into the binary |
247-
| `LIVEKIT_BUILD_CAPTURE` | OFF | Enable GStreamer, pattern, and clock capture sources in the Rust FFI |
247+
| `LIVEKIT_CAPTURE` | empty (`none`) | Capture sources for the Rust FFI (`all`, `none`, or a comma-separated list; see [Capture sources](#capture-sources)) |
248248

249249
## Build output
250250

@@ -405,13 +405,23 @@ separately when it is no longer needed.
405405

406406
## Capture sources
407407

408-
Capture is disabled by default for every repository preset. Use `--capture`
409-
with any build command to enable all three sources (GStreamer, GPU pattern, and
410-
GPU wall clock), or `--no-capture` to disable them explicitly:
408+
Capture is disabled by default. Select sources with `-DLIVEKIT_CAPTURE=<value>`
409+
or `--capture[=list]` / `--no-capture`.
410+
411+
Available sources (comma-separated; each maps to `capture-*` on `livekit-ffi`):
412+
413+
| Source | Description |
414+
|--------|-------------|
415+
| `gstreamer` | GStreamer pipelines (needs GStreamer at build and runtime) |
416+
| `pattern` | GPU test pattern |
417+
| `clock` | GPU wall clock |
418+
419+
Special values: `none` / `OFF` / empty (disabled), `all` / `ON` (every source).
420+
`LIVEKIT_CAPTURE_ENABLED` is 1 when any source is selected; installed
421+
`share/livekit/build-info.json` also records `cargo_features`.
411422

412423
```bash
413424
./build.sh release --capture --bundle --prefix sdk-out/livekit-sdk-capture
414-
./build.sh debug-tests
415425
```
416426

417427
On Windows, use `build.cmd release --capture --bundle --prefix sdk-out\livekit-sdk-capture`.

‎include/livekit/capture_source.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,8 @@ struct CaptureResult {
165165
/// a track from @ref CaptureSource::videoSource(), merge application options
166166
/// through @ref CaptureSource::publishOptions(), then call @ref CaptureSource::start().
167167
///
168-
/// Requires a capture-enabled SDK build (`LIVEKIT_BUILD_CAPTURE`), with
169-
/// `capture-gstreamer`, `capture-pattern`, and `capture-clock` Rust features.
170-
/// Otherwise creation fails.
168+
/// Requires a capture-enabled SDK build (`LIVEKIT_CAPTURE`). Creation fails
169+
/// when the requested source was not compiled into the Rust FFI.
171170
///
172171
/// @note Keep this object alive while the track is published. Destroying it
173172
/// stops a running capture.

0 commit comments

Comments
 (0)