From 887a3997b1a1181b61dac66ac89caaec4ebff43a Mon Sep 17 00:00:00 2001 From: Adam Shiervani Date: Wed, 29 Oct 2025 15:08:41 +0100 Subject: [PATCH 1/2] Add default video quality --- config.go | 3 ++- internal/native/cgo/ctrl.c | 6 +++--- internal/native/cgo/video.c | 2 +- internal/native/native.go | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config.go b/config.go index 26f54a45b..5a3e7dc8f 100644 --- a/config.go +++ b/config.go @@ -177,7 +177,8 @@ func getDefaultConfig() Config { _ = confparser.SetDefaultsAndValidate(c) return c }(), - DefaultLogLevel: "INFO", + DefaultLogLevel: "INFO", + VideoQualityFactor: 1.0, } } diff --git a/internal/native/cgo/ctrl.c b/internal/native/cgo/ctrl.c index 0c10ee15a..547d5694b 100644 --- a/internal/native/cgo/ctrl.c +++ b/internal/native/cgo/ctrl.c @@ -306,7 +306,7 @@ int jetkvm_ui_add_flag(const char *obj_name, const char *flag_name) { if (obj == NULL) { return -1; } - + lv_obj_flag_t flag_val = str_to_lv_obj_flag(flag_name); if (flag_val == 0) { @@ -368,7 +368,7 @@ void jetkvm_video_stop() { } int jetkvm_video_set_quality_factor(float quality_factor) { - if (quality_factor < 0 || quality_factor > 1) { + if (quality_factor <= 0 || quality_factor > 1) { return -1; } video_set_quality_factor(quality_factor); @@ -417,4 +417,4 @@ void jetkvm_crash() { // let's call a function that will crash the program int* p = 0; *p = 0; -} \ No newline at end of file +} diff --git a/internal/native/cgo/video.c b/internal/native/cgo/video.c index 917e91637..857acbbb9 100644 --- a/internal/native/cgo/video.c +++ b/internal/native/cgo/video.c @@ -235,7 +235,7 @@ int video_init(float factor) { detect_sleep_mode(); - if (factor < 0 || factor > 1) { + if (factor <= 0 || factor > 1) { factor = 1.0f; } quality_factor = factor; diff --git a/internal/native/native.go b/internal/native/native.go index 2a9055cea..3b1cc0b46 100644 --- a/internal/native/native.go +++ b/internal/native/native.go @@ -69,7 +69,7 @@ func NewNative(opts NativeOptions) *Native { sleepModeSupported := isSleepModeSupported() defaultQualityFactor := opts.DefaultQualityFactor - if defaultQualityFactor < 0 || defaultQualityFactor > 1 { + if defaultQualityFactor <= 0 || defaultQualityFactor > 1 { defaultQualityFactor = 1.0 } From 509cea64fa14267083083da9e00560eb02826135 Mon Sep 17 00:00:00 2001 From: Adam Shiervani Date: Wed, 29 Oct 2025 15:33:49 +0100 Subject: [PATCH 2/2] refactor: update stream quality factor handling in JSON-RPC Replaced the static stream factor with a configurable video quality factor. The new implementation saves the updated quality factor to the configuration, ensuring persistence across sessions. --- jsonrpc.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jsonrpc.go b/jsonrpc.go index dede5bf0b..5ed90a7a2 100644 --- a/jsonrpc.go +++ b/jsonrpc.go @@ -177,10 +177,8 @@ func rpcReboot(force bool) error { return hwReboot(force, nil, 0) } -var streamFactor = 1.0 - func rpcGetStreamQualityFactor() (float64, error) { - return streamFactor, nil + return config.VideoQualityFactor, nil } func rpcSetStreamQualityFactor(factor float64) error { @@ -190,7 +188,10 @@ func rpcSetStreamQualityFactor(factor float64) error { return err } - streamFactor = factor + config.VideoQualityFactor = factor + if err := SaveConfig(); err != nil { + return fmt.Errorf("failed to save config: %w", err) + } return nil }