优化语音对讲

This commit is contained in:
648540858
2023-01-05 16:38:33 +08:00
parent 16f3b0553d
commit e14cef8062
6 changed files with 42 additions and 67 deletions

View File

@@ -9,14 +9,15 @@ public class SipTransactionInfo {
private String toTag;
private String viaBranch;
private boolean fromServer;
// 自己是否媒体流发送者
private boolean asSender;
public SipTransactionInfo(SIPResponse response, boolean fromServer) {
public SipTransactionInfo(SIPResponse response, boolean asSender) {
this.callId = response.getCallIdHeader().getCallId();
this.fromTag = response.getFromTag();
this.toTag = response.getToTag();
this.viaBranch = response.getTopmostViaHeader().getBranch();
this.fromServer = fromServer;
this.asSender = asSender;
}
public SipTransactionInfo(SIPResponse response) {
@@ -24,7 +25,6 @@ public class SipTransactionInfo {
this.fromTag = response.getFromTag();
this.toTag = response.getToTag();
this.viaBranch = response.getTopmostViaHeader().getBranch();
this.fromServer = true;
}
public SipTransactionInfo() {
@@ -62,11 +62,11 @@ public class SipTransactionInfo {
this.viaBranch = viaBranch;
}
public boolean isFromServer() {
return fromServer;
public boolean isAsSender() {
return asSender;
}
public void setFromServer(boolean fromServer) {
this.fromServer = fromServer;
public void setAsSender(boolean asSender) {
this.asSender = asSender;
}
}

View File

@@ -170,11 +170,11 @@ public class SIPRequestHeaderProvider {
//from
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.isFromServer()?transactionInfo.getFromTag():transactionInfo.getToTag());
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.isAsSender()? transactionInfo.getFromTag():transactionInfo.getToTag());
//to
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress());
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,transactionInfo.isFromServer()?transactionInfo.getToTag():transactionInfo.getFromTag());
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.isAsSender()?transactionInfo.getToTag():transactionInfo.getFromTag());
//Forwards
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
@@ -186,11 +186,6 @@ public class SIPRequestHeaderProvider {
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
return request;
}

View File

@@ -655,7 +655,12 @@ public class SIPCommander implements ISIPCommander {
*/
@Override
public void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, callId, stream);
SsrcTransaction ssrcTransaction;
if (callId != null) {
ssrcTransaction = streamSession.getSsrcTransaction(null, null, callId, null);
}else {
ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, null, stream);
}
if (ssrcTransaction == null) {
throw new SsrcTransactionNotFoundException(device.getDeviceId(), channelId, callId, stream);
}

View File

@@ -62,7 +62,12 @@ public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent i
return;
}
String result = getText(rootElement, "Result");
logger.info("[语音广播]回复:{}, {}/{}", result, device.getDeviceId(), channelId );
Element infoElement = rootElement.element("Info");
String reason = null;
if (infoElement != null) {
reason = getText(infoElement, "Reason");
}
logger.info("[语音广播]回复:{}, {}/{}", reason == null? result : result + ": " + reason, device.getDeviceId(), channelId );
// 回复200 OK
responseAck(request, Response.OK);