From fe1b509a40633c84e603ab313e632b99b2ae60fd Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Tue, 13 Jan 2026 15:02:11 +0800 Subject: [PATCH] fix: fixed namespace conflicts for VideoFrame/KeyProviderOptions. --- client-sdk-rust | 2 +- examples/simple_room/fallback_capture.cpp | 2 +- examples/simple_room/sdl_media_manager.cpp | 2 +- examples/simple_room/sdl_video_renderer.cpp | 2 +- include/livekit/e2ee.h | 10 +++---- include/livekit/video_frame.h | 28 +++++++++--------- include/livekit/video_source.h | 6 ++-- include/livekit/video_stream.h | 2 +- src/e2ee.cpp | 4 +-- src/video_frame.cpp | 32 ++++++++++----------- src/video_source.cpp | 2 +- src/video_stream.cpp | 2 +- src/video_utils.cpp | 10 +++---- src/video_utils.h | 6 ++-- 14 files changed, 55 insertions(+), 55 deletions(-) diff --git a/client-sdk-rust b/client-sdk-rust index 4b05e89..3a3f42d 160000 --- a/client-sdk-rust +++ b/client-sdk-rust @@ -1 +1 @@ -Subproject commit 4b05e89d27c6b81a735215d1714033b5df7e9abc +Subproject commit 3a3f42d7403a648c40920d60f3cf6f1e4b808aea diff --git a/examples/simple_room/fallback_capture.cpp b/examples/simple_room/fallback_capture.cpp index 83d46d1..5d28195 100644 --- a/examples/simple_room/fallback_capture.cpp +++ b/examples/simple_room/fallback_capture.cpp @@ -68,7 +68,7 @@ void runNoiseCaptureLoop(const std::shared_ptr &source, // Fake video source: solid color cycling void runFakeVideoCaptureLoop(const std::shared_ptr &source, std::atomic &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)) { diff --git a/examples/simple_room/sdl_media_manager.cpp b/examples/simple_room/sdl_media_manager.cpp index aef067f..6cd9d22 100644 --- a/examples/simple_room/sdl_media_manager.cpp +++ b/examples/simple_room/sdl_media_manager.cpp @@ -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; diff --git a/examples/simple_room/sdl_video_renderer.cpp b/examples/simple_room/sdl_video_renderer.cpp index 55aa799..1008f38 100644 --- a/examples/simple_room/sdl_video_renderer.cpp +++ b/examples/simple_room/sdl_video_renderer.cpp @@ -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. diff --git a/include/livekit/e2ee.h b/include/livekit/e2ee.h index cf14265..724fdef 100644 --- a/include/livekit/e2ee.h +++ b/include/livekit/e2ee.h @@ -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 @@ -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 }; @@ -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 &key, int key_index = 0); @@ -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 { diff --git a/include/livekit/video_frame.h b/include/livekit/video_frame.h index 987f696..2f8f80c 100644 --- a/include/livekit/video_frame.h +++ b/include/livekit/video_frame.h @@ -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 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_; } @@ -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 @@ -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_; diff --git a/include/livekit/video_source.h b/include/livekit/video_source.h index 0e8c352..47715dc 100644 --- a/include/livekit/video_source.h +++ b/include/livekit/video_source.h @@ -22,7 +22,7 @@ namespace livekit { -class LKVideoFrame; +class VideoFrame; /** * Rotation of a video frame. @@ -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. @@ -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: diff --git a/include/livekit/video_stream.h b/include/livekit/video_stream.h index f3f233b..0f66608 100644 --- a/include/livekit/video_stream.h +++ b/include/livekit/video_stream.h @@ -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; }; diff --git a/src/e2ee.cpp b/src/e2ee.cpp index dbadb50..dc95252 100644 --- a/src/e2ee.cpp +++ b/src/e2ee.cpp @@ -43,10 +43,10 @@ std::vector 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_; } diff --git a/src/video_frame.cpp b/src/video_frame.cpp index c06bff4..5e1f230 100644 --- a/src/video_frame.cpp +++ b/src/video_frame.cpp @@ -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(width); @@ -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"); } } @@ -79,7 +79,7 @@ std::vector computePlaneInfos(uintptr_t base, int width, int height, VideoBufferType type) { std::vector 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; } @@ -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 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 buffer(size, 0); - return LKVideoFrame(width, height, type, std::move(buffer)); + return VideoFrame(width, height, type, std::move(buffer)); } -std::vector LKVideoFrame::planeInfos() const { +std::vector VideoFrame::planeInfos() const { if (data_.empty()) { return {}; } @@ -292,24 +292,24 @@ std::vector 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 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(info.width()); const int height = static_cast(info.height()); @@ -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 diff --git a/src/video_source.cpp b/src/video_source.cpp index 4d29e1c..09e4858 100644 --- a/src/video_source.cpp +++ b/src/video_source.cpp @@ -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_) { diff --git a/src/video_stream.cpp b/src/video_stream.cpp index c7b5fc8..ece6d35 100644 --- a/src/video_stream.cpp +++ b/src/video_stream.cpp @@ -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(fr.rotation())}; diff --git a/src/video_utils.cpp b/src/video_utils.cpp index 247f39e..19b3237 100644 --- a/src/video_utils.cpp +++ b/src/video_utils.cpp @@ -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(); @@ -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(info.width()); const int height = static_cast(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(); @@ -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(); diff --git a/src/video_utils.h b/src/video_utils.h index 733e4a5..8fc27dc 100644 --- a/src/video_utils.h +++ b/src/video_utils.h @@ -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);