Skip to content

(WIP) Integrate livekit capture - #227

Draft
ladvoc wants to merge 27 commits into
mainfrom
ladvoc/livekit-capture
Draft

(WIP) Integrate livekit capture#227
ladvoc wants to merge 27 commits into
mainfrom
ladvoc/livekit-capture

Conversation

@ladvoc

@ladvoc ladvoc commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@stephen-derosa
stephen-derosa force-pushed the ladvoc/livekit-capture branch from 653a32f to 328419a Compare July 31, 2026 19:43

// Application options are merged in; source-dictated fields win.
TrackPublishOptions app_options;
app_options.source = TrackSource::SOURCE_CAMERA;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

from sync: Should the capture source specify this field?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@ladvoc im trying to recall the conversation but i cant remember

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

check if this is actually needed or should be inferred

Stopped = 0,
/// The producer reached the end of its stream.
EndOfStream = 1,
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

from sync: Add panic reason.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@ladvoc has this gotten into the rust layer?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should be in rust, need to float up here

libabsl-dev \
libcurl4-openssl-dev \
libwayland-dev libdecor-0-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Help me understand the difference in versions between these installs and the one at the top of this file for Windows? 1.0-dev vs. 1.28.5? Just making sure no surprises

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good callout, I added a clarifying comment. Effectively we are doing this to ensure we go through through each platform’s native package mechanism (linux/mac use latest whereas windows uses an explicit pinned version).

Comment on lines +62 to +64
Bps = 0,
/// Kilobits per second.
Kbps = 1,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we have any precedence for bit rate enums/units elsewhere? Might be worth consolidating if so

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

After reviewing the Rust side earlier today, looks like we have GStreamer-specific bit rates in Rust too, so maybe better to match that? CC @ladvoc on thoughts, I'm curious if both Rust and C++ can consolidate bitrates into a more generic unit/enum. Not a biggie if not, just trying to minimize API surface

Comment on lines +68 to +71
struct CaptureResolution {
int width = 0;
int height = 0;
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similar comment here: https://github.com/livekit/client-sdk-cpp/pull/227/changes#r3845438732

If we have a generic video resolution struct somewhere, a smaller API surface would be ideal

Comment thread include/livekit/capture_source.h Outdated
Comment thread include/livekit/capture_source.h Outdated
Comment on lines +133 to +147
Nv12 = 1,
/// Packed BGRA.
Bgra = 2,
/// Packed RGB24.
Rgb24 = 3,
/// Packed BGR24.
Bgr24 = 4,
/// Packed YUYV/YUY2.
Yuyv = 5,
/// Packed UYVY.
Uyvy = 6,
/// Single-plane 8-bit luma.
Grey = 7,
/// Encoded MJPEG frames.
Mjpeg = 8,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Definitely a fan of enum styling consistency if we have precedence for CapitalLetterEnum style, but wondering if some of these would be all caps, like RGB24. I'd default first to our SDK precedent and second to how Rust defines them

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice good catch, ill align with our SDK

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

updated

Comment thread src/capture_source.cpp Outdated
Comment on lines +320 to +326
const proto::CaptureDeviceList list = devices.get();
std::vector<CaptureDeviceInfo> out;
out.reserve(static_cast<std::size_t>(list.devices_size()));
for (const proto::CaptureDeviceInfo& info : list.devices()) {
out.push_back(fromProto(info));
}
return out;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Worth collapsing into a from helper (see below) for similar pattern/unit testability? listDevices has tests but am assuming most if not all will fail in CI, moving this bit out at least covers some of it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yup good point, ill add the helper add some tests

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

also broke this into the private api

Comment thread src/capture_source.cpp Outdated
Comment thread include/livekit/capture_source.h Outdated
Comment thread src/capture_source.cpp
Comment on lines +48 to +50
if (resolution.width <= 0 || resolution.height <= 0) {
throw CaptureSourceError(std::string(field) + " must be positive, got " + std::to_string(resolution.width) + "x" +
std::to_string(resolution.height));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are there any upper invalid bounds to consider?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hm, i wasnt able to find upper bounds on resolution anywhere in the rust SDK (@ladvoc any idea if this exists ?) and i dont feel like its appropriate to set the precedent here.

The resolution is currently just bounded by INT_MAX

/// Skips the calling test when the FFI library was built without the capture
/// feature. A feature-less FFI reports only a generic invalid handle, so this
/// has to be decided at compile time rather than sniffed from an error string.
#ifdef LIVEKIT_TEST_CAPTURE_ENABLED

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need a specific test flag? What about just using a LIVEKIT_CAPTURE_ENABLED from the public API/build, or is the idea to hide from users

@stephen-derosa stephen-derosa Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

good call no this should be LIVEKIT_CAPTURE_ENABLED specifically to cover the case where users can build with it off

@stephen-derosa
stephen-derosa force-pushed the ladvoc/livekit-capture branch from e844dd6 to 57e6fe9 Compare August 25, 2026 17:59
@stephen-derosa stephen-derosa changed the title (WIP) Integrate capture (WIP) Integrate livekit capture Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants