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") 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 { if !pconf.RPICameraSecondary {
switch pconf.RPICameraCodec { switch pconf.RPICameraCodec {
case "auto", "hardwareH264", "softwareH264": case "auto", "hardwareH264", "softwareH264":

View file

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