rpi: prevent invalid MJPEG sizes (#6080)
width and height of MJPEG frames must be multiple of 8 and less than 2048, otherwise they cannot be routed with RTP/RTSP.
This commit is contained in:
@@ -414,6 +414,24 @@ func TestConfErrors(t *testing.T) {
|
||||
" source: rpiCamera\n",
|
||||
"'rpiCamera' with same camera ID 0 is used as source in two paths, 'cam1' and 'cam2'",
|
||||
},
|
||||
{
|
||||
"invalid rpi camera mjpeg width",
|
||||
"paths:\n" +
|
||||
" cam:\n" +
|
||||
" source: rpiCamera\n" +
|
||||
" rpiCameraCodec: mjpeg\n" +
|
||||
" rpiCameraWidth: 1921\n",
|
||||
"'rpiCameraWidth' must be a multiple of 8 and less than 2048 when using MJPEG",
|
||||
},
|
||||
{
|
||||
"invalid rpi camera mjpeg height",
|
||||
"paths:\n" +
|
||||
" cam:\n" +
|
||||
" source: rpiCamera\n" +
|
||||
" rpiCameraCodec: mjpeg\n" +
|
||||
" rpiCameraHeight: 2048\n",
|
||||
"'rpiCameraHeight' must be a multiple of 8 and less than 2048 when using MJPEG",
|
||||
},
|
||||
{
|
||||
"invalid srt publish passphrase",
|
||||
"paths:\n" +
|
||||
|
||||
+11
-1
@@ -585,7 +585,6 @@ func (pconf *Path) validate(
|
||||
}
|
||||
|
||||
case pconf.Source == "rpiCamera":
|
||||
|
||||
if pconf.RPICameraWidth == 0 {
|
||||
return fmt.Errorf("invalid 'rpiCameraWidth' value")
|
||||
}
|
||||
@@ -594,6 +593,17 @@ func (pconf *Path) validate(
|
||||
return fmt.Errorf("invalid 'rpiCameraHeight' value")
|
||||
}
|
||||
|
||||
if pconf.RPICameraCodec == "mjpeg" ||
|
||||
(pconf.RPICameraSecondary && pconf.RPICameraCodec == "auto") {
|
||||
if pconf.RPICameraWidth >= 2048 || (pconf.RPICameraWidth%8) != 0 {
|
||||
return fmt.Errorf("'rpiCameraWidth' must be a multiple of 8 and less than 2048 when using MJPEG")
|
||||
}
|
||||
|
||||
if pconf.RPICameraHeight >= 2048 || (pconf.RPICameraHeight%8) != 0 {
|
||||
return fmt.Errorf("'rpiCameraHeight' must be a multiple of 8 and less than 2048 when using MJPEG")
|
||||
}
|
||||
}
|
||||
|
||||
switch pconf.RPICameraExposure {
|
||||
case "normal", "short", "long", "custom":
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user