rpi: rename rpiCameraProfile into rpiCameraH264Profile, rpiCameraLevel into rpiCameraH264Level (#3965) (#4785)

This commit is contained in:
Alessandro Ros 2025-07-25 11:44:55 +02:00 committed by GitHub
parent 1cabc382b0
commit 0fe12f8bf6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 66 additions and 52 deletions

View file

@ -452,9 +452,9 @@ components:
type: integer type: integer
rpiCameraBitrate: rpiCameraBitrate:
type: integer type: integer
rpiCameraProfile: rpiCameraHardwareH264Profile:
type: string type: string
rpiCameraLevel: rpiCameraHardwareH264Level:
type: string type: string
rpiCameraMJPEGQuality: rpiCameraMJPEGQuality:
type: integer type: integer

View file

@ -48,40 +48,40 @@ func TestConfFromFile(t *testing.T) {
pa, ok := conf.Paths["cam1"] pa, ok := conf.Paths["cam1"]
require.Equal(t, true, ok) require.Equal(t, true, ok)
require.Equal(t, &Path{ require.Equal(t, &Path{
Name: "cam1", Name: "cam1",
Source: "publisher", Source: "publisher",
SourceOnDemandStartTimeout: 10 * Duration(time.Second), SourceOnDemandStartTimeout: 10 * Duration(time.Second),
SourceOnDemandCloseAfter: 10 * Duration(time.Second), SourceOnDemandCloseAfter: 10 * Duration(time.Second),
RecordPath: "./recordings/%path/%Y-%m-%d_%H-%M-%S-%f", RecordPath: "./recordings/%path/%Y-%m-%d_%H-%M-%S-%f",
RecordFormat: RecordFormatFMP4, RecordFormat: RecordFormatFMP4,
RecordPartDuration: Duration(1 * time.Second), RecordPartDuration: Duration(1 * time.Second),
RecordMaxPartSize: 50 * 1024 * 1024, RecordMaxPartSize: 50 * 1024 * 1024,
RecordSegmentDuration: 3600000000000, RecordSegmentDuration: 3600000000000,
RecordDeleteAfter: 86400000000000, RecordDeleteAfter: 86400000000000,
OverridePublisher: true, OverridePublisher: true,
RPICameraWidth: 1920, RPICameraWidth: 1920,
RPICameraHeight: 1080, RPICameraHeight: 1080,
RPICameraContrast: 1, RPICameraContrast: 1,
RPICameraSaturation: 1, RPICameraSaturation: 1,
RPICameraSharpness: 1, RPICameraSharpness: 1,
RPICameraExposure: "normal", RPICameraExposure: "normal",
RPICameraAWB: "auto", RPICameraAWB: "auto",
RPICameraAWBGains: []float64{0, 0}, RPICameraAWBGains: []float64{0, 0},
RPICameraDenoise: "off", RPICameraDenoise: "off",
RPICameraMetering: "centre", RPICameraMetering: "centre",
RPICameraFPS: 30, RPICameraFPS: 30,
RPICameraAfMode: "continuous", RPICameraAfMode: "continuous",
RPICameraAfRange: "normal", RPICameraAfRange: "normal",
RPICameraAfSpeed: "normal", RPICameraAfSpeed: "normal",
RPICameraTextOverlay: "%Y-%m-%d %H:%M:%S - MediaMTX", RPICameraTextOverlay: "%Y-%m-%d %H:%M:%S - MediaMTX",
RPICameraCodec: "auto", RPICameraCodec: "auto",
RPICameraIDRPeriod: 60, RPICameraIDRPeriod: 60,
RPICameraBitrate: 5000000, RPICameraBitrate: 5000000,
RPICameraProfile: "main", RPICameraHardwareH264Profile: "main",
RPICameraLevel: "4.1", RPICameraHardwareH264Level: "4.1",
RPICameraMJPEGQuality: 60, RPICameraMJPEGQuality: 60,
RunOnDemandStartTimeout: 5 * Duration(time.Second), RunOnDemandStartTimeout: 5 * Duration(time.Second),
RunOnDemandCloseAfter: 10 * Duration(time.Second), RunOnDemandCloseAfter: 10 * Duration(time.Second),
}, pa) }, pa)
}() }()

View file

