| | |
| | | "encoding/json" |
| | | "flag" |
| | | "fmt" |
| | | "strconv" |
| | | "strings" |
| | | // "videoServer/demo" |
| | | ) |
| | | |
| | |
| | | |
| | | ipcURL string |
| | | proc string |
| | | |
| | | testIt bool |
| | | ) |
| | | |
| | | func init() { |
| | |
| | | flag.StringVar(&picFolder, "f", ".", "test pic folder") |
| | | |
| | | flag.StringVar(&ipcURL, "ipc", "ipc:///tmp/pic.ipc", "ipc label") |
| | | |
| | | flag.BoolVar(&testIt, "test", false, "use test") |
| | | } |
| | | |
| | | // CameraInfo camera info |
| | |
| | | func main() { |
| | | flag.Parse() |
| | | |
| | | if testIt { |
| | | test() |
| | | } |
| | | |
| | | // ctx, cancel := context.WithCancel(context.Background()) |
| | | ctx, cancel := context.WithCancel(context.Background()) |
| | | |
| | | // ch := make(chan CameraInfo) |
| | | // go recvFromIPC(ctx, "tcp://192.168.1.124:7000", ch) |
| | | ch := make(chan CameraInfo) |
| | | go recvFromIPC(ctx, "tcp://192.168.1.124:7000", ch) |
| | | |
| | | // for { |
| | | // select { |
| | | // case <-ctx.Done(): |
| | | // return |
| | | // case c := <-ch: |
| | | // if _, ok := mapCI[c.ID]; !ok { |
| | | // mapCI[c.ID] = c |
| | | // ipc := "tcp://192.168.1.124:" + strconv.Itoa(port) |
| | | // port++ |
| | | // fmt.Printf("create ipc %s for decode : %s, on camera id %s\n", ipc, c.URL, c.ID) |
| | | // demo.SendByIPC("rtsp://admin:a1234567@192.168.1.188:554/h264/ch1/main/av_stream", "cid0", |
| | | // "tcp://192.168.1.140:7000", false) |
| | | for { |
| | | select { |
| | | case <-ctx.Done(): |
| | | return |
| | | case c := <-ch: |
| | | if _, ok := mapCI[c.ID]; !ok { |
| | | mapCI[c.ID] = c |
| | | ipc := "tcp://192.168.1.124:" + strconv.Itoa(port) |
| | | port++ |
| | | fmt.Printf("create ipc %s for decode : %s, on camera id %s\n", ipc, c.URL, c.ID) |
| | | |
| | | // url := strings.TrimSpace(c.URL) |
| | | // id := strings.TrimSpace(c.ID) |
| | | // i := strings.TrimSpace(ipc) |
| | | // go demo.SendByIPC(url, id, i) |
| | | // } |
| | | // } |
| | | // } |
| | | // cancel() |
| | | |
| | | url := strings.TrimSpace(c.URL) |
| | | id := strings.TrimSpace(c.ID) |
| | | i := strings.TrimSpace(ipc) |
| | | go demo.SendByIPC(url, id, i, false) |
| | | } |
| | | } |
| | | } |
| | | cancel() |
| | | } |
| | | |
| | | func test() { |
| | |
| | | |
| | | fmt.Println(picFolder) |
| | | |
| | | demo.SendByIPC(streamURL, "camera1", ipcURL, true) |
| | | demo.SendByIPC(streamURL, "camera1", ipcURL, false) |
| | | } |