兼容科达国标级联语音对讲
parent
6f28e6b497
commit
696d182f6a
|
@ -69,13 +69,8 @@ public interface IPlatformService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向上级发送语音喊话的消息
|
* 向上级发送语音喊话的消息
|
||||||
* @param platform 平台
|
|
||||||
* @param channelId 通道
|
|
||||||
* @param hookEvent hook事件
|
|
||||||
* @param errorEvent 信令错误事件
|
|
||||||
* @param timeoutCallback 超时事件
|
|
||||||
*/
|
*/
|
||||||
void broadcastInvite(Platform platform, CommonGBChannel channelId, MediaServer mediaServerItem, HookSubscribe.Event hookEvent,
|
void broadcastInvite(Platform platform, CommonGBChannel channel, String sourceId, MediaServer mediaServerItem, HookSubscribe.Event hookEvent,
|
||||||
SipSubscribe.Event errorEvent, InviteTimeOutCallback timeoutCallback) throws InvalidArgumentException, ParseException, SipException;
|
SipSubscribe.Event errorEvent, InviteTimeOutCallback timeoutCallback) throws InvalidArgumentException, ParseException, SipException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -484,7 +484,7 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void broadcastInvite(Platform platform, CommonGBChannel channel, MediaServer mediaServerItem, HookSubscribe.Event hookEvent,
|
public void broadcastInvite(Platform platform, CommonGBChannel channel, String sourceId, MediaServer mediaServerItem, HookSubscribe.Event hookEvent,
|
||||||
SipSubscribe.Event errorEvent, InviteTimeOutCallback timeoutCallback) throws InvalidArgumentException, ParseException, SipException {
|
SipSubscribe.Event errorEvent, InviteTimeOutCallback timeoutCallback) throws InvalidArgumentException, ParseException, SipException {
|
||||||
|
|
||||||
if (mediaServerItem == null) {
|
if (mediaServerItem == null) {
|
||||||
|
@ -565,7 +565,7 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, userSetting.getPlayTimeout());
|
}, userSetting.getPlayTimeout());
|
||||||
commanderForPlatform.broadcastInviteCmd(platform, channel, mediaServerItem, ssrcInfo, (hookData)->{
|
commanderForPlatform.broadcastInviteCmd(platform, channel,sourceId, mediaServerItem, ssrcInfo, (hookData)->{
|
||||||
log.info("[国标级联] 发起语音喊话 收到上级推流 deviceId: {}, channelId: {}", platform.getServerGBId(), channel.getGbDeviceId());
|
log.info("[国标级联] 发起语音喊话 收到上级推流 deviceId: {}, channelId: {}", platform.getServerGBId(), channel.getGbDeviceId());
|
||||||
dynamicTask.stop(timeOutTaskKey);
|
dynamicTask.stop(timeOutTaskKey);
|
||||||
// hook响应
|
// hook响应
|
||||||
|
|
|
@ -146,7 +146,7 @@ public interface ISIPCommanderForPlatform {
|
||||||
|
|
||||||
void streamByeCmd(Platform platform, CommonGBChannel channel, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
|
void streamByeCmd(Platform platform, CommonGBChannel channel, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
|
||||||
|
|
||||||
void broadcastInviteCmd(Platform platform, CommonGBChannel channel, MediaServer mediaServerItem,
|
void broadcastInviteCmd(Platform platform, CommonGBChannel channel, String sourceId, MediaServer mediaServerItem,
|
||||||
SSRCInfo ssrcInfo, HookSubscribe.Event event, SipSubscribe.Event okEvent,
|
SSRCInfo ssrcInfo, HookSubscribe.Event event, SipSubscribe.Event okEvent,
|
||||||
SipSubscribe.Event errorEvent) throws ParseException, SipException, InvalidArgumentException;
|
SipSubscribe.Event errorEvent) throws ParseException, SipException, InvalidArgumentException;
|
||||||
|
|
||||||
|
|
|
@ -312,12 +312,12 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Request createInviteRequest(Platform platform, String channelId, String content, String viaTag, String fromTag, String ssrc, CallIdHeader callIdHeader) throws PeerUnavailableException, ParseException, InvalidArgumentException {
|
public Request createInviteRequest(Platform platform,String sourceId, String channelId, String content, String viaTag, String fromTag, String ssrc, CallIdHeader callIdHeader) throws PeerUnavailableException, ParseException, InvalidArgumentException {
|
||||||
Request request = null;
|
Request request = null;
|
||||||
//请求行
|
//请求行
|
||||||
String platformHostAddress = platform.getServerIp() + ":" + platform.getServerPort();
|
String platformHostAddress = platform.getServerIp() + ":" + platform.getServerPort();
|
||||||
String localHostAddress = sipLayer.getLocalIp(platform.getDeviceIp())+":"+ platform.getDevicePort();
|
String localHostAddress = sipLayer.getLocalIp(platform.getDeviceIp())+":"+ platform.getDevicePort();
|
||||||
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, platformHostAddress);
|
SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(sourceId, platformHostAddress);
|
||||||
//via
|
//via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(platform.getDeviceIp()), platform.getDevicePort(), platform.getTransport(), viaTag);
|
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(platform.getDeviceIp()), platform.getDevicePort(), platform.getTransport(), viaTag);
|
||||||
|
@ -329,7 +329,7 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
||||||
//to
|
//to
|
||||||
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, platformHostAddress);
|
SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sourceId, platformHostAddress);
|
||||||
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null);
|
ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null);
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),localHostAddress));
|
Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),localHostAddress));
|
||||||
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
|
||||||
// Subject
|
// Subject
|
||||||
SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", sipConfig.getId(), ssrc, channelId, 0));
|
SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", sourceId, ssrc, channelId, 0));
|
||||||
request.addHeader(subjectHeader);
|
request.addHeader(subjectHeader);
|
||||||
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
||||||
request.setContent(content, contentTypeHeader);
|
request.setContent(content, contentTypeHeader);
|
||||||
|
|
|
@ -691,7 +691,7 @@ public class SIPCommanderForPlatform implements ISIPCommanderForPlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void broadcastInviteCmd(Platform platform, CommonGBChannel channel, MediaServer mediaServerItem,
|
public void broadcastInviteCmd(Platform platform, CommonGBChannel channel,String sourceId, MediaServer mediaServerItem,
|
||||||
SSRCInfo ssrcInfo, HookSubscribe.Event event, SipSubscribe.Event okEvent,
|
SSRCInfo ssrcInfo, HookSubscribe.Event event, SipSubscribe.Event okEvent,
|
||||||
SipSubscribe.Event errorEvent) throws ParseException, SipException, InvalidArgumentException {
|
SipSubscribe.Event errorEvent) throws ParseException, SipException, InvalidArgumentException {
|
||||||
String stream = ssrcInfo.getStream();
|
String stream = ssrcInfo.getStream();
|
||||||
|
@ -712,8 +712,9 @@ public class SIPCommanderForPlatform implements ISIPCommanderForPlatform {
|
||||||
|
|
||||||
StringBuffer content = new StringBuffer(200);
|
StringBuffer content = new StringBuffer(200);
|
||||||
content.append("v=0\r\n");
|
content.append("v=0\r\n");
|
||||||
content.append("o=" + channel.getGbDeviceId() + " 0 0 IN IP4 " + sdpIp + "\r\n");
|
content.append("o=" + platform.getDeviceGBId() + " 0 0 IN IP4 " + sdpIp + "\r\n");
|
||||||
content.append("s=Play\r\n");
|
content.append("s=Play\r\n");
|
||||||
|
content.append("u=" + channel.getGbDeviceId() + ":0\r\n");
|
||||||
content.append("c=IN IP4 " + sdpIp + "\r\n");
|
content.append("c=IN IP4 " + sdpIp + "\r\n");
|
||||||
content.append("t=0 0\r\n");
|
content.append("t=0 0\r\n");
|
||||||
|
|
||||||
|
@ -738,10 +739,10 @@ public class SIPCommanderForPlatform implements ISIPCommanderForPlatform {
|
||||||
|
|
||||||
content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc
|
content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc
|
||||||
// f字段:f= v/编码格式/分辨率/帧率/码率类型/码率大小a/编码格式/码率大小/采样率
|
// f字段:f= v/编码格式/分辨率/帧率/码率类型/码率大小a/编码格式/码率大小/采样率
|
||||||
content.append("f=v/////a/1/8/1\r\n");
|
content.append("f=v/2/5/25/1/4096a/1/8/1\r\n");
|
||||||
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(platform.getDeviceIp()), platform.getTransport());
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(platform.getDeviceIp()), platform.getTransport());
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createInviteRequest(platform, channel.getGbDeviceId(),
|
Request request = headerProviderPlatformProvider.createInviteRequest(platform, sourceId, channel.getGbDeviceId(),
|
||||||
content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), ssrcInfo.getSsrc(),
|
content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), ssrcInfo.getSsrc(),
|
||||||
callIdHeader);
|
callIdHeader);
|
||||||
sipSender.transmitRequest(sipLayer.getLocalIp(platform.getDeviceIp()), request, (e -> {
|
sipSender.transmitRequest(sipLayer.getLocalIp(platform.getDeviceIp()), request, (e -> {
|
||||||
|
|
|
@ -91,7 +91,13 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp
|
||||||
}
|
}
|
||||||
String targetId = targetIDElement.getText();
|
String targetId = targetIDElement.getText();
|
||||||
|
|
||||||
|
Element sourceIdElement = rootElement.element("SourceID");
|
||||||
|
String sourceId;
|
||||||
|
if (sourceIdElement != null) {
|
||||||
|
sourceId = sourceIdElement.getText();
|
||||||
|
}else {
|
||||||
|
sourceId = targetId;
|
||||||
|
}
|
||||||
log.info("[国标级联 语音喊话] platform: {}, channel: {}", platform.getServerGBId(), targetId);
|
log.info("[国标级联 语音喊话] platform: {}, channel: {}", platform.getServerGBId(), targetId);
|
||||||
|
|
||||||
CommonGBChannel channel = channelService.queryOneWithPlatform(platform.getId(), targetId);
|
CommonGBChannel channel = channelService.queryOneWithPlatform(platform.getId(), targetId);
|
||||||
|
@ -125,7 +131,7 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp
|
||||||
}, eventResult->{
|
}, eventResult->{
|
||||||
// 消息发送成功, 向上级发送invite,获取推流
|
// 消息发送成功, 向上级发送invite,获取推流
|
||||||
try {
|
try {
|
||||||
platformService.broadcastInvite(platform, channel, mediaServerForMinimumLoad, (hookData)->{
|
platformService.broadcastInvite(platform, channel, sourceId, mediaServerForMinimumLoad, (hookData)->{
|
||||||
// 上级平台推流成功
|
// 上级平台推流成功
|
||||||
AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(channel.getGbId());
|
AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(channel.getGbId());
|
||||||
if (broadcastCatch != null ) {
|
if (broadcastCatch != null ) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class SendRtpServerServiceImpl implements ISendRtpServerService {
|
||||||
public SendRtpInfo createSendRtpInfo(MediaServer mediaServer, String ip, Integer port, String ssrc, String requesterId,
|
public SendRtpInfo createSendRtpInfo(MediaServer mediaServer, String ip, Integer port, String ssrc, String requesterId,
|
||||||
String deviceId, Integer channelId, Boolean isTcp, Boolean rtcp) {
|
String deviceId, Integer channelId, Boolean isTcp, Boolean rtcp) {
|
||||||
int localPort = getNextPort(mediaServer);
|
int localPort = getNextPort(mediaServer);
|
||||||
if (localPort == 0) {
|
if (localPort <= 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return SendRtpInfo.getInstance(localPort, mediaServer, ip, port, ssrc, deviceId, null, channelId,
|
return SendRtpInfo.getInstance(localPort, mediaServer, ip, port, ssrc, deviceId, null, channelId,
|
||||||
|
|
Loading…
Reference in New Issue