Ver código fonte

点播接口添加更多log信息

kindring 2 anos atrás
pai
commit
cc1515a3e8

+ 1 - 0
src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java

@@ -35,6 +35,7 @@ public class VManageBootstrap extends SpringBootServletInitializer {
 	private static String[] args;
 	private static ConfigurableApplicationContext context;
 	public static void main(String[] args) {
+		logger.info("start");
 		VManageBootstrap.args = args;
 		VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args);
 		GitUtil gitUtil1 = SpringBeanFactory.getBean("gitUtil");

+ 4 - 0
src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java

@@ -20,6 +20,9 @@ public class WVPTimerTask {
     @Value("${server.port}")
     private int serverPort;
 
+    @Value("${server.http.port}")
+    private int httpPort;
+
     @Autowired
     private SipConfig sipConfig;
 
@@ -28,6 +31,7 @@ public class WVPTimerTask {
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("ip", sipConfig.getIp());
         jsonObject.put("port", serverPort);
+        jsonObject.put("httpPort", httpPort);
         redisCatchStorage.updateWVPInfo(jsonObject, 3);
     }
 }

+ 4 - 0
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java

@@ -60,6 +60,10 @@ public class MediaServerServiceImpl implements IMediaServerService {
     @Value("${server.port}")
     private Integer serverPort;
 
+
+    @Value("${server.http.port}")
+    private Integer serverHttpPort;
+
     @Autowired
     private UserSetting userSetting;
 

+ 5 - 1
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java

@@ -121,6 +121,7 @@ public class PlayServiceImpl implements IPlayService {
                                  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;
@@ -132,6 +133,7 @@ public class PlayServiceImpl implements IPlayService {
         StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
 
         if (streamInfo != null) {
+            logger.info("可以找到对应的stream");
             String streamId = streamInfo.getStream();
             if (streamId == null) {
                 WVPResult wvpResult = new WVPResult();
@@ -176,11 +178,11 @@ public class PlayServiceImpl implements IPlayService {
                     streamInfo = null;
                 }
             } else {
+                logger.warn("获取rtpinfo失败");
                 //zlm连接失败
                 redisCatchStorage.stopPlay(streamInfo);
                 storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
                 streamInfo = null;
-
             }
         }
         if (streamInfo == null) {
@@ -210,6 +212,7 @@ 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));
@@ -220,6 +223,7 @@ public class PlayServiceImpl implements IPlayService {
                 }
             }, (code, msgStr) -> {
                 // invite点播超时
+                logger.warn("sip 点播超时");
                 WVPResult wvpResult = new WVPResult();
                 wvpResult.setCode(ErrorCode.ERROR100.getCode());
                 if (code == 0) {

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

@@ -107,6 +107,7 @@ public class PlayController {
 													@PathVariable String channelId,
 													@RequestParam(value = "isUsePs", defaultValue = "1", required=false )int isUsePs
 	) {
+		logger.info("[视频点播] {}-{}开始点播视频",deviceId,channelId);
 		// 获取可用的zlm
 		Device device = storager.queryVideoDevice(deviceId);
 		MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
@@ -131,6 +132,7 @@ public class PlayController {
 		});
 		// TODO 在点播未成功的情况下在此调用接口点播会导致返回的流地址ip错误
 		deferredResultEx.setFilter(result1 -> {
+			logger.info("点播成功");
 			WVPResult<StreamInfo> wvpResult1 = (WVPResult<StreamInfo>)result1;
 			WVPResult<StreamContent> resultStream = new WVPResult<>();
 			resultStream.setCode(wvpResult1.getCode());
@@ -151,6 +153,14 @@ public class PlayController {
 
 		if (!exist) {
 			playService.play(newMediaServerItem, deviceId, channelId,isUsePs, null, null, null);
+		}else{
+			logger.info("未知异常");
+			// 释放rtpserver
+			WVPResult<StreamInfo> wvpResult = new WVPResult<>();
+			wvpResult.setCode(ErrorCode.ERROR100.getCode());
+			wvpResult.setMsg("未知异常");
+			msg.setData(wvpResult);
+			resultHolder.invokeResult(msg);
 		}
 		return result;
 	}

+ 3 - 1
src/main/resources/application.yml

@@ -75,7 +75,9 @@ rj-druid-manage:
 
 # [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
 server:
-    port: 29001
+    port: 29002
+    http:
+        port: 29001
     # [可选] HTTPS配置, 默认不开启
     ssl:
         # [可选] 是否开启HTTPS访问