package processor

import (
	"fmt"

	"git.insit.tech/psa/rtsp_reader-writer/writer/pkg/storage"
)

func Process(date, startTime, endTime string) (string, error) {
	// Set path with the records.
	path := "/home/psa/GoRepository/data/1280x720/"

	// Collect filenames into TXT file.
	fileNamesTXT, err := storage.CreateTXT(path, date, startTime, endTime)
	if err != nil {
		return "", fmt.Errorf("collect filenames into TXT file error: %s", err.Error())
	}

	// Merge the collected files into one MP4 file.
	fileNameRes, err := storage.MergeFiles(path, fileNamesTXT)
	if err != nil {
		return "", fmt.Errorf("merge files error: %s", err.Error())
	}

	pathFileNameRes := path + fileNameRes

	return pathFileNameRes, nil
}
