|
@@ -160,7 +160,8 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> {
|
|
|
* @param rtspName
|
|
|
* @return
|
|
|
*/
|
|
|
- private ResultDTO pushStream(CameraDTO cameraDTO, String appName, String rtspName) {
|
|
|
+ private ResultDTO pushStream(CameraDTO cameraDTO, String appName, String rtspName) {
|
|
|
+ ResultDTO resultDTO = new ResultDTO();
|
|
|
String rtmpUrl = "rtmp://" + cameraProperties.getRtmp().getRtmphost() + "/live/" + appName; //rtmp链
|
|
|
String flvUrl = "http://" + cameraProperties.getRtmp().getHttphost() + "/live/" + appName + ".live.flv"; //live-flv链
|
|
|
String hlsUrl = "http://" + cameraProperties.getRtmp().getHttphost() + "/live/" + appName + "/hls.m3u8"; //hls链
|
|
@@ -173,9 +174,63 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> {
|
|
|
flowService.removeById(cameraFlow.getId());
|
|
|
}
|
|
|
|
|
|
+// // 初始化Socket.IO服务器
|
|
|
+// Configuration config = new Configuration();
|
|
|
+// config.setHostname("0.0.0.0");
|
|
|
+// config.setPort(3000);
|
|
|
+// server = new SocketIOServer(config);
|
|
|
+// server.addListeners(new DataListener<byte[]>() {
|
|
|
+// @Override
|
|
|
+// public void onData(SocketIOClient client, byte[] data, AckRequest ackSender) throws Exception {
|
|
|
+// // 处理接收到的数据
|
|
|
+// }
|
|
|
+//
|
|
|
+// });
|
|
|
+//
|
|
|
+// server.addEventListener("videoFrame", byte[].class, (client, data, ackRequest) -> {
|
|
|
+// // 发送视频帧数据
|
|
|
+// client.sendEvent("videoFrame", data);
|
|
|
+// });
|
|
|
+//
|
|
|
+// server.start();
|
|
|
+// System.out.println("Socket.IO server started on port 3000");
|
|
|
+//
|
|
|
+// HCNetTools hcTool = cameraDTO.getHcTool();
|
|
|
+// hcTool.getRealStreamData(new HCNetSDK.FRealDataCallBack_V30() {
|
|
|
+// @Override
|
|
|
+// public void invoke(int lRealHandle, int dwDataType, ByteByReference pBuffer, int dwBufSize, Pointer pUser) {
|
|
|
+// try {
|
|
|
+// if (dwDataType == HCNetSDK.NET_DVR_STREAMDATA) {
|
|
|
+// if(dwBufSize > 0){
|
|
|
+// // 获取所有连接的客户端
|
|
|
+// if(ObjectUtils.isEmpty(server.getAllClients())){
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// System.out.println("client size:" + server.getAllClients().size());
|
|
|
+// for (SocketIOClient client : server.getAllClients()) {
|
|
|
+// System.out.println("client...");
|
|
|
+// client.sendEvent("videoFrame",pBuffer.getPointer().getByteArray(0,dwBufSize),0,dwBufSize);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// try {
|
|
|
+// Thread.sleep(Long.MAX_VALUE);
|
|
|
+// } catch (InterruptedException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//开始推流
|
|
|
String taskName = ffmpegService.startTranscoding(appName, rtspName, rtmpUrl);
|
|
|
- ResultDTO resultDTO = new ResultDTO();
|
|
|
+
|
|
|
if (ObjectUtils.isNotEmpty(taskName)) {
|
|
|
resultDTO.setTaskName(taskName);
|
|
|
resultDTO.setResult("success");
|
|
@@ -214,10 +269,10 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> {
|
|
|
resultDTO.setResult("未找到该设备");
|
|
|
return resultDTO;
|
|
|
}
|
|
|
- String appName = cameraDTO.getAccount() + cameraDTO.getIp().replace(".", "");
|
|
|
String channelNumberStr = cameraDTO.getChannelNumber() + "02"; //新通道(2012年之后设备,02代表子码流)
|
|
|
String rtspName = "rtsp://" + cameraDTO.getAccount() + ":" + cameraDTO.getPassword() + "@" + cameraDTO.getIp() + ":554/" + channelNumberStr + "?transportmode=unicast"; //新码流
|
|
|
- resultDTO = pushStream(cameraDTO, appName, rtspName);
|
|
|
+ resultDTO.setRtspUrl(rtspName);
|
|
|
+ resultDTO.setWebrtcUrl("http://"+cameraProperties.getRtmp().getWebrtchost());
|
|
|
return resultDTO;
|
|
|
}
|
|
|
|
|
@@ -241,19 +296,13 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> {
|
|
|
startTime = sdf.format(cameraDTO.getHistoryDTO().getStartTime());
|
|
|
endTime = null;
|
|
|
}
|
|
|
- String appName;
|
|
|
if (cameraDTO.getType() == 1) {
|
|
|
//摄像机
|
|
|
- appName = "history" + cameraDTO.getVcr().getAccount() + cameraDTO.getVcr().getIp().replace(".", "") + "to" + cameraDTO.getIp().replace(".", "") + "start" + startTime + "end" + endTime;
|
|
|
+ //appName = "history" + cameraDTO.getVcr().getAccount() + cameraDTO.getVcr().getIp().replace(".", "") + "to" + cameraDTO.getIp().replace(".", "") + "start" + startTime + "end" + endTime;
|
|
|
} else {
|
|
|
throw new OperateException("目前只支持带有录像机的回放数据");
|
|
|
//NVR
|
|
|
- //appName = "history" + cameraDTO.getAccount() + cameraDTO.getIp().replace(".", "") + "to" + cameraDTO.getIpcAddress().replace(".", "") + "start" + startTime + "end" + endTime;
|
|
|
- //channelNumber = HikCameraUtils.getIpcChannel(cameraDTO.getChannelList(), cameraDTO.getIpcAddress());
|
|
|
}
|
|
|
-// if (channelNumber == -1) {
|
|
|
-// logger.info("历史流-未搜索到ip:" + cameraDTO.getIp() + ", ipc:" + cameraDTO.getIpcAddress() + " 的设备");
|
|
|
-// }
|
|
|
//未推流
|
|
|
String channelNumberStr = cameraDTO.getChannelNumber() + "01"; //回放流只有主码流
|
|
|
String rtspName = "rtsp://";
|
|
@@ -262,7 +311,8 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> {
|
|
|
} else {
|
|
|
rtspName += cameraDTO.getVcr().getAccount() + ":" + cameraDTO.getVcr().getPassword() + "@" + cameraDTO.getVcr().getIp() + ":554/Streaming/tracks/" + channelNumberStr + "?starttime=" + startTime;
|
|
|
}
|
|
|
- resultDTO = pushStream(cameraDTO, appName, rtspName);
|
|
|
+ //resultDTO = pushStream(cameraDTO, appName, rtspName);
|
|
|
+ resultDTO.setRtspUrl(rtspName);
|
|
|
return resultDTO;
|
|
|
}
|
|
|
|