From 0fe12f8bf65155fe740acfa30f958e725cd31f6d Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Fri, 25 Jul 2025 11:44:55 +0200 Subject: [PATCH] rpi: rename rpiCameraProfile into rpiCameraH264Profile, rpiCameraLevel into rpiCameraH264Level (#3965) (#4785) --- apidocs/openapi.yaml | 4 +- internal/conf/conf_test.go | 68 +++++++++++----------- internal/conf/path.go | 34 +++++++---- internal/staticsources/rpicamera/source.go | 4 +- mediamtx.yml | 8 +-- 5 files changed, 66 insertions(+), 52 deletions(-) diff --git a/apidocs/openapi.yaml b/apidocs/openapi.yaml index a939b26f..9c7108f5 100644 --- a/apidocs/openapi.yaml +++ b/apidocs/openapi.yaml @@ -452,9 +452,9 @@ components: type: integer rpiCameraBitrate: type: integer - rpiCameraProfile: + rpiCameraHardwareH264Profile: type: string - rpiCameraLevel: + rpiCameraHardwareH264Level: type: string rpiCameraMJPEGQuality: type: integer diff --git a/internal/conf/conf_test.go b/internal/conf/conf_test.go index 608fd1b5..6864f649 100644 --- a/internal/conf/conf_test.go +++ b/internal/conf/conf_test.go @@ -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) }() diff --git a/internal/conf/path.go b/internal/conf/path.go index 47a9c6a0..84bad9d7 100644 --- a/internal/conf/path.go +++ b/internal/conf/path.go @@ -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 { diff --git a/internal/staticsources/rpicamera/source.go b/internal/staticsources/rpicamera/source.go index a0a543b8..d9cbf4f6 100644 --- a/internal/staticsources/rpicamera/source.go +++ b/internal/staticsources/rpicamera/source.go @@ -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), diff --git a/mediamtx.yml b/mediamtx.yml index 7bb19c87..648ee4ae 100644 --- a/mediamtx.yml +++ b/mediamtx.yml @@ -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