Browse Source

去除所有的system.print, 优化日志显示

pull/93/head
panlinlin 4 years ago
parent
commit
f7a2d2a92d
  1. 11
      src/main/java/com/genersoft/iot/vmp/conf/MediaServerConfig.java
  2. 26
      src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java
  3. 10
      src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java
  4. 6
      src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java
  5. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
  6. 17
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/AckRequestProcessor.java
  7. 8
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/ByeRequestProcessor.java
  8. 22
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
  9. 6
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/OtherRequestProcessor.java
  10. 8
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/SubscribeRequestProcessor.java
  11. 6
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/response/impl/InviteResponseProcessor.java
  12. 15
      src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java
  13. 2
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
  14. 1
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
  15. 4
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
  16. 4
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
  17. 4
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
  18. 12
      src/main/java/com/genersoft/iot/vmp/onvif/impl/ONVIFServerIMpl.java
  19. 11
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
  20. 11
      src/main/java/com/genersoft/iot/vmp/utils/GpsUtil.java
  21. 4
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java

11
src/main/java/com/genersoft/iot/vmp/conf/MediaServerConfig.java

@ -22,6 +22,9 @@ public class MediaServerConfig {
@JSONField(name = "general.enableVhost") @JSONField(name = "general.enableVhost")
private String generalEnableVhost; private String generalEnableVhost;
@JSONField(name = "general.mediaServerId")
private String generalMediaServerId;
@JSONField(name = "general.flowThreshold") @JSONField(name = "general.flowThreshold")
private String generalFlowThreshold; private String generalFlowThreshold;
@ -738,4 +741,12 @@ public class MediaServerConfig {
public void setUpdateTime(long updateTime) { public void setUpdateTime(long updateTime) {
this.updateTime = updateTime; this.updateTime = updateTime;
} }
public String getGeneralMediaServerId() {
return generalMediaServerId;
}
public void setGeneralMediaServerId(String generalMediaServerId) {
this.generalMediaServerId = generalMediaServerId;
}
} }

26
src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java

