Skip to content

Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.

fix(android): keep a PC's screen mirroring settings within what the phone can encode

Beeecafb2b8c2c4
diff --git a/android/app/src/main/kotlin/app/nectarlink/android/core/PhonePlatform.kt b/android/app/src/main/kotlin/app/nectarlink/android/core/PhonePlatform.kt
index 37b64a1..f3e1dcf 100644
--- a/android/app/src/main/kotlin/app/nectarlink/android/core/PhonePlatform.kt
+++ b/android/app/src/main/kotlin/app/nectarlink/android/core/PhonePlatform.kt
@@ -141,11 +141,13 @@ internal class PhonePlatform(
if (options.app != null) {
appWindows.open(pcId, options)
} else {
+ // Kept within what the encoder can take: a zero or huge value from
+ // the PC would only make this mirroring fail to start.
val request = MirrorRequest(
pcId,
- options.maxSize.toInt(),
- options.fps.toInt(),
- options.bitrate.toInt(),
+ options.maxSize.coerceIn(320u, 4096u).toInt(),
+ options.fps.coerceIn(1u, 120u).toInt(),
+ options.bitrate.coerceIn(500_000u, 50_000_000u).toInt(),
options.audio,
options.stayAwake,
options.screenOff,