Commit 80d96042e7b6f2942585bde482f02a3392477033

Authored by 648540858
1 parent 12fa3b4c

优化语音对讲

src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java
@@ -35,7 +35,7 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> { @@ -35,7 +35,7 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> {
35 @Override 35 @Override
36 public Object beforeBodyWrite(Object body, @NotNull MethodParameter returnType, @NotNull MediaType selectedContentType, @NotNull Class<? extends HttpMessageConverter<?>> selectedConverterType, @NotNull ServerHttpRequest request, @NotNull ServerHttpResponse response) { 36 public Object beforeBodyWrite(Object body, @NotNull MethodParameter returnType, @NotNull MediaType selectedContentType, @NotNull Class<? extends HttpMessageConverter<?>> selectedConverterType, @NotNull ServerHttpRequest request, @NotNull ServerHttpResponse response) {
37 // 排除api文档的接口,这个接口不需要统一 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 for (String path : excludePath) { 39 for (String path : excludePath) {
40 if (request.getURI().getPath().startsWith(path)) { 40 if (request.getURI().getPath().startsWith(path)) {
41 return body; 41 return body;
@@ -62,8 +62,8 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice&lt;Object&gt; { @@ -62,8 +62,8 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice&lt;Object&gt; {
62 * 防止返回string时出错 62 * 防止返回string时出错
63 * @return 63 * @return
64 */ 64 */
65 - @Bean 65 + /*@Bean
66 public HttpMessageConverters custHttpMessageConverter() { 66 public HttpMessageConverters custHttpMessageConverter() {
67 return new HttpMessageConverters(new FastJsonHttpMessageConverter()); 67 return new HttpMessageConverters(new FastJsonHttpMessageConverter());
68 - } 68 + }*/
69 } 69 }
src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
@@ -86,7 +86,7 @@ public class MediaConfig{ @@ -86,7 +86,7 @@ public class MediaConfig{
86 86
87 public String getHookIp() { 87 public String getHookIp() {
88 if (ObjectUtils.isEmpty(hookIp)){ 88 if (ObjectUtils.isEmpty(hookIp)){
89 - return sipIp.split(",")[0]; 89 + return sipIp;
90 }else { 90 }else {
91 return hookIp; 91 return hookIp;
92 } 92 }
src/main/java/com/genersoft/iot/vmp/gb28181/bean/AudioBroadcastCatch.java
1 package com.genersoft.iot.vmp.gb28181.bean; 1 package com.genersoft.iot.vmp.gb28181.bean;
2 2
3 3
4 -import gov.nist.javax.sip.message.SIPRequest;  
5 import gov.nist.javax.sip.message.SIPResponse; 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,6 +73,6 @@ public class AudioBroadcastCatch {
77 } 73 }
78 74
79 public void setSipTransactionInfoByRequset(SIPResponse response) { 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 package com.genersoft.iot.vmp.gb28181.bean; 1 package com.genersoft.iot.vmp.gb28181.bean;
2 2
3 -import gov.nist.javax.sip.message.SIPRequest;  
4 import gov.nist.javax.sip.message.SIPResponse; 3 import gov.nist.javax.sip.message.SIPResponse;
5 4
6 public class SipTransactionInfo { 5 public class SipTransactionInfo {
@@ -10,11 +9,22 @@ public class SipTransactionInfo { @@ -10,11 +9,22 @@ public class SipTransactionInfo {
10 private String toTag; 9 private String toTag;
11 private String viaBranch; 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 public SipTransactionInfo(SIPResponse response) { 22 public SipTransactionInfo(SIPResponse response) {
14 this.callId = response.getCallIdHeader().getCallId(); 23 this.callId = response.getCallIdHeader().getCallId();
15 this.fromTag = response.getFromTag(); 24 this.fromTag = response.getFromTag();
16 this.toTag = response.getToTag(); 25 this.toTag = response.getToTag();
17 this.viaBranch = response.getTopmostViaHeader().getBranch(); 26 this.viaBranch = response.getTopmostViaHeader().getBranch();
  27 + this.fromServer = true;
18 } 28 }
19 29
20 public SipTransactionInfo() { 30 public SipTransactionInfo() {
@@ -51,4 +61,12 @@ public class SipTransactionInfo { @@ -51,4 +61,12 @@ public class SipTransactionInfo {
51 public void setViaBranch(String viaBranch) { 61 public void setViaBranch(String viaBranch) {
52 this.viaBranch = viaBranch; 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 package com.genersoft.iot.vmp.gb28181.session; 1 package com.genersoft.iot.vmp.gb28181.session;
2 2
3 -import com.alibaba.fastjson2.JSON;  
4 import com.genersoft.iot.vmp.common.VideoManagerConstants; 3 import com.genersoft.iot.vmp.common.VideoManagerConstants;
5 import com.genersoft.iot.vmp.conf.UserSetting; 4 import com.genersoft.iot.vmp.conf.UserSetting;
6 import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; 5 import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
@@ -52,8 +51,6 @@ public class VideoStreamSessionManager { @@ -52,8 +51,6 @@ public class VideoStreamSessionManager {
52 ssrcTransaction.setSsrc(ssrc); 51 ssrcTransaction.setSsrc(ssrc);
53 ssrcTransaction.setMediaServerId(mediaServerId); 52 ssrcTransaction.setMediaServerId(mediaServerId);
54 ssrcTransaction.setType(type); 53 ssrcTransaction.setType(type);
55 - System.out.println(22222);  
56 - System.out.println(JSON.toJSONString(ssrcTransaction));  
57 RedisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() 54 RedisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId()
58 + "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction); 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,6 +5,7 @@ import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
5 import com.genersoft.iot.vmp.gb28181.bean.Device; 5 import com.genersoft.iot.vmp.gb28181.bean.Device;
6 import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; 6 import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
7 import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback; 7 import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback;
  8 +import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
8 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; 9 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
9 import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; 10 import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
10 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; 11 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
@@ -14,8 +15,6 @@ import gov.nist.javax.sip.message.SIPRequest; @@ -14,8 +15,6 @@ import gov.nist.javax.sip.message.SIPRequest;
14 import javax.sip.InvalidArgumentException; 15 import javax.sip.InvalidArgumentException;
15 import javax.sip.SipException; 16 import javax.sip.SipException;
16 import java.text.ParseException; 17 import java.text.ParseException;
17 -import javax.sip.message.Message;  
18 -import javax.sip.message.Request;  
19 18
20 /** 19 /**
21 * @description:设备能力接口,用于定义设备的控制、查询能力 20 * @description:设备能力接口,用于定义设备的控制、查询能力
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
@@ -161,8 +161,8 @@ public class SIPRequestHeaderProvider { @@ -161,8 +161,8 @@ public class SIPRequestHeaderProvider {
161 161
162 public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException { 162 public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException {
163 Request request = null; 163 Request request = null;
164 - //请求行  
165 SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); 164 SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
  165 +
166 // via 166 // via
167 ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); 167 ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
168 ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); 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,11 +170,11 @@ public class SIPRequestHeaderProvider {
170 //from 170 //from
171 SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); 171 SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
172 Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); 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 //to 174 //to
175 SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress()); 175 SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress());
176 Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); 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 //Forwards 179 //Forwards
180 MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); 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,10 +671,10 @@ public class SIPCommander implements ISIPCommander {
671 @Override 671 @Override
672 public void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { 672 public void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
673 Request byteRequest = headerProvider.createByteRequest(device, channelId, sipTransactionInfo); 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 * @param device 视频设备 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,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
4 import com.alibaba.fastjson2.JSONObject; 4 import com.alibaba.fastjson2.JSONObject;
5 import com.genersoft.iot.vmp.conf.DynamicTask; 5 import com.genersoft.iot.vmp.conf.DynamicTask;
6 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; 6 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
  7 +import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch;
7 import com.genersoft.iot.vmp.gb28181.bean.Device; 8 import com.genersoft.iot.vmp.gb28181.bean.Device;
8 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; 9 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
9 import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; 10 import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
@@ -134,69 +135,41 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In @@ -134,69 +135,41 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
134 param.put("udp_rtcp_timeout", sendRtpItem.isRtcp()? "1":"0"); 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 } else { 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 }else { 153 }else {
  154 + param.put("is_udp", is_Udp);
  155 + param.put("dst_url", sendRtpItem.getIp());
  156 + param.put("dst_port", sendRtpItem.getPort());
192 startSendRtpStreamResult = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param); 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 private void startSendRtpStreamHand(RequestEvent evt, SendRtpItem sendRtpItem, ParentPlatform parentPlatform, 175 private void startSendRtpStreamHand(RequestEvent evt, SendRtpItem sendRtpItem, ParentPlatform parentPlatform,
@@ -209,7 +182,16 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In @@ -209,7 +182,16 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
209 } else { 182 } else {
210 logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"), JSON.toJSONString(param)); 183 logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"), JSON.toJSONString(param));
211 if (sendRtpItem.isOnlyAudio()) { 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 }else { 195 }else {
214 // 向上级平台 196 // 向上级平台
215 try { 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,6 +98,16 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
98 if (sendRtpItem != null){ 98 if (sendRtpItem != null){
99 logger.info("[收到bye] {}/{}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId()); 99 logger.info("[收到bye] {}/{}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId());
100 String streamId = sendRtpItem.getStreamId(); 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 Map<String, Object> param = new HashMap<>(); 111 Map<String, Object> param = new HashMap<>();
102 param.put("vhost","__defaultVhost__"); 112 param.put("vhost","__defaultVhost__");
103 param.put("app",sendRtpItem.getApp()); 113 param.put("app",sendRtpItem.getApp());
@@ -107,6 +117,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In @@ -107,6 +117,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
107 MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); 117 MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
108 redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), callIdHeader.getCallId(), null); 118 redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), callIdHeader.getCallId(), null);
109 zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param); 119 zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param);
  120 +
110 int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId); 121 int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId);
111 if (totalReaderCount <= 0) { 122 if (totalReaderCount <= 0) {
112 logger.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId); 123 logger.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId);
@@ -131,6 +142,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In @@ -131,6 +142,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
131 redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel); 142 redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel);
132 } 143 }
133 } 144 }
  145 +
134 playService.stopAudioBroadcast(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); 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,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
11 import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; 11 import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
12 import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; 12 import com.genersoft.iot.vmp.gb28181.transmit.SIPSender;
13 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; 13 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
  14 +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
14 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; 15 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
15 import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; 16 import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
16 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; 17 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
@@ -97,7 +98,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @@ -97,7 +98,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
97 private IMediaServerService mediaServerService; 98 private IMediaServerService mediaServerService;
98 99
99 @Autowired 100 @Autowired
100 - private IMediaService mediaService; 101 + private ISIPCommander commander;
101 102
102 @Autowired 103 @Autowired
103 private ZLMRESTfulUtils zlmresTfulUtils; 104 private ZLMRESTfulUtils zlmresTfulUtils;
@@ -1003,7 +1004,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @@ -1003,7 +1004,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
1003 String stream = device.getDeviceId() + "_" + audioBroadcastCatch.getChannelId(); 1004 String stream = device.getDeviceId() + "_" + audioBroadcastCatch.getChannelId();
1004 1005
1005 CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); 1006 CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME);
1006 - sendRtpItem.setPlayType(InviteStreamType.PLAY); 1007 + sendRtpItem.setPlayType(InviteStreamType.TALK);
1007 sendRtpItem.setCallId(callIdHeader.getCallId()); 1008 sendRtpItem.setCallId(callIdHeader.getCallId());
1008 sendRtpItem.setPlatformId(requesterId); 1009 sendRtpItem.setPlatformId(requesterId);
1009 sendRtpItem.setStatus(1); 1010 sendRtpItem.setStatus(1);
@@ -1017,12 +1018,14 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @@ -1017,12 +1018,14 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
1017 1018
1018 Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream); 1019 Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream);
1019 if (streamReady) { 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 }else { 1022 }else {
1025 logger.warn("[语音通话], 未发现待推送的流,app={},stream={}", app, stream); 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 playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId()); 1029 playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
1027 } 1030 }
1028 } catch (SdpException e) { 1031 } catch (SdpException e) {
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -525,17 +525,22 @@ public class ZLMHttpHookListener { @@ -525,17 +525,22 @@ public class ZLMHttpHookListener {
525 if (platform != null) { 525 if (platform != null) {
526 commanderFroPlatform.streamByeCmd(platform, sendRtpItem); 526 commanderFroPlatform.streamByeCmd(platform, sendRtpItem);
527 }else { 527 }else {
528 - if ("talk".equals(param.getApp()) && sendRtpItem.isOnlyAudio()) { 528 + if (sendRtpItem.isOnlyAudio()) {
529 AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); 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 logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); 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,9 +1065,6 @@ public class PlayServiceImpl implements IPlayService {
1065 if (device == null) { 1065 if (device == null) {
1066 return; 1066 return;
1067 } 1067 }
1068 -// if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) {  
1069 -// cmder.streamByeCmd(device, audioBroadcastCatch.getChannelId(), null, audioBroadcastCatch.getSipTransactionInfo().getCallId());  
1070 -// }  
1071 SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null); 1068 SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
1072 if (sendRtpItem != null) { 1069 if (sendRtpItem != null) {
1073 redisCatchStorage.deleteSendRTPServer(deviceId, sendRtpItem.getChannelId(), null, null); 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,8 +73,8 @@ public class RedisAlarmMsgListener implements MessageListener {
73 deviceAlarm.setAlarmPriority("1"); 73 deviceAlarm.setAlarmPriority("1");
74 deviceAlarm.setAlarmTime(DateUtil.getNowForISO8601()); 74 deviceAlarm.setAlarmTime(DateUtil.getNowForISO8601());
75 deviceAlarm.setAlarmType("1"); 75 deviceAlarm.setAlarmType("1");
76 - deviceAlarm.setLongitude(0);  
77 - deviceAlarm.setLatitude(0); 76 + deviceAlarm.setLongitude(0D);
  77 + deviceAlarm.setLatitude(0D);
78 78
79 if (ObjectUtils.isEmpty(gbId)) { 79 if (ObjectUtils.isEmpty(gbId)) {
80 // 发送给所有的上级 80 // 发送给所有的上级