Commit 5f50a3cfd9571eced413d23d729fb0b68b16df0a
1 parent
4df90d9b
修复语音对讲Bye消息的发送
Showing
7 changed files
with
56 additions
and
3 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
| @@ -166,6 +166,8 @@ public interface ISIPCommander { | @@ -166,6 +166,8 @@ public interface ISIPCommander { | ||
| 166 | void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException; | 166 | void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException; |
| 167 | 167 | ||
| 168 | 168 | ||
| 169 | + void streamByeCmdForDeviceInvite(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException; | ||
| 170 | + | ||
| 169 | /** | 171 | /** |
| 170 | * /** | 172 | * /** |
| 171 | * 语音广播 | 173 | * 语音广播 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
| @@ -195,6 +195,41 @@ public class SIPRequestHeaderProvider { | @@ -195,6 +195,41 @@ public class SIPRequestHeaderProvider { | ||
| 195 | return request; | 195 | return request; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | + public Request createByteRequestForDeviceInvite(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException { | ||
| 199 | + Request request = null; | ||
| 200 | + //请求行 | ||
| 201 | + SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress()); | ||
| 202 | + // via | ||
| 203 | + ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | ||
| 204 | + ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); | ||
| 205 | + viaHeaders.add(viaHeader); | ||
| 206 | + //from | ||
| 207 | + SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); | ||
| 208 | + Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); | ||
| 209 | + FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getToTag()); | ||
| 210 | + //to | ||
| 211 | + SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress()); | ||
| 212 | + Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); | ||
| 213 | + ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getFromTag()); | ||
| 214 | + | ||
| 215 | + //Forwards | ||
| 216 | + MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); | ||
| 217 | + | ||
| 218 | + //ceq | ||
| 219 | + CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); | ||
| 220 | + CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); | ||
| 221 | + request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | ||
| 222 | + | ||
| 223 | + request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); | ||
| 224 | + | ||
| 225 | + Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); | ||
| 226 | + request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); | ||
| 227 | + | ||
| 228 | + request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); | ||
| 229 | + | ||
| 230 | + return request; | ||
| 231 | + } | ||
| 232 | + | ||
| 198 | public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { | 233 | public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 199 | Request request = null; | 234 | Request request = null; |
| 200 | // sipuri | 235 | // sipuri |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -700,6 +700,12 @@ public class SIPCommander implements ISIPCommander { | @@ -700,6 +700,12 @@ public class SIPCommander implements ISIPCommander { | ||
| 700 | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent); | 700 | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent); |
| 701 | } | 701 | } |
| 702 | 702 | ||
| 703 | + @Override | ||
| 704 | + public void streamByeCmdForDeviceInvite(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { | ||
| 705 | + Request byteRequest = headerProvider.createByteRequestForDeviceInvite(device, channelId, sipTransactionInfo); | ||
| 706 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent); | ||
| 707 | + } | ||
| 708 | + | ||
| 703 | /** | 709 | /** |
| 704 | * 语音广播 | 710 | * 语音广播 |
| 705 | * | 711 | * |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; | @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson2.JSON; | 3 | import com.alibaba.fastjson2.JSON; |
| 4 | import com.alibaba.fastjson2.JSONObject; | 4 | import com.alibaba.fastjson2.JSONObject; |
| 5 | +import com.genersoft.iot.vmp.common.InviteSessionType; | ||
| 5 | import com.genersoft.iot.vmp.common.StreamInfo; | 6 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 6 | import com.genersoft.iot.vmp.common.VideoManagerConstants; | 7 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 7 | import com.genersoft.iot.vmp.conf.DynamicTask; | 8 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| @@ -10,6 +11,7 @@ import com.genersoft.iot.vmp.conf.UserSetting; | @@ -10,6 +11,7 @@ import com.genersoft.iot.vmp.conf.UserSetting; | ||
| 10 | import com.genersoft.iot.vmp.gb28181.bean.*; | 11 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 11 | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; | 12 | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; |
| 12 | import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; | 13 | import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; |
| 14 | +import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; | ||
| 13 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; | 15 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| 14 | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; | 16 | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| 15 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | 17 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| @@ -126,6 +128,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -126,6 +128,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 126 | @Autowired | 128 | @Autowired |
| 127 | private RedisGbPlayMsgListener redisGbPlayMsgListener; | 129 | private RedisGbPlayMsgListener redisGbPlayMsgListener; |
| 128 | 130 | ||
| 131 | + @Autowired | ||
| 132 | + private VideoStreamSessionManager streamSession; | ||
| 133 | + | ||
| 129 | 134 | ||
| 130 | @Override | 135 | @Override |
| 131 | public void afterPropertiesSet() throws Exception { | 136 | public void afterPropertiesSet() throws Exception { |
| @@ -1139,9 +1144,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -1139,9 +1144,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 1139 | audioBroadcastCatch.setStatus(AudioBroadcastCatchStatus.Ok); | 1144 | audioBroadcastCatch.setStatus(AudioBroadcastCatchStatus.Ok); |
| 1140 | audioBroadcastCatch.setSipTransactionInfoByRequset(sipResponse); | 1145 | audioBroadcastCatch.setSipTransactionInfoByRequset(sipResponse); |
| 1141 | audioBroadcastManager.update(audioBroadcastCatch); | 1146 | audioBroadcastManager.update(audioBroadcastCatch); |
| 1142 | - | 1147 | + streamSession.put(device.getDeviceId(), sendRtpItem.getChannelId(), request.getCallIdHeader().getCallId(), sendRtpItem.getStream(), sendRtpItem.getSsrc(), sendRtpItem.getMediaServerId(), sipResponse, InviteSessionType.BROADCAST); |
| 1143 | // 开启发流,大华在收到200OK后就会开始建立连接 | 1148 | // 开启发流,大华在收到200OK后就会开始建立连接 |
| 1144 | if (!device.isBroadcastPushAfterAck()) { | 1149 | if (!device.isBroadcastPushAfterAck()) { |
| 1150 | + logger.info("[语音喊话] 回复200OK后发现 BroadcastPushAfterAck为False,现在开始推流"); | ||
| 1145 | playService.startPushStream(sendRtpItem, sipResponse, parentPlatform, request.getCallIdHeader()); | 1151 | playService.startPushStream(sendRtpItem, sipResponse, parentPlatform, request.getCallIdHeader()); |
| 1146 | } | 1152 | } |
| 1147 | 1153 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java
| @@ -3,9 +3,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message; | @@ -3,9 +3,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message; | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 3 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 5 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 6 | +import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd.CatalogQueryMessageHandler; | ||
| 7 | +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | ||
| 8 | +import gov.nist.javax.sip.message.SIPRequest; | ||
| 6 | import org.dom4j.Element; | 9 | import org.dom4j.Element; |
| 7 | import org.slf4j.Logger; | 10 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; | 11 | import org.slf4j.LoggerFactory; |
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | 13 | ||
| 10 | import javax.sip.InvalidArgumentException; | 14 | import javax.sip.InvalidArgumentException; |
| 11 | import javax.sip.RequestEvent; | 15 | import javax.sip.RequestEvent; |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -1139,7 +1139,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -1139,7 +1139,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 1139 | param.put("stream", sendRtpItem.getStream()); | 1139 | param.put("stream", sendRtpItem.getStream()); |
| 1140 | zlmresTfulUtils.stopSendRtp(mediaInfo, param); | 1140 | zlmresTfulUtils.stopSendRtp(mediaInfo, param); |
| 1141 | try { | 1141 | try { |
| 1142 | - cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null); | 1142 | + cmder.streamByeCmdForDeviceInvite(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null); |
| 1143 | } catch (InvalidArgumentException | ParseException | SipException | | 1143 | } catch (InvalidArgumentException | ParseException | SipException | |
| 1144 | SsrcTransactionNotFoundException e) { | 1144 | SsrcTransactionNotFoundException e) { |
| 1145 | logger.error("[消息发送失败] 发送语音喊话BYE失败"); | 1145 | logger.error("[消息发送失败] 发送语音喊话BYE失败"); |
src/main/java/com/genersoft/iot/vmp/vmanager/ps/PsController.java
| @@ -100,7 +100,7 @@ public class PsController { | @@ -100,7 +100,7 @@ public class PsController { | ||
| 100 | } | 100 | } |
| 101 | } | 101 | } |
| 102 | String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_" + callId + "_" + stream; | 102 | String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_" + callId + "_" + stream; |
| 103 | - int localPort = zlmServerFactory.createRTPServer(mediaServerItem, stream, ssrcInt, null, false, tcpMode); | 103 | + int localPort = zlmServerFactory.createRTPServer(mediaServerItem, stream, ssrcInt, null, false, false, tcpMode); |
| 104 | if (localPort == 0) { | 104 | if (localPort == 0) { |
| 105 | throw new ControllerException(ErrorCode.ERROR100.getCode(), "获取端口失败"); | 105 | throw new ControllerException(ErrorCode.ERROR100.getCode(), "获取端口失败"); |
| 106 | } | 106 | } |