rpi: add validity checks on rpiCameraProfile and rpiCameraLevel (#4783)

This commit is contained in:
Alessandro Ros 2025-07-25 11:36:40 +02:00 committed by GitHub
parent 3f2e4a3ef5
commit 94e001e736
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 18 deletions

View file

@ -494,6 +494,18 @@ func (pconf *Path) validate(
return fmt.Errorf("invalid 'rpiCameraAfSpeed' value")
}
switch pconf.RPICameraProfile {
case "baseline", "main", "high":
default:
return fmt.Errorf("invalid 'rpiCameraProfile' value")
}
switch pconf.RPICameraLevel {
case "4.0", "4.1", "4.2":
default:
return fmt.Errorf("invalid 'rpiCameraLevel' value")
}
if !pconf.RPICameraSecondary {
switch pconf.RPICameraCodec {
case "auto", "hardwareH264", "softwareH264":

View file

@ -562,22 +562,20 @@ pathDefaults:
# values: normal, short, long, custom.
rpiCameraExposure: normal
# Auto-white-balance mode.
# values: auto, incandescent, tungsten, fluorescent, indoor, daylight, cloudy, custom.
# (auto, incandescent, tungsten, fluorescent, indoor, daylight, cloudy or custom).
rpiCameraAWB: auto
# Auto-white-balance fixed gains. This can be used in place of rpiCameraAWB.
# format: [red,blue].
rpiCameraAWBGains: [0, 0]
# Denoise operating mode.
# values: off, cdn_off, cdn_fast, cdn_hq.
# Denoise operating mode (off, cdn_off, cdn_fast, cdn_hq).
rpiCameraDenoise: "off"
# Fixed shutter speed, in microseconds.
rpiCameraShutter: 0
# Metering mode of the AEC/AGC algorithm.
# values: centre, spot, matrix, custom.
# Metering mode of the AEC/AGC algorithm (centre, spot, matrix or custom).
rpiCameraMetering: centre
# Fixed gain.
rpiCameraGain: 0
# EV compensation of the image [-10, 10].
# EV compensation of the image in range [-10, 10].
rpiCameraEV: 0
# Region of interest, in format x,y,width,height (all normalized between 0 and 1).
rpiCameraROI:
@ -590,14 +588,11 @@ pathDefaults:
rpiCameraMode:
# frames per second.
rpiCameraFPS: 30
# Autofocus mode.
# values: auto, manual, continuous.
# Autofocus mode (auto, manual or continuous).
rpiCameraAfMode: continuous
# Autofocus range.
# values: normal, macro, full.
# Autofocus range (normal, macro or full).
rpiCameraAfRange: normal
# Autofocus speed.
# values: normal, fast.
# Autofocus speed (normal or fast).
rpiCameraAfSpeed: normal
# Lens position (for manual autofocus only), will be set to focus to a specific distance
# calculated by the following formula: d = 1 / value
@ -605,7 +600,7 @@ pathDefaults:
# 0.5 moves the lens to focus on objects 2m away.
# 2 moves the lens to focus on objects 50cm away.
rpiCameraLensPosition: 0.0
# Specifies the autofocus window, in the form x,y,width,height where the coordinates
# Autofocus window, in the form x,y,width,height where the coordinates
# are given as a proportion of the entire image.
rpiCameraAfWindow:
# Manual flicker correction period, in microseconds.
@ -615,15 +610,16 @@ pathDefaults:
# Text that is printed on each frame.
# format is the one of the strftime() function.
rpiCameraTextOverlay: '%Y-%m-%d %H:%M:%S - MediaMTX'
# Codec. Available values: auto, hardwareH264, softwareH264, mjpeg.
# Codec (auto, hardwareH264, softwareH264 or mjpeg).
# When auto, hardwareH264 is used if the Raspberry has a H264 encoder, otherwise softwareH264.
rpiCameraCodec: auto
# Period between H264 IDR frames.
# Period between IDR frames (when codec is hardwareH264 or softwareH264).
rpiCameraIDRPeriod: 60
# H264 Bitrate.
# Bitrate (when codec is hardwareH264 or softwareH264).
rpiCameraBitrate: 5000000
# H264 profile.
# H264 profile (baseline, main or high).
rpiCameraProfile: main
# H264 level.
# H264 level (4.0, 4.1 or 4.2).
rpiCameraLevel: '4.1'
# JPEG quality.
rpiCameraJPEGQuality: 60