Commit 80d96042e7b6f2942585bde482f02a3392477033
1 parent
12fa3b4c
优化语音对讲
Showing
14 changed files
with
105 additions
and
96 deletions
src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java
| ... | ... | @@ -35,7 +35,7 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> { |
| 35 | 35 | @Override |
| 36 | 36 | public Object beforeBodyWrite(Object body, @NotNull MethodParameter returnType, @NotNull MediaType selectedContentType, @NotNull Class<? extends HttpMessageConverter<?>> selectedConverterType, @NotNull ServerHttpRequest request, @NotNull ServerHttpResponse response) { |
| 37 | 37 | // 排除api文档的接口,这个接口不需要统一 |
| 38 | - String[] excludePath = {"/v3/api-docs","/api/v1","/index/hook"}; | |
| 38 | + String[] excludePath = {"/v3/api-docs","/api/v1","/index/hook","/api/video-"}; | |
| 39 | 39 | for (String path : excludePath) { |
| 40 | 40 | if (request.getURI().getPath().startsWith(path)) { |
| 41 | 41 | return body; |
| ... | ... | @@ -62,8 +62,8 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> { |
| 62 | 62 | * 防止返回string时出错 |
| 63 | 63 | * @return |
| 64 | 64 | */ |
| 65 | - @Bean | |
| 65 | + /*@Bean | |
| 66 | 66 | public HttpMessageConverters custHttpMessageConverter() { |
| 67 | 67 | return new HttpMessageConverters(new FastJsonHttpMessageConverter()); |
| 68 | - } | |
| 68 | + }*/ | |
| 69 | 69 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
src/main/java/com/genersoft/iot/vmp/gb28181/bean/AudioBroadcastCatch.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.bean; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import gov.nist.javax.sip.message.SIPRequest; | |
| 5 | 4 | import gov.nist.javax.sip.message.SIPResponse; |
| 6 | -import gov.nist.javax.sip.stack.SIPDialog; | |
| 7 | - | |
| 8 | -import javax.sip.Dialog; | |
| 9 | 5 | |
| 10 | 6 | /** |
| 11 | 7 | * 缓存语音广播的状态 |
| ... | ... | @@ -77,6 +73,6 @@ public class AudioBroadcastCatch { |
| 77 | 73 | } |
| 78 | 74 | |
| 79 | 75 | public void setSipTransactionInfoByRequset(SIPResponse response) { |
| 80 | - this.sipTransactionInfo = new SipTransactionInfo(response); | |
| 76 | + this.sipTransactionInfo = new SipTransactionInfo(response, false); | |
| 81 | 77 | } |
| 82 | 78 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipTransactionInfo.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.bean; |
| 2 | 2 | |
| 3 | -import gov.nist.javax.sip.message.SIPRequest; | |
| 4 | 3 | import gov.nist.javax.sip.message.SIPResponse; |
| 5 | 4 | |
| 6 | 5 | public class SipTransactionInfo { |
| ... | ... | @@ -10,11 +9,22 @@ public class SipTransactionInfo { |
| 10 | 9 | private String toTag; |
| 11 | 10 | private String viaBranch; |
| 12 | 11 | |
| 12 | + private boolean fromServer; | |
| 13 | + | |
| 14 | + public SipTransactionInfo(SIPResponse response, boolean fromServer) { | |
| 15 | + this.callId = response.getCallIdHeader().getCallId(); | |
| 16 | + this.fromTag = response.getFromTag(); | |
| 17 | + this.toTag = response.getToTag(); | |
| 18 | + this.viaBranch = response.getTopmostViaHeader().getBranch(); | |
| 19 | + this.fromServer = fromServer; | |
| 20 | + } | |
| 21 | + | |
| 13 | 22 | public SipTransactionInfo(SIPResponse response) { |
| 14 | 23 | this.callId = response.getCallIdHeader().getCallId(); |
| 15 | 24 | this.fromTag = response.getFromTag(); |
| 16 | 25 | this.toTag = response.getToTag(); |
| 17 | 26 | this.viaBranch = response.getTopmostViaHeader().getBranch(); |
| 27 | + this.fromServer = true; | |
| 18 | 28 | } |
| 19 | 29 | |
| 20 | 30 | public SipTransactionInfo() { |
| ... | ... | @@ -51,4 +61,12 @@ public class SipTransactionInfo { |
| 51 | 61 | public void setViaBranch(String viaBranch) { |
| 52 | 62 | this.viaBranch = viaBranch; |
| 53 | 63 | } |
| 64 | + | |
| 65 | + public boolean isFromServer() { | |
| 66 | + return fromServer; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public void setFromServer(boolean fromServer) { | |
| 70 | + this.fromServer = fromServer; | |
| 71 | + } | |
| 54 | 72 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.session; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson2.JSON; | |
| 4 | 3 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 5 | 4 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 6 | 5 | import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; |
| ... | ... | @@ -52,8 +51,6 @@ public class VideoStreamSessionManager { |
| 52 | 51 | ssrcTransaction.setSsrc(ssrc); |
| 53 | 52 | ssrcTransaction.setMediaServerId(mediaServerId); |
| 54 | 53 | ssrcTransaction.setType(type); |
| 55 | - System.out.println(22222); | |
| 56 | - System.out.println(JSON.toJSONString(ssrcTransaction)); | |
| 57 | 54 | RedisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() |
| 58 | 55 | + "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction); |
| 59 | 56 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
| ... | ... | @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; |
| 7 | 7 | import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback; |
| 8 | +import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; | |
| 8 | 9 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 9 | 10 | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 10 | 11 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| ... | ... | @@ -14,8 +15,6 @@ import gov.nist.javax.sip.message.SIPRequest; |
| 14 | 15 | import javax.sip.InvalidArgumentException; |
| 15 | 16 | import javax.sip.SipException; |
| 16 | 17 | import java.text.ParseException; |
| 17 | -import javax.sip.message.Message; | |
| 18 | -import javax.sip.message.Request; | |
| 19 | 18 | |
| 20 | 19 | /** |
| 21 | 20 | * @description:设备能力接口,用于定义设备的控制、查询能力 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
| ... | ... | @@ -161,8 +161,8 @@ public class SIPRequestHeaderProvider { |
| 161 | 161 | |
| 162 | 162 | public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 163 | 163 | Request request = null; |
| 164 | - //请求行 | |
| 165 | 164 | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); |
| 165 | + | |
| 166 | 166 | // via |
| 167 | 167 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 168 | 168 | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); |
| ... | ... | @@ -170,11 +170,11 @@ public class SIPRequestHeaderProvider { |
| 170 | 170 | //from |
| 171 | 171 | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); |
| 172 | 172 | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); |
| 173 | - FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); | |
| 173 | + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.isFromServer()?transactionInfo.getFromTag():transactionInfo.getToTag()); | |
| 174 | 174 | //to |
| 175 | 175 | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress()); |
| 176 | 176 | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); |
| 177 | - ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); | |
| 177 | + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,transactionInfo.isFromServer()?transactionInfo.getToTag():transactionInfo.getFromTag()); | |
| 178 | 178 | |
| 179 | 179 | //Forwards |
| 180 | 180 | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| ... | ... | @@ -671,10 +671,10 @@ public class SIPCommander implements ISIPCommander { |
| 671 | 671 | @Override |
| 672 | 672 | public void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { |
| 673 | 673 | Request byteRequest = headerProvider.createByteRequest(device, channelId, sipTransactionInfo); |
| 674 | - sipSender.transmitRequest(device.getTransport(), byteRequest, null, okEvent); | |
| 674 | + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent); | |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - /** | |
| 677 | + /** | |
| 678 | 678 | * 语音广播 |
| 679 | 679 | * |
| 680 | 680 | * @param device 视频设备 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
| ... | ... | @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON; |
| 4 | 4 | import com.alibaba.fastjson2.JSONObject; |
| 5 | 5 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| 7 | +import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch; | |
| 7 | 8 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 8 | 9 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 9 | 10 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| ... | ... | @@ -134,69 +135,41 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In |
| 134 | 135 | param.put("udp_rtcp_timeout", sendRtpItem.isRtcp()? "1":"0"); |
| 135 | 136 | } |
| 136 | 137 | |
| 137 | - JSONObject jsonObject; | |
| 138 | - if (sendRtpItem.isTcpActive()) { | |
| 139 | - jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param); | |
| 138 | + if (mediaInfo == null) { | |
| 139 | + RequestPushStreamMsg requestPushStreamMsg = RequestPushStreamMsg.getInstance( | |
| 140 | + sendRtpItem.getMediaServerId(), sendRtpItem.getApp(), sendRtpItem.getStreamId(), | |
| 141 | + sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc(), sendRtpItem.isTcp(), | |
| 142 | + sendRtpItem.getLocalPort(), sendRtpItem.getPt(), sendRtpItem.isUsePs(), sendRtpItem.isOnlyAudio()); | |
| 143 | + redisGbPlayMsgListener.sendMsgForStartSendRtpStream(sendRtpItem.getServerId(), requestPushStreamMsg, json -> { | |
| 144 | + startSendRtpStreamHand(evt, sendRtpItem, parentPlatform, json, param, callIdHeader); | |
| 145 | + }); | |
| 140 | 146 | } else { |
| 141 | - param.put("is_udp", is_Udp); | |
| 142 | - param.put("dst_url", sendRtpItem.getIp()); | |
| 143 | - param.put("dst_port", sendRtpItem.getPort()); | |
| 144 | - jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param); | |
| 145 | - System.out.println(JSON.toJSONString(param)); | |
| 146 | - System.out.println(); | |
| 147 | - System.out.println(jsonObject); | |
| 148 | - } | |
| 149 | - | |
| 150 | - if (jsonObject == null) { | |
| 151 | - logger.error("RTP推流失败: 请检查ZLM服务"); | |
| 152 | - } else if (jsonObject.getInteger("code") == 0) { | |
| 153 | - logger.info("RTP推流成功[ {}/{} ],{}->{}:{}, ", param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port")); | |
| 154 | - } else { | |
| 155 | - logger.error("RTP推流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSON(param)); | |
| 156 | - if (sendRtpItem.isOnlyAudio()) { | |
| 157 | - // 语音对讲 | |
| 158 | - Device device = deviceService.getDevice(platformGbId); | |
| 159 | - if (device != null) { | |
| 160 | - try { | |
| 161 | - cmder.streamByeCmd(device, sendRtpItem.getChannelId(), sendRtpItem.getStreamId(), null); | |
| 162 | - } catch (SipException | ParseException | InvalidArgumentException | | |
| 163 | - SsrcTransactionNotFoundException e) { | |
| 164 | - logger.error("[命令发送失败] 停止语音对讲: {}", e.getMessage()); | |
| 165 | - } | |
| 166 | - } | |
| 167 | - | |
| 168 | - } else { | |
| 169 | - // 向上级平台 | |
| 170 | - try { | |
| 171 | - commanderForPlatform.streamByeCmd(parentPlatform, callIdHeader.getCallId()); | |
| 172 | - } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 173 | - logger.error("[命令发送失败] 国标级联, 回复BYE: {}", e.getMessage()); | |
| 174 | - } | |
| 175 | - } | |
| 176 | - if (mediaInfo == null) { | |
| 177 | - RequestPushStreamMsg requestPushStreamMsg = RequestPushStreamMsg.getInstance( | |
| 178 | - sendRtpItem.getMediaServerId(), sendRtpItem.getApp(), sendRtpItem.getStreamId(), | |
| 179 | - sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc(), sendRtpItem.isTcp(), | |
| 180 | - sendRtpItem.getLocalPort(), sendRtpItem.getPt(), sendRtpItem.isUsePs(), sendRtpItem.isOnlyAudio()); | |
| 181 | - redisGbPlayMsgListener.sendMsgForStartSendRtpStream(sendRtpItem.getServerId(), requestPushStreamMsg, json -> { | |
| 182 | - startSendRtpStreamHand(evt, sendRtpItem, parentPlatform, json, param, callIdHeader); | |
| 183 | - }); | |
| 184 | - } else { | |
| 185 | - // 如果是非严格模式,需要关闭端口占用 | |
| 186 | - JSONObject startSendRtpStreamResult = null; | |
| 187 | - if (sendRtpItem.getLocalPort() != 0) { | |
| 188 | - if (zlmrtpServerFactory.releasePort(mediaInfo, sendRtpItem.getSsrc())) { | |
| 189 | - startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param); | |
| 190 | - } | |
| 147 | + // 如果是非严格模式,需要关闭端口占用 | |
| 148 | + JSONObject startSendRtpStreamResult = null; | |
| 149 | + if (sendRtpItem.getLocalPort() != 0) { | |
| 150 | + if (zlmrtpServerFactory.releasePort(mediaInfo, sendRtpItem.getSsrc())) { | |
| 151 | + if (sendRtpItem.isTcpActive()) { | |
| 152 | + startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param); | |
| 191 | 153 | }else { |
| 154 | + param.put("is_udp", is_Udp); | |
| 155 | + param.put("dst_url", sendRtpItem.getIp()); | |
| 156 | + param.put("dst_port", sendRtpItem.getPort()); | |
| 192 | 157 | startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param); |
| 193 | 158 | } |
| 194 | - if (startSendRtpStreamResult != null) { | |
| 195 | - startSendRtpStreamHand(evt, sendRtpItem, parentPlatform, startSendRtpStreamResult, param, callIdHeader); | |
| 196 | - } | |
| 197 | 159 | } |
| 198 | - | |
| 199 | - | |
| 160 | + }else { | |
| 161 | + if (sendRtpItem.isTcpActive()) { | |
| 162 | + startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param); | |
| 163 | + }else { | |
| 164 | + param.put("is_udp", is_Udp); | |
| 165 | + param.put("dst_url", sendRtpItem.getIp()); | |
| 166 | + param.put("dst_port", sendRtpItem.getPort()); | |
| 167 | + startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param); | |
| 168 | + } | |
| 169 | + } | |
| 170 | + if (startSendRtpStreamResult != null) { | |
| 171 | + startSendRtpStreamHand(evt, sendRtpItem, parentPlatform, startSendRtpStreamResult, param, callIdHeader); | |
| 172 | + } | |
| 200 | 173 | } |
| 201 | 174 | } |
| 202 | 175 | private void startSendRtpStreamHand(RequestEvent evt, SendRtpItem sendRtpItem, ParentPlatform parentPlatform, |
| ... | ... | @@ -209,7 +182,16 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In |
| 209 | 182 | } else { |
| 210 | 183 | logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"), JSON.toJSONString(param)); |
| 211 | 184 | if (sendRtpItem.isOnlyAudio()) { |
| 212 | - // TODO 可能是语音对讲 | |
| 185 | + Device device = deviceService.getDevice(sendRtpItem.getDeviceId()); | |
| 186 | + AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); | |
| 187 | + if (audioBroadcastCatch != null) { | |
| 188 | + try { | |
| 189 | + cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null); | |
| 190 | + } catch (SipException | ParseException | InvalidArgumentException | | |
| 191 | + SsrcTransactionNotFoundException e) { | |
| 192 | + logger.error("[命令发送失败] 停止语音对讲: {}", e.getMessage()); | |
| 193 | + } | |
| 194 | + } | |
| 213 | 195 | }else { |
| 214 | 196 | // 向上级平台 |
| 215 | 197 | try { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
| ... | ... | @@ -98,6 +98,16 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In |
| 98 | 98 | if (sendRtpItem != null){ |
| 99 | 99 | logger.info("[收到bye] {}/{}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId()); |
| 100 | 100 | String streamId = sendRtpItem.getStreamId(); |
| 101 | + MediaServerItem mediaServerItem = mediaServerService.getOne(sendRtpItem.getMediaServerId()); | |
| 102 | + if (mediaServerItem == null) { | |
| 103 | + return; | |
| 104 | + } | |
| 105 | + | |
| 106 | + Boolean ready = zlmrtpServerFactory.isStreamReady(mediaServerItem, sendRtpItem.getApp(), streamId); | |
| 107 | + if (!ready) { | |
| 108 | + logger.info("[收到bye] 发现流{}/{}已经结束,不需处理", sendRtpItem.getApp(), sendRtpItem.getStreamId()); | |
| 109 | + return; | |
| 110 | + } | |
| 101 | 111 | Map<String, Object> param = new HashMap<>(); |
| 102 | 112 | param.put("vhost","__defaultVhost__"); |
| 103 | 113 | param.put("app",sendRtpItem.getApp()); |
| ... | ... | @@ -107,6 +117,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In |
| 107 | 117 | MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); |
| 108 | 118 | redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), callIdHeader.getCallId(), null); |
| 109 | 119 | zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param); |
| 120 | + | |
| 110 | 121 | int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId); |
| 111 | 122 | if (totalReaderCount <= 0) { |
| 112 | 123 | logger.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId); |
| ... | ... | @@ -131,6 +142,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In |
| 131 | 142 | redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel); |
| 132 | 143 | } |
| 133 | 144 | } |
| 145 | + | |
| 134 | 146 | playService.stopAudioBroadcast(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); |
| 135 | 147 | } |
| 136 | 148 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| ... | ... | @@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 11 | 11 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| 12 | 12 | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| 13 | 13 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 14 | +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; | |
| 14 | 15 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 15 | 16 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| 16 | 17 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| ... | ... | @@ -97,7 +98,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 97 | 98 | private IMediaServerService mediaServerService; |
| 98 | 99 | |
| 99 | 100 | @Autowired |
| 100 | - private IMediaService mediaService; | |
| 101 | + private ISIPCommander commander; | |
| 101 | 102 | |
| 102 | 103 | @Autowired |
| 103 | 104 | private ZLMRESTfulUtils zlmresTfulUtils; |
| ... | ... | @@ -1003,7 +1004,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 1003 | 1004 | String stream = device.getDeviceId() + "_" + audioBroadcastCatch.getChannelId(); |
| 1004 | 1005 | |
| 1005 | 1006 | CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); |
| 1006 | - sendRtpItem.setPlayType(InviteStreamType.PLAY); | |
| 1007 | + sendRtpItem.setPlayType(InviteStreamType.TALK); | |
| 1007 | 1008 | sendRtpItem.setCallId(callIdHeader.getCallId()); |
| 1008 | 1009 | sendRtpItem.setPlatformId(requesterId); |
| 1009 | 1010 | sendRtpItem.setStatus(1); |
| ... | ... | @@ -1017,12 +1018,14 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 1017 | 1018 | |
| 1018 | 1019 | Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream); |
| 1019 | 1020 | if (streamReady) { |
| 1020 | - SIPResponse sipResponse = sendOk(device, sendRtpItem, sdp, request, mediaServerItem, mediaTransmissionTCP, ssrc); | |
| 1021 | - // 添加事务信息 | |
| 1022 | - streamSession.put(device.getDeviceId(), audioBroadcastCatch.getChannelId(), request.getCallIdHeader().getCallId() | |
| 1023 | - , stream, sendRtpItem.getSsrc(), mediaServerItem.getId(), sipResponse, VideoStreamSessionManager.SessionType.broadcast ); | |
| 1021 | + sendOk(device, sendRtpItem, sdp, request, mediaServerItem, mediaTransmissionTCP, ssrc); | |
| 1024 | 1022 | }else { |
| 1025 | 1023 | logger.warn("[语音通话], 未发现待推送的流,app={},stream={}", app, stream); |
| 1024 | + try { | |
| 1025 | + responseAck(request, Response.GONE); | |
| 1026 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 1027 | + logger.error("[命令发送失败] 语音通话 回复410失败, {}", e.getMessage()); | |
| 1028 | + } | |
| 1026 | 1029 | playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId()); |
| 1027 | 1030 | } |
| 1028 | 1031 | } catch (SdpException e) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| ... | ... | @@ -525,17 +525,22 @@ public class ZLMHttpHookListener { |
| 525 | 525 | if (platform != null) { |
| 526 | 526 | commanderFroPlatform.streamByeCmd(platform, sendRtpItem); |
| 527 | 527 | }else { |
| 528 | - if ("talk".equals(param.getApp()) && sendRtpItem.isOnlyAudio()) { | |
| 528 | + if (sendRtpItem.isOnlyAudio()) { | |
| 529 | 529 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); |
| 530 | - if (device != null && audioBroadcastCatch != null) { | |
| 531 | -// cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null); | |
| 530 | + if (audioBroadcastCatch != null) { | |
| 531 | +// playService.stopAudioBroadcast(device.getDeviceId(), sendRtpItem.getChannelId()); | |
| 532 | + if ("talk".equals(param.getApp())) { | |
| 533 | +// cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null); | |
| 534 | + }else { | |
| 535 | +// cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null); | |
| 536 | + } | |
| 532 | 537 | } |
| 533 | - }else { | |
| 534 | - cmder.streamByeCmd(device, null, null, sendRtpItem.getCallId()); | |
| 535 | 538 | } |
| 536 | 539 | |
| 540 | + | |
| 541 | + | |
| 537 | 542 | } |
| 538 | - } catch (SipException | InvalidArgumentException | ParseException | SsrcTransactionNotFoundException e) { | |
| 543 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 539 | 544 | logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); |
| 540 | 545 | } |
| 541 | 546 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| ... | ... | @@ -1065,9 +1065,6 @@ public class PlayServiceImpl implements IPlayService { |
| 1065 | 1065 | if (device == null) { |
| 1066 | 1066 | return; |
| 1067 | 1067 | } |
| 1068 | -// if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) { | |
| 1069 | -// cmder.streamByeCmd(device, audioBroadcastCatch.getChannelId(), null, audioBroadcastCatch.getSipTransactionInfo().getCallId()); | |
| 1070 | -// } | |
| 1071 | 1068 | SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null); |
| 1072 | 1069 | if (sendRtpItem != null) { |
| 1073 | 1070 | redisCatchStorage.deleteSendRTPServer(deviceId, sendRtpItem.getChannelId(), null, null); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java
| ... | ... | @@ -73,8 +73,8 @@ public class RedisAlarmMsgListener implements MessageListener { |
| 73 | 73 | deviceAlarm.setAlarmPriority("1"); |
| 74 | 74 | deviceAlarm.setAlarmTime(DateUtil.getNowForISO8601()); |
| 75 | 75 | deviceAlarm.setAlarmType("1"); |
| 76 | - deviceAlarm.setLongitude(0); | |
| 77 | - deviceAlarm.setLatitude(0); | |
| 76 | + deviceAlarm.setLongitude(0D); | |
| 77 | + deviceAlarm.setLatitude(0D); | |
| 78 | 78 | |
| 79 | 79 | if (ObjectUtils.isEmpty(gbId)) { |
| 80 | 80 | // 发送给所有的上级 | ... | ... |