utils

package
v0.0.0-...-8016b3b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MaxUint16 = ^uint16(0)

MaxUint16 - maximum value which can be held in an uint16

View Source
const MaxUint8 = ^uint8(0)

MaxUint8 - maximum value which can be held in an uint8

View Source
const MinUint16 = 0

MinUint16 - minimum value which can be held in an uint8

View Source
const MinUint8 = 0

MinUint8 - minimum value which can be held in an uint8

Variables

View Source
var VERSION = "0.0.0"

VERSION is the agent version. It defaults to "0.0.0" for local dev builds and is overridden at build time via:

go build -ldflags "-X github.com/kerberos-io/agent/machinery/src/utils.VERSION=v1.2.3"

Functions

func CheckDataDirectoryPermissions

func CheckDataDirectoryPermissions(configDirectory string) error

func CheckDirectoryPermissions

func CheckDirectoryPermissions(directory string) error

func CountDigits

func CountDigits(i int64) (count int)

func CreateFragmentedMP4

func CreateFragmentedMP4(fullName string, fragmentedDuration int64)

func CreateRecordingPath

func CreateRecordingPath(directory, fileName string, recordedAt time.Time) (string, error)

func Decrypt

func Decrypt(directoryOrFile string, symmetricKey []byte)

func DirSize

func DirSize(path string) (int64, error)

func FindOldestFile

func FindOldestFile(dir string) (oldestFile os.FileInfo, err error)

func GetDays

func GetDays(files []os.FileInfo, recordingDirectory string, configuration *models.Configuration) []string

func GetMediaFormatted

func GetMediaFormatted(files []os.FileInfo, recordingDirectory string, configuration *models.Configuration, eventFilter models.EventFilter) []models.Media

func GetSortedDirectory

func GetSortedDirectory(files []os.FileInfo) []os.FileInfo

func ImageToBytes

func ImageToBytes(img *image.Image) ([]byte, error)

func NumberOfFilesInDirectory

func NumberOfFilesInDirectory(path string) int

func NumberOfMP4sInDirectory

func NumberOfMP4sInDirectory(path string) int

NumberOfMP4sInDirectory counts MP4 files, including dated subdirectories.

func OpenRecording

func OpenRecording(directory, name string) (*os.File, error)

func PrintASCIIArt

func PrintASCIIArt()

func PrintConfiguration

func PrintConfiguration(configuration *models.Configuration)

func PrintEnvironmentVariables

func PrintEnvironmentVariables()

func RandStringBytesMaskImpr

func RandStringBytesMaskImpr(n int) string

func RandStringBytesRmndr

func RandStringBytesRmndr(n int) string

func ReadDirectory

func ReadDirectory(directory string) ([]os.FileInfo, error)

func ReadRecordingDirectory

func ReadRecordingDirectory(directory string) ([]os.FileInfo, error)

ReadRecordingDirectory returns MP4s with root-relative names, preserving the file information used by the existing sorting and media formatting helpers.

func RecordingFileName

func RecordingFileName(timestamp int64, deviceKey string) (string, error)

func RecordingStartTime

func RecordingStartTime(name string) (time.Time, error)

func RemoveRecording

func RemoveRecording(directory, name string) error

func ResizeHeightWithAspectRatio

func ResizeHeightWithAspectRatio(newWidth int, width int, height int) (int, int)

func ResizeImage

func ResizeImage(img image.Image, newWidth uint, newHeight uint) (*image.Image, error)

func ResolveBaseDimensions

func ResolveBaseDimensions(baseWidth, baseHeight, width, height int) (int, int)

ResolveBaseDimensions resolves the liveview/motion base dimensions for a stream given the (optionally configured) base width/height and the camera's probed source width/height. It returns the width and height that should be stored on the configuration.

The aspect-ratio branch is gated on width>0 && height>0: a not-yet-probed stream has width=height=0, which previously made the ratio +Inf and int(float * +Inf) yield MinInt. That poisoned value, later cast to uint at the ResizeImage call sites, wrapped to ~MaxUint and crashed resize with "makeslice: len out of range". When the source isn't probed yet we fall back to the source dimensions (0,0 -> "auto") instead.

func ResolveRecordingPath

func ResolveRecordingPath(directory, name string) (string, error)

ResolveRecordingPath accepts relative paths from listings and historical basename-only references from upload markers and playback URLs.

func Unique

func Unique(intSlice []string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址