revid/config.go: define max value for MinFrames

Issue #156 resolved
Saxon Milton created an issue

Without a max value, if the revid config is updated with something ridiculous, it causes undefined behaviour, namely a hang.
For context: MinFrames is a field in the Config struct (av/revid/config/config.go). It defines the minimum number of frames that will be in a “clip” of media. More specifically for Raspivid, it will define the intra refresh interval i.e. for MinFrames = 100, there will be 100 frames between i-frames i.e. for 25 fps 100/25=4 seconds between frames. We would like to validate this value in Config.Validate. You will find that there is already some validation:

if c.MinFrames == 0 {
        c.Logger.Log(logger.Info, pkg+"no min period defined, defaulting", "MinFrames", defaultMinFrames)
        c.MinFrames = defaultMinFrames
    } else if c.MinFrames < 0 {
        return errors.New("refresh period is less than 0")
    }

but it is not enough.

Comments (4)

  1. Log in to comment