Skip to content

Commit 176a6a0

Browse files
authored
fix: fixed namespace conflicts for VideoFrame/KeyProviderOptions. (#38)
1 parent 5135833 commit 176a6a0

File tree

14 files changed

+55
-55
lines changed

14 files changed

+55
-55
lines changed

client-sdk-rust

examples/simple_room/fallback_capture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void runNoiseCaptureLoop(const std::shared_ptr<AudioSource> &source,
6868
// Fake video source: solid color cycling
6969
void runFakeVideoCaptureLoop(const std::shared_ptr<VideoSource> &source,
7070
std::atomic<bool> &running_flag) {
71-
auto frame = LKVideoFrame::create(1280, 720, VideoBufferType::BGRA);
71+
auto frame = VideoFrame::create(1280, 720, VideoBufferType::BGRA);
7272
const double framerate = 1.0 / 30.0;
7373

7474
while (running_flag.load(std::memory_order_relaxed)) {

examples/simple_room/sdl_media_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ bool SDLMediaManager::startCamera(
174174
[src = cam_source_](const uint8_t *pixels, int pitch, int width,
175175
int height, SDL_PixelFormat /*fmt*/,
176176
Uint64 timestampNS) {
177-
auto frame = LKVideoFrame::create(width, height, VideoBufferType::RGBA);
177+
auto frame = VideoFrame::create(width, height, VideoBufferType::RGBA);
178178
uint8_t *dst = frame.data();
179179
const int dstPitch = width * 4;
180180

examples/simple_room/sdl_video_renderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void SDLVideoRenderer::render() {
103103
return;
104104
}
105105

106-
livekit::LKVideoFrame &frame = vfe.frame;
106+
livekit::VideoFrame &frame = vfe.frame;
107107

108108
// 4) Ensure the frame is RGBA.
109109
// Ideally you requested RGBA from VideoStream::Options so this is a no-op.

include/livekit/e2ee.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ inline constexpr int kDefaultFailureTolerance = -1;
4747
* - `ratchet_window_size` and `failure_tolerance` use SDK defaults unless
4848
* overridden.
4949
*/
50-
struct EncryptionKeyProviderOptions {
50+
struct KeyProviderOptions {
5151
/// Shared static key for "shared-key E2EE" (optional).
5252
///
5353
/// If set, it must be identical (byte-for-byte) across all participants
@@ -85,7 +85,7 @@ struct EncryptionKeyProviderOptions {
8585
* per-participant).
8686
*/
8787
struct E2EEOptions {
88-
EncryptionKeyProviderOptions key_provider_options{};
88+
KeyProviderOptions key_provider_options{};
8989
EncryptionType encryption_type = EncryptionType::GCM; // default & recommended
9090
};
9191

@@ -124,7 +124,7 @@ class E2EEManager {
124124
KeyProvider &operator=(KeyProvider &&) noexcept = default;
125125

126126
/// Returns the options used to initialize this KeyProvider.
127-
const EncryptionKeyProviderOptions &options() const;
127+
const KeyProviderOptions &options() const;
128128

129129
/// Sets the shared key for the given key slot.
130130
void setSharedKey(const std::vector<std::uint8_t> &key, int key_index = 0);
@@ -150,9 +150,9 @@ class E2EEManager {
150150
private:
151151
friend class E2EEManager;
152152
KeyProvider(std::uint64_t room_handle,
153-
EncryptionKeyProviderOptions options);
153+
KeyProviderOptions options);
154154
std::uint64_t room_handle_{0};
155-
EncryptionKeyProviderOptions options_;
155+
KeyProviderOptions options_;
156156
};
157157

158158
class FrameCryptor {

include/livekit/video_frame.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,23 @@ class OwnedVideoBuffer;
5656
* - The SDK can expose the backing memory to Rust via data_ptr + layout for
5757
* the duration of a blocking FFI call (similar to AudioFrame).
5858
*/
59-
class LKVideoFrame {
59+
class VideoFrame {
6060
public:
61-
LKVideoFrame();
62-
LKVideoFrame(int width, int height, VideoBufferType type,
61+
VideoFrame();
62+
VideoFrame(int width, int height, VideoBufferType type,
6363
std::vector<std::uint8_t> data);
64-
virtual ~LKVideoFrame() = default;
64+
virtual ~VideoFrame() = default;
6565

66-
LKVideoFrame(const LKVideoFrame &) = delete;
67-
LKVideoFrame &operator=(const LKVideoFrame &) = delete;
68-
LKVideoFrame(LKVideoFrame &&) noexcept = default;
69-
LKVideoFrame &operator=(LKVideoFrame &&) noexcept = default;
66+
VideoFrame(const VideoFrame &) = delete;
67+
VideoFrame &operator=(const VideoFrame &) = delete;
68+
VideoFrame(VideoFrame &&) noexcept = default;
69+
VideoFrame &operator=(VideoFrame &&) noexcept = default;
7070

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

7777
// Basic properties
7878
int width() const noexcept { return width_; }
@@ -95,13 +95,13 @@ class LKVideoFrame {
9595
* Convert this frame into another pixel format.
9696
*
9797
* This uses the underlying FFI `video_convert` pipeline to transform the
98-
* current frame into a new `LKVideoFrame` with the requested
98+
* current frame into a new `VideoFrame` with the requested
9999
* `dst` buffer type (e.g. ARGB → I420, BGRA → RGB24, etc.).
100100
*
101101
* @param dst Desired output format (see VideoBufferType).
102102
* @param flip_y If true, the converted frame will be vertically flipped.
103103
*
104-
* @return A new LKVideoFrame containing the converted image data.
104+
* @return A new VideoFrame containing the converted image data.
105105
*
106106
* Notes:
107107
* - This function allocates a new buffer and copies pixel data; it does
@@ -114,15 +114,15 @@ class LKVideoFrame {
114114
* format combination is unsupported.
115115
*
116116
* Typical usage:
117-
* LKVideoFrame i420 = frame.convert(VideoBufferType::I420);
117+
* VideoFrame i420 = frame.convert(VideoBufferType::I420);
118118
*/
119-
LKVideoFrame convert(VideoBufferType dst, bool flip_y = false) const;
119+
VideoFrame convert(VideoBufferType dst, bool flip_y = false) const;
120120

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

127127
private:
128128
int width_;

include/livekit/video_source.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
namespace livekit {
2424

25-
class LKVideoFrame;
25+
class VideoFrame;
2626

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

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

8484
private:

include/livekit/video_stream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace livekit {
3333

3434
// A single video frame event delivered by VideoStream::read().
3535
struct VideoFrameEvent {
36-
LKVideoFrame frame;
36+
VideoFrame frame;
3737
std::int64_t timestamp_us;
3838
VideoRotation rotation;
3939
};

src/e2ee.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ std::vector<std::uint8_t> stringToBytes(const std::string &s) {
4343
// ============================================================================
4444

4545
E2EEManager::KeyProvider::KeyProvider(std::uint64_t room_handle,
46-
EncryptionKeyProviderOptions options)
46+
KeyProviderOptions options)
4747
: room_handle_(room_handle), options_(std::move(options)) {}
4848

49-
const EncryptionKeyProviderOptions &E2EEManager::KeyProvider::options() const {
49+
const KeyProviderOptions &E2EEManager::KeyProvider::options() const {
5050
return options_;
5151
}
5252

src/video_frame.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace {
1616
std::size_t computeBufferSize(int width, int height, VideoBufferType type) {
1717
if (width <= 0 || height <= 0) {
1818
throw std::invalid_argument(
19-
"LKVideoFrame: width and height must be positive");
19+
"VideoFrame: width and height must be positive");
2020
}
2121

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

7272
default:
73-
throw std::runtime_error("LKVideoFrame: unsupported VideoBufferType");
73+
throw std::runtime_error("VideoFrame: unsupported VideoBufferType");
7474
}
7575
}
7676

@@ -79,7 +79,7 @@ std::vector<VideoPlaneInfo>
7979
computePlaneInfos(uintptr_t base, int width, int height, VideoBufferType type) {
8080
std::vector<VideoPlaneInfo> planes;
8181
if (!base || width <= 0 || height <= 0) {
82-
std::cerr << "[LKVideoFrame] Warning: invalid planeInfos input (ptr="
82+
std::cerr << "[VideoFrame] Warning: invalid planeInfos input (ptr="
8383
<< base << ", w=" << width << ", h=" << height << ")\n";
8484
return planes;
8585
}
@@ -261,29 +261,29 @@ computePlaneInfos(uintptr_t base, int width, int height, VideoBufferType type) {
261261
} // namespace
262262

263263
// ----------------------------------------------------------------------------
264-
// LKVideoFrame implementation
264+
// VideoFrame implementation
265265
// ----------------------------------------------------------------------------
266266

267-
LKVideoFrame::LKVideoFrame()
267+
VideoFrame::VideoFrame()
268268
: width_{0}, height_{0}, type_{VideoBufferType::BGRA}, data_{} {}
269269

270-
LKVideoFrame::LKVideoFrame(int width, int height, VideoBufferType type,
270+
VideoFrame::VideoFrame(int width, int height, VideoBufferType type,
271271
std::vector<std::uint8_t> data)
272272
: width_(width), height_(height), type_(type), data_(std::move(data)) {
273273
const std::size_t expected = computeBufferSize(width_, height_, type_);
274274
if (data_.size() < expected) {
275-
throw std::invalid_argument("LKVideoFrame: provided data is too small for "
275+
throw std::invalid_argument("VideoFrame: provided data is too small for "
276276
"the specified format and size");
277277
}
278278
}
279279

280-
LKVideoFrame LKVideoFrame::create(int width, int height, VideoBufferType type) {
280+
VideoFrame VideoFrame::create(int width, int height, VideoBufferType type) {
281281
const std::size_t size = computeBufferSize(width, height, type);
282282
std::vector<std::uint8_t> buffer(size, 0);
283-
return LKVideoFrame(width, height, type, std::move(buffer));
283+
return VideoFrame(width, height, type, std::move(buffer));
284284
}
285285

286-
std::vector<VideoPlaneInfo> LKVideoFrame::planeInfos() const {
286+
std::vector<VideoPlaneInfo> VideoFrame::planeInfos() const {
287287
if (data_.empty()) {
288288
return {};
289289
}
@@ -292,24 +292,24 @@ std::vector<VideoPlaneInfo> LKVideoFrame::planeInfos() const {
292292
return computePlaneInfos(base, width_, height_, type_);
293293
}
294294

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

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

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

362-
return LKVideoFrame(width, height, type, std::move(buffer));
362+
return VideoFrame(width, height, type, std::move(buffer));
363363
}
364364

365365
} // namespace livekit

0 commit comments

Comments
 (0)