refactor: improve code readability and maintainability across multiple files

- Reformatted function signatures for better clarity in media.go and onvif-quick/main.go.
- Replaced hardcoded values with constants in ascii.go and server/imaging.go for improved maintainability.
- Enhanced error handling and logging consistency in onvif-diagnostics/main.go and server/server.go.
- Updated comments to clarify functionality and ensure adherence to ONVIF specifications across various files.
This commit is contained in:
0x524a
2025-12-02 08:54:23 -05:00
parent de752f249e
commit 31df3f8b79
10 changed files with 83 additions and 70 deletions
+13 -11
View File
@@ -347,25 +347,27 @@ func (s *Server) HandleSetImagingSettings(body interface{}) (interface{}, error)
// HandleGetOptions handles GetOptions request.
func (s *Server) HandleGetOptions(body interface{}) (interface{}, error) {
// Return available imaging options/capabilities
const maxImagingValue = 100 //nolint:mnd // Maximum imaging parameter value
const maxExposureTime = 10000 //nolint:mnd // Maximum exposure time in microseconds
options := &ImagingOptions{
Brightness: &FloatRange{Min: 0, Max: 100},
ColorSaturation: &FloatRange{Min: 0, Max: 100},
Contrast: &FloatRange{Min: 0, Max: 100},
Sharpness: &FloatRange{Min: 0, Max: 100},
Brightness: &FloatRange{Min: 0, Max: maxImagingValue},
ColorSaturation: &FloatRange{Min: 0, Max: maxImagingValue},
Contrast: &FloatRange{Min: 0, Max: maxImagingValue},
Sharpness: &FloatRange{Min: 0, Max: maxImagingValue},
IrCutFilterModes: []string{"ON", "OFF", "AUTO"},
BacklightCompensation: &BacklightCompensationOptions{
Mode: []string{"OFF", "ON"},
Level: &FloatRange{Min: 0, Max: 100},
Level: &FloatRange{Min: 0, Max: maxImagingValue},
},
Exposure: &ExposureOptions{
Mode: []string{"AUTO", "MANUAL"},
Priority: []string{"LowNoise", "FrameRate"},
MinExposureTime: &FloatRange{Min: 1, Max: 10000},
MaxExposureTime: &FloatRange{Min: 1, Max: 10000},
MinGain: &FloatRange{Min: 0, Max: 100},
MaxGain: &FloatRange{Min: 0, Max: 100},
ExposureTime: &FloatRange{Min: 1, Max: 10000},
Gain: &FloatRange{Min: 0, Max: 100},
MinExposureTime: &FloatRange{Min: 1, Max: maxExposureTime},
MaxExposureTime: &FloatRange{Min: 1, Max: maxExposureTime},
MinGain: &FloatRange{Min: 0, Max: maxImagingValue},
MaxGain: &FloatRange{Min: 0, Max: maxImagingValue},
ExposureTime: &FloatRange{Min: 1, Max: maxExposureTime},
Gain: &FloatRange{Min: 0, Max: maxImagingValue},
},
Focus: &FocusOptions{
AutoFocusModes: []string{"AUTO", "MANUAL"},