Refactoring.
This commit is contained in:
parent
4045b4efad
commit
6bc30e63f0
@ -2,11 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
logger "git.insit.tech/psa/rtsp_reader-writer/writer/internal/log"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.insit.tech/psa/rtsp_reader-writer/writer/internal/config"
|
"git.insit.tech/psa/rtsp_reader-writer/writer/internal/config"
|
||||||
"git.insit.tech/psa/rtsp_reader-writer/writer/internal/ingest/rtsp"
|
"git.insit.tech/psa/rtsp_reader-writer/writer/internal/ingest/rtsp"
|
||||||
|
logger "git.insit.tech/psa/rtsp_reader-writer/writer/internal/log"
|
||||||
log2 "git.insit.tech/sas/rtsp_proxy/core/log"
|
log2 "git.insit.tech/sas/rtsp_proxy/core/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ require (
|
|||||||
github.com/gen2brain/aac-go v0.0.0-20230119102159-ef1e76509d21
|
github.com/gen2brain/aac-go v0.0.0-20230119102159-ef1e76509d21
|
||||||
github.com/golang/snappy v1.0.0
|
github.com/golang/snappy v1.0.0
|
||||||
github.com/pion/rtp v1.8.13
|
github.com/pion/rtp v1.8.13
|
||||||
|
go.uber.org/zap v1.27.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,7 +24,6 @@ require (
|
|||||||
github.com/pion/sdp/v3 v3.0.11 // indirect
|
github.com/pion/sdp/v3 v3.0.11 // indirect
|
||||||
github.com/zaf/g711 v1.4.0 // indirect
|
github.com/zaf/g711 v1.4.0 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.27.0 // indirect
|
|
||||||
golang.org/x/net v0.37.0 // indirect
|
golang.org/x/net v0.37.0 // indirect
|
||||||
golang.org/x/sys v0.31.0 // indirect
|
golang.org/x/sys v0.31.0 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
// lastPartURI returns the last part of the URI after "/".
|
// LastPartURI returns the last part of the URI after "/".
|
||||||
func lastPartURI(URI string) (CutURI string) {
|
func LastPartURI(URI string) (CutURI string) {
|
||||||
split := strings.Split(URI, "/")
|
split := strings.Split(URI, "/")
|
||||||
return split[len(split)-1]
|
return split[len(split)-1]
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ func rtsp(dir string, period int, link string, number int) error {
|
|||||||
dirData := log2.DirCreator(dir, "data")
|
dirData := log2.DirCreator(dir, "data")
|
||||||
|
|
||||||
// Create logger.
|
// Create logger.
|
||||||
cutURI := lastPartURI(link)
|
cutURI := LastPartURI(link)
|
||||||
cam := log2.CamLogging(fmt.Sprintf("%s/%s/Cam_%s.log", dirData, cutURI, time.Now().Format("15-04-05_02-01-2006")))
|
cam := log2.CamLogging(fmt.Sprintf("%s/%s/Cam_%s.log", dirData, cutURI, time.Now().Format("15-04-05_02-01-2006")))
|
||||||
|
|
||||||
// Connect to the server.
|
// Connect to the server.
|
||||||
|
@ -2,6 +2,7 @@ package storage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"git.insit.tech/sas/rtsp_proxy/proto/common"
|
"git.insit.tech/sas/rtsp_proxy/proto/common"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,3 +18,18 @@ func CreateFileName(dirData string, resolutions []string, cutURI string, period
|
|||||||
|
|
||||||
return &fn
|
return &fn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadDir reads directory and returns the slice of files in th directory.
|
||||||
|
func ReadDir(dirData string) ([]os.DirEntry, error) {
|
||||||
|
homeDir, err := os.UserHomeDir()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
files, err := os.ReadDir(homeDir + dirData)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return files, nil
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user