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
6969import livekit.org.webrtc.VideoProcessor
7070import javax.inject.Named
7171import kotlin.math.max
72+ import kotlin.math.min
7273
7374class 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