| | |
| | | flag.BoolVar(&asServer, "server", false, "run ipc as server") |
| | | } |
| | | |
| | | // cameraInfo camera info |
| | | // CameraInfo camera info |
| | | type CameraInfo struct { |
| | | ID string `json:"Cameraid"` |
| | | URL string `json:"Rtsp"` |
| | |
| | | Subproject commit 70008056eb8983dae4ee2c960c043ae69191d03e |
| | | Subproject commit f4f467c5a908ddca5d28b61497b8e40c8668fff8 |
| | |
| | | "decoder/valib/ipc" |
| | | "encoding/gob" |
| | | "fmt" |
| | | "time" |
| | | ) |
| | | |
| | | // Sender decoder ingo |
| | |
| | | gf := goffmpeg.New() |
| | | if gf != nil { |
| | | s.ffmpeg = gf |
| | | } else { |
| | | fmt.Println("create decoder ffmpeg error") |
| | | return |
| | | } |
| | | imageChan := make(chan ImageInfo) |
| | | dataChan := make(chan []byte) |
| | | |
| | | go s.serializeImageInfo(imageChan, dataChan) |
| | | |
| | | gf.ActiveDecoder(func(d *[]byte, w, h *int) { |
| | | if *w > 0 && *h > 0 { |
| | | img := ImageInfo{*d, *w, *h} |
| | | imageChan <- img |
| | | } else { |
| | | fmt.Println("decode jpg error") |
| | | gf.BuildDecoder() |
| | | |
| | | go func(f *goffmpeg.GoFFMPEG, ch chan<- ImageInfo) { |
| | | for { |
| | | data, wid, hei := f.GetPicDecoder() |
| | | if wid > 0 && hei > 0 { |
| | | img := ImageInfo{Data: data, Width: wid, Height: hei} |
| | | ch <- img |
| | | } else { |
| | | time.Sleep(time.Millisecond * time.Duration(10)) |
| | | } |
| | | } |
| | | }) |
| | | |
| | | }(gf, imageChan) |
| | | |
| | | gf.Run(s.streamURL) |
| | | |
| | | i.SendFromChannel(dataChan) |
| | | } |
| | | |