Change archiving files organization.

This commit is contained in:
Сергей Петров 2025-04-03 17:47:30 +05:00
parent 15688905d3
commit 8020f41b8f
3 changed files with 25 additions and 5 deletions
reader/internal
handlers
unpacker
writer/internal/ingest/rtsp

@ -49,3 +49,23 @@ func HLS(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
http.StripPrefix("/hls", http.FileServer(http.Dir(path))).ServeHTTP(w, r)
}
//
// vod
//
// GET List VOD locations
// GET List files in VOD locations which are played by the clients
// GET Get VOD location
// PUT Save VOD location
// DEL Delete VOD location
// GET List files in a VOD location
// GET Get a single VOD file
// PUT Save a VOD file
// DEL Delete a VOD file
//
// List VOD locations
//
// This method allows to get the list of all VOD locations. VOD location is a virtual filepath used to place files for
// VOD (Video on Demand) broadcasting.
//

@ -28,7 +28,7 @@ func CreateVideo(dir string) error {
if err != nil {
return err
}
dirData := fmt.Sprintf("%s/%s/data", homeDir, dir)
dirData := fmt.Sprintf("%s/%s/vod", homeDir, dir)
exist := storage.Exists(dirData)
if !exist {
@ -44,7 +44,7 @@ func CreateVideo(dir string) error {
for _, file := range files {
// Create logger.
cam := log2.CamLogging(
fmt.Sprintf("%s/%s/reader-cam_%s.log", dirData, file.Name(), strconv.FormatInt(time.Now().Unix(), 10)))
fmt.Sprintf("%s/%s/log/reader-cam_%s.log", dirData, file.Name(), strconv.FormatInt(time.Now().Unix(), 10)))
res, err := storage.ReadDir(fmt.Sprintf("%s/%s", dirData, file.Name()))
if err != nil {
@ -53,7 +53,7 @@ func CreateVideo(dir string) error {
}
resolutions := make([]string, 0)
for _, r := range res {
if r.IsDir() {
if r.IsDir() && r.Name() != "log" {
resolutions = append(resolutions, r.Name())
}
}

@ -54,11 +54,11 @@ func rtsp(dir string, period int, link string, number int) error {
defer metrics.ActiveCameras.Dec()
// Create data folder in the directory.
dirData := log2.DirCreator(dir, "data")
dirData := log2.DirCreator(dir, "vod")
// Create cam logger.
cutURI := LastPartURI(link)
cam := log2.CamLogging(fmt.Sprintf("%s/%s/writer-cam_%s.log", dirData, cutURI, strconv.FormatInt(time.Now().Unix(), 10)))
cam := log2.CamLogging(fmt.Sprintf("%s/%s/log/writer-cam_%s.log", dirData, cutURI, strconv.FormatInt(time.Now().Unix(), 10)))
// Connect to the server.
c := gortsplib.Client{