sql/2.6.9¸üÐÂ.sql
@@ -5,4 +5,4 @@ add auto_push_channel bool default false alter table wvp_stream_proxy add stream_key varying(255) add stream_key character varying(255) src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
@@ -89,17 +89,17 @@ ResponseEvent event = (ResponseEvent) eventResult.event; if (event.getResponse().getRawContent() != null) { // æå logger.info("[åæ¶ç®å½è®¢é 订é ]æåï¼ {}", device.getDeviceId()); logger.info("[åæ¶ç®å½è®¢é ]æåï¼ {}", device.getDeviceId()); }else { // æå logger.info("[åæ¶ç®å½è®¢é 订é ]æåï¼ {}", device.getDeviceId()); logger.info("[åæ¶ç®å½è®¢é ]æåï¼ {}", device.getDeviceId()); } },eventResult -> { // 失败 logger.warn("[åæ¶ç®å½è®¢é 订é ]失败ï¼ä¿¡ä»¤åéå¤±è´¥ï¼ {}-{} ", device.getDeviceId(), eventResult.msg); logger.warn("[åæ¶ç®å½è®¢é ]失败ï¼ä¿¡ä»¤åéå¤±è´¥ï¼ {}-{} ", device.getDeviceId(), eventResult.msg); }); } catch (InvalidArgumentException | SipException | ParseException e) { logger.error("[å½ä»¤åé失败] åæ¶ç®å½è®¢é 订é : {}", e.getMessage()); logger.error("[å½ä»¤åé失败] åæ¶ç®å½è®¢é : {}", e.getMessage()); } } } src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
@@ -132,7 +132,6 @@ if (CmdType.CATALOG.equals(cmd)) { logger.info("æ¥æ¶å°Catalogéç¥"); processNotifyCatalogList(take.getEvt()); notifyRequestForCatalogProcessor.process(take.getEvt()); } else if (CmdType.ALARM.equals(cmd)) { logger.info("æ¥æ¶å°Alarméç¥"); @@ -365,114 +364,6 @@ // åå¤200 OK if (redisCatchStorage.deviceIsOnline(deviceId)) { publisher.deviceAlarmEventPublish(deviceAlarm); } } catch (DocumentException e) { logger.error("æªå¤ççå¼å¸¸ ", e); } } /*** * å¤çcatalog设å¤ç®å½å表Notify * * @param evt */ private void processNotifyCatalogList(RequestEvent evt) { try { FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader); Device device = redisCatchStorage.getDevice(deviceId); if (device == null || !device.isOnLine()) { logger.warn("[æ¶å°ç®å½è®¢é ]ï¼{}, 使¯è®¾å¤å·²ç»ç¦»çº¿", (device != null ? device.getDeviceId():"" )); return; } Element rootElement = getRootElement(evt, device.getCharset()); if (rootElement == null) { logger.warn("[ æ¶å°ç®å½è®¢é ] content cannot be null, {}", evt.getRequest()); return; } Element deviceListElement = rootElement.element("DeviceList"); if (deviceListElement == null) { return; } Iterator<Element> deviceListIterator = deviceListElement.elementIterator(); if (deviceListIterator != null) { // éåDeviceList while (deviceListIterator.hasNext()) { Element itemDevice = deviceListIterator.next(); Element channelDeviceElement = itemDevice.element("DeviceID"); if (channelDeviceElement == null) { continue; } Element eventElement = itemDevice.element("Event"); String event; if (eventElement == null) { logger.warn("[æ¶å°ç®å½è®¢é ]ï¼{}, 使¯Event为空, 设为é»è®¤å¼ ADD", (device != null ? device.getDeviceId():"" )); event = CatalogEvent.ADD; }else { event = eventElement.getText().toUpperCase(); } DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, event, civilCodeFileConf); if (channel == null) { logger.info("[æ¶å°ç®å½è®¢é ]ï¼ä½æ¯è§£æå¤±è´¥ {}", new String(evt.getRequest().getRawContent())); continue; } if (channel.getParentId() != null && channel.getParentId().equals(sipConfig.getId())) { channel.setParentId(null); } channel.setDeviceId(device.getDeviceId()); logger.info("[æ¶å°ç®å½è®¢é ]ï¼{}/{}", device.getDeviceId(), channel.getChannelId()); switch (event) { case CatalogEvent.ON: // ä¸çº¿ logger.info("[æ¶å°ééä¸çº¿éç¥] æ¥èªè®¾å¤: {}, éé {}", device.getDeviceId(), channel.getChannelId()); storager.deviceChannelOnline(deviceId, channel.getChannelId()); break; case CatalogEvent.OFF : // 离线 logger.info("[æ¶å°éé离线éç¥] æ¥èªè®¾å¤: {}, éé {}", device.getDeviceId(), channel.getChannelId()); if (userSetting.getRefuseChannelStatusChannelFormNotify()) { storager.deviceChannelOffline(deviceId, channel.getChannelId()); }else { logger.info("[æ¶å°éé离线éç¥] 使¯å¹³å°å·²é ç½®æç»æ¤æ¶æ¯ï¼æ¥èªè®¾å¤: {}, éé {}", device.getDeviceId(), channel.getChannelId()); } break; case CatalogEvent.VLOST: // è§é¢ä¸¢å¤± logger.info("[æ¶å°ééè§é¢ä¸¢å¤±éç¥] æ¥èªè®¾å¤: {}, éé {}", device.getDeviceId(), channel.getChannelId()); if (userSetting.getRefuseChannelStatusChannelFormNotify()) { storager.deviceChannelOffline(deviceId, channel.getChannelId()); }else { logger.info("[æ¶å°ééè§é¢ä¸¢å¤±éç¥] 使¯å¹³å°å·²é ç½®æç»æ¤æ¶æ¯ï¼æ¥èªè®¾å¤: {}, éé {}", device.getDeviceId(), channel.getChannelId()); } break; case CatalogEvent.DEFECT: // æ é break; case CatalogEvent.ADD: // å¢å logger.info("[æ¶å°å¢å éééç¥] æ¥èªè®¾å¤: {}, éé {}", device.getDeviceId(), channel.getChannelId()); deviceChannelService.updateChannel(deviceId, channel); break; case CatalogEvent.DEL: // å é¤ logger.info("[æ¶å°å é¤éééç¥] æ¥èªè®¾å¤: {}, éé {}", device.getDeviceId(), channel.getChannelId()); storager.delChannel(deviceId, channel.getChannelId()); break; case CatalogEvent.UPDATE: // æ´æ° logger.info("[æ¶å°æ´æ°éééç¥] æ¥èªè®¾å¤: {}, éé {}", device.getDeviceId(), channel.getChannelId()); deviceChannelService.updateChannel(deviceId, channel); break; default: logger.warn("[ NotifyCatalog ] event not found ï¼ {}", event ); } // 转åååä¿¡æ¯ eventPublisher.catalogEventPublish(null, channel, event); } } } catch (DocumentException e) { logger.error("æªå¤ççå¼å¸¸ ", e); src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
@@ -218,6 +218,21 @@ } } public JSONObject isMediaOnline(MediaServerItem mediaServerItem, String app, String stream, String schema){ Map<String, Object> param = new HashMap<>(); if (app != null) { param.put("app",app); } if (stream != null) { param.put("stream",stream); } if (schema != null) { param.put("schema",schema); } param.put("vhost","__defaultVhost__"); return sendPost(mediaServerItem, "isMediaOnline", param, null); } public JSONObject getMediaList(MediaServerItem mediaServerItem, String app, String stream, String schema, RequestCallback callback){ Map<String, Object> param = new HashMap<>(); if (app != null) { src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
@@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForServerStarted; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.service.IMediaServerService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
@@ -545,16 +545,18 @@ // ç®å½è®¢é ç¸å ³çä¿¡æ¯ if (device.getSubscribeCycleForCatalog() > 0) { if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) { deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); if (deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) { if (device.getSubscribeCycleForCatalog() > 0) { // è¥å·²å¼å¯è®¢é ï¼ä½è®¢é 卿ä¸åï¼åå åæ¶ if (deviceInStore.getSubscribeCycleForCatalog() != 0) { removeCatalogSubscribe(deviceInStore); } // å¼å¯è®¢é addCatalogSubscribe(deviceInStore); } }else if (device.getSubscribeCycleForCatalog() == 0) { if (deviceInStore.getSubscribeCycleForCatalog() != 0) { deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); addCatalogSubscribe(deviceInStore); }else if (device.getSubscribeCycleForCatalog() == 0) { // åæ¶è®¢é deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); removeCatalogSubscribe(deviceInStore); } } @@ -569,6 +571,8 @@ } }else if (device.getSubscribeCycleForMobilePosition() == 0) { if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) { deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval()); deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition()); // åæ¶è®¢é removeMobilePositionSubscribe(deviceInStore); } src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java
@@ -257,7 +257,7 @@ ":" + inviteInfo.getDeviceId() + ":" + inviteInfo.getChannelId() + ":" + inviteInfo.getStream() + ":" + inviteInfo.getSsrcInfo().getSsrc(); ":" + ssrc; if (inviteInfoInDb.getSsrcInfo() != null) { inviteInfoInDb.getSsrcInfo().setSsrc(ssrc); } src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
@@ -35,15 +35,19 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.function.Function; import java.util.stream.Collectors; /** * è§é¢ä»£çä¸å¡ @@ -554,4 +558,43 @@ return new ResourceBaseInfo(total, online); } @Scheduled(cron = "* 0/10 * * * ?") public void asyncCheckStreamProxyStatus() { List<MediaServerItem> all = mediaServerService.getAllOnline(); if (CollectionUtils.isEmpty(all)){ return; } Map<String, MediaServerItem> serverItemMap = all.stream().collect(Collectors.toMap(MediaServerItem::getId, Function.identity(), (m1, m2) -> m1)); List<StreamProxyItem> list = videoManagerStorager.getStreamProxyListForEnable(true); if (CollectionUtils.isEmpty(list)){ return; } for (StreamProxyItem streamProxyItem : list) { MediaServerItem mediaServerItem = serverItemMap.get(streamProxyItem.getMediaServerId()); // TODO æ¯æå ¶ä» schema JSONObject mediaInfo = zlmresTfulUtils.isMediaOnline(mediaServerItem, streamProxyItem.getApp(), streamProxyItem.getStream(), "rtsp"); if (mediaInfo == null){ streamProxyItem.setStatus(false); } else { if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) { streamProxyItem.setStatus(true); } else { streamProxyItem.setStatus(false); } } updateStreamProxy(streamProxyItem); } } } src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
@@ -506,6 +506,9 @@ stream.setUpdateTime(DateUtil.getNow()); stream.setCreateTime(DateUtil.getNow()); stream.setServerId(userSetting.getServerId()); stream.setMediaServerId(mediaConfig.getId()); stream.setSelf(true); stream.setPushIng(true); // æ¾å¨äºå¡å æ§è¡ boolean result = false;