修复级联点播时海康使用自定义ssrc的情况
This commit is contained in:
parent
7620fb951c
commit
a287261c5d
@ -715,12 +715,10 @@ public class SIPCommander implements ISIPCommander {
|
|||||||
}
|
}
|
||||||
dialog = streamSession.getDialogByStream(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
dialog = streamSession.getDialogByStream(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
||||||
}
|
}
|
||||||
if (ssrcTransaction != null) {
|
MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId());
|
||||||
MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId());
|
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc());
|
||||||
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc());
|
mediaServerService.closeRTPServer(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
||||||
mediaServerService.closeRTPServer(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
||||||
streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dialog == null) {
|
if (dialog == null) {
|
||||||
logger.warn("[ {} -> {}]停止视频流的时候发现对话已丢失", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
|
logger.warn("[ {} -> {}]停止视频流的时候发现对话已丢失", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
|
||||||
|
@ -31,6 +31,7 @@ import javax.sip.address.SipURI;
|
|||||||
import javax.sip.header.*;
|
import javax.sip.header.*;
|
||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -546,14 +547,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
}
|
}
|
||||||
notifyRequest.addHeader(event);
|
notifyRequest.addHeader(event);
|
||||||
SipURI sipURI = (SipURI) notifyRequest.getRequestURI();
|
SipURI sipURI = (SipURI) notifyRequest.getRequestURI();
|
||||||
if (subscribeInfo.getTransaction() != null) {
|
sipURI.setHost(parentPlatform.getServerIP());
|
||||||
SIPRequest request = (SIPRequest) subscribeInfo.getTransaction().getRequest();
|
sipURI.setPort(parentPlatform.getServerPort());
|
||||||
sipURI.setHost(request.getRemoteAddress().getHostAddress());
|
|
||||||
sipURI.setPort(request.getRemotePort());
|
|
||||||
}else {
|
|
||||||
sipURI.setHost(parentPlatform.getServerIP());
|
|
||||||
sipURI.setPort(parentPlatform.getServerPort());
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientTransaction transaction = null;
|
ClientTransaction transaction = null;
|
||||||
if ("TCP".equals(parentPlatform.getTransport())) {
|
if ("TCP".equals(parentPlatform.getTransport())) {
|
||||||
|
@ -372,7 +372,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
|||||||
if (mediaServerItem.isRtpEnable()) {
|
if (mediaServerItem.isRtpEnable()) {
|
||||||
streamId = String.format("%s_%s", device.getDeviceId(), channelId);
|
streamId = String.format("%s_%s", device.getDeviceId(), channelId);
|
||||||
}
|
}
|
||||||
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, true, false);
|
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, null, device.isSsrcCheck(), false);
|
||||||
sendRtpItem.setStreamId(ssrcInfo.getStream());
|
sendRtpItem.setStreamId(ssrcInfo.getStream());
|
||||||
// 写入redis, 超时时回复
|
// 写入redis, 超时时回复
|
||||||
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
redisCatchStorage.updateSendRTPSever(sendRtpItem);
|
||||||
|
@ -239,19 +239,20 @@ public class PlayServiceImpl implements IPlayService {
|
|||||||
if (ssrcInfo == null) {
|
if (ssrcInfo == null) {
|
||||||
ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false);
|
ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false);
|
||||||
}
|
}
|
||||||
|
logger.info("[点播开始] deviceId: {}, channelId: {}, SSRC: {}", device.getDeviceId(), channelId, ssrcInfo.getSsrc() );
|
||||||
// 超时处理
|
// 超时处理
|
||||||
String timeOutTaskKey = UUID.randomUUID().toString();
|
String timeOutTaskKey = UUID.randomUUID().toString();
|
||||||
SSRCInfo finalSsrcInfo = ssrcInfo;
|
SSRCInfo finalSsrcInfo = ssrcInfo;
|
||||||
dynamicTask.startDelay( timeOutTaskKey,()->{
|
dynamicTask.startDelay( timeOutTaskKey,()->{
|
||||||
logger.warn(String.format("设备点播超时,deviceId:%s ,channelId:%s", device.getDeviceId(), channelId));
|
|
||||||
|
|
||||||
SIPDialog dialog = streamSession.getDialogByStream(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
|
SIPDialog dialog = streamSession.getDialogByStream(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
|
logger.info("[点播超时] 收流超时 deviceId: {}, channelId: {}", device.getDeviceId(), channelId);
|
||||||
timeoutCallback.run(1, "收流超时");
|
timeoutCallback.run(1, "收流超时");
|
||||||
// 点播超时回复BYE 同时释放ssrc以及此次点播的资源
|
// 点播超时回复BYE 同时释放ssrc以及此次点播的资源
|
||||||
cmder.streamByeCmd(device.getDeviceId(), channelId, finalSsrcInfo.getStream(), null);
|
cmder.streamByeCmd(device.getDeviceId(), channelId, finalSsrcInfo.getStream(), null);
|
||||||
}else {
|
}else {
|
||||||
|
logger.info("[点播超时] 消息未响应 deviceId: {}, channelId: {}", device.getDeviceId(), channelId);
|
||||||
timeoutCallback.run(0, "点播超时");
|
timeoutCallback.run(0, "点播超时");
|
||||||
mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
|
mediaServerService.releaseSsrc(mediaServerItem.getId(), finalSsrcInfo.getSsrc());
|
||||||
mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
|
mediaServerService.closeRTPServer(device.getDeviceId(), channelId, finalSsrcInfo.getStream());
|
||||||
@ -266,6 +267,8 @@ public class PlayServiceImpl implements IPlayService {
|
|||||||
// hook响应
|
// hook响应
|
||||||
onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId, uuid);
|
onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId, uuid);
|
||||||
hookEvent.response(mediaServerItemInuse, response);
|
hookEvent.response(mediaServerItemInuse, response);
|
||||||
|
logger.info("[点播成功] deviceId: {}, channelId: {}", device.getDeviceId(), channelId);
|
||||||
|
|
||||||
}, (event) -> {
|
}, (event) -> {
|
||||||
ResponseEvent responseEvent = (ResponseEvent)event.event;
|
ResponseEvent responseEvent = (ResponseEvent)event.event;
|
||||||
String contentString = new String(responseEvent.getResponse().getRawContent());
|
String contentString = new String(responseEvent.getResponse().getRawContent());
|
||||||
@ -279,8 +282,10 @@ public class PlayServiceImpl implements IPlayService {
|
|||||||
if (ssrc.equals(ssrcInResponse)) {
|
if (ssrc.equals(ssrcInResponse)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.info("[SIP 消息] 收到invite 200, 发现下级自定义了ssrc 开启修正");
|
logger.info("[点播消息] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse );
|
||||||
if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) {
|
if (!mediaServerItem.isRtpEnable() || device.isSsrcCheck()) {
|
||||||
|
logger.info("[SIP 消息] SSRC修正 {}->{}", ssrc, ssrcInResponse);
|
||||||
|
|
||||||
if (!mediaServerItem.getSsrcConfig().checkSsrc(ssrcInResponse)) {
|
if (!mediaServerItem.getSsrcConfig().checkSsrc(ssrcInResponse)) {
|
||||||
// ssrc 不可用
|
// ssrc 不可用
|
||||||
// 释放ssrc
|
// 释放ssrc
|
||||||
|
Loading…
Reference in New Issue
Block a user