Эх сурвалжийг харах

fix:
1. 修复点播通道时无法正确释放异步请求导致的无法点播

kindring 2 жил өмнө
parent
commit
a3d2a33679

+ 7 - 0
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java

@@ -57,6 +57,13 @@ public class DeferredResultHolder {
 	public static final String CALLBACK_CMD_BROADCAST_INVITE = "CALLBACK_BROADCAST_INVITE";
 	private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>();
 
+	/**
+	 * 获取所有的key
+	 * @return
+	 */
+	public Set<String> getKeys() {
+		return map.keySet();
+	}
 
 	public void put(String key, String id, DeferredResultEx result) {
 		Map<String, DeferredResultEx> deferredResultMap = map.get(key);

+ 17 - 18
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java

@@ -120,48 +120,53 @@ public class PlayServiceImpl implements IPlayService {
                                 String channelId,int isUsePs,
                                  ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
                                  Runnable timeoutCallback) {
-        if (mediaServerItem == null) {
-            logger.info("无法找到zlm服务");
-            throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm");
-        }
-        String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
 
+        String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
+        WVPResult wvpResult = new WVPResult();
         RequestMessage msg = new RequestMessage();
-        msg.setKey(key);
-
         Device device = redisCatchStorage.getDevice(deviceId);
         StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
 
+        msg.setKey(key);
+
+        if (mediaServerItem == null) {
+            logger.info("无法找到zlm服务");
+            // 释放异步请求
+            wvpResult.setCode(ErrorCode.ERROR100.getCode());
+            wvpResult.setMsg("点播失败, 无法找到zlm服务");
+            msg.setData(wvpResult);
+            resultHolder.invokeAllResult(msg);
+            return;
+        }
+
         if (streamInfo != null) {
             logger.info("可以找到对应的stream");
             String streamId = streamInfo.getStream();
+
             if (streamId == null) {
-                WVPResult wvpResult = new WVPResult();
                 wvpResult.setCode(ErrorCode.ERROR100.getCode());
                 wvpResult.setMsg("点播失败, redis缓存streamId等于null");
                 msg.setData(wvpResult);
                 resultHolder.invokeAllResult(msg);
                 return;
             }
+
             String mediaServerId = streamInfo.getMediaServerId();
             MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
-
             JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaInfo, streamId);
+
             if (rtpInfo.getInteger("code") == 0) {
                 if (rtpInfo.getBoolean("exist")) {
                     int localPort = rtpInfo.getInteger("local_port");
                     if (localPort == 0) {
                         logger.warn("[点播],点播时发现rtpServerC存在,但是尚未开始推流");
                         // 此时说明rtpServer已经创建但是流还没有推上来
-                        WVPResult wvpResult = new WVPResult();
                         wvpResult.setCode(ErrorCode.ERROR100.getCode());
                         wvpResult.setMsg("点播已经在进行中,请稍候重试");
                         msg.setData(wvpResult);
-
                         resultHolder.invokeAllResult(msg);
                         return;
                     } else {
-                        WVPResult wvpResult = new WVPResult();
                         wvpResult.setCode(ErrorCode.SUCCESS.getCode());
                         wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
                         wvpResult.setData(streamInfo);
@@ -171,7 +176,6 @@ public class PlayServiceImpl implements IPlayService {
                             hookEvent.response(mediaServerItem, JSON.parseObject(JSON.toJSONString(streamInfo)));
                         }
                     }
-
                 } else {
                     redisCatchStorage.stopPlay(streamInfo);
                     storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
@@ -190,17 +194,14 @@ public class PlayServiceImpl implements IPlayService {
             if (mediaServerItem.isRtpEnable()) {
                 logger.info("test ----- {}",device.getDeviceId());
                 logger.info("test ----- {}",channelId);
-
                 streamId = String.format("%s_%s", device.getDeviceId(), channelId);
             }
             SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false);
             logger.info(JSONObject.toJSONString(ssrcInfo));
 			if (ssrcInfo == null) {
-                WVPResult wvpResult = new WVPResult();
                 wvpResult.setCode(ErrorCode.ERROR100.getCode());
                 wvpResult.setMsg("开启收流失败");
                 msg.setData(wvpResult);
-
                 resultHolder.invokeAllResult(msg);
                 return;
             }
@@ -213,7 +214,6 @@ public class PlayServiceImpl implements IPlayService {
             }, event -> {
                 // sip error错误
                logger.warn("sip 错误,点播失败");
-                WVPResult wvpResult = new WVPResult();
                 wvpResult.setCode(ErrorCode.ERROR100.getCode());
                 wvpResult.setMsg(String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg));
                 msg.setData(wvpResult);
@@ -224,7 +224,6 @@ public class PlayServiceImpl implements IPlayService {
             }, (code, msgStr) -> {
                 // invite点播超时
                 logger.warn("sip 点播超时");
-                WVPResult wvpResult = new WVPResult();
                 wvpResult.setCode(ErrorCode.ERROR100.getCode());
                 if (code == 0) {
                     wvpResult.setMsg("点播超时,请稍候重试");

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java

@@ -154,11 +154,11 @@ public class PlayController {
 		if (!exist) {
 			playService.play(newMediaServerItem, deviceId, channelId,isUsePs, null, null, null);
 		}else{
-			logger.info("未知异常");
+			logger.info("当前设备通道在推流中");
 			// 释放rtpserver
 			WVPResult<StreamInfo> wvpResult = new WVPResult<>();
 			wvpResult.setCode(ErrorCode.ERROR100.getCode());
-			wvpResult.setMsg("未知异常");
+			wvpResult.setMsg("当前设备通道在推流中,请先停止(如遇非正常停止,请等待一分钟后重试)");
 			msg.setData(wvpResult);
 			resultHolder.invokeResult(msg);
 		}

+ 2 - 1
web_src/src/components/layoutCom/user_header.vue

@@ -28,7 +28,7 @@ export default {
       this.activeIndex = this.$route.path;
       let user = userService.getUser();
       console.log(user);
-      if(user&&user.role){
+      if(user && user.role){
         let roleId = user.role.id;
         console.log(roleId)
         console.log(typeof roleId)
@@ -38,6 +38,7 @@ export default {
         this.editUser = false;
         // todo: 重新获取用户信息,或者重新登录
       }
+      this.$nextTick()
 
     }
   }