From 9c72aca4ac30b997d40ad2ebee875e3d8e4d9012 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Sun, 18 Aug 2024 16:14:08 +0200 Subject: [PATCH] rpi: add rpiCameraFlickerPeriod (#3463) --- apidocs/openapi.yaml | 2 ++ internal/conf/conf_test.go | 1 + internal/conf/path.go | 2 ++ internal/core/path_manager.go | 1 + internal/staticsources/rpicamera/params.go | 1 + internal/staticsources/rpicamera/source.go | 1 + mediamtx.yml | 2 ++ 7 files changed, 10 insertions(+) diff --git a/apidocs/openapi.yaml b/apidocs/openapi.yaml index a13c5795b06d..26b6de7081c7 100644 --- a/apidocs/openapi.yaml +++ b/apidocs/openapi.yaml @@ -374,6 +374,8 @@ components: type: number rpiCameraExposure: type: string + rpiCameraFlickerPeriod: + type: string rpiCameraAWB: type: string rpiCameraAWBGains: diff --git a/internal/conf/conf_test.go b/internal/conf/conf_test.go index f0d1529ad856..5a1f536ec516 100644 --- a/internal/conf/conf_test.go +++ b/internal/conf/conf_test.go @@ -64,6 +64,7 @@ func TestConfFromFile(t *testing.T) { RPICameraSaturation: 1, RPICameraSharpness: 1, RPICameraExposure: "normal", + RPICameraFlickerPeriod: "auto", RPICameraAWB: "auto", RPICameraAWBGains: []float64{0, 0}, RPICameraDenoise: "off", diff --git a/internal/conf/path.go b/internal/conf/path.go index 925f050f439b..915b43fd6f2c 100644 --- a/internal/conf/path.go +++ b/internal/conf/path.go @@ -140,6 +140,7 @@ type Path struct { RPICameraSaturation float64 `json:"rpiCameraSaturation"` RPICameraSharpness float64 `json:"rpiCameraSharpness"` RPICameraExposure string `json:"rpiCameraExposure"` + RPICameraFlickerPeriod string `json:"rpiCameraFlickerPeriod"` RPICameraAWB string `json:"rpiCameraAWB"` RPICameraAWBGains []float64 `json:"rpiCameraAWBGains"` RPICameraDenoise string `json:"rpiCameraDenoise"` @@ -205,6 +206,7 @@ func (pconf *Path) setDefaults() { pconf.RPICameraSaturation = 1 pconf.RPICameraSharpness = 1 pconf.RPICameraExposure = "normal" + pconf.RPICameraFlickerPeriod = "auto" pconf.RPICameraAWB = "auto" pconf.RPICameraAWBGains = []float64{0, 0} pconf.RPICameraDenoise = "off" diff --git a/internal/core/path_manager.go b/internal/core/path_manager.go index ae78ba1b1e23..623ac6a7c65b 100644 --- a/internal/core/path_manager.go +++ b/internal/core/path_manager.go @@ -24,6 +24,7 @@ func pathConfCanBeUpdated(oldPathConf *conf.Path, newPathConf *conf.Path) bool { clone.RPICameraSaturation = newPathConf.RPICameraSaturation clone.RPICameraSharpness = newPathConf.RPICameraSharpness clone.RPICameraExposure = newPathConf.RPICameraExposure + clone.RPICameraFlickerPeriod = newPathConf.RPICameraFlickerPeriod clone.RPICameraAWB = newPathConf.RPICameraAWB clone.RPICameraAWBGains = newPathConf.RPICameraAWBGains clone.RPICameraDenoise = newPathConf.RPICameraDenoise diff --git a/internal/staticsources/rpicamera/params.go b/internal/staticsources/rpicamera/params.go index c847a388545f..db6340955fc2 100644 --- a/internal/staticsources/rpicamera/params.go +++ b/internal/staticsources/rpicamera/params.go @@ -12,6 +12,7 @@ type params struct { Saturation float64 Sharpness float64 Exposure string + FlickerPeriod string AWB string AWBGainRed float64 AWBGainBlue float64 diff --git a/internal/staticsources/rpicamera/source.go b/internal/staticsources/rpicamera/source.go index 1a4d49c6b2f3..e198656a6f50 100644 --- a/internal/staticsources/rpicamera/source.go +++ b/internal/staticsources/rpicamera/source.go @@ -37,6 +37,7 @@ func paramsFromConf(logLevel conf.LogLevel, cnf *conf.Path) params { Saturation: cnf.RPICameraSaturation, Sharpness: cnf.RPICameraSharpness, Exposure: cnf.RPICameraExposure, + FlickerPeriod: cnf.RPICameraFlickerPeriod, AWB: cnf.RPICameraAWB, AWBGainRed: cnf.RPICameraAWBGains[0], AWBGainBlue: cnf.RPICameraAWBGains[1], diff --git a/mediamtx.yml b/mediamtx.yml index f936a305d3e5..eb5f7f90f2e6 100644 --- a/mediamtx.yml +++ b/mediamtx.yml @@ -527,6 +527,8 @@ pathDefaults: # exposure mode. # values: normal, short, long, custom rpiCameraExposure: normal + # Manual flicker correction period + rpiCameraFlickerPeriod: auto # auto-white-balance mode. # values: auto, incandescent, tungsten, fluorescent, indoor, daylight, cloudy, custom rpiCameraAWB: auto