Skip to content

Commit b0eda5d

Browse files
authored
Fix maxFps not applying for very low framerates (#573)
1 parent 3afefad commit b0eda5d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"client-sdk-android": patch
3+
---
4+
5+
Fix maxFps not applying for very low framerates

livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 LiveKit, Inc.
2+
* Copyright 2023-2025 LiveKit, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,6 +69,7 @@ import livekit.org.webrtc.VideoCapturer
6969
import livekit.org.webrtc.VideoProcessor
7070
import javax.inject.Named
7171
import kotlin.math.max
72+
import kotlin.math.min
7273

7374
class LocalParticipant
7475
@AssistedInject
@@ -591,7 +592,7 @@ internal constructor(
591592
// if resolution is high enough, we send both h and q res.
592593
// otherwise only send h
593594
val size = max(width, height)
594-
595+
val maxFps = encoding.maxFps
595596
fun calculateScaleDown(captureParam: VideoCaptureParameter): Double {
596597
val targetSize = max(captureParam.width, captureParam.height)
597598
return size / targetSize.toDouble()
@@ -600,11 +601,11 @@ internal constructor(
600601
val lowScale = calculateScaleDown(lowPreset.capture)
601602
val midScale = calculateScaleDown(midPreset.capture)
602603

603-
addEncoding(lowPreset.encoding, lowScale)
604-
addEncoding(midPreset.encoding, midScale)
604+
addEncoding(lowPreset.encoding.copy(maxFps = min(lowPreset.encoding.maxFps, maxFps)), lowScale)
605+
addEncoding(midPreset.encoding.copy(maxFps = min(midPreset.encoding.maxFps, maxFps)), midScale)
605606
} else {
606607
val lowScale = calculateScaleDown(lowPreset.capture)
607-
addEncoding(lowPreset.encoding, lowScale)
608+
addEncoding(lowPreset.encoding.copy(maxFps = min(lowPreset.encoding.maxFps, maxFps)), lowScale)
608609
}
609610
addEncoding(encoding, 1.0)
610611
} else {

0 commit comments

Comments
 (0)