|
|
|
@ -1,5 +1,6 @@
|
|
|
|
package com.zhehekeji.web.controller;
|
|
|
|
package com.zhehekeji.web.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.zhehekeji.common.util.ValidatorUtil;
|
|
|
|
import com.zhehekeji.common.util.ValidatorUtil;
|
|
|
|
import com.zhehekeji.core.pojo.Result;
|
|
|
|
import com.zhehekeji.core.pojo.Result;
|
|
|
|
@ -17,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.*;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@Api(value = "camera",tags = "球机管理")
|
|
|
|
@Api(value = "camera",tags = "球机管理")
|
|
|
|
@ -121,4 +122,39 @@ public class CameraController {
|
|
|
|
cameraControlModule.toPtz(ptzId,req.getCameraId());
|
|
|
|
cameraControlModule.toPtz(ptzId,req.getCameraId());
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/downloadConfig")
|
|
|
|
|
|
|
|
@ApiOperation(value = "下载")
|
|
|
|
|
|
|
|
public Result downloadConfig() throws IOException {
|
|
|
|
|
|
|
|
File file = new File("./config.json");
|
|
|
|
|
|
|
|
if (file.exists()) { // 如果已存在,删除旧文件
|
|
|
|
|
|
|
|
file.delete();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
file.createNewFile();
|
|
|
|
|
|
|
|
List<Camera> cameras = cameraService.allCameras();
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
|
|
JSONObject server = new JSONObject();
|
|
|
|
|
|
|
|
server.put("http_port",":8083");
|
|
|
|
|
|
|
|
String [] strings = new String[1];
|
|
|
|
|
|
|
|
strings[0] = "stun:stun.l.google.com:19302";
|
|
|
|
|
|
|
|
server.put("ice_servers",strings);
|
|
|
|
|
|
|
|
server.put("ice_username","");
|
|
|
|
|
|
|
|
server.put("ice_credential","");
|
|
|
|
|
|
|
|
jsonObject.put("server",server);
|
|
|
|
|
|
|
|
JSONObject streams = new JSONObject();
|
|
|
|
|
|
|
|
cameras.forEach(camera -> {
|
|
|
|
|
|
|
|
JSONObject obj = new JSONObject();
|
|
|
|
|
|
|
|
obj.put("on_demand",false);
|
|
|
|
|
|
|
|
obj.put("disable_audio",true);
|
|
|
|
|
|
|
|
obj.put("url",camera.getRtsp());
|
|
|
|
|
|
|
|
streams.put("camera"+camera.getId(),obj);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
jsonObject.put("streams",streams);
|
|
|
|
|
|
|
|
Writer write = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
|
|
|
|
|
|
|
|
write.write(jsonObject.toJSONString());
|
|
|
|
|
|
|
|
write.flush();
|
|
|
|
|
|
|
|
write.close();
|
|
|
|
|
|
|
|
return Result.success();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|