@ -191,8 +191,10 @@ type Path struct {
RPICameraCodec string `json:"rpiCameraCodec"` RPICameraCodec string `json:"rpiCameraCodec"`
RPICameraIDRPeriod uint `json:"rpiCameraIDRPeriod"` RPICameraIDRPeriod uint `json:"rpiCameraIDRPeriod"`
RPICameraBitrate uint `json:"rpiCameraBitrate"` RPICameraBitrate uint `json:"rpiCameraBitrate"`
RPICameraProfile string `json:"rpiCameraProfile"` RPICameraProfile *string `json:"rpiCameraProfile,omitempty"` // deprecated
RPICameraLevel string `json:"rpiCameraLevel"` RPICameraLevel *string `json:"rpiCameraLevel,omitempty"` // deprecated
RPICameraHardwareH264Profile string `json:"rpiCameraHardwareH264Profile"`
RPICameraHardwareH264Level string `json:"rpiCameraHardwareH264Level"`
RPICameraJPEGQuality *uint `json:"rpiCameraJPEGQuality,omitempty"` // deprecated RPICameraJPEGQuality *uint `json:"rpiCameraJPEGQuality,omitempty"` // deprecated
RPICameraMJPEGQuality uint `json:"rpiCameraMJPEGQuality"` RPICameraMJPEGQuality uint `json:"rpiCameraMJPEGQuality"`
RPICameraPrimaryName string `json:"-"` // filled by Check() RPICameraPrimaryName string `json:"-"` // filled by Check()
@ -255,8 +257,8 @@ func (pconf *Path) setDefaults() {
pconf.RPICameraCodec = "auto" pconf.RPICameraCodec = "auto"
pconf.RPICameraIDRPeriod = 60 pconf.RPICameraIDRPeriod = 60
pconf.RPICameraBitrate = 5000000 pconf.RPICameraBitrate = 5000000
pconf.RPICameraProfile = "main" pconf.RPICameraHardwareH264Profile = "main"
pconf.RPICameraLevel = "4.1" pconf.RPICameraHardwareH264Level = "4.1"
pconf.RPICameraMJPEGQuality = 60 pconf.RPICameraMJPEGQuality = 60
// Hooks // Hooks
@ -495,16 +497,28 @@ func (pconf *Path) validate(
return fmt.Errorf("invalid 'rpiCameraAfSpeed' value") return fmt.Errorf("invalid 'rpiCameraAfSpeed' value")
} }
switch pconf.RPICameraProfile { if pconf.RPICameraProfile != nil {
case "baseline", "main", "high": l.Log(logger.Warn, "parameter 'rpiCameraProfile' is deprecated"+
default: " and has been replaced with 'rpiCameraHardwareH264Profile'")
return fmt.Errorf("invalid 'rpiCameraProfile' value") pconf.RPICameraHardwareH264Profile = *pconf.RPICameraProfile
} }
switch pconf.RPICameraLevel { if pconf.RPICameraLevel != nil {
l.Log(logger.Warn, "parameter 'rpiCameraLevel' is deprecated"+
" and has been replaced with 'rpiCameraHardwareH264Level'")
pconf.RPICameraHardwareH264Level = *pconf.RPICameraLevel
}
switch pconf.RPICameraHardwareH264Profile {
case "baseline", "main", "high":
default:
return fmt.Errorf("invalid 'rpiCameraHardwareH264Profile' value")
}
switch pconf.RPICameraHardwareH264Level {
case "4.0", "4.1", "4.2": case "4.0", "4.1", "4.2":
default: default:
return fmt.Errorf("invalid 'rpiCameraLevel' value") return fmt.Errorf("invalid 'rpiCameraHardwareH264Level' value")
} }
if pconf.RPICameraJPEGQuality != nil { if pconf.RPICameraJPEGQuality != nil {

View file

@ -71,8 +71,8 @@ func paramsFromConf(logLevel conf.LogLevel, cnf *conf.Path) params {
Codec: cnf.RPICameraCodec, Codec: cnf.RPICameraCodec,
IDRPeriod: uint32(cnf.RPICameraIDRPeriod), IDRPeriod: uint32(cnf.RPICameraIDRPeriod),
Bitrate: uint32(cnf.RPICameraBitrate), Bitrate: uint32(cnf.RPICameraBitrate),
Profile: cnf.RPICameraProfile, Profile: cnf.RPICameraHardwareH264Profile,
Level: cnf.RPICameraLevel, Level: cnf.RPICameraHardwareH264Level,
SecondaryWidth: uint32(cnf.RPICameraSecondaryWidth), SecondaryWidth: uint32(cnf.RPICameraSecondaryWidth),
SecondaryHeight: uint32(cnf.RPICameraSecondaryHeight), SecondaryHeight: uint32(cnf.RPICameraSecondaryHeight),
SecondaryFPS: float32(cnf.RPICameraSecondaryFPS), SecondaryFPS: float32(cnf.RPICameraSecondaryFPS),

View file

@ -618,10 +618,10 @@ pathDefaults:
rpiCameraIDRPeriod: 60 rpiCameraIDRPeriod: 60
# Bitrate (when codec is hardwareH264 or softwareH264). # Bitrate (when codec is hardwareH264 or softwareH264).
rpiCameraBitrate: 5000000 rpiCameraBitrate: 5000000
# H264 profile (baseline, main or high). # Hardware H264 profile (baseline, main or high) (when codec is hardwareH264).
rpiCameraProfile: main rpiCameraHardwareH264Profile: main
# H264 level (4.0, 4.1 or 4.2). # Hardware H264 level (4.0, 4.1 or 4.2) (when codec is hardwareH264).
rpiCameraLevel: '4.1' rpiCameraHardwareH264Level: '4.1'
# M-JPEG JPEG quality (when codec is mjpeg). # M-JPEG JPEG quality (when codec is mjpeg).
rpiCameraMJPEGQuality: 60 rpiCameraMJPEGQuality: 60