Merge remote-tracking branch 'origin/wvp-28181-2.0' into wvp-28181-2.0

pull/567/head
gushouzheng 2022-08-06 09:00:14 +08:00
commit d21d281b2c
8 changed files with 17 additions and 8 deletions

View File

@ -127,7 +127,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
SipURI sipUri = (SipURI) request.getRequestURI(); SipURI sipUri = (SipURI) request.getRequestURI();
//从subject读取channelId,不再从request-line读取。 有些平台request-line是平台国标编码不是设备国标编码。 //从subject读取channelId,不再从request-line读取。 有些平台request-line是平台国标编码不是设备国标编码。
//String channelId = sipURI.getUser(); //String channelId = sipURI.getUser();
String channelId = SipUtils.getChannelIdFromHeader(request); String channelId = SipUtils.getChannelIdFromRequest(request);
String requesterId = SipUtils.getUserIdFromFromHeader(request); String requesterId = SipUtils.getUserIdFromFromHeader(request);
CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME);
if (requesterId == null || channelId == null) { if (requesterId == null || channelId == null) {

View File

@ -27,6 +27,7 @@ import javax.sip.SipException;
import javax.sip.address.SipURI; import javax.sip.address.SipURI;
import javax.sip.header.CSeqHeader; import javax.sip.header.CSeqHeader;
import javax.sip.header.CallIdHeader; import javax.sip.header.CallIdHeader;
import javax.sip.message.Request;
import javax.sip.message.Response; import javax.sip.message.Response;
import java.text.ParseException; import java.text.ParseException;
import java.util.Map; import java.util.Map;
@ -68,22 +69,23 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
@Override @Override
public void process(RequestEvent evt) { public void process(RequestEvent evt) {
SIPRequest sipRequest = (SIPRequest)evt.getRequest();
logger.debug("接收到消息:" + evt.getRequest()); logger.debug("接收到消息:" + evt.getRequest());
String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest());
CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); CallIdHeader callIdHeader = sipRequest.getCallIdHeader();
// 先从会话内查找 // 先从会话内查找
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null); SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
if (ssrcTransaction != null) { // 兼容海康 媒体通知 消息from字段不是设备ID的问题 // 兼容海康 媒体通知 消息from字段不是设备ID的问题
if (ssrcTransaction != null) {
deviceId = ssrcTransaction.getDeviceId(); deviceId = ssrcTransaction.getDeviceId();
} }
// 查询设备是否存在 // 查询设备是否存在
CSeqHeader cseqHeader = (CSeqHeader) evt.getRequest().getHeader(CSeqHeader.NAME);
String method = cseqHeader.getMethod();
Device device = redisCatchStorage.getDevice(deviceId); Device device = redisCatchStorage.getDevice(deviceId);
// 查询上级平台是否存在 // 查询上级平台是否存在
ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId); ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId);
try { try {
if (device != null && parentPlatform != null) { if (device != null && parentPlatform != null) {
logger.warn("[重复]平台与设备编号重复:{}", deviceId); logger.warn("[重复]平台与设备编号重复:{}", deviceId);
SIPRequest request = (SIPRequest) evt.getRequest(); SIPRequest request = (SIPRequest) evt.getRequest();
String hostAddress = request.getRemoteAddress().getHostAddress(); String hostAddress = request.getRemoteAddress().getHostAddress();

View File

@ -23,9 +23,10 @@ public class SipUtils {
/** /**
* subjectchannelId * subjectchannelId
* */ * */
public static String getChannelIdFromHeader(Request request) { public static String getChannelIdFromRequest(Request request) {
Header subject = request.getHeader("subject"); Header subject = request.getHeader("subject");
if (subject == null) { if (subject == null) {
// 如果缺失subject
return null; return null;
} }
return ((Subject) subject).getSubject().split(":")[0]; return ((Subject) subject).getSubject().split(":")[0];

View File

@ -451,7 +451,6 @@ public class ZLMHttpHookListener {
redisCatchStorage.stopPlayback(streamInfo.getDeviceID(), streamInfo.getChannelId(), redisCatchStorage.stopPlayback(streamInfo.getDeviceID(), streamInfo.getChannelId(),
streamInfo.getStream(), null); streamInfo.getStream(), null);
} }
} }
}else { }else {
if (!"rtp".equals(app)){ if (!"rtp".equals(app)){

View File

@ -85,6 +85,7 @@ public class ZLMMediaListManager {
streamPushMapper.add(transform); streamPushMapper.add(transform);
}else { }else {
streamPushMapper.update(transform); streamPushMapper.update(transform);
gbStreamMapper.updateMediaServer(mediaItem.getApp(), mediaItem.getStream(), mediaItem.getMediaServerId());
} }
if (transform != null) { if (transform != null) {
if (getChannelOnlineEventLister(transform.getApp(), transform.getStream()) != null) { if (getChannelOnlineEventLister(transform.getApp(), transform.getStream()) != null) {

View File

@ -492,6 +492,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
try { try {
int addStreamResult = streamPushMapper.add(stream); int addStreamResult = streamPushMapper.add(stream);
if (!StringUtils.isEmpty(stream.getGbId())) { if (!StringUtils.isEmpty(stream.getGbId())) {
stream.setStreamType("push");
gbStreamMapper.add(stream); gbStreamMapper.add(stream);
} }
dataSourceTransactionManager.commit(transactionStatus); dataSourceTransactionManager.commit(transactionStatus);

View File

@ -143,4 +143,9 @@ public interface GbStreamMapper {
"</foreach>" + "</foreach>" +
"</script>") "</script>")
List<GbStream> selectAllForAppAndStream(List<StreamPushItem> streamPushItems); List<GbStream> selectAllForAppAndStream(List<StreamPushItem> streamPushItems);
@Update("UPDATE gb_stream " +
"SET mediaServerId=#{mediaServerId}" +
"WHERE app=#{app} AND stream=#{stream}")
void updateMediaServer(String app, String stream, String mediaServerId);
} }

View File

@ -149,7 +149,7 @@ media:
enable: true enable: true
# [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性不然自动配置此属性可能不成功 # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性不然自动配置此属性可能不成功
port-range: 30000,30500 # 端口范围 port-range: 30000,30500 # 端口范围
# [可选] 国标级联在此范围内选择端口发送媒体流, # [可选] 国标级联在此范围内选择端口发送媒体流
send-port-range: 30000,30500 # 端口范围 send-port-range: 30000,30500 # 端口范围
# 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载 0 表示不使用 # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载 0 表示不使用
record-assist-port: 0 record-assist-port: 0