|
@@ -1,12 +1,29 @@
|
|
|
package com.genersoft.iot.vmp.service.impl;
|
|
package com.genersoft.iot.vmp.service.impl;
|
|
|
|
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.TransactionDefinition;
|
|
|
|
|
+import org.springframework.transaction.TransactionStatus;
|
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
|
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
|
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
|
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
|
|
-import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
|
|
|
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
|
|
import com.genersoft.iot.vmp.gb28181.session.SsrcConfig;
|
|
import com.genersoft.iot.vmp.gb28181.session.SsrcConfig;
|
|
|
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
|
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
|
@@ -15,30 +32,16 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
|
|
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
|
|
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
|
|
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
|
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
|
|
-import com.genersoft.iot.vmp.service.IStreamProxyService;
|
|
|
|
|
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
|
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
|
|
-import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
|
|
|
|
import com.genersoft.iot.vmp.storager.dao.MediaServerMapper;
|
|
import com.genersoft.iot.vmp.storager.dao.MediaServerMapper;
|
|
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
|
import com.genersoft.iot.vmp.utils.DateUtil;
|
|
|
import com.genersoft.iot.vmp.utils.redis.JedisUtil;
|
|
import com.genersoft.iot.vmp.utils.redis.JedisUtil;
|
|
|
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
|
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
|
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
|
|
-import okhttp3.*;
|
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
-import org.springframework.transaction.TransactionDefinition;
|
|
|
|
|
-import org.springframework.transaction.TransactionStatus;
|
|
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
-import java.text.ParseException;
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
|
-import java.util.*;
|
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
|
|
+import okhttp3.Request;
|
|
|
|
|
+import okhttp3.Response;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 媒体服务器节点管理
|
|
* 媒体服务器节点管理
|
|
@@ -81,12 +84,6 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private IVideoManagerStorage storager;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private IStreamProxyService streamProxyService;
|
|
|
|
|
-
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private EventPublisher publisher;
|
|
private EventPublisher publisher;
|
|
|
|
|
|
|
@@ -124,7 +121,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String presetSsrc, boolean ssrcCheck, boolean isPlayback) {
|
|
|
|
|
|
|
+ public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String presetSsrc, boolean ssrcCheck, boolean isPlayback, Integer port) {
|
|
|
if (mediaServerItem == null || mediaServerItem.getId() == null) {
|
|
if (mediaServerItem == null || mediaServerItem.getId() == null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
@@ -152,13 +149,18 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
|
|
}
|
|
}
|
|
|
int rtpServerPort = mediaServerItem.getRtpProxyPort();
|
|
int rtpServerPort = mediaServerItem.getRtpProxyPort();
|
|
|
if (mediaServerItem.isRtpEnable()) {
|
|
if (mediaServerItem.isRtpEnable()) {
|
|
|
- rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0);
|
|
|
|
|
|
|
+ rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0, port);
|
|
|
}
|
|
}
|
|
|
redisUtil.set(key, mediaServerItem);
|
|
redisUtil.set(key, mediaServerItem);
|
|
|
return new SSRCInfo(rtpServerPort, ssrc, streamId);
|
|
return new SSRCInfo(rtpServerPort, ssrc, streamId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback) {
|
|
|
|
|
+ return openRTPServer(mediaServerItem, streamId, ssrc, ssrcCheck, isPlayback, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void closeRTPServer(String deviceId, String channelId, String stream) {
|
|
public void closeRTPServer(String deviceId, String channelId, String stream) {
|
|
|
String mediaServerId = streamSession.getMediaServerId(deviceId, channelId, stream);
|
|
String mediaServerId = streamSession.getMediaServerId(deviceId, channelId, stream);
|
|
@@ -355,14 +357,15 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public void zlmServerOnline(ZLMServerConfig zlmServerConfig) {
|
|
public void zlmServerOnline(ZLMServerConfig zlmServerConfig) {
|
|
|
- logger.info("[ZLM] 正在连接 : {} -> {}:{}",
|
|
|
|
|
- zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(), zlmServerConfig.getHttpPort());
|
|
|
|
|
|
|
|
|
|
MediaServerItem serverItem = mediaServerMapper.queryOne(zlmServerConfig.getGeneralMediaServerId());
|
|
MediaServerItem serverItem = mediaServerMapper.queryOne(zlmServerConfig.getGeneralMediaServerId());
|
|
|
if (serverItem == null) {
|
|
if (serverItem == null) {
|
|
|
logger.warn("[未注册的zlm] 拒接接入:{}来自{}:{}", zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(),zlmServerConfig.getHttpPort() );
|
|
logger.warn("[未注册的zlm] 拒接接入:{}来自{}:{}", zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(),zlmServerConfig.getHttpPort() );
|
|
|
logger.warn("请检查ZLM的<general.mediaServerId>配置是否与WVP的<media.id>一致");
|
|
logger.warn("请检查ZLM的<general.mediaServerId>配置是否与WVP的<media.id>一致");
|
|
|
return;
|
|
return;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ logger.info("[ZLM] 正在连接 : {} -> {}:{}",
|
|
|
|
|
+ zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(), zlmServerConfig.getHttpPort());
|
|
|
}
|
|
}
|
|
|
serverItem.setHookAliveInterval(zlmServerConfig.getHookAliveInterval());
|
|
serverItem.setHookAliveInterval(zlmServerConfig.getHookAliveInterval());
|
|
|
if (serverItem.getHttpPort() == 0) {
|
|
if (serverItem.getHttpPort() == 0) {
|
|
@@ -599,9 +602,6 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
|
|
boolean result = false;
|
|
boolean result = false;
|
|
|
OkHttpClient client = new OkHttpClient();
|
|
OkHttpClient client = new OkHttpClient();
|
|
|
String url = String.format("http://%s:%s/index/api/record", ip, port);
|
|
String url = String.format("http://%s:%s/index/api/record", ip, port);
|
|
|
-
|
|
|
|
|
- FormBody.Builder builder = new FormBody.Builder();
|
|
|
|
|
-
|
|
|
|
|
Request request = new Request.Builder()
|
|
Request request = new Request.Builder()
|
|
|
.get()
|
|
.get()
|
|
|
.url(url)
|
|
.url(url)
|
|
@@ -633,7 +633,6 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
|
|
MediaServerItem mediaServerItem = getOne(mediaServerId);
|
|
MediaServerItem mediaServerItem = getOne(mediaServerId);
|
|
|
if (mediaServerItem == null) {
|
|
if (mediaServerItem == null) {
|
|
|
// zlm连接重试
|
|
// zlm连接重试
|
|
|
-
|
|
|
|
|
logger.warn("[更新ZLM 保活信息]失败,未找到流媒体信息");
|
|
logger.warn("[更新ZLM 保活信息]失败,未找到流媒体信息");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -652,7 +651,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
|
|
mediaServerItemMap.put(mediaServerItem.getId(), mediaServerItem);
|
|
mediaServerItemMap.put(mediaServerItem.getId(), mediaServerItem);
|
|
|
}
|
|
}
|
|
|
for (MediaServerItem mediaServerItem : allInCatch) {
|
|
for (MediaServerItem mediaServerItem : allInCatch) {
|
|
|
- if (mediaServerItemMap.get(mediaServerItem) == null) {
|
|
|
|
|
|
|
+ if (!mediaServerItemMap.containsKey(mediaServerItem.getId())) {
|
|
|
delete(mediaServerItem.getId());
|
|
delete(mediaServerItem.getId());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|