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
10 changes: 10 additions & 0 deletions include/livekit/room.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ struct RoomOptions {
///
/// If unset, the Rust SDK default is used.
std::optional<std::chrono::milliseconds> connect_timeout;

/// @cond
/// Additional LiveKit SDKs layered on top of this one, reported to the server
/// as part of the client info.
///
/// Comma separated list of `name:version` pairs, e.g.
/// "ros_portal:1.2.3,components-cpp:2.0.0". If unset, no additional SDKs are reported.
/// this is for internal use only.
std::optional<std::string> other_sdks;
Comment thread
stephen-derosa marked this conversation as resolved.
/// @endcond
};

/// Represents a LiveKit room session.
Expand Down
6 changes: 4 additions & 2 deletions src/ffi_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ const auto optional_to_string = [](const auto& value) -> std::string {
return *value ? "true" : "false";
} else if constexpr (std::is_same_v<Value, std::chrono::milliseconds>) {
return std::to_string(value->count());
} else if constexpr (std::is_same_v<Value, std::string>) {
return *value;
} else {
return std::to_string(*value);
}
Expand Down Expand Up @@ -503,10 +505,10 @@ std::future<proto::ConnectCallback> FfiClient::connectAsync(const std::string& u

LK_LOG_DEBUG(
"[FfiClient] connectAsync: auto_subscribe={}, adaptive_stream={}, dynacast={}, "
"single_peer_connection={}, join_retries={}, connect_timeout_ms={}",
"single_peer_connection={}, join_retries={}, connect_timeout_ms={}, other_sdks={}",
options.auto_subscribe, optional_to_string(options.adaptive_stream), options.dynacast,
options.single_peer_connection, optional_to_string(options.join_retries),
optional_to_string(options.connect_timeout));
optional_to_string(options.connect_timeout), optional_to_string(options.other_sdks));

try {
const proto::FfiResponse resp = sendRequest(req);
Expand Down
3 changes: 3 additions & 0 deletions src/room_proto_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@ proto::RoomOptions toProto(const RoomOptions& in) {
if (in.connect_timeout) {
out.set_connect_timeout_ms(static_cast<std::uint64_t>(in.connect_timeout->count()));
}
if (in.other_sdks) {
out.set_other_sdks(*in.other_sdks);
}
return out;
}

Expand Down
17 changes: 17 additions & 0 deletions src/tests/unit/test_room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ TEST_F(RoomTest, RoomOptionsDefaults) {
EXPECT_FALSE(options.join_retries.has_value()) << "join_retries should defer to Rust default";
EXPECT_TRUE(options.single_peer_connection) << "single_peer_connection should default to true";
EXPECT_FALSE(options.connect_timeout.has_value()) << "connect_timeout should defer to Rust default";
EXPECT_FALSE(options.other_sdks.has_value()) << "other_sdks should not report additional SDKs by default";
}

TEST_F(RoomTest, RoomOptionsToProtoSerializesDefaults) {
Expand All @@ -208,6 +209,7 @@ TEST_F(RoomTest, RoomOptionsToProtoSerializesDefaults) {
EXPECT_TRUE(proto_options.has_single_peer_connection());
EXPECT_TRUE(proto_options.single_peer_connection());
EXPECT_FALSE(proto_options.has_connect_timeout_ms());
EXPECT_FALSE(proto_options.has_other_sdks());
}

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

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

Expand Down Expand Up @@ -255,6 +258,8 @@ TEST_F(RoomTest, RoomOptionsProtoConverter) {
EXPECT_FALSE(proto_options.single_peer_connection());
EXPECT_TRUE(proto_options.has_connect_timeout_ms());
EXPECT_EQ(proto_options.connect_timeout_ms(), 750U);
EXPECT_TRUE(proto_options.has_other_sdks());
EXPECT_EQ(proto_options.other_sdks(), "ros_portal:1.2.3,another-sdk:2.0.0");
}

TEST(RoomOptionsProtoTest, ConnectRequestSerializesRetryOptions) {
Expand Down Expand Up @@ -285,6 +290,18 @@ TEST(RoomOptionsProtoTest, ConnectRequestSerializesRetryOptions) {
EXPECT_EQ(decoded.connect().options().connect_timeout_ms(), 750U);
}

TEST(RoomOptionsProtoTest, EmptyOtherSdksIsStillSerialized) {
// An explicitly empty list stays distinguishable from unset on the wire; Rust
// collapses both to "no additional SDKs".
RoomOptions options;
options.other_sdks = "";

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

ASSERT_TRUE(proto_options.has_other_sdks());
EXPECT_EQ(proto_options.other_sdks(), "");
}

TEST_F(RoomTest, RtcConfigDefaults) {
RtcConfig config;

Expand Down
Loading