Skip to content
Merged
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
2 changes: 1 addition & 1 deletion client-sdk-rust
2 changes: 1 addition & 1 deletion examples/simple_room/fallback_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void runNoiseCaptureLoop(const std::shared_ptr<AudioSource> &source,
// Fake video source: solid color cycling
void runFakeVideoCaptureLoop(const std::shared_ptr<VideoSource> &source,
std::atomic<bool> &running_flag) {
auto frame = LKVideoFrame::create(1280, 720, VideoBufferType::BGRA);
auto frame = VideoFrame::create(1280, 720, VideoBufferType::BGRA);
const double framerate = 1.0 / 30.0;

while (running_flag.load(std::memory_order_relaxed)) {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_room/sdl_media_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ bool SDLMediaManager::startCamera(
[src = cam_source_](const uint8_t *pixels, int pitch, int width,
int height, SDL_PixelFormat /*fmt*/,
Uint64 timestampNS) {
auto frame = LKVideoFrame::create(width, height, VideoBufferType::RGBA);
auto frame = VideoFrame::create(width, height, VideoBufferType::RGBA);
uint8_t *dst = frame.data();
const int dstPitch = width * 4;

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_room/sdl_video_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void SDLVideoRenderer::render() {
return;
}

livekit::LKVideoFrame &frame = vfe.frame;
livekit::VideoFrame &frame = vfe.frame;

// 4) Ensure the frame is RGBA.
// Ideally you requested RGBA from VideoStream::Options so this is a no-op.
Expand Down
10 changes: 5 additions & 5 deletions include/livekit/e2ee.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ inline constexpr int kDefaultFailureTolerance = -1;
* - `ratchet_window_size` and `failure_tolerance` use SDK defaults unless
* overridden.
*/
struct EncryptionKeyProviderOptions {
struct KeyProviderOptions {
/// Shared static key for "shared-key E2EE" (optional).
///
/// If set, it must be identical (byte-for-byte) across all participants
Expand Down Expand Up @@ -85,7 +85,7 @@ struct EncryptionKeyProviderOptions {
* per-participant).
*/
struct E2EEOptions {
EncryptionKeyProviderOptions key_provider_options{};
KeyProviderOptions key_provider_options{};
EncryptionType encryption_type = EncryptionType::GCM; // default & recommended
};

Expand Down Expand Up @@ -124,7 +124,7 @@ class E2EEManager {
KeyProvider &operator=(KeyProvider &&) noexcept = default;

/// Returns the options used to initialize this KeyProvider.
const EncryptionKeyProviderOptions &options() const;
const KeyProviderOptions &options() const;

/// Sets the shared key for the given key slot.
void setSharedKey(const std::vector<std::uint8_t> &key, int key_index = 0);
Expand All @@ -150,9 +150,9 @@ class E2EEManager {
private:
friend class E2EEManager;
KeyProvider(std::uint64_t room_handle,
EncryptionKeyProviderOptions options);
KeyProviderOptions options);
std::uint64_t room_handle_{0};
EncryptionKeyProviderOptions options_;
KeyProviderOptions options_;
};

class FrameCryptor {
Expand Down
28 changes: 14 additions & 14 deletions include/livekit/video_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ class OwnedVideoBuffer;
* - The SDK can expose the backing memory to Rust via data_ptr + layout for
* the duration of a blocking FFI call (similar to AudioFrame).
*/
class LKVideoFrame {
class VideoFrame {
public:
LKVideoFrame();
LKVideoFrame(int width, int height, VideoBufferType type,
VideoFrame();
VideoFrame(int width, int height, VideoBufferType type,
std::vector<std::uint8_t> data);
virtual ~LKVideoFrame() = default;
virtual ~VideoFrame() = default;

LKVideoFrame(const LKVideoFrame &) = delete;
LKVideoFrame &operator=(const LKVideoFrame &) = delete;
LKVideoFrame(LKVideoFrame &&) noexcept = default;
LKVideoFrame &operator=(LKVideoFrame &&) noexcept = default;
VideoFrame(const VideoFrame &) = delete;
VideoFrame &operator=(const VideoFrame &) = delete;
VideoFrame(VideoFrame &&) noexcept = default;
VideoFrame &operator=(VideoFrame &&) noexcept = default;

/**
* Allocate a new frame with the correct buffer size for the given format.
* Data is zero-initialized.
*/
static LKVideoFrame create(int width, int height, VideoBufferType type);
static VideoFrame create(int width, int height, VideoBufferType type);

// Basic properties
int width() const noexcept { return width_; }
Expand All @@ -95,13 +95,13 @@ class LKVideoFrame {
* Convert this frame into another pixel format.
*
* This uses the underlying FFI `video_convert` pipeline to transform the
* current frame into a new `LKVideoFrame` with the requested
* current frame into a new `VideoFrame` with the requested
* `dst` buffer type (e.g. ARGB → I420, BGRA → RGB24, etc.).
*
* @param dst Desired output format (see VideoBufferType).
* @param flip_y If true, the converted frame will be vertically flipped.
*
* @return A new LKVideoFrame containing the converted image data.
* @return A new VideoFrame containing the converted image data.
*
* Notes:
* - This function allocates a new buffer and copies pixel data; it does
Expand All @@ -114,15 +114,15 @@ class LKVideoFrame {
* format combination is unsupported.
*
* Typical usage:
* LKVideoFrame i420 = frame.convert(VideoBufferType::I420);
* VideoFrame i420 = frame.convert(VideoBufferType::I420);
*/
LKVideoFrame convert(VideoBufferType dst, bool flip_y = false) const;
VideoFrame convert(VideoBufferType dst, bool flip_y = false) const;

protected:
friend class VideoStream;
// Only internal classes (e.g., VideoStream)
// should construct frames directly from FFI buffers.
static LKVideoFrame fromOwnedInfo(const proto::OwnedVideoBuffer &owned);
static VideoFrame fromOwnedInfo(const proto::OwnedVideoBuffer &owned);

private:
int width_;
Expand Down
6 changes: 3 additions & 3 deletions include/livekit/video_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace livekit {

class LKVideoFrame;
class VideoFrame;

/**
* Rotation of a video frame.
Expand Down Expand Up @@ -67,7 +67,7 @@ class VideoSource {
std::uint64_t ffi_handle_id() const noexcept { return handle_.get(); }

/**
* Push a LKVideoFrame into the FFI video source.
* Push a VideoFrame into the FFI video source.
*
* @param frame Video frame to send.
* @param timestamp_us Optional timestamp in microseconds.
Expand All @@ -78,7 +78,7 @@ class VideoSource {
* - Fire-and-forget to send a frame to FFI
* lifetime correctly (e.g., persistent frame pools, GPU buffers, etc.).
*/
void captureFrame(const LKVideoFrame &frame, std::int64_t timestamp_us = 0,
void captureFrame(const VideoFrame &frame, std::int64_t timestamp_us = 0,
VideoRotation rotation = VideoRotation::VIDEO_ROTATION_0);

private:
Expand Down
2 changes: 1 addition & 1 deletion include/livekit/video_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace livekit {

// A single video frame event delivered by VideoStream::read().
struct VideoFrameEvent {
LKVideoFrame frame;
VideoFrame frame;
std::int64_t timestamp_us;
VideoRotation rotation;
};
Expand Down
4 changes: 2 additions & 2 deletions src/e2ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ std::vector<std::uint8_t> stringToBytes(const std::string &s) {
// ============================================================================

E2EEManager::KeyProvider::KeyProvider(std::uint64_t room_handle,
EncryptionKeyProviderOptions options)
KeyProviderOptions options)
: room_handle_(room_handle), options_(std::move(options)) {}

const EncryptionKeyProviderOptions &E2EEManager::KeyProvider::options() const {
const KeyProviderOptions &E2EEManager::KeyProvider::options() const {
return options_;
}

Expand Down
32 changes: 16 additions & 16 deletions src/video_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace {
std::size_t computeBufferSize(int width, int height, VideoBufferType type) {
if (width <= 0 || height <= 0) {
throw std::invalid_argument(
"LKVideoFrame: width and height must be positive");
"VideoFrame: width and height must be positive");
}

const auto w = static_cast<std::size_t>(width);
Expand Down Expand Up @@ -70,7 +70,7 @@ std::size_t computeBufferSize(int width, int height, VideoBufferType type) {
}

default:
throw std::runtime_error("LKVideoFrame: unsupported VideoBufferType");
throw std::runtime_error("VideoFrame: unsupported VideoBufferType");
}
}

Expand All @@ -79,7 +79,7 @@ std::vector<VideoPlaneInfo>
computePlaneInfos(uintptr_t base, int width, int height, VideoBufferType type) {
std::vector<VideoPlaneInfo> planes;
if (!base || width <= 0 || height <= 0) {
std::cerr << "[LKVideoFrame] Warning: invalid planeInfos input (ptr="
std::cerr << "[VideoFrame] Warning: invalid planeInfos input (ptr="
<< base << ", w=" << width << ", h=" << height << ")\n";
return planes;
}
Expand Down Expand Up @@ -261,29 +261,29 @@ computePlaneInfos(uintptr_t base, int width, int height, VideoBufferType type) {
} // namespace

// ----------------------------------------------------------------------------
// LKVideoFrame implementation
// VideoFrame implementation
// ----------------------------------------------------------------------------

LKVideoFrame::LKVideoFrame()
VideoFrame::VideoFrame()
: width_{0}, height_{0}, type_{VideoBufferType::BGRA}, data_{} {}

LKVideoFrame::LKVideoFrame(int width, int height, VideoBufferType type,
VideoFrame::VideoFrame(int width, int height, VideoBufferType type,
std::vector<std::uint8_t> data)
: width_(width), height_(height), type_(type), data_(std::move(data)) {
const std::size_t expected = computeBufferSize(width_, height_, type_);
if (data_.size() < expected) {
throw std::invalid_argument("LKVideoFrame: provided data is too small for "
throw std::invalid_argument("VideoFrame: provided data is too small for "
"the specified format and size");
}
}

LKVideoFrame LKVideoFrame::create(int width, int height, VideoBufferType type) {
VideoFrame VideoFrame::create(int width, int height, VideoBufferType type) {
const std::size_t size = computeBufferSize(width, height, type);
std::vector<std::uint8_t> buffer(size, 0);
return LKVideoFrame(width, height, type, std::move(buffer));
return VideoFrame(width, height, type, std::move(buffer));
}

std::vector<VideoPlaneInfo> LKVideoFrame::planeInfos() const {
std::vector<VideoPlaneInfo> VideoFrame::planeInfos() const {
if (data_.empty()) {
return {};
}
Expand All @@ -292,24 +292,24 @@ std::vector<VideoPlaneInfo> LKVideoFrame::planeInfos() const {
return computePlaneInfos(base, width_, height_, type_);
}

LKVideoFrame LKVideoFrame::convert(VideoBufferType dst, bool flip_y) const {
VideoFrame VideoFrame::convert(VideoBufferType dst, bool flip_y) const {
// Fast path: same format, no flip -> just clone the buffer.
// We still return a *new* LKVideoFrame, never `*this`, so copy-ctor
// We still return a *new* VideoFrame, never `*this`, so copy-ctor
// being deleted is not a problem.
if (dst == type_ && !flip_y) {
std::cerr << "KVideoFrame::convert Warning: converting to the same format"
<< std::endl;
// copy pixel data
std::vector<std::uint8_t> buf = data_;
return LKVideoFrame(width_, height_, type_, std::move(buf));
return VideoFrame(width_, height_, type_, std::move(buf));
}

// General path: delegate to the FFI-based conversion helper.
// This returns a brand new LKVideoFrame (move-constructed / elided).
// This returns a brand new VideoFrame (move-constructed / elided).
return convertViaFfi(*this, dst, flip_y);
}

LKVideoFrame LKVideoFrame::fromOwnedInfo(const proto::OwnedVideoBuffer &owned) {
VideoFrame VideoFrame::fromOwnedInfo(const proto::OwnedVideoBuffer &owned) {
const auto &info = owned.info();
const int width = static_cast<int>(info.width());
const int height = static_cast<int>(info.height());
Expand Down Expand Up @@ -359,7 +359,7 @@ LKVideoFrame LKVideoFrame::fromOwnedInfo(const proto::OwnedVideoBuffer &owned) {
// owned_handle destroyed at end of scope → native buffer disposed.
}

return LKVideoFrame(width, height, type, std::move(buffer));
return VideoFrame(width, height, type, std::move(buffer));
}

} // namespace livekit
2 changes: 1 addition & 1 deletion src/video_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ VideoSource::VideoSource(int width, int height)
handle_ = FfiHandle(resp.new_video_source().source().handle().id());
}

void VideoSource::captureFrame(const LKVideoFrame &frame,
void VideoSource::captureFrame(const VideoFrame &frame,
std::int64_t timestamp_us,
VideoRotation rotation) {
if (!handle_) {
Expand Down
2 changes: 1 addition & 1 deletion src/video_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void VideoStream::onFfiEvent(const proto::FfiEvent &event) {

// Convert owned buffer->VideoFrame via a helper.
// You should implement this static function in your VideoFrame class.
LKVideoFrame frame = LKVideoFrame::fromOwnedInfo(fr.buffer());
VideoFrame frame = VideoFrame::fromOwnedInfo(fr.buffer());

VideoFrameEvent ev{std::move(frame), fr.timestamp_us(),
static_cast<VideoRotation>(fr.rotation())};
Expand Down
10 changes: 5 additions & 5 deletions src/video_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ VideoBufferType fromProto(proto::VideoBufferType t) {
}
}

proto::VideoBufferInfo toProto(const LKVideoFrame &frame) {
proto::VideoBufferInfo toProto(const VideoFrame &frame) {
proto::VideoBufferInfo info;

const int w = frame.width();
Expand Down Expand Up @@ -128,15 +128,15 @@ proto::VideoBufferInfo toProto(const LKVideoFrame &frame) {
return info;
}

LKVideoFrame fromOwnedProto(const proto::OwnedVideoBuffer &owned) {
VideoFrame fromOwnedProto(const proto::OwnedVideoBuffer &owned) {
const auto &info = owned.info();

const int width = static_cast<int>(info.width());
const int height = static_cast<int>(info.height());
const VideoBufferType type = fromProto(info.type());

// Allocate a new LKVideoFrame with the correct size/format
LKVideoFrame frame = LKVideoFrame::create(width, height, type);
// Allocate a new VideoFrame with the correct size/format
VideoFrame frame = VideoFrame::create(width, height, type);

// Copy from the FFI-provided buffer into our own backing storage
auto *dst = frame.data();
Expand All @@ -159,7 +159,7 @@ LKVideoFrame fromOwnedProto(const proto::OwnedVideoBuffer &owned) {
return frame;
}

LKVideoFrame convertViaFfi(const LKVideoFrame &frame, VideoBufferType dst,
VideoFrame convertViaFfi(const VideoFrame &frame, VideoBufferType dst,
bool flip_y) {
proto::FfiRequest req;
auto *vc = req.mutable_video_convert();
Expand Down
6 changes: 3 additions & 3 deletions src/video_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
namespace livekit {

// Video FFI Utils
proto::VideoBufferInfo toProto(const LKVideoFrame &frame);
LKVideoFrame fromOwnedProto(const proto::OwnedVideoBuffer &owned);
LKVideoFrame convertViaFfi(const LKVideoFrame &frame, VideoBufferType dst,
proto::VideoBufferInfo toProto(const VideoFrame &frame);
VideoFrame fromOwnedProto(const proto::OwnedVideoBuffer &owned);
VideoFrame convertViaFfi(const VideoFrame &frame, VideoBufferType dst,
bool flip_y);
proto::VideoBufferType toProto(VideoBufferType t);
VideoBufferType fromProto(proto::VideoBufferType t);
Expand Down
Loading