| | |
| | | |
| | | import ( |
| | | "context" |
| | | "decoder/valib/goffmpeg" |
| | | "decoder/valib/ipc" |
| | | srv "decoder/work/service" |
| | | "encoding/json" |
| | |
| | | func main() { |
| | | flag.Parse() |
| | | |
| | | if testIt { |
| | | test() |
| | | } |
| | | goffmpeg.InitFFmpeg() |
| | | |
| | | ctx, cancel := context.WithCancel(context.Background()) |
| | | |
| | | if testIt { |
| | | test(ctx) |
| | | } |
| | | |
| | | ch := make(chan CameraInfo) |
| | | |
| | |
| | | url := strings.TrimSpace(c.URL) |
| | | id := strings.TrimSpace(c.ID) |
| | | addr := strings.TrimSpace(ipcAddr) |
| | | go runSender(id, url, addr) |
| | | go runSender(ctx, id, url, addr) |
| | | } |
| | | } |
| | | } |
| | | |
| | | goffmpeg.FreeFFmpeg() |
| | | cancel() |
| | | } |
| | | |
| | | func runSender(cameraID, rtspURL, ipcLabel string) { |
| | | d := srv.NewSender(cameraID, rtspURL, ipcLabel) |
| | | func runSender(ctx context.Context, cameraID, rtspURL, ipcLabel string) { |
| | | d := srv.NewSender(ctx, cameraID, rtspURL, ipcLabel) |
| | | if asServer { |
| | | d.RunAsServer() |
| | | } |
| | | d.RunAsClient() |
| | | } |
| | | |
| | | func test() { |
| | | func test(ctx context.Context) { |
| | | fmt.Println("start test") |
| | | |
| | | fmt.Println(picFolder) |
| | | |
| | | runSender("cameraid", streamURL, ipcURL) |
| | | runSender(ctx, "cameraid", streamURL, ipcURL) |
| | | } |