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
rpiCameraBitrate:
type: integer
rpiCameraProfile:
rpiCameraHardwareH264Profile:
type: string
rpiCameraLevel:
rpiCameraHardwareH264Level:
type: string
rpiCameraMJPEGQuality:
type: integer

View file

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

View file

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

View file

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

View file

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