| | |
| | | package service |
| | | |
| | | import ( |
| | | "errors" |
| | | "path/filepath" |
| | | "strconv" |
| | | "webserver/extend/config" |
| | | "webserver/extend/esutil" |
| | | |
| | | "basic.com/dbapi.git" |
| | | "basic.com/fileServer/WeedFSClient.git" |
| | | "basic.com/valib/capture.git" |
| | | "basic.com/valib/logger.git" |
| | | "errors" |
| | | "strconv" |
| | | "webserver/cache" |
| | | ) |
| | | /*以下属于旧版本地摄像机获取截图(国标摄像机底图无法刷新) |
| | | func PostFormBufferData(uri string, filepath string, fileName string) (maps map[string]interface{}, err0 error) { |
| | |
| | | if camera.Type == 1{//国标摄像机 |
| | | m = capture.GB28181 |
| | | } |
| | | b,err := capture.Capture("./runtime/libcffmpeg.so",m,camera.Rtsp,capture.JPEGFileExt,1280,720,10) |
| | | b,err := capture.Capture("libcffmpeg.so",m,camera.Rtsp,capture.JPEGFileExt,1280,720,10) |
| | | if err == nil{ |
| | | var weedfsUri = "http://"+config.WeedFs.Ip+":"+strconv.Itoa(config.WeedFs.UploadPort)+"/submit" |
| | | resp, err := esutil.PostFormBufferData(weedfsUri, camera.Name+".jpg", "file", b) |
| | | localConf, err2 := cache.GetServerInfo() |
| | | if err2 !=nil || localConf.WebPicIp == "" { |
| | | logger.Debug("localConfig is wrong!!!") |
| | | return "",err2 |
| | | } |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit" |
| | | weedFilePath, err := WeedFSClient.UploadFile(weedfsUri, camera.Name+".jpg", b) |
| | | if err != nil { |
| | | return "",err |
| | | } else { |
| | | fileurl := resp["fileUrl"].(string) // 文件路径 |
| | | filename := filepath.Base(fileurl) |
| | | ok := cameraApi.UpdateSnapshotUrl(cid, filename) |
| | | ok := cameraApi.UpdateSnapshotUrl(cid, weedFilePath) |
| | | if !ok { |
| | | return "", errors.New("update camera's snapshot fail") |
| | | } |
| | | return filename, nil |
| | | return weedFilePath, nil |
| | | } |
| | | }else{ |
| | | return "",err |