Skip to content

Commit 93c4041

Browse files
Merge branch 'main' of github.com:livekit/client-sdk-cpp into ladvoc/schema-metadata
2 parents 053ecb8 + 2b81279 commit 93c4041

6 files changed

Lines changed: 50 additions & 2 deletions

File tree

AGENTS.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,21 @@ CI step will fail loudly if its symbols escape the public ABI of
352352

353353
Tests are under `src/tests/` using Google Test:
354354

355-
```
355+
```bash
356+
source .token_helpers/set_data_track_test_tokens.bash
356357
./build.sh debug-tests
357358
cd build-debug && ctest
358359
```
359360

361+
Always source the test tokens before running tests, even for a targeted local
362+
test run. The integration and stress suites require `LIVEKIT_URL`,
363+
`LIVEKIT_TOKEN_A`, and `LIVEKIT_TOKEN_B`; use
364+
`source .token_helpers/set_data_track_test_tokens.bash` from the repository
365+
root so the current shell inherits them. Do not report an integration test as
366+
verified just because it was skipped for missing tokens. If tokens cannot be
367+
sourced or the LiveKit server is not available, say that the integration test
368+
was not actually exercised.
369+
360370
Integration tests (`src/tests/integration/`) cover: room connections, callbacks, data tracks, RPC, logging, audio processing, and the subscription thread dispatcher. The token source HTTP/JSON wire contract (request serialization, response parsing, header passthrough, GET support, sandbox URL/header resolution) is covered by mocked unit tests in `src/tests/unit/test_token_source.cpp`, which inject a stub HTTP transport so no live server is needed. For a full end-to-end check, `TokenSourceEndpointConnectTest` connects a `Room` with a real JWT minted by the `livekit/token-server-action` token server pointed at the local dev `livekit-server`. The action exposes its `/createToken` endpoint as a `token-url` output; `tests.yml` passes that to the integration test step as `LIVEKIT_CREATE_TOKEN_URL`, which the test reads to locate the endpoint. The server is started in the `e2e-testing` jobs via the token server's reusable GitHub Action, pinned by SHA in `tests.yml`.
361371

362372
When adding new client facing functionality, add a new test case to the existing test suite.

include/livekit/room_event_types.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,19 @@ struct AudioEncodingOptions {
273273
std::uint64_t max_bitrate = 0;
274274
};
275275

276+
/// @brief Controls how the encoder degrades quality when bandwidth is constrained.
277+
enum class DegradationPreference {
278+
/// Balance between framerate and resolution degradation.
279+
Balanced = 0,
280+
/// Degrade resolution to maintain framerate (prioritize smooth motion).
281+
MaintainFramerate = 1,
282+
/// Degrade framerate to maintain resolution (prioritize image clarity).
283+
MaintainResolution = 2,
284+
/// Maintain both framerate and resolution. Frames may be dropped before
285+
/// encoding if necessary to avoid overusing network and encoder resources.
286+
MaintainFramerateAndResolution = 4,
287+
};
288+
276289
/// Optional frame metadata features for published video tracks.
277290
struct FrameMetadataFeatures {
278291
/// Embed a user-supplied wall-clock timestamp.
@@ -324,6 +337,10 @@ struct TrackPublishOptions {
324337
/// @deprecated Use frame_metadata_features instead.
325338
[[deprecated("TrackPublishOptions::packet_trailer_features is deprecated; use frame_metadata_features instead")]]
326339
FrameMetadataFeatures packet_trailer_features{};
340+
341+
/// Controls how the encoder trades off between resolution and framerate
342+
/// when bandwidth is constrained. If not set, the server defaults apply.
343+
std::optional<DegradationPreference> degradation_preference;
327344
};
328345

329346
// ---------------------------------------------------------

src/room_proto_converter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@ proto::TrackPublishOptions toProto(const TrackPublishOptions& in) {
526526
for (const proto::FrameMetadataFeature feature : toProto(mergedFrameMetadataFeatures(in))) {
527527
msg.add_frame_metadata_features(feature);
528528
}
529+
if (in.degradation_preference) {
530+
msg.set_degradation_preference(static_cast<proto::DegradationPreference>(*in.degradation_preference));
531+
}
529532
return msg;
530533
}
531534

@@ -563,6 +566,9 @@ TrackPublishOptions fromProto(const proto::TrackPublishOptions& in) {
563566
out.frame_metadata_features = frame_metadata_features;
564567
}
565568
out.packet_trailer_features = frame_metadata_features;
569+
if (in.has_degradation_preference()) {
570+
out.degradation_preference = static_cast<DegradationPreference>(in.degradation_preference());
571+
}
566572
return out;
567573
}
568574

src/tests/common/test_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ class LiveKitTestBase : public ::testing::Test {
548548
/// Fail the test if the required environment variables are not set
549549
void failIfNotConfigured() {
550550
if (!config_.available) {
551-
FAIL() << "LIVEKIT_URL, LIVEKIT_TOKEN_A, and LIVEKIT_TOKEN_B not set";
551+
throw std::runtime_error("LIVEKIT_URL, LIVEKIT_TOKEN_A, and LIVEKIT_TOKEN_B not set");
552552
}
553553
}
554554

src/tests/unit/test_room_event_types.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ TEST(RoomEventTypesTest, TrackPublishOptionsDefaults) {
4949
EXPECT_FALSE(options.packet_trailer_features.user_timestamp);
5050
EXPECT_FALSE(options.packet_trailer_features.frame_id);
5151
EXPECT_FALSE(options.packet_trailer_features.user_data);
52+
EXPECT_FALSE(options.degradation_preference.has_value());
5253
}
5354

5455
TEST(RoomEventTypesTest, UserPacketDataDefaults) {

src/tests/unit/test_video_frame_metadata.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ TEST(TrackPublishOptionsTest, FrameMetadataFeaturesRoundTrip) {
138138
EXPECT_TRUE(round_trip.frame_metadata_features->user_data);
139139
}
140140

141+
TEST(TrackPublishOptionsTest, DegradationPreferenceRoundTrip) {
142+
TrackPublishOptions options;
143+
options.degradation_preference = DegradationPreference::MaintainFramerateAndResolution;
144+
145+
proto::TrackPublishOptions proto_options = toProto(options);
146+
ASSERT_TRUE(proto_options.has_degradation_preference());
147+
EXPECT_EQ(proto_options.degradation_preference(),
148+
proto::DegradationPreference::DEGRADATION_PREFERENCE_MAINTAIN_FRAMERATE_AND_RESOLUTION);
149+
150+
TrackPublishOptions round_trip = fromProto(proto_options);
151+
ASSERT_TRUE(round_trip.degradation_preference.has_value());
152+
EXPECT_EQ(*round_trip.degradation_preference, DegradationPreference::MaintainFramerateAndResolution);
153+
}
154+
141155
TEST(TrackPublishOptionsTest, DeprecatedPacketTrailerFeaturesAreMerged) {
142156
TrackPublishOptions options;
143157

0 commit comments

Comments
 (0)