@ -39,6 +39,8 @@ import javax.sip.message.Request;
import javax.sip.message.Response; import javax.sip.message.Response;
import gov.nist.core.InternalErrorHandler; import gov.nist.core.InternalErrorHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Implements the HTTP digest authentication method server side functionality. * Implements the HTTP digest authentication method server side functionality.
@ -49,6 +51,8 @@ import gov.nist.core.InternalErrorHandler;
public class DigestServerAuthenticationHelper { public class DigestServerAuthenticationHelper {
private Logger logger = LoggerFactory.getLogger(DigestServerAuthenticationHelper.class);
private MessageDigest messageDigest; private MessageDigest messageDigest;
public static final String DEFAULT_ALGORITHM = "MD5"; public static final String DEFAULT_ALGORITHM = "MD5";
@ -204,18 +208,18 @@ public class DigestServerAuthenticationHelper {
String A2 = request.getMethod().toUpperCase() + ":" + uri.toString(); String A2 = request.getMethod().toUpperCase() + ":" + uri.toString();
byte mdbytes[] = messageDigest.digest(A1.getBytes()); byte mdbytes[] = messageDigest.digest(A1.getBytes());
String HA1 = toHexString(mdbytes); String HA1 = toHexString(mdbytes);
System.out.println("A1: " + A1); logger.debug("A1: " + A1);
System.out.println("A2: " + A2); logger.debug("A2: " + A2);
mdbytes = messageDigest.digest(A2.getBytes()); mdbytes = messageDigest.digest(A2.getBytes());
String HA2 = toHexString(mdbytes); String HA2 = toHexString(mdbytes);
System.out.println("HA1: " + HA1); logger.debug("HA1: " + HA1);
System.out.println("HA2: " + HA2); logger.debug("HA2: " + HA2);
String cnonce = authHeader.getCNonce(); String cnonce = authHeader.getCNonce();
System.out.println("nonce: " + nonce); logger.debug("nonce: " + nonce);
System.out.println("nc: " + ncStr); logger.debug("nc: " + ncStr);
System.out.println("cnonce: " + cnonce); logger.debug("cnonce: " + cnonce);
System.out.println("qop: " + qop); logger.debug("qop: " + qop);
String KD = HA1 + ":" + nonce; String KD = HA1 + ":" + nonce;
if (qop != null && qop.equals("auth") ) { if (qop != null && qop.equals("auth") ) {
@ -228,12 +232,12 @@ public class DigestServerAuthenticationHelper {
KD += ":" + qop; KD += ":" + qop;
} }
KD += ":" + HA2; KD += ":" + HA2;
System.out.println("KD: " + KD); logger.debug("KD: " + KD);
mdbytes = messageDigest.digest(KD.getBytes()); mdbytes = messageDigest.digest(KD.getBytes());
String mdString = toHexString(mdbytes); String mdString = toHexString(mdbytes);
System.out.println("mdString: " + mdString); logger.debug("mdString: " + mdString);
String response = authHeader.getResponse(); String response = authHeader.getResponse();
System.out.println("response: " + response); logger.debug("response: " + response);
return mdString.equals(response); return mdString.equals(response);
} }

10
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java

@ -1,5 +1,7 @@
package com.genersoft.iot.vmp.gb28181.event.offline; package com.genersoft.iot.vmp.gb28181.event.offline;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
@ -17,6 +19,8 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
@Component @Component
public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessageListener { public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessageListener {
private Logger logger = LoggerFactory.getLogger(KeepaliveTimeoutListenerForPlatform.class);
@Autowired @Autowired
private EventPublisher publisher; private EventPublisher publisher;
@ -34,9 +38,9 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa
public void onMessage(Message message, byte[] pattern) { public void onMessage(Message message, byte[] pattern) {
// 获取失效的key // 获取失效的key
String expiredKey = message.toString(); String expiredKey = message.toString();
System.out.println(expiredKey); logger.info(expiredKey);
if(!expiredKey.startsWith(VideoManagerConstants.PLATFORM_PREFIX)){ if(!expiredKey.startsWith(VideoManagerConstants.PLATFORM_PREFIX)){
System.out.println("收到redis过期监听,但开头不是"+VideoManagerConstants.PLATFORM_PREFIX+",忽略"); logger.info("收到redis过期监听,但开头不是"+VideoManagerConstants.PLATFORM_PREFIX+",忽略");
return; return;
} }
// 平台心跳到期,需要重发, 判断是否已经多次未收到心跳回复, 多次未收到,则重新发起注册, 注册尝试多次未得到回复,则认为平台离线 // 平台心跳到期,需要重发, 判断是否已经多次未收到心跳回复, 多次未收到,则重新发起注册, 注册尝试多次未得到回复,则认为平台离线
@ -45,7 +49,7 @@ public class KeepaliveTimeoutListenerForPlatform extends KeyExpirationEventMessa
publisher.platformKeepaliveExpireEventPublish(platformGBId); publisher.platformKeepaliveExpireEventPublish(platformGBId);
}else if (expiredKey.startsWith(VideoManagerConstants.PLATFORM_REGISTER_PREFIX)) { }else if (expiredKey.startsWith(VideoManagerConstants.PLATFORM_REGISTER_PREFIX)) {
System.out.println("11111111111111"); logger.info("11111111111111");
String platformGBId = expiredKey.substring(VideoManagerConstants.PLATFORM_REGISTER_PREFIX.length(),expiredKey.length()); String platformGBId = expiredKey.substring(VideoManagerConstants.PLATFORM_REGISTER_PREFIX.length(),expiredKey.length());
publisher.platformNotRegisterEventPublish(platformGBId); publisher.platformNotRegisterEventPublish(platformGBId);

6
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java

@ -1,5 +1,7 @@
package com.genersoft.iot.vmp.gb28181.event.offline; package com.genersoft.iot.vmp.gb28181.event.offline;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
@ -17,6 +19,8 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
@Component @Component
public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener { public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener {
private Logger logger = LoggerFactory.getLogger(KeepliveTimeoutListener.class);
@Autowired @Autowired
private EventPublisher publisher; private EventPublisher publisher;
@ -34,7 +38,7 @@ public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener {
// 获取失效的key // 获取失效的key
String expiredKey = message.toString(); String expiredKey = message.toString();
if(!expiredKey.startsWith(VideoManagerConstants.KEEPLIVEKEY_PREFIX)){ if(!expiredKey.startsWith(VideoManagerConstants.KEEPLIVEKEY_PREFIX)){
System.out.println("收到redis过期监听,但开头不是"+VideoManagerConstants.KEEPLIVEKEY_PREFIX+",忽略"); logger.info("收到redis过期监听,但开头不是"+VideoManagerConstants.KEEPLIVEKEY_PREFIX+",忽略");
return; return;
} }

2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

@ -280,7 +280,7 @@ public class SIPCommander implements ISIPCommander {
public boolean frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) { public boolean frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) {
try { try {
String cmdStr= frontEndCmdString(cmdCode, parameter1, parameter2, combineCode2); String cmdStr= frontEndCmdString(cmdCode, parameter1, parameter2, combineCode2);
System.out.println("控制字符串:" + cmdStr); logger.info("控制字符串:" + cmdStr);
StringBuffer ptzXml = new StringBuffer(200); StringBuffer ptzXml = new StringBuffer(200);
ptzXml.append("<?xml version=\"1.0\" ?>\r\n"); ptzXml.append("<?xml version=\"1.0\" ?>\r\n");
ptzXml.append("<Control>\r\n"); ptzXml.append("<Control>\r\n");

17
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/AckRequestProcessor.java

@ -14,6 +14,8 @@ import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @Description:ACK请求处理器 * @Description:ACK请求处理器
@ -22,6 +24,9 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
*/ */
public class AckRequestProcessor extends SIPRequestAbstractProcessor { public class AckRequestProcessor extends SIPRequestAbstractProcessor {
private Logger logger = LoggerFactory.getLogger(AckRequestProcessor.class);
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
private ZLMRTPServerFactory zlmrtpServerFactory; private ZLMRTPServerFactory zlmrtpServerFactory;
@ -55,8 +60,8 @@ public class AckRequestProcessor extends SIPRequestAbstractProcessor {
} }
redisCatchStorage.updateSendRTPSever(sendRtpItem); redisCatchStorage.updateSendRTPSever(sendRtpItem);
System.out.println(platformGbId); logger.info(platformGbId);
System.out.println(channelId); logger.info(channelId);
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("vhost","__defaultVhost__"); param.put("vhost","__defaultVhost__");
param.put("app",streamInfo.getApp()); param.put("app",streamInfo.getApp());
@ -74,16 +79,16 @@ public class AckRequestProcessor extends SIPRequestAbstractProcessor {
if (System.currentTimeMillis() - startTime < 30 * 1000) { if (System.currentTimeMillis() - startTime < 30 * 1000) {
if (zlmrtpServerFactory.isStreamReady(streamInfo.getApp(), streamInfo.getStreamId())) { if (zlmrtpServerFactory.isStreamReady(streamInfo.getApp(), streamInfo.getStreamId())) {
rtpPushed = true; rtpPushed = true;
System.out.println("已获取设备推流,开始向上级推流"); logger.info("已获取设备推流,开始向上级推流");
zlmrtpServerFactory.startSendRtpStream(param); zlmrtpServerFactory.startSendRtpStream(param);
} else { } else {
System.out.println("等待设备推流......."); logger.info("等待设备推流.......");
Thread.sleep(1000); Thread.sleep(1000);
continue; continue;
} }
} else { } else {
rtpPushed = true; rtpPushed = true;
System.out.println("设备推流超时,终止向上级推流"); logger.info("设备推流超时,终止向上级推流");
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
@ -95,7 +100,7 @@ public class AckRequestProcessor extends SIPRequestAbstractProcessor {
// CSeq csReq = (CSeq) request.getHeader(CSeq.NAME); // CSeq csReq = (CSeq) request.getHeader(CSeq.NAME);
// ackRequest = dialog.createAck(csReq.getSeqNumber()); // ackRequest = dialog.createAck(csReq.getSeqNumber());
// dialog.sendAck(ackRequest); // dialog.sendAck(ackRequest);
// System.out.println("send ack to callee:" + ackRequest.toString()); // logger.info("send ack to callee:" + ackRequest.toString());
// } catch (SipException e) { // } catch (SipException e) {
// e.printStackTrace(); // e.printStackTrace();
// } catch (InvalidArgumentException e) { // } catch (InvalidArgumentException e) {

8
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/ByeRequestProcessor.java

@ -16,6 +16,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException; import java.text.ParseException;
import java.util.HashMap; import java.util.HashMap;
@ -28,6 +30,8 @@ import java.util.Map;
*/ */
public class ByeRequestProcessor extends SIPRequestAbstractProcessor { public class ByeRequestProcessor extends SIPRequestAbstractProcessor {
private Logger logger = LoggerFactory.getLogger(ByeRequestProcessor.class);
private ISIPCommander cmder; private ISIPCommander cmder;
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@ -54,11 +58,11 @@ public class ByeRequestProcessor extends SIPRequestAbstractProcessor {
param.put("vhost","__defaultVhost__"); param.put("vhost","__defaultVhost__");
param.put("app",sendRtpItem.getApp()); param.put("app",sendRtpItem.getApp());
param.put("stream",streamId); param.put("stream",streamId);
System.out.println("停止向上级推流:" + streamId); logger.info("停止向上级推流:" + streamId);
zlmrtpServerFactory.stopSendRtpStream(param); zlmrtpServerFactory.stopSendRtpStream(param);
redisCatchStorage.deleteSendRTPServer(platformGbId, channelId); redisCatchStorage.deleteSendRTPServer(platformGbId, channelId);
if (zlmrtpServerFactory.totalReaderCount(sendRtpItem.getApp(), streamId) == 0) { if (zlmrtpServerFactory.totalReaderCount(sendRtpItem.getApp(), streamId) == 0) {
System.out.println(streamId + "无其它观看者,通知设备停止推流"); logger.info(streamId + "无其它观看者,通知设备停止推流");
cmder.streamByeCmd(sendRtpItem.getDeviceId(), channelId); cmder.streamByeCmd(sendRtpItem.getDeviceId(), channelId);
} }
} }

22
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java

@ -114,13 +114,13 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
String cmd = XmlUtil.getText(rootElement, "CmdType"); String cmd = XmlUtil.getText(rootElement, "CmdType");
if (MESSAGE_KEEP_ALIVE.equals(cmd)) { if (MESSAGE_KEEP_ALIVE.equals(cmd)) {
logger.info("接收到KeepAlive消息"); logger.debug("接收到KeepAlive消息");
processMessageKeepAlive(evt); processMessageKeepAlive(evt);
} else if (MESSAGE_CONFIG_DOWNLOAD.equals(cmd)) { } else if (MESSAGE_CONFIG_DOWNLOAD.equals(cmd)) {
logger.info("接收到ConfigDownload消息"); logger.debug("接收到ConfigDownload消息");
processMessageConfigDownload(evt); processMessageConfigDownload(evt);
} else if (MESSAGE_CATALOG.equals(cmd)) { } else if (MESSAGE_CATALOG.equals(cmd)) {
logger.info("接收到Catalog消息"); logger.debug("接收到Catalog消息");
processMessageCatalogList(evt); processMessageCatalogList(evt);
} else if (MESSAGE_DEVICE_INFO.equals(cmd)) { } else if (MESSAGE_DEVICE_INFO.equals(cmd)) {
// DeviceInfo消息处理 // DeviceInfo消息处理
@ -129,31 +129,31 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
// DeviceStatus消息处理 // DeviceStatus消息处理
processMessageDeviceStatus(evt); processMessageDeviceStatus(evt);
} else if (MESSAGE_DEVICE_CONTROL.equals(cmd)) { } else if (MESSAGE_DEVICE_CONTROL.equals(cmd)) {
logger.info("接收到DeviceControl消息"); logger.debug("接收到DeviceControl消息");
processMessageDeviceControl(evt); processMessageDeviceControl(evt);
} else if (MESSAGE_DEVICE_CONFIG.equals(cmd)) { } else if (MESSAGE_DEVICE_CONFIG.equals(cmd)) {
logger.info("接收到DeviceConfig消息"); logger.info("接收到DeviceConfig消息");
processMessageDeviceConfig(evt); processMessageDeviceConfig(evt);
} else if (MESSAGE_ALARM.equals(cmd)) { } else if (MESSAGE_ALARM.equals(cmd)) {
logger.info("接收到Alarm消息"); logger.debug("接收到Alarm消息");
processMessageAlarm(evt); processMessageAlarm(evt);
} else if (MESSAGE_RECORD_INFO.equals(cmd)) { } else if (MESSAGE_RECORD_INFO.equals(cmd)) {
logger.info("接收到RecordInfo消息"); logger.debug("接收到RecordInfo消息");
processMessageRecordInfo(evt); processMessageRecordInfo(evt);
}else if (MESSAGE_MEDIA_STATUS.equals(cmd)) { }else if (MESSAGE_MEDIA_STATUS.equals(cmd)) {
logger.info("接收到MediaStatus消息"); logger.debug("接收到MediaStatus消息");
processMessageMediaStatus(evt); processMessageMediaStatus(evt);
} else if (MESSAGE_MOBILE_POSITION.equals(cmd)) { } else if (MESSAGE_MOBILE_POSITION.equals(cmd)) {
logger.info("接收到MobilePosition消息"); logger.debug("接收到MobilePosition消息");
processMessageMobilePosition(evt); processMessageMobilePosition(evt);
} else if (MESSAGE_PRESET_QUERY.equals(cmd)) { } else if (MESSAGE_PRESET_QUERY.equals(cmd)) {
logger.info("接收到PresetQuery消息"); logger.debug("接收到PresetQuery消息");
processMessagePresetQuery(evt); processMessagePresetQuery(evt);
} else if (MESSAGE_BROADCAST.equals(cmd)) { } else if (MESSAGE_BROADCAST.equals(cmd)) {
// Broadcast消息处理 // Broadcast消息处理
processMessageBroadcast(evt); processMessageBroadcast(evt);
} else { } else {
logger.info("接收到消息:" + cmd); logger.debug("接收到消息:" + cmd);
responseAck(evt); responseAck(evt);
} }
} catch (DocumentException | SipException |InvalidArgumentException | ParseException e) { } catch (DocumentException | SipException |InvalidArgumentException | ParseException e) {
@ -467,7 +467,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
cmderFroPlatform.deviceInfoResponse(parentPlatform, sn, fromHeader.getTag()); cmderFroPlatform.deviceInfoResponse(parentPlatform, sn, fromHeader.getTag());
} }
} else { } else {
logger.info("接收到DeviceInfo应答消息"); logger.debug("接收到DeviceInfo应答消息");
Device device = storager.queryVideoDevice(deviceId); Device device = storager.queryVideoDevice(deviceId);
if (device == null) { if (device == null) {
return; return;

6
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/OtherRequestProcessor.java

@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.transmit.request.impl;
import javax.sip.RequestEvent; import javax.sip.RequestEvent;
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @Description:暂不支持的消息请求处理器 * @Description:暂不支持的消息请求处理器
@ -11,6 +13,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcesso
*/ */
public class OtherRequestProcessor extends SIPRequestAbstractProcessor { public class OtherRequestProcessor extends SIPRequestAbstractProcessor {
private Logger logger = LoggerFactory.getLogger(OtherRequestProcessor.class);
/** /**
* <p>Title: process</p> * <p>Title: process</p>
* <p>Description: </p> * <p>Description: </p>
@ -21,7 +25,7 @@ public class OtherRequestProcessor extends SIPRequestAbstractProcessor {
*/ */
@Override @Override
public void process(RequestEvent evt) { public void process(RequestEvent evt) {
System.out.println("Unsupported the method: " + evt.getRequest().getMethod()); logger.info("Unsupported the method: " + evt.getRequest().getMethod());
} }
} }

8
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/SubscribeRequestProcessor.java

@ -11,6 +11,8 @@ import javax.sip.message.Request;
import javax.sip.message.Response; import javax.sip.message.Response;
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @Description:SUBSCRIBE请求处理器 * @Description:SUBSCRIBE请求处理器
@ -19,6 +21,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcesso
*/ */
public class SubscribeRequestProcessor extends SIPRequestAbstractProcessor { public class SubscribeRequestProcessor extends SIPRequestAbstractProcessor {
private Logger logger = LoggerFactory.getLogger(SubscribeRequestProcessor.class);
/** /**
* 处理SUBSCRIBE请求 * 处理SUBSCRIBE请求
* *
@ -38,13 +42,13 @@ public class SubscribeRequestProcessor extends SIPRequestAbstractProcessor {
ExpiresHeader expireHeader = getHeaderFactory().createExpiresHeader(30); ExpiresHeader expireHeader = getHeaderFactory().createExpiresHeader(30);
response.setExpires(expireHeader); response.setExpires(expireHeader);
} }
System.out.println("response : " + response.toString()); logger.info("response : " + response.toString());
ServerTransaction transaction = getServerTransaction(evt); ServerTransaction transaction = getServerTransaction(evt);
if (transaction != null) { if (transaction != null) {
transaction.sendResponse(response); transaction.sendResponse(response);
transaction.terminate(); transaction.terminate();
} else { } else {
System.out.println("processRequest serverTransactionId is null."); logger.info("processRequest serverTransactionId is null.");
} }
} catch (ParseException e) { } catch (ParseException e) {

6
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/response/impl/InviteResponseProcessor.java

@ -9,6 +9,8 @@ import javax.sip.message.Request;
import javax.sip.message.Response; import javax.sip.message.Response;
import gov.nist.javax.sip.ResponseEventExt; import gov.nist.javax.sip.ResponseEventExt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
@ -24,7 +26,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.response.ISIPResponseProcessor;
@Component @Component
public class InviteResponseProcessor implements ISIPResponseProcessor { public class InviteResponseProcessor implements ISIPResponseProcessor {
// private final static Logger logger = LoggerFactory.getLogger(InviteResponseProcessor.class); private final static Logger logger = LoggerFactory.getLogger(InviteResponseProcessor.class);
/** /**
* 处理invite响应 * 处理invite响应
@ -51,7 +53,7 @@ public class InviteResponseProcessor implements ISIPResponseProcessor {
requestURI.setHost(event.getRemoteIpAddress()); requestURI.setHost(event.getRemoteIpAddress());
requestURI.setPort(event.getRemotePort()); requestURI.setPort(event.getRemotePort());
reqAck.setRequestURI(requestURI); reqAck.setRequestURI(requestURI);
System.out.println("向 " + event.getRemoteIpAddress() + ":" + event.getRemotePort() + "回复ack"); logger.info("向 " + event.getRemoteIpAddress() + ":" + event.getRemotePort() + "回复ack");
dialog.sendAck(reqAck); dialog.sendAck(reqAck);
} }
} catch (InvalidArgumentException | SipException e) { } catch (InvalidArgumentException | SipException e) {

15
src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java

@ -1,5 +1,8 @@
package com.genersoft.iot.vmp.gb28181.utils; package com.genersoft.iot.vmp.gb28181.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* 数值格式判断和处理 * 数值格式判断和处理
* @author lawrencehj * @author lawrencehj
@ -7,6 +10,8 @@ package com.genersoft.iot.vmp.gb28181.utils;
*/ */
public class NumericUtil { public class NumericUtil {
private static Logger logger = LoggerFactory.getLogger(NumericUtil.class);
/** /**
* 判断是否Double格式 * 判断是否Double格式
* @param str * @param str
@ -14,11 +19,11 @@ public class NumericUtil {
*/ */
public static boolean isDouble(String str) { public static boolean isDouble(String str) {
try { try {
Double num2 = Double.valueOf(str); Double num2 = Double.valueOf(str);
System.out.println(num2 + " is a valid numeric string!"); logger.debug(num2 + " is a valid numeric string!");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
System.out.println(str + " is an invalid numeric string!"); logger.debug(str + " is an invalid numeric string!");
return false; return false;
} }
} }
@ -31,10 +36,10 @@ public class NumericUtil {
public static boolean isInteger(String str) { public static boolean isInteger(String str) {
try { try {
int num2 = Integer.valueOf(str); int num2 = Integer.valueOf(str);
System.out.println(num2 + " is an integer!"); logger.debug(num2 + " is an integer!");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
System.out.println(str + " is not an integer!"); logger.debug(str + " is not an integer!");
return false; return false;
} }
} }

2
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java

@ -251,7 +251,7 @@ public class ZLMHttpHookListener {
JSONArray tracks = json.getJSONArray("tracks"); JSONArray tracks = json.getJSONArray("tracks");
boolean regist = json.getBoolean("regist"); boolean regist = json.getBoolean("regist");
if (tracks != null) { if (tracks != null) {
System.out.println("on_stream_changed->>" + schema); logger.info("[stream: " + streamId + "]on_stream_changed->>" + schema);
} }
if ("rtmp".equals(schema)){ if ("rtmp".equals(schema)){
if ("rtp".equals(app) && !regist ) { if ("rtp".equals(app) && !regist ) {

1
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java

@ -71,7 +71,6 @@ public class ZLMMediaListManager {
jsonObject.put("app", streamPushItem.getApp()); jsonObject.put("app", streamPushItem.getApp());
jsonObject.put("stream", streamPushItem.getStream()); jsonObject.put("stream", streamPushItem.getStream());
subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_play,jsonObject,(response)->{ subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_play,jsonObject,(response)->{
System.out.println(1222211111);
updateMedia(response.getString("app"), response.getString("stream")); updateMedia(response.getString("app"), response.getString("stream"));
}); });
} }

4
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java

@ -131,8 +131,8 @@ public class ZLMRESTfulUtils {
} }
public JSONObject addFFmpegSource(String src_url, String dst_url, String timeout_ms){ public JSONObject addFFmpegSource(String src_url, String dst_url, String timeout_ms){
System.out.println(src_url); logger.info(src_url);
System.out.println(dst_url); logger.info(dst_url);
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("src_url", src_url); param.put("src_url", src_url);
param.put("dst_url", dst_url); param.put("dst_url", dst_url);

4
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java

@ -189,7 +189,7 @@ public class ZLMRTPServerFactory {
public Boolean startSendRtpStream(Map<String, Object>param) { public Boolean startSendRtpStream(Map<String, Object>param) {
Boolean result = false; Boolean result = false;
JSONObject jsonObject = zlmresTfulUtils.startSendRtp(param); JSONObject jsonObject = zlmresTfulUtils.startSendRtp(param);
System.out.println(jsonObject); logger.info(jsonObject.toJSONString());
if (jsonObject == null) { if (jsonObject == null) {
logger.error("RTP推流失败: 请检查ZLM服务"); logger.error("RTP推流失败: 请检查ZLM服务");
} else if (jsonObject.getInteger("code") == 0) { } else if (jsonObject.getInteger("code") == 0) {
@ -233,7 +233,7 @@ public class ZLMRTPServerFactory {
public Boolean stopSendRtpStream(Map<String, Object>param) { public Boolean stopSendRtpStream(Map<String, Object>param) {
Boolean result = false; Boolean result = false;
JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(param); JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(param);
System.out.println(jsonObject); logger.info(jsonObject.toJSONString());
if (jsonObject == null) { if (jsonObject == null) {
logger.error("停止RTP推流失败: 请检查ZLM服务"); logger.error("停止RTP推流失败: 请检查ZLM服务");
} else if (jsonObject.getInteger("code") == 0) { } else if (jsonObject.getInteger("code") == 0) {

4
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java

@ -154,11 +154,11 @@ public class ZLMRunner implements CommandLineRunner {
* zlm 连接成功或者zlm重启后 * zlm 连接成功或者zlm重启后
*/ */
private void zLmRunning(MediaServerConfig mediaServerConfig){ private void zLmRunning(MediaServerConfig mediaServerConfig){
logger.info("zlm接入成功..."); logger.info( "[ id: " + mediaServerConfig.getGeneralMediaServerId() + "] zlm接入成功...");
if (autoConfig) saveZLMConfig(); if (autoConfig) saveZLMConfig();
MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
if (mediaInfo != null && System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){ if (mediaInfo != null && System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){
logger.info("zlm刚刚更新,忽略这次更新"); logger.info("[ id: " + mediaServerConfig.getGeneralMediaServerId() + "]zlm刚刚更新,忽略这次更新");
return; return;
} }
mediaServerConfig.setLocalIP(mediaIp); mediaServerConfig.setLocalIP(mediaIp);

12
src/main/java/com/genersoft/iot/vmp/onvif/impl/ONVIFServerIMpl.java

@ -43,7 +43,7 @@ public class ONVIFServerIMpl implements IONVIFServer {
public void onDevicesFound(List<Device> devices) { public void onDevicesFound(List<Device> devices) {
if (devices == null || devices.size() == 0) return; if (devices == null || devices.size() == 0) return;
for (Device device : devices){ for (Device device : devices){
System.out.println(device.getHostName()); logger.info(device.getHostName());
deviceMap.put(device.getHostName(), device); deviceMap.put(device.getHostName(), device);
} }
} }
@ -53,7 +53,7 @@ public class ONVIFServerIMpl implements IONVIFServer {
public void onDiscoveryFinished() { public void onDiscoveryFinished() {
ArrayList<String> result = new ArrayList<>(); ArrayList<String> result = new ArrayList<>();
for (Device device : deviceMap.values()) { for (Device device : deviceMap.values()) {
System.out.println(device.getHostName()); logger.info(device.getHostName());
result.add(device.getHostName()); result.add(device.getHostName());
} }
callBack.run(0, result); callBack.run(0, result);
@ -71,14 +71,14 @@ public class ONVIFServerIMpl implements IONVIFServer {
@Override @Override
public void onResponse(OnvifDevice onvifDevice, OnvifResponse response) { public void onResponse(OnvifDevice onvifDevice, OnvifResponse response) {
System.out.println("[RESPONSE] " + onvifDevice.getHostName() logger.info("[RESPONSE] " + onvifDevice.getHostName()
+ "======" + response.getErrorCode() + "======" + response.getErrorCode()
+ "======" + response.getErrorMessage()); + "======" + response.getErrorMessage());
} }
@Override @Override
public void onError(OnvifDevice onvifDevice, int errorCode, String errorMessage) { public void onError(OnvifDevice onvifDevice, int errorCode, String errorMessage) {
System.out.println("[ERROR] " + onvifDevice.getHostName() + "======" + errorCode + "=======" + errorMessage); logger.info("[ERROR] " + onvifDevice.getHostName() + "======" + errorCode + "=======" + errorMessage);
callBack.run(errorCode, errorMessage); callBack.run(errorCode, errorMessage);
} }
}); });
@ -91,8 +91,8 @@ public class ONVIFServerIMpl implements IONVIFServer {
@Override @Override
public void onMediaProfilesReceived(OnvifDevice device, List<OnvifMediaProfile> mediaProfiles) { public void onMediaProfilesReceived(OnvifDevice device, List<OnvifMediaProfile> mediaProfiles) {
for (OnvifMediaProfile mediaProfile : mediaProfiles) { for (OnvifMediaProfile mediaProfile : mediaProfiles) {
System.out.println(mediaProfile.getName()); logger.info(mediaProfile.getName());
System.out.println(mediaProfile.getToken()); logger.info(mediaProfile.getToken());
if (mediaProfile.getName().equals("mainStream")) { if (mediaProfile.getName().equals("mainStream")) {
onvifManager.getMediaStreamURI(device, mediaProfile, (OnvifDevice onvifDevice, onvifManager.getMediaStreamURI(device, mediaProfile, (OnvifDevice onvifDevice,
OnvifMediaProfile profile, String uri) -> { OnvifMediaProfile profile, String uri) -> {

11
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java

@ -12,6 +12,8 @@ import com.genersoft.iot.vmp.storager.dao.*;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -29,6 +31,9 @@ import org.springframework.transaction.annotation.Transactional;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Component @Component
public class VideoManagerStoragerImpl implements IVideoManagerStorager { public class VideoManagerStoragerImpl implements IVideoManagerStorager {
private Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class);
@Autowired @Autowired
DataSourceTransactionManager dataSourceTransactionManager; DataSourceTransactionManager dataSourceTransactionManager;
@ -232,7 +237,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
return false; return false;
} }
device.setOnline(1); device.setOnline(1);
System.out.println("更新设备在线"); logger.info("更新设备在线: " + deviceId);
return deviceMapper.update(device) > 0; return deviceMapper.update(device) > 0;
} }
@ -244,7 +249,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
*/ */
@Override @Override
public synchronized boolean outline(String deviceId) { public synchronized boolean outline(String deviceId) {
System.out.println("更新设备离线: " + deviceId); logger.info("更新设备离线: " + deviceId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId); Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) return false; if (device == null) return false;
device.setOnline(0); device.setOnline(0);
@ -540,7 +545,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
@Override @Override
public void updateMediaList(List<StreamPushItem> streamPushItems) { public void updateMediaList(List<StreamPushItem> streamPushItems) {
if (streamPushItems == null || streamPushItems.size() == 0) return; if (streamPushItems == null || streamPushItems.size() == 0) return;
System.out.printf("updateMediaList: " + streamPushItems.size()); logger.info("updateMediaList: " + streamPushItems.size());
streamPushMapper.addAll(streamPushItems); streamPushMapper.addAll(streamPushItems);
// TODO 待优化 // TODO 待优化
for (int i = 0; i < streamPushItems.size(); i++) { for (int i = 0; i < streamPushItems.size(); i++) {

11
src/main/java/com/genersoft/iot/vmp/utils/GpsUtil.java

@ -7,9 +7,16 @@ import java.net.Socket;
import java.util.Base64; import java.util.Base64;
import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint; import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GpsUtil { public class GpsUtil {
private static Logger logger = LoggerFactory.getLogger(GpsUtil.class);
public static BaiduPoint Wgs84ToBd09(String xx, String yy) { public static BaiduPoint Wgs84ToBd09(String xx, String yy) {
try { try {
Socket s = new Socket("api.map.baidu.com", 80); Socket s = new Socket("api.map.baidu.com", 80);
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream(), "UTF-8")); BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream(), "UTF-8"));
@ -26,7 +33,7 @@ public class GpsUtil {
String json = ""; String json = "";
String tmp = ""; String tmp = "";
while ((tmp = br.readLine()) != null) { while ((tmp = br.readLine()) != null) {
// System.out.println(tmp); // logger.info(tmp);
json += tmp; json += tmp;
} }
@ -44,7 +51,7 @@ public class GpsUtil {
return bdPoint; return bdPoint;
//return (new String(decode(x)) + "," + new String(decode(y))); //return (new String(decode(x)) + "," + new String(decode(y)));
} else { } else {
System.out.println("gps坐标无效!!"); logger.info("gps坐标无效!!");
} }
out.close(); out.close();
br.close(); br.close();

4
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java

@ -167,7 +167,7 @@ public class PlayController {
streamId ); streamId );
String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId); String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId);
JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(srcUrl, dstUrl, "1000000"); JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(srcUrl, dstUrl, "1000000");
System.out.println(jsonObject); logger.info(jsonObject.toJSONString());
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
if (jsonObject != null && jsonObject.getInteger("code") == 0) { if (jsonObject != null && jsonObject.getInteger("code") == 0) {
result.put("code", 0); result.put("code", 0);
@ -198,7 +198,7 @@ public class PlayController {
public ResponseEntity<String> playConvertStop(@PathVariable String key) { public ResponseEntity<String> playConvertStop(@PathVariable String key) {
JSONObject jsonObject = zlmresTfulUtils.delFFmpegSource(key); JSONObject jsonObject = zlmresTfulUtils.delFFmpegSource(key);
System.out.println(jsonObject); logger.info(jsonObject.toJSONString());
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
if (jsonObject != null && jsonObject.getInteger("code") == 0) { if (jsonObject != null && jsonObject.getInteger("code") == 0) {
result.put("code", 0); result.put("code", 0);

Loading…
Cancel
Save