32 lines
742 B
Go
32 lines
742 B
Go
package config
|
|
|
|
import (
|
|
"git.insit.tech/sas/rtsp_proxy/protos"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
// CreateFileName creates FileName structure.
|
|
func CreateFileName(resolutions []string, period int) *protos.FileName {
|
|
fn := protos.FileName{
|
|
Path: "../../data/" + resolutions[0] + "/",
|
|
TimeNow: time.Now().Format("15-04-05_02-01-2006"),
|
|
Name: "videoFragment",
|
|
Number: -1,
|
|
Duration: float64(period * 60),
|
|
}
|
|
|
|
return &fn
|
|
}
|
|
|
|
// Waiter waits for the next period.
|
|
func Waiter(period int) {
|
|
periodTD := time.Duration(period) * time.Minute
|
|
|
|
now := time.Now()
|
|
nextSegment := now.Truncate(periodTD).Add(periodTD)
|
|
waitDuration := nextSegment.Sub(now)
|
|
log.Printf("waiting for start recording: %v\n", waitDuration)
|
|
time.Sleep(waitDuration)
|
|
}
|