Skip to content

Commit d702a89

Browse files
other_sdks
1 parent e638f6f commit d702a89

5 files changed

Lines changed: 32 additions & 3 deletions

File tree

client-sdk-rust

include/livekit/room.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ struct RoomOptions {
121121
///
122122
/// If unset, the Rust SDK default is used.
123123
std::optional<std::chrono::milliseconds> connect_timeout;
124+
125+
/// Additional LiveKit SDKs layered on top of this one, reported to the server
126+
/// as part of the client info.
127+
///
128+
/// Comma separated list of `name:version` pairs, e.g.
129+
/// "ros_portal:1.2.3,components-cpp:2.0.0". If unset, no additional SDKs are reported.
130+
std::optional<std::string> other_sdks;
124131
};
125132

126133
/// Represents a LiveKit room session.

src/ffi_client.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ const auto optional_to_string = [](const auto& value) -> std::string {
6161
return *value ? "true" : "false";
6262
} else if constexpr (std::is_same_v<Value, std::chrono::milliseconds>) {
6363
return std::to_string(value->count());
64+
} else if constexpr (std::is_same_v<Value, std::string>) {
65+
return *value;
6466
} else {
6567
return std::to_string(*value);
6668
}
@@ -503,10 +505,10 @@ std::future<proto::ConnectCallback> FfiClient::connectAsync(const std::string& u
503505

504506
LK_LOG_DEBUG(
505507
"[FfiClient] connectAsync: auto_subscribe={}, adaptive_stream={}, dynacast={}, "
506-
"single_peer_connection={}, join_retries={}, connect_timeout_ms={}",
508+
"single_peer_connection={}, join_retries={}, connect_timeout_ms={}, other_sdks={}",
507509
options.auto_subscribe, optional_to_string(options.adaptive_stream), options.dynacast,
508510
options.single_peer_connection, optional_to_string(options.join_retries),
509-
optional_to_string(options.connect_timeout));
511+
optional_to_string(options.connect_timeout), optional_to_string(options.other_sdks));
510512

511513
try {
512514
const proto::FfiResponse resp = sendRequest(req);

src/room_proto_converter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,9 @@ proto::RoomOptions toProto(const RoomOptions& in) {
469469
if (in.connect_timeout) {
470470
out.set_connect_timeout_ms(static_cast<std::uint64_t>(in.connect_timeout->count()));
471471
}
472+
if (in.other_sdks) {
473+
out.set_other_sdks(*in.other_sdks);
474+
}
472475
return out;
473476
}
474477

src/tests/unit/test_room.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ TEST_F(RoomTest, RoomOptionsDefaults) {
192192
EXPECT_FALSE(options.join_retries.has_value()) << "join_retries should defer to Rust default";
193193
EXPECT_TRUE(options.single_peer_connection) << "single_peer_connection should default to true";
194194
EXPECT_FALSE(options.connect_timeout.has_value()) << "connect_timeout should defer to Rust default";
195+
EXPECT_FALSE(options.other_sdks.has_value()) << "other_sdks should not report additional SDKs by default";
195196
}
196197

197198
TEST_F(RoomTest, RoomOptionsToProtoSerializesDefaults) {
@@ -208,6 +209,7 @@ TEST_F(RoomTest, RoomOptionsToProtoSerializesDefaults) {
208209
EXPECT_TRUE(proto_options.has_single_peer_connection());
209210
EXPECT_TRUE(proto_options.single_peer_connection());
210211
EXPECT_FALSE(proto_options.has_connect_timeout_ms());
212+
EXPECT_FALSE(proto_options.has_other_sdks());
211213
}
212214

213215
TEST_F(RoomTest, RoomOptionsProtoConverter) {
@@ -227,6 +229,7 @@ TEST_F(RoomTest, RoomOptionsProtoConverter) {
227229
options.join_retries = 8;
228230
options.single_peer_connection = false;
229231
options.connect_timeout = std::chrono::milliseconds(750);
232+
options.other_sdks = "ros_portal:1.2.3,another-sdk:2.0.0";
230233

231234
const proto::RoomOptions proto_options = toProto(options);
232235

@@ -255,6 +258,8 @@ TEST_F(RoomTest, RoomOptionsProtoConverter) {
255258
EXPECT_FALSE(proto_options.single_peer_connection());
256259
EXPECT_TRUE(proto_options.has_connect_timeout_ms());
257260
EXPECT_EQ(proto_options.connect_timeout_ms(), 750U);
261+
EXPECT_TRUE(proto_options.has_other_sdks());
262+
EXPECT_EQ(proto_options.other_sdks(), "ros_portal:1.2.3,another-sdk:2.0.0");
258263
}
259264

260265
TEST(RoomOptionsProtoTest, ConnectRequestSerializesRetryOptions) {
@@ -285,6 +290,18 @@ TEST(RoomOptionsProtoTest, ConnectRequestSerializesRetryOptions) {
285290
EXPECT_EQ(decoded.connect().options().connect_timeout_ms(), 750U);
286291
}
287292

293+
TEST(RoomOptionsProtoTest, EmptyOtherSdksIsStillSerialized) {
294+
// An explicitly empty list stays distinguishable from unset on the wire; Rust
295+
// collapses both to "no additional SDKs".
296+
RoomOptions options;
297+
options.other_sdks = "";
298+
299+
const proto::RoomOptions proto_options = toProto(options);
300+
301+
ASSERT_TRUE(proto_options.has_other_sdks());
302+
EXPECT_EQ(proto_options.other_sdks(), "");
303+
}
304+
288305
TEST_F(RoomTest, RtcConfigDefaults) {
289306
RtcConfig config;
290307

0 commit comments

Comments
 (0)