Commit ecf84bb0f1952c4a044ff6c8aa18226b31593f3f

Authored by 648540858
1 parent f223aad7

合并主线

Showing 28 changed files with 231 additions and 350 deletions
src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java
... ... @@ -223,8 +223,8 @@ public class StreamInfo implements Serializable, Cloneable{
223 223 }
224 224 }
225 225  
226   - public void setRtc(String host, int port, int sslPort, String app, String stream, String callIdParam) {
227   - String file = String.format("index/api/webrtc?app=%s&stream=%s&type=play%s", app, stream, callIdParam);
  226 + public void setRtc(String host, int port, int sslPort, String app, String stream, String callIdParam, boolean isPlay) {
  227 + String file = String.format("index/api/webrtc?app=%s&stream=%s&type=%s%s", app, stream, callIdParam, isPlay?"play":"push");
228 228 this.rtc = new StreamURL("http", host, port, file);
229 229 if (sslPort != 0) {
230 230 this.rtcs = new StreamURL("https", host, sslPort, file);
... ...
src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
... ... @@ -94,9 +94,4 @@ public class SipConfig {
94 94 this.alarm = alarm;
95 95 }
96 96  
97   - public void getLocalIp(String deviceLocalIp) {
98   - if (ObjectUtils.isEmpty(deviceLocalIp)) {
99   -
100   - }
101   - }
102 97 }
... ...
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
... ... @@ -31,7 +31,7 @@ public class UserSetting {
31 31  
32 32 private Boolean logInDatebase = Boolean.TRUE;
33 33  
34   - private Boolean usePushingAsStatus = Boolean.TRUE;
  34 + private Boolean usePushingAsStatus = Boolean.FALSE;
35 35  
36 36 private Boolean useSourceIpAsStreamIp = Boolean.FALSE;
37 37  
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/session/AudioBroadcastManager.java
... ... @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.session;
2 2  
3 3 import com.genersoft.iot.vmp.conf.SipConfig;
4 4 import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch;
  5 +import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
5 6 import org.springframework.beans.factory.annotation.Autowired;
6 7 import org.springframework.stereotype.Component;
7 8  
... ... @@ -27,11 +28,20 @@ public class AudioBroadcastManager {
27 28 }
28 29  
29 30 public void update(AudioBroadcastCatch audioBroadcastCatch) {
30   - data.put(audioBroadcastCatch.getDeviceId() + audioBroadcastCatch.getChannelId(), audioBroadcastCatch);
  31 + if (SipUtils.isFrontEnd(audioBroadcastCatch.getDeviceId())) {
  32 + data.put(audioBroadcastCatch.getDeviceId(), audioBroadcastCatch);
  33 + }else {
  34 + data.put(audioBroadcastCatch.getDeviceId() + audioBroadcastCatch.getChannelId(), audioBroadcastCatch);
  35 + }
31 36 }
32 37  
33 38 public void del(String deviceId, String channelId) {
34   - data.remove(deviceId + channelId);
  39 + if (SipUtils.isFrontEnd(deviceId)) {
  40 + data.remove(deviceId);
  41 + }else {
  42 + data.remove(deviceId + channelId);
  43 + }
  44 +
35 45 }
36 46  
37 47 public void delByDeviceId(String deviceId) {
... ... @@ -50,15 +60,22 @@ public class AudioBroadcastManager {
50 60  
51 61 public boolean exit(String deviceId, String channelId) {
52 62 for (String key : data.keySet()) {
53   - if (key.equals(deviceId + channelId)) {
54   - return true;
  63 + if (SipUtils.isFrontEnd(deviceId)) {
  64 + return key.equals(deviceId);
  65 + }else {
  66 + return key.equals(deviceId + channelId);
55 67 }
56 68 }
57 69 return false;
58 70 }
59 71  
60 72 public AudioBroadcastCatch get(String deviceId, String channelId) {
61   - AudioBroadcastCatch audioBroadcastCatch = data.get(deviceId + channelId);
  73 + AudioBroadcastCatch audioBroadcastCatch;
  74 + if (SipUtils.isFrontEnd(deviceId)) {
  75 + audioBroadcastCatch = data.get(deviceId);
  76 + }else {
  77 + audioBroadcastCatch = data.get(deviceId + channelId);
  78 + }
62 79 if (audioBroadcastCatch == null) {
63 80 Stream<AudioBroadcastCatch> allAudioBroadcastCatchStreamForDevice = data.values().stream().filter(
64 81 audioBroadcastCatchItem -> Objects.equals(audioBroadcastCatchItem.getDeviceId(), deviceId));
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
... ... @@ -15,6 +15,7 @@ import javax.sip.SipException;
15 15 import javax.sip.message.Message;
16 16 import javax.sip.message.Request;
17 17 import java.text.ParseException;
  18 +import javax.sip.message.Message;
18 19 import javax.sip.message.Request;
19 20  
20 21 /**
... ... @@ -361,4 +362,5 @@ public interface ISIPCommander {
361 362 */
362 363 void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException;
363 364  
  365 +
364 366 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
... ... @@ -318,32 +318,32 @@ public class SIPRequestHeaderProvider {
318 318 public Request createBroadcastMessageRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
319 319 Request request = null;
320 320 // sipuri
321   - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
  321 + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
322 322 // via
323 323 ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
324   - ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
  324 + ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
325 325 viaHeader.setRPort();
326 326 viaHeaders.add(viaHeader);
327 327 // from
328   - SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
329   - Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
330   - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag);
  328 + SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
  329 + Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
  330 + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag);
331 331 // to
332   - SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
333   - Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
334   - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag);
  332 + SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
  333 + Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
  334 + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, toTag);
335 335  
336 336 // Forwards
337   - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
  337 + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
338 338 // ceq
339   - CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
  339 + CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
340 340  
341   - ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
  341 + ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
342 342  
343   - request = sipFactory.createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
  343 + request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
344 344 toHeader, viaHeaders, maxForwards, contentTypeHeader, content);
345 345  
346   - request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
  346 + request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
347 347  
348 348 return request;
349 349 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
... ... @@ -19,15 +19,11 @@ import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
19 19 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
20 20 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
21 21 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamPush;
22   -import com.genersoft.iot.vmp.utils.DateUtil;
23   -import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
24   -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
25 22 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
26 23 import com.genersoft.iot.vmp.service.IMediaServerService;
27 24 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
28   -import com.genersoft.iot.vmp.utils.GitUtil;
29   -import gov.nist.javax.sip.SipProviderImpl;
30 25 import com.genersoft.iot.vmp.utils.DateUtil;
  26 +import com.genersoft.iot.vmp.utils.GitUtil;
31 27 import gov.nist.javax.sip.message.SIPRequest;
32 28 import gov.nist.javax.sip.message.SIPResponse;
33 29 import org.slf4j.Logger;
... ... @@ -41,8 +37,6 @@ import javax.sip.InvalidArgumentException;
41 37 import javax.sip.ResponseEvent;
42 38 import javax.sip.SipException;
43 39 import javax.sip.header.CallIdHeader;
44   -import javax.sip.*;
45   -import javax.sip.header.*;
46 40 import javax.sip.message.Request;
47 41 import java.text.ParseException;
48 42  
... ... @@ -78,6 +72,9 @@ public class SIPCommander implements ISIPCommander {
78 72 @Autowired
79 73 private ZlmHttpHookSubscribe subscribe;
80 74  
  75 + @Autowired
  76 + private GitUtil gitUtil;
  77 +
81 78  
82 79  
83 80 @Autowired
... ... @@ -607,8 +604,7 @@ public class SIPCommander implements ISIPCommander {
607 604 }
608 605 });
609 606  
610   - CallIdHeader callIdHeader = device.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId()
611   - : udpSipProvider.getNewCallId();
  607 + CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()), device.getTransport());
612 608 callIdHeader.setCallId(callId);
613 609 HookSubscribeForStreamPush hookSubscribeForStreamPush = HookSubscribeFactory.on_publish("rtp", stream, null, mediaServerItem.getId());
614 610 subscribe.addSubscribe(hookSubscribeForStreamPush, (MediaServerItem mediaServerItemInUse, JSONObject json) -> {
... ... @@ -633,7 +629,7 @@ public class SIPCommander implements ISIPCommander {
633 629 content.append("f=v/////a/1/8/1" + "\r\n");
634 630  
635 631 Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(), callIdHeader);
636   - transmitRequest(device.getTransport(), request, (e -> {
  632 + sipSender.transmitRequest(device.getTransport(), request, (e -> {
637 633 streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
638 634 mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
639 635 errorEvent.response(e);
... ... @@ -675,7 +671,7 @@ public class SIPCommander implements ISIPCommander {
675 671 @Override
676 672 public synchronized void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException {
677 673 Request byteRequest = headerProvider.createByteRequest(device, channelId, sipTransactionInfo);
678   - transmitRequest(device.getTransport(), byteRequest, null, okEvent);
  674 + sipSender.transmitRequest(device.getTransport(), byteRequest, null, okEvent);
679 675 }
680 676  
681 677 /**
... ... @@ -695,10 +691,8 @@ public class SIPCommander implements ISIPCommander {
695 691 broadcastXml.append("<TargetID>" + channelId + "</TargetID>\r\n");
696 692 broadcastXml.append("</Notify>\r\n");
697 693  
698   -
699   -
700 694 Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
701   - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request);
  695 + sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent);
702 696  
703 697 }
704 698  
... ... @@ -1342,8 +1336,6 @@ public class SIPCommander implements ISIPCommander {
1342 1336  
1343 1337  
1344 1338  
1345   -
1346   -
1347 1339 /**
1348 1340 * 回放暂停
1349 1341 */
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
1 1 package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
2 2  
3 3 import com.alibaba.fastjson2.JSON;
4   -import com.alibaba.fastjson2.JSONObject;
5 4 import com.genersoft.iot.vmp.gb28181.SipLayer;
6 5 import com.genersoft.iot.vmp.gb28181.bean.*;
7 6 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
... ... @@ -9,13 +8,13 @@ import com.genersoft.iot.vmp.gb28181.transmit.SIPSender;
9 8 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
10 9 import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider;
11 10 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
12   -import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
13   -import com.genersoft.iot.vmp.utils.DateUtil;
14 11 import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
15 12 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
16 13 import com.genersoft.iot.vmp.service.IMediaServerService;
17 14 import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
18 15 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  16 +import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
  17 +import com.genersoft.iot.vmp.utils.DateUtil;
19 18 import gov.nist.javax.sip.message.MessageFactoryImpl;
20 19 import gov.nist.javax.sip.message.SIPRequest;
21 20 import org.slf4j.Logger;
... ... @@ -26,10 +25,10 @@ import org.springframework.lang.Nullable;
26 25 import org.springframework.stereotype.Component;
27 26 import org.springframework.util.ObjectUtils;
28 27  
29   -
30   -import com.genersoft.iot.vmp.utils.DateUtil;
31   -import javax.sip.*;
32   -import javax.sip.header.*;
  28 +import javax.sip.InvalidArgumentException;
  29 +import javax.sip.SipException;
  30 +import javax.sip.header.CallIdHeader;
  31 +import javax.sip.header.WWWAuthenticateHeader;
33 32 import javax.sip.message.Request;
34 33 import java.text.ParseException;
35 34 import java.util.ArrayList;
... ... @@ -629,21 +628,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
629 628 logger.info("[向上级发送BYE], sendRtpItem 为NULL");
630 629 return;
631 630 }
632   - if (parentPlatform == null) {
  631 + if (platform == null) {
633 632 logger.info("[向上级发送BYE], platform 为NULL");
634 633 return;
635 634 }
636   - logger.info("[向上级发送BYE], {}/{}", parentPlatform.getServerGBId(), sendRtpItem.getChannelId());
  635 + logger.info("[向上级发送BYE], {}/{}", platform.getServerGBId(), sendRtpItem.getChannelId());
637 636 String mediaServerId = sendRtpItem.getMediaServerId();
638 637 MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
639 638 if (mediaServerItem != null) {
640 639 mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc());
641 640 zlmrtpServerFactory.closeRtpServer(mediaServerItem, sendRtpItem.getStreamId());
642 641 }
643   - SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(parentPlatform, sendRtpItem);
  642 + SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(platform, sendRtpItem);
644 643 if (byeRequest == null) {
645 644 logger.warn("[向上级发送bye]:无法创建 byeRequest");
646 645 }
647   - sipSender.transmitRequest(parentPlatform.getDeviceIp(),byeRequest);
  646 + sipSender.transmitRequest(platform.getDeviceIp(),byeRequest);
648 647 }
649 648 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
... ... @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request;
2 2  
3 3 import com.genersoft.iot.vmp.conf.SipConfig;
4 4 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
  5 +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
5 6 import com.genersoft.iot.vmp.gb28181.transmit.SIPSender;
6 7 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
7 8 import gov.nist.javax.sip.SipProviderImpl;
... ... @@ -17,6 +18,7 @@ import org.slf4j.Logger;
17 18 import org.slf4j.LoggerFactory;
18 19 import org.springframework.beans.factory.annotation.Autowired;
19 20 import org.springframework.beans.factory.annotation.Qualifier;
  21 +import org.springframework.security.core.parameters.P;
20 22  
21 23 import javax.sip.*;
22 24 import javax.sip.address.Address;
... ... @@ -93,52 +95,6 @@ public abstract class SIPRequestProcessorParent {
93 95 return responseAck(sipRequest, statusCode, msg, null);
94 96 }
95 97  
96   -// public SIPResponse responseAck(ServerTransaction serverTransaction, int statusCode, String msg, ResponseAckExtraParam responseAckExtraParam) throws SipException, InvalidArgumentException, ParseException {
97   -// if (serverTransaction == null) {
98   -// logger.warn("[回复消息] ServerTransaction 为null");
99   -// return null;
100   -// }
101   -// ToHeader toHeader = (ToHeader) serverTransaction.getRequest().getHeader(ToHeader.NAME);
102   -// if (toHeader.getTag() == null) {
103   -// toHeader.setTag(SipUtils.getNewTag());
104   -// }
105   -// SIPResponse response = (SIPResponse)getMessageFactory().createResponse(statusCode, serverTransaction.getRequest());
106   -// if (msg != null) {
107   -// response.setReasonPhrase(msg);
108   -// }
109   -// if (responseAckExtraParam != null) {
110   -// if (responseAckExtraParam.sipURI != null && serverTransaction.getRequest().getMethod().equals(Request.INVITE)) {
111   -// logger.debug("responseSdpAck SipURI: {}:{}", responseAckExtraParam.sipURI.getHost(), responseAckExtraParam.sipURI.getPort());
112   -// Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(
113   -// SipFactory.getInstance().createAddressFactory().createSipURI(responseAckExtraParam.sipURI.getUser(), responseAckExtraParam.sipURI.getHost()+":"+responseAckExtraParam.sipURI.getPort()
114   -// ));
115   -// response.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress));
116   -// }
117   -// if (responseAckExtraParam.contentTypeHeader != null) {
118   -// response.setContent(responseAckExtraParam.content, responseAckExtraParam.contentTypeHeader);
119   -// }
120   -//
121   -// if (serverTransaction.getRequest().getMethod().equals(Request.SUBSCRIBE)) {
122   -// if (responseAckExtraParam.expires == -1) {
123   -// logger.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header");
124   -// }else {
125   -// ExpiresHeader expiresHeader = SipFactory.getInstance().createHeaderFactory().createExpiresHeader(responseAckExtraParam.expires);
126   -// response.addHeader(expiresHeader);
127   -// }
128   -// }
129   -// }else {
130   -// if (serverTransaction.getRequest().getMethod().equals(Request.SUBSCRIBE)) {
131   -// logger.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header");
132   -// }
133   -// }
134   -// serverTransaction.sendResponse(response);
135   -// if (statusCode >= 200 && !"NOTIFY".equalsIgnoreCase(serverTransaction.getRequest().getMethod())) {
136   -// if (serverTransaction.getDialog() != null) {
137   -// serverTransaction.getDialog().delete();
138   -// }
139   -// }
140   -// return response;
141   -// }
142 98  
143 99 public SIPResponse responseAck(SIPRequest sipRequest, int statusCode, String msg, ResponseAckExtraParam responseAckExtraParam) throws SipException, InvalidArgumentException, ParseException {
144 100 if (sipRequest.getToHeader().getTag() == null) {
... ... @@ -182,6 +138,8 @@ public abstract class SIPRequestProcessorParent {
182 138 return response;
183 139 }
184 140  
  141 +
  142 +
185 143 /**
186 144 * 回复带sdp的200
187 145 */
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
... ... @@ -152,10 +152,10 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In
152 152 } else if (jsonObject.getInteger("code") == 0) {
153 153 logger.info("RTP推流成功[ {}/{} ],{}->{}:{}, ", param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port"));
154 154 } else {
155   - logger.error("RTP推流失败: {}, 参数:{}", jsonObject.getString("msg"), JSONObject.toJSON(param));
  155 + logger.error("RTP推流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSON(param));
156 156 if (sendRtpItem.isOnlyAudio()) {
157 157 // 语音对讲
158   - Device device = deviceService.queryDevice(platformGbId);
  158 + Device device = deviceService.getDevice(platformGbId);
159 159 if (device != null) {
160 160 try {
161 161 cmder.streamByeCmd(device, sendRtpItem.getChannelId(), sendRtpItem.getStreamId(), null);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
... ... @@ -111,7 +111,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
111 111 if (totalReaderCount <= 0) {
112 112 logger.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId);
113 113 if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) {
114   - Device device = deviceService.queryDevice(sendRtpItem.getDeviceId());
  114 + Device device = deviceService.getDevice(sendRtpItem.getDeviceId());
115 115 if (device == null) {
116 116 logger.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId);
117 117 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
... ... @@ -4,19 +4,14 @@ import com.alibaba.fastjson2.JSONObject;
4 4 import com.genersoft.iot.vmp.conf.DynamicTask;
5 5 import com.genersoft.iot.vmp.conf.SipConfig;
6 6 import com.genersoft.iot.vmp.conf.UserSetting;
7   -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
8 7 import com.genersoft.iot.vmp.gb28181.bean.*;
9 8 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
10 9 import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
11 10 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
12 11 import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
  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.callback.RequestMessage;
15   -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
16 14 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
17   -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
18   -import com.genersoft.iot.vmp.gb28181.transmit.SIPSender;
19   -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
20 15 import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
21 16 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
22 17 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
... ... @@ -25,11 +20,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
25 20 import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
26 21 import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
27 22 import com.genersoft.iot.vmp.media.zlm.dto.*;
28   -import com.genersoft.iot.vmp.service.IMediaServerService;
29   -import com.genersoft.iot.vmp.service.IMediaService;
30   -import com.genersoft.iot.vmp.service.IPlayService;
31   -import com.genersoft.iot.vmp.service.IStreamProxyService;
32   -import com.genersoft.iot.vmp.service.IStreamPushService;
  23 +import com.genersoft.iot.vmp.service.*;
33 24 import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
34 25 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
35 26 import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener;
... ... @@ -37,8 +28,6 @@ import com.genersoft.iot.vmp.service.redisMsg.RedisPushStreamResponseListener;
37 28 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
38 29 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
39 30 import com.genersoft.iot.vmp.utils.DateUtil;
40   -import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
41   -import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
42 31 import gov.nist.javax.sdp.TimeDescriptionImpl;
43 32 import gov.nist.javax.sdp.fields.TimeField;
44 33 import gov.nist.javax.sip.message.SIPRequest;
... ... @@ -530,10 +519,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
530 519  
531 520 // 写入redis, 超时时回复
532 521 redisCatchStorage.updateSendRTPSever(sendRtpItem);
533   - MediaServerItem finalMediaServerItem = mediaServerItem;
534 522 playService.play(mediaServerItem, ssrcInfo, device, channelId, hookEvent, errorEvent, (code, msg) -> {
535   - logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId);
536   - redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null);
  523 + logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, finalChannelId);
  524 + redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), finalChannelId, callIdHeader.getCallId(), null);
537 525 });
538 526 } else {
539 527 sendRtpItem.setStreamId(playTransaction.getStream());
... ... @@ -908,13 +896,12 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
908 896 if (audioBroadcastCatch == null) {
909 897 logger.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId);
910 898 try {
911   - responseAck(serverTransaction, Response.FORBIDDEN);
  899 + responseAck(request, Response.FORBIDDEN);
912 900 } catch (SipException | InvalidArgumentException | ParseException e) {
913 901 logger.error("[命令发送失败] 来自设备的Invite请求非语音广播 FORBIDDEN: {}", e.getMessage());
914 902 }
915 903 return;
916 904 }
917   - Request request = serverTransaction.getRequest();
918 905 if (device != null) {
919 906 logger.info("收到设备" + requesterId + "的语音广播Invite请求");
920 907 try {
... ... @@ -985,7 +972,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
985 972 if (mediaServerItem == null) {
986 973 logger.warn("未找到可用的zlm");
987 974 try {
988   - responseAck(serverTransaction, Response.BUSY_HERE);
  975 + responseAck(request, Response.BUSY_HERE);
989 976 } catch (SipException | InvalidArgumentException | ParseException e) {
990 977 logger.error("[命令发送失败] invite 未找到可用的zlm: {}", e.getMessage());
991 978 }
... ... @@ -997,7 +984,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
997 984 if (sendRtpItem == null) {
998 985 logger.warn("服务器端口资源不足");
999 986 try {
1000   - responseAck(serverTransaction, Response.BUSY_HERE);
  987 + responseAck(request, Response.BUSY_HERE);
1001 988 } catch (SipException | InvalidArgumentException | ParseException e) {
1002 989 logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage());
1003 990 }
... ... @@ -1024,7 +1011,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
1024 1011  
1025 1012 Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream);
1026 1013 if (streamReady) {
1027   - sendOk(device, sendRtpItem, sdp, serverTransaction, mediaServerItem, mediaTransmissionTCP, ssrc);
  1014 + sendOk(device, sendRtpItem, sdp, request, mediaServerItem, mediaTransmissionTCP, ssrc);
1028 1015 }else {
1029 1016 logger.warn("[语音通话], 未发现待推送的流,app={},stream={}", app, stream);
1030 1017 playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
... ... @@ -1042,7 +1029,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
1042 1029 }
1043 1030 }
1044 1031  
1045   - void sendOk(Device device, SendRtpItem sendRtpItem, SessionDescription sdp, ServerTransaction serverTransaction, MediaServerItem mediaServerItem, boolean mediaTransmissionTCP, String ssrc){
  1032 + void sendOk(Device device, SendRtpItem sendRtpItem, SessionDescription sdp, SIPRequest request, MediaServerItem mediaServerItem, boolean mediaTransmissionTCP, String ssrc){
1046 1033 try {
1047 1034 sendRtpItem.setStatus(2);
1048 1035 redisCatchStorage.updateSendRTPSever(sendRtpItem);
... ... @@ -1078,7 +1065,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
1078 1065 parentPlatform.setServerPort(device.getPort());
1079 1066 parentPlatform.setServerGBId(device.getDeviceId());
1080 1067  
1081   - SIPResponse sipResponse = responseSdpAck(serverTransaction, content.toString(), parentPlatform);
  1068 + SIPResponse sipResponse = responseSdpAck(request, content.toString(), parentPlatform);
1082 1069  
1083 1070 AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(device.getDeviceId(), sendRtpItem.getChannelId());
1084 1071  
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
... ... @@ -101,33 +101,38 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
101 101 if (!taskQueueHandlerRun) {
102 102 taskQueueHandlerRun = true;
103 103 taskExecutor.execute(()-> {
104   - while (!taskQueue.isEmpty()) {
105   - try {
106   - HandlerCatchData take = taskQueue.poll();
107   - Element rootElement = getRootElement(take.getEvt());
108   - if (rootElement == null) {
109   - logger.error("处理NOTIFY消息时未获取到消息体,{}", take.getEvt().getRequest());
110   - continue;
  104 + try {
  105 + while (!taskQueue.isEmpty()) {
  106 + try {
  107 + HandlerCatchData take = taskQueue.poll();
  108 + Element rootElement = getRootElement(take.getEvt());
  109 + if (rootElement == null) {
  110 + logger.error("处理NOTIFY消息时未获取到消息体,{}", take.getEvt().getRequest());
  111 + continue;
  112 + }
  113 + String cmd = XmlUtil.getText(rootElement, "CmdType");
  114 +
  115 + if (CmdType.CATALOG.equals(cmd)) {
  116 + logger.info("接收到Catalog通知");
  117 + processNotifyCatalogList(take.getEvt());
  118 + } else if (CmdType.ALARM.equals(cmd)) {
  119 + logger.info("接收到Alarm通知");
  120 + processNotifyAlarm(take.getEvt());
  121 + } else if (CmdType.MOBILE_POSITION.equals(cmd)) {
  122 + logger.info("接收到MobilePosition通知");
  123 + processNotifyMobilePosition(take.getEvt());
  124 + } else {
  125 + logger.info("接收到消息:" + cmd);
  126 + }
  127 + } catch (DocumentException e) {
  128 + logger.error("处理NOTIFY消息时错误", e);
111 129 }
112   - String cmd = XmlUtil.getText(rootElement, "CmdType");
113   -
114   - if (CmdType.CATALOG.equals(cmd)) {
115   - logger.info("接收到Catalog通知");
116   - processNotifyCatalogList(take.getEvt());
117   - } else if (CmdType.ALARM.equals(cmd)) {
118   - logger.info("接收到Alarm通知");
119   - processNotifyAlarm(take.getEvt());
120   - } else if (CmdType.MOBILE_POSITION.equals(cmd)) {
121   - logger.info("接收到MobilePosition通知");
122   - processNotifyMobilePosition(take.getEvt());
123   - } else {
124   - logger.info("接收到消息:" + cmd);
125   - }
126   - } catch (DocumentException e) {
127   - logger.error("处理NOTIFY消息时错误", e);
128 130 }
  131 + }catch (Exception e) {
  132 + logger.error("处理NOTIFY消息时错误", e);
  133 + }finally {
  134 + taskQueueHandlerRun = false;
129 135 }
130   - taskQueueHandlerRun = false;
131 136 });
132 137 }
133 138 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
... ... @@ -120,13 +120,6 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
120 120  
121 121 if (request.getExpires() == null) {
122 122 response = getMessageFactory().createResponse(Response.BAD_REQUEST, request);
123   - if (evt.getDialog() != null ) {
124   - if (evt.getDialog().isServer()) {
125   - ServerTransaction serverTransaction = getServerTransaction(evt);
126   - serverTransaction.sendResponse(response);
127   - serverTransaction.getDialog().delete();
128   - }
129   - }
130 123 sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
131 124 return;
132 125 }
... ... @@ -185,12 +178,4 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
185 178 e.printStackTrace();
186 179 }
187 180 }
188   -
189   - private void sendResponse(RequestEvent evt, Response response) throws InvalidArgumentException, SipException {
190   - ServerTransaction serverTransaction = getServerTransaction(evt);
191   - serverTransaction.sendResponse(response);
192   - if (serverTransaction.getDialog() != null) {
193   - serverTransaction.getDialog().delete();
194   - }
195   - }
196 181 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java
... ... @@ -3,15 +3,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message;
3 3 import com.genersoft.iot.vmp.gb28181.bean.Device;
4 4 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
5 5 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
6   -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.AckRequestProcessor;
  6 +import gov.nist.javax.sip.message.SIPRequest;
7 7 import org.dom4j.Element;
8 8 import org.slf4j.Logger;
9 9 import org.slf4j.LoggerFactory;
10   -import org.springframework.beans.factory.annotation.Autowired;
11 10  
12 11 import javax.sip.InvalidArgumentException;
13 12 import javax.sip.RequestEvent;
14   -import javax.sip.ServerTransaction;
15 13 import javax.sip.SipException;
16 14 import javax.sip.message.Response;
17 15 import java.text.ParseException;
... ... @@ -34,7 +32,11 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
34 32 public void handForDevice(RequestEvent evt, Device device, Element element) {
35 33 String cmd = getText(element, "CmdType");
36 34 if (cmd == null) {
37   - handNullCmd(evt);
  35 + try {
  36 + responseAck((SIPRequest) evt.getRequest(), Response.OK);
  37 + } catch (SipException | InvalidArgumentException | ParseException e) {
  38 + logger.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
  39 + }
38 40 return;
39 41 }
40 42 IMessageHandler messageHandler = messageHandlerMap.get(cmd);
... ... @@ -51,13 +53,4 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i
51 53 messageHandler.handForPlatform(evt, parentPlatform, element);
52 54 }
53 55 }
54   -
55   - public void handNullCmd(RequestEvent evt){
56   - try {
57   - ServerTransaction serverTransaction = getServerTransaction(evt);
58   - responseAck(serverTransaction, Response.OK);
59   - } catch (SipException | InvalidArgumentException | ParseException e) {
60   - logger.error("[命令发送失败] 回复200 OK: {}", e.getMessage());
61   - }
62   - }
63 56 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java
1 1 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
2 2  
3   -import com.alibaba.fastjson.JSONObject;
  3 +import com.alibaba.fastjson2.JSONObject;
4 4 import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch;
5 5 import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatchStatus;
6 6 import com.genersoft.iot.vmp.gb28181.bean.Device;
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
... ... @@ -122,4 +122,21 @@ public class SipUtils {
122 122 public static String getNewCallId() {
123 123 return (int) Math.floor(Math.random() * 10000) + "";
124 124 }
  125 +
  126 + public static int getTypeCodeFromGbCode(String deviceId) {
  127 + if (ObjectUtils.isEmpty(deviceId)) {
  128 + return 0;
  129 + }
  130 + return Integer.parseInt(deviceId.substring(10, 13));
  131 + }
  132 +
  133 + /**
  134 + * 判断是否是前端外围设备
  135 + * @param deviceId
  136 + * @return
  137 + */
  138 + public static boolean isFrontEnd(String deviceId) {
  139 + int typeCodeFromGbCode = getTypeCodeFromGbCode(deviceId);
  140 + return typeCodeFromGbCode > 130 && typeCodeFromGbCode < 199;
  141 + }
125 142 }
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
... ... @@ -9,21 +9,16 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
9 9 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
10 10 import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
11 11 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
  12 +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
12 13 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
13   -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
14 14 import com.genersoft.iot.vmp.media.zlm.dto.HookType;
15 15 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
16 16 import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
17 17 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
18 18 import com.genersoft.iot.vmp.media.zlm.dto.hook.*;
19   -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
20   -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
21   -import com.genersoft.iot.vmp.media.zlm.dto.*;
22 19 import com.genersoft.iot.vmp.service.*;
23 20 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
24 21 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
25   -import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
26   -import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
27 22 import org.slf4j.Logger;
28 23 import org.slf4j.LoggerFactory;
29 24 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -294,9 +289,9 @@ public class ZLMHttpHookListener {
294 289  
295 290  
296 291 JSONObject json = (JSONObject) JSON.toJSON(param);
297   - taskExecutor.execute(()->{
  292 + taskExecutor.execute(()-> {
298 293 ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json);
299   - if (subscribe != null ) {
  294 + if (subscribe != null) {
300 295 MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId());
301 296 if (mediaInfo != null) {
302 297 subscribe.response(mediaInfo, json);
... ... @@ -312,15 +307,16 @@ public class ZLMHttpHookListener {
312 307 StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream());
313 308 if (streamAuthorityInfo == null) {
314 309 streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param);
315   - }else {
  310 + } else {
316 311 streamAuthorityInfo.setOriginType(param.getOriginType());
317 312 streamAuthorityInfo.setOriginTypeStr(param.getOriginTypeStr());
318 313 }
319 314 redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo);
320 315 }
321   - }else {
  316 + } else {
322 317 redisCatchStorage.removeStreamAuthorityInfo(param.getApp(), param.getStream());
323 318 }
  319 + });
324 320  
325 321 if ("rtsp".equals(param.getSchema())){
326 322 logger.info("on_stream_changed:注册->{}, app->{}, stream->{}", param.isRegist(), param.getApp(), param.getStream());
... ... @@ -329,12 +325,12 @@ public class ZLMHttpHookListener {
329 325 }else {
330 326 mediaServerService.removeCount(param.getMediaServerId());
331 327 }
332   - if (item.getOriginType() == OriginType.PULL.ordinal()
333   - || item.getOriginType() == OriginType.FFMPEG_PULL.ordinal()) {
  328 + if (param.getOriginType() == OriginType.PULL.ordinal()
  329 + || param.getOriginType() == OriginType.FFMPEG_PULL.ordinal()) {
334 330 // 设置拉流代理上线/离线
335   - streamProxyService.updateStatus(param.isRegist(), app, param.getStream());
  331 + streamProxyService.updateStatus(param.isRegist(), param.getApp(), param.getStream());
336 332 }
337   - if ("rtp".equals(app) && !regist ) {
  333 + if ("rtp".equals(param.getApp()) && !param.isRegist() ) {
338 334 StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(param.getStream());
339 335 if (streamInfo!=null){
340 336 redisCatchStorage.stopPlay(streamInfo);
... ... @@ -346,47 +342,49 @@ public class ZLMHttpHookListener {
346 342 streamInfo.getStream(), null);
347 343 }
348 344 }
349   - }else if ("broadcast".equals(app)){
  345 + }else if ("broadcast".equals(param.getApp())){
350 346 // 语音对讲推流 stream需要满足格式deviceId_channelId
351   - if (regist && param.getStream().indexOf("_") > 0) {
  347 + if (param.isRegist() && param.getStream().indexOf("_") > 0) {
352 348 String[] streamArray = param.getStream().split("_");
353 349 if (streamArray.length == 2) {
354 350 String deviceId = streamArray[0];
355 351 String channelId = streamArray[1];
356   - Device device = deviceService.queryDevice(deviceId);
  352 + Device device = deviceService.getDevice(deviceId);
357 353 if (device != null) {
358 354 DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
359 355 if (deviceChannel != null) {
360 356 if (audioBroadcastManager.exit(deviceId, channelId)) {
361 357 // 直接推流
362   - SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, stream, null);
  358 + SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, param.getStream(), null);
363 359 if (sendRtpItem == null) {
364 360 // TODO 可能数据错误,重新开启语音通道
365 361 }else {
366 362 String is_Udp = sendRtpItem.isTcp() ? "0" : "1";
367 363 MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
368 364 logger.info("rtp/{}开始向上级推流, 目标={}:{},SSRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc());
369   - Map<String, Object> param = new HashMap<>(12);
370   - param.put("vhost","__defaultVhost__");
371   - param.put("app",sendRtpItem.getApp());
372   - param.put("stream",sendRtpItem.getStreamId());
373   - param.put("ssrc", sendRtpItem.getSsrc());
374   - param.put("src_port", sendRtpItem.getLocalPort());
375   - param.put("pt", sendRtpItem.getPt());
376   - param.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0");
377   - param.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0");
  365 + Map<String, Object> sendParam = new HashMap<>(12);
  366 + sendParam.put("vhost","__defaultVhost__");
  367 + sendParam.put("app",sendRtpItem.getApp());
  368 + sendParam.put("stream",sendRtpItem.getStreamId());
  369 + sendParam.put("ssrc", sendRtpItem.getSsrc());
  370 + sendParam.put("src_port", sendRtpItem.getLocalPort());
  371 + sendParam.put("pt", sendRtpItem.getPt());
  372 + sendParam.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0");
  373 + sendParam.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0");
378 374  
379 375 JSONObject jsonObject;
380 376 if (sendRtpItem.isTcpActive()) {
381   - jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param);
  377 + jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, sendParam);
382 378 } else {
383   - param.put("is_udp", is_Udp);
384   - param.put("dst_url", sendRtpItem.getIp());
385   - param.put("dst_port", sendRtpItem.getPort());
386   - jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
  379 + sendParam.put("is_udp", is_Udp);
  380 + sendParam.put("dst_url", sendRtpItem.getIp());
  381 + sendParam.put("dst_port", sendRtpItem.getPort());
  382 + jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, sendParam);
387 383 }
388 384 if (jsonObject != null && jsonObject.getInteger("code") == 0) {
389 385 logger.info("[语音对讲] 自动推流成功, device: {}, channel: {}", deviceId, channelId);
  386 + }else {
  387 + logger.info("[语音对讲] 推流失败, 结果: {}", jsonObject);
390 388 }
391 389  
392 390 }
... ... @@ -406,43 +404,43 @@ public class ZLMHttpHookListener {
406 404 }
407 405 }
408 406  
409   - }else if ("talk".equals(app)){
  407 + }else if ("talk".equals(param.getApp())){
410 408 // 语音对讲推流 stream需要满足格式deviceId_channelId
411   - if (regist && stream.indexOf("_") > 0) {
412   - String[] streamArray = stream.split("_");
  409 + if (param.isRegist() && param.getStream().indexOf("_") > 0) {
  410 + String[] streamArray = param.getStream().split("_");
413 411 if (streamArray.length == 2) {
414 412 String deviceId = streamArray[0];
415 413 String channelId = streamArray[1];
416   - Device device = deviceService.queryDevice(deviceId);
  414 + Device device = deviceService.getDevice(deviceId);
417 415 if (device != null) {
418 416 DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
419 417 if (deviceChannel != null) {
420 418 if (audioBroadcastManager.exit(deviceId, channelId)) {
421 419 // 直接推流
422   - SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, stream, null);
  420 + SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, param.getStream(), null);
423 421 if (sendRtpItem == null) {
424 422 // TODO 可能数据错误,重新开启语音通道
425 423 }else {
426 424 MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
427 425 logger.info("rtp/{}开始向上级推流, 目标={}:{},SSRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc());
428   - Map<String, Object> param = new HashMap<>(12);
429   - param.put("vhost","__defaultVhost__");
430   - param.put("app",sendRtpItem.getApp());
431   - param.put("stream",sendRtpItem.getStreamId());
432   - param.put("ssrc", sendRtpItem.getSsrc());
433   - param.put("src_port", sendRtpItem.getLocalPort());
434   - param.put("pt", sendRtpItem.getPt());
435   - param.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0");
436   - param.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0");
  426 + Map<String, Object> sendParam = new HashMap<>(12);
  427 + sendParam.put("vhost","__defaultVhost__");
  428 + sendParam.put("app",sendRtpItem.getApp());
  429 + sendParam.put("stream",sendRtpItem.getStreamId());
  430 + sendParam.put("ssrc", sendRtpItem.getSsrc());
  431 + sendParam.put("src_port", sendRtpItem.getLocalPort());
  432 + sendParam.put("pt", sendRtpItem.getPt());
  433 + sendParam.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0");
  434 + sendParam.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0");
437 435  
438 436 JSONObject jsonObject;
439 437 if (sendRtpItem.isTcpActive()) {
440   - jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param);
  438 + jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, sendParam);
441 439 } else {
442   - param.put("is_udp", sendRtpItem.isTcp() ? "0" : "1");
443   - param.put("dst_url", sendRtpItem.getIp());
444   - param.put("dst_port", sendRtpItem.getPort());
445   - jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param);
  440 + sendParam.put("is_udp", sendRtpItem.isTcp() ? "0" : "1");
  441 + sendParam.put("dst_url", sendRtpItem.getIp());
  442 + sendParam.put("dst_port", sendRtpItem.getPort());
  443 + jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, sendParam);
446 444 }
447 445 if (jsonObject != null && jsonObject.getInteger("code") == 0) {
448 446 logger.info("[语音对讲] 自动推流成功, device: {}, channel: {}", deviceId, channelId);
... ... @@ -450,7 +448,7 @@ public class ZLMHttpHookListener {
450 448 }
451 449 }else {
452 450 // 开启语音对讲通道
453   - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
  451 + MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
454 452 playService.talk(mediaServerItem, device, channelId, (mediaServer, jsonObject)->{
455 453 System.out.println("开始推流");
456 454 }, eventResult -> {
... ... @@ -466,9 +464,9 @@ public class ZLMHttpHookListener {
466 464 }
467 465  
468 466 }else{
469   - if (!"rtp".equals(app)){
470   - String type = OriginType.values()[item.getOriginType()].getType();
471   - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
  467 + if (!"rtp".equals(param.getApp())){
  468 + String type = OriginType.values()[param.getOriginType()].getType();
  469 + MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
472 470  
473 471 if (mediaServerItem != null){
474 472 if (param.isRegist()) {
... ... @@ -478,7 +476,7 @@ public class ZLMHttpHookListener {
478 476 callId = streamAuthorityInfo.getCallId();
479 477 }
480 478 StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem,
481   - param.getApp(), param.getStream(), tracks, callId);
  479 + param.getApp(), param.getStream(), param.getTracks(), callId);
482 480 param.setStreamInfo(streamInfoByAppAndStream);
483 481 redisCatchStorage.addStream(mediaServerItem, type, param.getApp(), param.getStream(), param);
484 482 if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal()
... ... @@ -489,7 +487,8 @@ public class ZLMHttpHookListener {
489 487 }
490 488 }else {
491 489 // 兼容流注销时类型从redis记录获取
492   - OnStreamChangedHookParam onStreamChangedHookParam = redisCatchStorage.getStreamInfo(param.getApp(), param.getStream(), param.getMediaServerId());
  490 + OnStreamChangedHookParam onStreamChangedHookParam = redisCatchStorage.getStreamInfo(
  491 + param.getApp(), param.getStream(), param.getMediaServerId());
493 492 if (onStreamChangedHookParam != null) {
494 493 type = OriginType.values()[onStreamChangedHookParam.getOriginType()].getType();
495 494 redisCatchStorage.removeStream(mediaServerItem.getId(), type, param.getApp(), param.getStream());
... ... @@ -526,13 +525,13 @@ public class ZLMHttpHookListener {
526 525 if (platform != null) {
527 526 commanderFroPlatform.streamByeCmd(platform, sendRtpItem);
528 527 }else {
529   - if ("talk".equals(app) && sendRtpItem.isOnlyAudio()) {
  528 + if ("talk".equals(param.getApp()) && sendRtpItem.isOnlyAudio()) {
530 529 AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
531 530 if (device != null && audioBroadcastCatch != null) {
532 531 // cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null);
533 532 }
534 533 }else {
535   - cmder.streamByeCmd(device, sendRtpItem.getChannelId(), stream, sendRtpItem.getCallId());
  534 + cmder.streamByeCmd(device, sendRtpItem.getChannelId(), param.getStream(), sendRtpItem.getCallId());
536 535 }
537 536  
538 537 }
... ... @@ -575,6 +574,9 @@ public class ZLMHttpHookListener {
575 574 if (sendRtpItems.size() > 0) {
576 575 for (SendRtpItem sendRtpItem : sendRtpItems) {
577 576 ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId());
  577 + if (parentPlatform == null) {
  578 + continue;
  579 + }
578 580 try {
579 581 commanderFroPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId());
580 582 } catch (SipException | InvalidArgumentException | ParseException e) {
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
... ... @@ -78,6 +78,7 @@ public class ZLMRESTfulUtils {
78 78 if (callback == null) {
79 79 try {
80 80 Response response = client.newCall(request).execute();
  81 +
81 82 if (response.isSuccessful()) {
82 83 ResponseBody responseBody = response.body();
83 84 if (responseBody != null) {
... ... @@ -85,6 +86,8 @@ public class ZLMRESTfulUtils {
85 86 responseJSON = JSON.parseObject(responseStr);
86 87 }
87 88 }else {
  89 + System.out.println( 2222);
  90 + System.out.println( response.code());
88 91 response.close();
89 92 Objects.requireNonNull(response.body()).close();
90 93 }
... ... @@ -93,11 +96,11 @@ public class ZLMRESTfulUtils {
93 96  
94 97 if(e instanceof SocketTimeoutException){
95 98 //读取超时超时异常
96   - logger.error(String.format("读取ZLM数据失败: %s, %s", url, e.getMessage()));
  99 + logger.error(String.format("读取ZLM数据超时失败: %s, %s", url, e.getMessage()));
97 100 }
98 101 if(e instanceof ConnectException){
99 102 //判断连接异常,我这里是报Failed to connect to 10.7.5.144
100   - logger.error(String.format("连接ZLM失败: %s, %s", url, e.getMessage()));
  103 + logger.error(String.format("连接ZLM连接失败: %s, %s", url, e.getMessage()));
101 104 }
102 105  
103 106 }catch (Exception e){
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
... ... @@ -5,9 +5,9 @@ import com.alibaba.fastjson2.JSONArray;
5 5 import com.alibaba.fastjson2.JSONObject;
6 6 import com.genersoft.iot.vmp.conf.UserSetting;
7 7 import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
8   -import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
  8 +import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
  9 +import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForRtpServerTimeout;
9 10 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
10   -import com.genersoft.iot.vmp.media.zlm.dto.*;
11 11 import org.slf4j.Logger;
12 12 import org.slf4j.LoggerFactory;
13 13 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -346,23 +346,4 @@ public class ZLMRTPServerFactory {
346 346 return result;
347 347 }
348 348  
349   - public void closeAllSendRtpStream() {
350   -
351   - }
352   -
353   - public MediaItem getMediaInfo(MediaServerItem mediaServerItem, String app, String stream) {
354   - JSONObject json = zlmresTfulUtils.getMediaList(mediaServerItem, app, stream);
355   - MediaItem mediaItem = null;
356   - if (json == null || json.getInteger("code") != 0) {
357   - return null;
358   - } else {
359   - JSONArray data = json.getJSONArray("data");
360   - if (data == null || data.size() == 0) {
361   - return null;
362   - }else {
363   - mediaItem = JSONObject.toJavaObject(data.getJSONObject(0), MediaItem.class);
364   - }
365   - }
366   - return mediaItem;
367   - }
368 349 }
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java
... ... @@ -37,7 +37,7 @@ public class HookSubscribeFactory {
37 37  
38 38 public static HookSubscribeForStreamPush on_publish(String app, String stream, String scheam, String mediaServerId) {
39 39 HookSubscribeForStreamPush hookSubscribe = new HookSubscribeForStreamPush();
40   - JSONObject subscribeKey = new com.alibaba.fastjson.JSONObject();
  40 + JSONObject subscribeKey = new JSONObject();
41 41 subscribeKey.put("app", app);
42 42 subscribeKey.put("stream", stream);
43 43 if (scheam != null) {
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamPush.java
1 1 package com.genersoft.iot.vmp.media.zlm.dto;
2 2  
3   -import com.alibaba.fastjson.JSONObject;
  3 +
  4 +import com.alibaba.fastjson2.JSONObject;
4 5  
5 6 import java.time.Instant;
6 7  
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaServerItemLite.java
1 1 package com.genersoft.iot.vmp.media.zlm.dto;
2 2  
3 3  
4   -import com.genersoft.iot.vmp.gb28181.session.SsrcConfig;
5   -import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
6   -import org.springframework.util.StringUtils;
7   -
8   -import java.util.HashMap;
9   -
10 4 /**
11 5 * 精简的MediaServerItem信息,方便给前端返回数据
12 6 */
... ... @@ -38,8 +32,6 @@ public class MediaServerItemLite {
38 32  
39 33 private String secret;
40 34  
41   - private int hookAliveInterval;
42   -
43 35 private int recordAssistPort;
44 36  
45 37  
... ... @@ -58,7 +50,6 @@ public class MediaServerItemLite {
58 50 this.rtspPort = mediaServerItem.getRtspPort();
59 51 this.rtspSSLPort = mediaServerItem.getRtspSSLPort();
60 52 this.secret = mediaServerItem.getSecret();
61   - this.hookAliveInterval = mediaServerItem.getHookAliveInterval();
62 53 this.recordAssistPort = mediaServerItem.getRecordAssistPort();
63 54 }
64 55  
... ... @@ -167,14 +158,6 @@ public class MediaServerItemLite {
167 158 this.secret = secret;
168 159 }
169 160  
170   - public int getHookAliveInterval() {
171   - return hookAliveInterval;
172   - }
173   -
174   - public void setHookAliveInterval(int hookAliveInterval) {
175   - this.hookAliveInterval = hookAliveInterval;
176   - }
177   -
178 161 public int getRecordAssistPort() {
179 162 return recordAssistPort;
180 163 }
... ...
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
1 1 package com.genersoft.iot.vmp.service;
2 2  
3   -import com.alibaba.fastjson2.JSONObject;
4   -import com.genersoft.iot.vmp.gb28181.bean.Device;
5   -import com.alibaba.fastjson.JSONObject;
6 3 import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
7 4 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
8 5 import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
9 6 import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
10 7 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
11   -import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
12 8  
13 9 import java.util.List;
14   -import java.util.Map;
15 10  
16 11 /**
17 12 * 媒体服务节点
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
... ... @@ -4,21 +4,18 @@ import com.alibaba.fastjson2.JSON;
4 4 import com.alibaba.fastjson2.JSONArray;
5 5 import com.alibaba.fastjson2.JSONObject;
6 6 import com.genersoft.iot.vmp.common.StreamInfo;
7   -import com.genersoft.iot.vmp.common.StreamURL;
8 7 import com.genersoft.iot.vmp.conf.MediaConfig;
9 8 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
10 9 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
11 10 import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
12 11 import com.genersoft.iot.vmp.service.IMediaServerService;
  12 +import com.genersoft.iot.vmp.service.IMediaService;
13 13 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
14 14 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
15   -import com.genersoft.iot.vmp.service.IMediaService;
16 15 import org.springframework.beans.factory.annotation.Autowired;
17 16 import org.springframework.stereotype.Service;
18 17 import org.springframework.util.ObjectUtils;
19 18  
20   -import java.net.URL;
21   -
22 19 @Service
23 20 public class MediaServiceImpl implements IMediaService {
24 21  
... ... @@ -104,7 +101,7 @@ public class MediaServiceImpl implements IMediaService {
104 101 streamInfoResult.setFmp4(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam);
105 102 streamInfoResult.setHls(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam);
106 103 streamInfoResult.setTs(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam);
107   - streamInfoResult.setRtc(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam);
  104 + streamInfoResult.setRtc(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam, isPlay);
108 105  
109 106 streamInfoResult.setTracks(tracks);
110 107 return streamInfoResult;
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
1 1 package com.genersoft.iot.vmp.service.impl;
2 2  
3   -import java.math.BigDecimal;
4   -import java.math.RoundingMode;
5   -import java.text.ParseException;
6   -import java.util.*;
7   -
8   -import javax.sip.InvalidArgumentException;
9   -import javax.sip.ResponseEvent;
10   -import javax.sip.SipException;
11   -
12   -import com.genersoft.iot.vmp.gb28181.bean.*;
13   -import com.genersoft.iot.vmp.common.VideoManagerConstants;
14 3 import com.alibaba.fastjson2.JSON;
15 4 import com.alibaba.fastjson2.JSONArray;
16 5 import com.alibaba.fastjson2.JSONObject;
17 6 import com.genersoft.iot.vmp.common.StreamInfo;
18 7 import com.genersoft.iot.vmp.conf.DynamicTask;
  8 +import com.genersoft.iot.vmp.conf.SipConfig;
19 9 import com.genersoft.iot.vmp.conf.UserSetting;
20 10 import com.genersoft.iot.vmp.conf.exception.ControllerException;
21 11 import com.genersoft.iot.vmp.conf.exception.ServiceException;
22 12 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
23   -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
24   -import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
25   -import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
26   -import com.genersoft.iot.vmp.service.IDeviceService;
27   -import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
28   -import com.genersoft.iot.vmp.utils.redis.RedisUtil;
29   -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
30   -import org.slf4j.Logger;
31   -import org.slf4j.LoggerFactory;
32   -import org.springframework.beans.factory.annotation.Autowired;
33   -import org.springframework.beans.factory.annotation.Qualifier;
34   -import org.springframework.beans.factory.annotation.Value;
35   -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
36   -import org.springframework.stereotype.Service;
37   -import org.springframework.util.ObjectUtils;
38   -import org.springframework.util.StringUtils;
39   -import org.springframework.web.context.request.async.DeferredResult;
40   -
41   -import com.alibaba.fastjson.JSON;
42   -import com.alibaba.fastjson.JSONArray;
43   -import com.alibaba.fastjson.JSONObject;
44   -import com.genersoft.iot.vmp.common.StreamInfo;
45   -import com.genersoft.iot.vmp.conf.DynamicTask;
46   -import com.genersoft.iot.vmp.conf.SipConfig;
47   -import com.genersoft.iot.vmp.conf.UserSetting;
48 13 import com.genersoft.iot.vmp.gb28181.bean.*;
49 14 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
50 15 import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
51 16 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
52 17 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
53 18 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
  19 +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
54 20 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
55   -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
  21 +import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
56 22 import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils;
57 23 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
58   -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
59 24 import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
  25 +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
60 26 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
61 27 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
62 28 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
... ... @@ -72,10 +38,10 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
72 38 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
73 39 import com.genersoft.iot.vmp.utils.DateUtil;
74 40 import com.genersoft.iot.vmp.utils.redis.RedisUtil;
  41 +import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult;
75 42 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
76 43 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
77 44 import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.AudioBroadcastEvent;
78   -import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
79 45 import org.slf4j.Logger;
80 46 import org.slf4j.LoggerFactory;
81 47 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -91,7 +57,9 @@ import javax.sip.SipException;
91 57 import java.math.BigDecimal;
92 58 import java.math.RoundingMode;
93 59 import java.text.ParseException;
  60 +import java.util.HashMap;
94 61 import java.util.List;
  62 +import java.util.Map;
95 63 import java.util.UUID;
96 64  
97 65 @SuppressWarnings(value = {"rawtypes", "unchecked"})
... ... @@ -1092,7 +1060,7 @@ public class PlayServiceImpl implements IPlayService {
1092 1060 AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId);
1093 1061 if (audioBroadcastCatch != null) {
1094 1062  
1095   - Device device = deviceService.queryDevice(deviceId);
  1063 + Device device = deviceService.getDevice(deviceId);
1096 1064 if (device == null) {
1097 1065 return;
1098 1066 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
... ... @@ -111,22 +111,25 @@ public class PlayController {
111 111 resultHolder.invokeResult(msg);
112 112 });
113 113  
114   - // TODO 在点播未成功的情况下在此调用接口点播会导致返回的流地址ip错误
115   - deferredResultEx.setFilter(result1 -> {
116   - WVPResult<StreamInfo> wvpResult1 = (WVPResult<StreamInfo>)result1;
117   - WVPResult<StreamInfo> clone = null;
118   - try {
119   - clone = (WVPResult<StreamInfo>)wvpResult1.clone();
120   - } catch (CloneNotSupportedException e) {
121   - throw new RuntimeException(e);
122   - }
123   - if (clone.getCode() == ErrorCode.SUCCESS.getCode()) {
124   - StreamInfo data = clone.getData().clone();
125   - data.channgeStreamIp(request.getLocalName());
126   - clone.setData(data);
127   - }
128   - return clone;
129   - });
  114 + if (userSetting.isUsePushingAsStatus()) {
  115 + // TODO 在点播未成功的情况下在此调用接口点播会导致返回的流地址ip错误
  116 + deferredResultEx.setFilter(result1 -> {
  117 + WVPResult<StreamInfo> wvpResult1 = (WVPResult<StreamInfo>)result1;
  118 + WVPResult<StreamInfo> clone = null;
  119 + try {
  120 + clone = (WVPResult<StreamInfo>)wvpResult1.clone();
  121 + } catch (CloneNotSupportedException e) {
  122 + throw new RuntimeException(e);
  123 + }
  124 + if (clone.getCode() == ErrorCode.SUCCESS.getCode()) {
  125 + StreamInfo data = clone.getData().clone();
  126 + data.channgeStreamIp(request.getLocalName());
  127 + clone.setData(data);
  128 + }
  129 + return clone;
  130 + });
  131 + }
  132 +
130 133  
131 134 // 录像查询以channelId作为deviceId查询
132 135 resultHolder.put(key, uuid, deferredResultEx);
... ...
web_src/src/components/dialog/devicePlayer.vue
... ... @@ -302,15 +302,13 @@
302 302 <script>
303 303 import rtcPlayer from '../dialog/rtcPlayer.vue'
304 304 import crypto from 'crypto'
305   -// import LivePlayer from '@liveqing/liveplayer'
306   -// import player from '../dialog/easyPlayer.vue'
307 305 import jessibucaPlayer from '../common/jessibuca.vue'
308 306 import recordDownload from '../dialog/recordDownload.vue'
309 307 export default {
310 308 name: 'devicePlayer',
311 309 props: {},
312 310 components: {
313   - LivePlayer, jessibucaPlayer, rtcPlayer, recordDownload,
  311 + jessibucaPlayer, rtcPlayer, recordDownload,
314 312 },
315 313 computed: {
316 314 getPlayerShared: function () {
... ... @@ -864,9 +862,9 @@ export default {
864 862 if (res.data.code == 0) {
865 863 let streamInfo = res.data.data.streamInfo;
866 864 if (document.location.protocol.includes("https")) {
867   - this.startBroadcast(streamInfo.rtcs)
  865 + this.startBroadcast(streamInfo.rtcs.url)
868 866 }else {
869   - this.startBroadcast(streamInfo.rtc)
  867 + this.startBroadcast(streamInfo.rtc.url)
870 868 }
871 869  
872 870 }else {
... ...