Skip to content

Commit

Permalink
Fix enconding presets
Browse files Browse the repository at this point in the history
Fixes an issue with compute_appropriate_encoding, where the last preset
in the list with the highest FPS wasn't considered.

Changes the order in into_rtp_encodings to have the highest quality
first.
  • Loading branch information
iparaskev committed Oct 8, 2024
1 parent ef99aad commit 1e44c25
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion livekit/src/room/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub fn compute_appropriate_encoding(

for preset in presets {
encoding = preset.encoding.clone();
if preset.width >= size {
if preset.width > size {
break;
}
}
Expand Down Expand Up @@ -244,6 +244,7 @@ pub fn into_rtp_encodings(
) -> Vec<RtpEncodingParameters> {
let mut encodings = Vec::with_capacity(presets.len());
let size = u32::min(initial_width, initial_height);
// TODO: When we have two should the last one be 'h' or 'f'?
for (i, preset) in presets.iter().enumerate() {
encodings.push(RtpEncodingParameters {
rid: VIDEO_RIDS[i].to_string(),
Expand All @@ -257,6 +258,7 @@ pub fn into_rtp_encodings(
})
}

encodings.reverse();
encodings
}

Expand Down

0 comments on commit 1e44c25

Please sign in to comment.