mirror of
https://github.com/kerberos-io/agent.git
synced 2026-08-23 15:08:32 +00:00
38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
package models
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
const RecordingUploadMetadataExtension = ".metadata"
|
|
|
|
// RecordingUploadMetadata is persisted in the upload queue marker associated
|
|
// with a recording. New optional fields can be added without changing the queue
|
|
// mechanism or breaking older agents.
|
|
type RecordingUploadMetadata struct {
|
|
FileName string `json:"filename"`
|
|
DeviceKey string `json:"device_key"`
|
|
Timestamp int64 `json:"timestamp"` // Unix milliseconds.
|
|
Duration uint64 `json:"duration"` // Milliseconds.
|
|
FPS float64 `json:"fps,omitempty"`
|
|
}
|
|
|
|
// RecordingUploadMetadataFileName returns the queue marker name associated
|
|
// with a recording, replacing the recording extension with .metadata.
|
|
func RecordingUploadMetadataFileName(recordingFileName string) string {
|
|
name := filepath.Base(recordingFileName)
|
|
extension := filepath.Ext(name)
|
|
return strings.TrimSuffix(name, extension) + RecordingUploadMetadataExtension
|
|
}
|
|
|
|
// RecordingFileNameFromUploadMarker resolves a queue entry to its recording.
|
|
// Markers created by older agents used the recording filename directly.
|
|
func RecordingFileNameFromUploadMarker(markerFileName string) string {
|
|
name := filepath.Base(markerFileName)
|
|
if strings.HasSuffix(name, RecordingUploadMetadataExtension) {
|
|
return strings.TrimSuffix(name, RecordingUploadMetadataExtension) + ".mp4"
|
|
}
|
|
return name
|
|
}
|