Commit ecf84bb0f1952c4a044ff6c8aa18226b31593f3f
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,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 | this.rtc = new StreamURL("http", host, port, file); | 228 | this.rtc = new StreamURL("http", host, port, file); |
| 229 | if (sslPort != 0) { | 229 | if (sslPort != 0) { |
| 230 | this.rtcs = new StreamURL("https", host, sslPort, file); | 230 | this.rtcs = new StreamURL("https", host, sslPort, file); |
src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
| @@ -31,7 +31,7 @@ public class UserSetting { | @@ -31,7 +31,7 @@ public class UserSetting { | ||
| 31 | 31 | ||
| 32 | private Boolean logInDatebase = Boolean.TRUE; | 32 | private Boolean logInDatebase = Boolean.TRUE; |
| 33 | 33 | ||
| 34 | - private Boolean usePushingAsStatus = Boolean.TRUE; | 34 | + private Boolean usePushingAsStatus = Boolean.FALSE; |
| 35 | 35 | ||
| 36 | private Boolean useSourceIpAsStreamIp = Boolean.FALSE; | 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,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.session; | ||
| 2 | 2 | ||
| 3 | import com.genersoft.iot.vmp.conf.SipConfig; | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch; | 4 | import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch; |
| 5 | +import com.genersoft.iot.vmp.gb28181.utils.SipUtils; | ||
| 5 | import org.springframework.beans.factory.annotation.Autowired; | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | import org.springframework.stereotype.Component; | 7 | import org.springframework.stereotype.Component; |
| 7 | 8 | ||
| @@ -27,11 +28,20 @@ public class AudioBroadcastManager { | @@ -27,11 +28,20 @@ public class AudioBroadcastManager { | ||
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | public void update(AudioBroadcastCatch audioBroadcastCatch) { | 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 | public void del(String deviceId, String channelId) { | 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 | public void delByDeviceId(String deviceId) { | 47 | public void delByDeviceId(String deviceId) { |
| @@ -50,15 +60,22 @@ public class AudioBroadcastManager { | @@ -50,15 +60,22 @@ public class AudioBroadcastManager { | ||
| 50 | 60 | ||
| 51 | public boolean exit(String deviceId, String channelId) { | 61 | public boolean exit(String deviceId, String channelId) { |
| 52 | for (String key : data.keySet()) { | 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 | return false; | 69 | return false; |
| 58 | } | 70 | } |
| 59 | 71 | ||
| 60 | public AudioBroadcastCatch get(String deviceId, String channelId) { | 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 | if (audioBroadcastCatch == null) { | 79 | if (audioBroadcastCatch == null) { |
| 63 | Stream<AudioBroadcastCatch> allAudioBroadcastCatchStreamForDevice = data.values().stream().filter( | 80 | Stream<AudioBroadcastCatch> allAudioBroadcastCatchStreamForDevice = data.values().stream().filter( |
| 64 | audioBroadcastCatchItem -> Objects.equals(audioBroadcastCatchItem.getDeviceId(), deviceId)); | 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,6 +15,7 @@ import javax.sip.SipException; | ||
| 15 | import javax.sip.message.Message; | 15 | import javax.sip.message.Message; |
| 16 | import javax.sip.message.Request; | 16 | import javax.sip.message.Request; |
| 17 | import java.text.ParseException; | 17 | import java.text.ParseException; |
| 18 | +import javax.sip.message.Message; | ||
| 18 | import javax.sip.message.Request; | 19 | import javax.sip.message.Request; |
| 19 | 20 | ||
| 20 | /** | 21 | /** |
| @@ -361,4 +362,5 @@ public interface ISIPCommander { | @@ -361,4 +362,5 @@ public interface ISIPCommander { | ||
| 361 | */ | 362 | */ |
| 362 | void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException; | 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,32 +318,32 @@ public class SIPRequestHeaderProvider { | ||
| 318 | public Request createBroadcastMessageRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { | 318 | public Request createBroadcastMessageRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 319 | Request request = null; | 319 | Request request = null; |
| 320 | // sipuri | 320 | // sipuri |
| 321 | - SipURI requestURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress()); | 321 | + SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress()); |
| 322 | // via | 322 | // via |
| 323 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 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 | viaHeader.setRPort(); | 325 | viaHeader.setRPort(); |
| 326 | viaHeaders.add(viaHeader); | 326 | viaHeaders.add(viaHeader); |
| 327 | // from | 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 | // to | 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 | // Forwards | 336 | // Forwards |
| 337 | - MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | 337 | + MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); |
| 338 | // ceq | 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 | toHeader, viaHeaders, maxForwards, contentTypeHeader, content); | 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 | return request; | 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,15 +19,11 @@ import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | ||
| 19 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | 19 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| 20 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; | 20 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; |
| 21 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamPush; | 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 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 22 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 26 | import com.genersoft.iot.vmp.service.IMediaServerService; | 23 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 27 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 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 | import com.genersoft.iot.vmp.utils.DateUtil; | 25 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 26 | +import com.genersoft.iot.vmp.utils.GitUtil; | ||
| 31 | import gov.nist.javax.sip.message.SIPRequest; | 27 | import gov.nist.javax.sip.message.SIPRequest; |
| 32 | import gov.nist.javax.sip.message.SIPResponse; | 28 | import gov.nist.javax.sip.message.SIPResponse; |
| 33 | import org.slf4j.Logger; | 29 | import org.slf4j.Logger; |
| @@ -41,8 +37,6 @@ import javax.sip.InvalidArgumentException; | @@ -41,8 +37,6 @@ import javax.sip.InvalidArgumentException; | ||
| 41 | import javax.sip.ResponseEvent; | 37 | import javax.sip.ResponseEvent; |
| 42 | import javax.sip.SipException; | 38 | import javax.sip.SipException; |
| 43 | import javax.sip.header.CallIdHeader; | 39 | import javax.sip.header.CallIdHeader; |
| 44 | -import javax.sip.*; | ||
| 45 | -import javax.sip.header.*; | ||
| 46 | import javax.sip.message.Request; | 40 | import javax.sip.message.Request; |
| 47 | import java.text.ParseException; | 41 | import java.text.ParseException; |
| 48 | 42 | ||
| @@ -78,6 +72,9 @@ public class SIPCommander implements ISIPCommander { | @@ -78,6 +72,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 78 | @Autowired | 72 | @Autowired |
| 79 | private ZlmHttpHookSubscribe subscribe; | 73 | private ZlmHttpHookSubscribe subscribe; |
| 80 | 74 | ||
| 75 | + @Autowired | ||
| 76 | + private GitUtil gitUtil; | ||
| 77 | + | ||
| 81 | 78 | ||
| 82 | 79 | ||
| 83 | @Autowired | 80 | @Autowired |
| @@ -607,8 +604,7 @@ public class SIPCommander implements ISIPCommander { | @@ -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 | callIdHeader.setCallId(callId); | 608 | callIdHeader.setCallId(callId); |
| 613 | HookSubscribeForStreamPush hookSubscribeForStreamPush = HookSubscribeFactory.on_publish("rtp", stream, null, mediaServerItem.getId()); | 609 | HookSubscribeForStreamPush hookSubscribeForStreamPush = HookSubscribeFactory.on_publish("rtp", stream, null, mediaServerItem.getId()); |
| 614 | subscribe.addSubscribe(hookSubscribeForStreamPush, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { | 610 | subscribe.addSubscribe(hookSubscribeForStreamPush, (MediaServerItem mediaServerItemInUse, JSONObject json) -> { |
| @@ -633,7 +629,7 @@ public class SIPCommander implements ISIPCommander { | @@ -633,7 +629,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 633 | content.append("f=v/////a/1/8/1" + "\r\n"); | 629 | content.append("f=v/////a/1/8/1" + "\r\n"); |
| 634 | 630 | ||
| 635 | Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(), callIdHeader); | 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 | streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); | 633 | streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); |
| 638 | mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); | 634 | mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); |
| 639 | errorEvent.response(e); | 635 | errorEvent.response(e); |
| @@ -675,7 +671,7 @@ public class SIPCommander implements ISIPCommander { | @@ -675,7 +671,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 675 | @Override | 671 | @Override |
| 676 | public synchronized void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { | 672 | public synchronized void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { |
| 677 | Request byteRequest = headerProvider.createByteRequest(device, channelId, sipTransactionInfo); | 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,10 +691,8 @@ public class SIPCommander implements ISIPCommander { | ||
| 695 | broadcastXml.append("<TargetID>" + channelId + "</TargetID>\r\n"); | 691 | broadcastXml.append("<TargetID>" + channelId + "</TargetID>\r\n"); |
| 696 | broadcastXml.append("</Notify>\r\n"); | 692 | broadcastXml.append("</Notify>\r\n"); |
| 697 | 693 | ||
| 698 | - | ||
| 699 | - | ||
| 700 | Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); | 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,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 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson2.JSON; | 3 | import com.alibaba.fastjson2.JSON; |
| 4 | -import com.alibaba.fastjson2.JSONObject; | ||
| 5 | import com.genersoft.iot.vmp.gb28181.SipLayer; | 4 | import com.genersoft.iot.vmp.gb28181.SipLayer; |
| 6 | import com.genersoft.iot.vmp.gb28181.bean.*; | 5 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 7 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 6 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| @@ -9,13 +8,13 @@ import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; | @@ -9,13 +8,13 @@ import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; | ||
| 9 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | 8 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 10 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider; | 9 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider; |
| 11 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; | 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 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; | 11 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 15 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 12 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 16 | import com.genersoft.iot.vmp.service.IMediaServerService; | 13 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 17 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; | 14 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| 18 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 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 | import gov.nist.javax.sip.message.MessageFactoryImpl; | 18 | import gov.nist.javax.sip.message.MessageFactoryImpl; |
| 20 | import gov.nist.javax.sip.message.SIPRequest; | 19 | import gov.nist.javax.sip.message.SIPRequest; |
| 21 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
| @@ -26,10 +25,10 @@ import org.springframework.lang.Nullable; | @@ -26,10 +25,10 @@ import org.springframework.lang.Nullable; | ||
| 26 | import org.springframework.stereotype.Component; | 25 | import org.springframework.stereotype.Component; |
| 27 | import org.springframework.util.ObjectUtils; | 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 | import javax.sip.message.Request; | 32 | import javax.sip.message.Request; |
| 34 | import java.text.ParseException; | 33 | import java.text.ParseException; |
| 35 | import java.util.ArrayList; | 34 | import java.util.ArrayList; |
| @@ -629,21 +628,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -629,21 +628,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 629 | logger.info("[向上级发送BYE], sendRtpItem 为NULL"); | 628 | logger.info("[向上级发送BYE], sendRtpItem 为NULL"); |
| 630 | return; | 629 | return; |
| 631 | } | 630 | } |
| 632 | - if (parentPlatform == null) { | 631 | + if (platform == null) { |
| 633 | logger.info("[向上级发送BYE], platform 为NULL"); | 632 | logger.info("[向上级发送BYE], platform 为NULL"); |
| 634 | return; | 633 | return; |
| 635 | } | 634 | } |
| 636 | - logger.info("[向上级发送BYE], {}/{}", parentPlatform.getServerGBId(), sendRtpItem.getChannelId()); | 635 | + logger.info("[向上级发送BYE], {}/{}", platform.getServerGBId(), sendRtpItem.getChannelId()); |
| 637 | String mediaServerId = sendRtpItem.getMediaServerId(); | 636 | String mediaServerId = sendRtpItem.getMediaServerId(); |
| 638 | MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); | 637 | MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); |
| 639 | if (mediaServerItem != null) { | 638 | if (mediaServerItem != null) { |
| 640 | mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc()); | 639 | mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc()); |
| 641 | zlmrtpServerFactory.closeRtpServer(mediaServerItem, sendRtpItem.getStreamId()); | 640 | zlmrtpServerFactory.closeRtpServer(mediaServerItem, sendRtpItem.getStreamId()); |
| 642 | } | 641 | } |
| 643 | - SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(parentPlatform, sendRtpItem); | 642 | + SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(platform, sendRtpItem); |
| 644 | if (byeRequest == null) { | 643 | if (byeRequest == null) { |
| 645 | logger.warn("[向上级发送bye]:无法创建 byeRequest"); | 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,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request; | ||
| 2 | 2 | ||
| 3 | import com.genersoft.iot.vmp.conf.SipConfig; | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; | ||
| 5 | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; | 6 | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| 6 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; | 7 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 7 | import gov.nist.javax.sip.SipProviderImpl; | 8 | import gov.nist.javax.sip.SipProviderImpl; |
| @@ -17,6 +18,7 @@ import org.slf4j.Logger; | @@ -17,6 +18,7 @@ import org.slf4j.Logger; | ||
| 17 | import org.slf4j.LoggerFactory; | 18 | import org.slf4j.LoggerFactory; |
| 18 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
| 19 | import org.springframework.beans.factory.annotation.Qualifier; | 20 | import org.springframework.beans.factory.annotation.Qualifier; |
| 21 | +import org.springframework.security.core.parameters.P; | ||
| 20 | 22 | ||
| 21 | import javax.sip.*; | 23 | import javax.sip.*; |
| 22 | import javax.sip.address.Address; | 24 | import javax.sip.address.Address; |
| @@ -93,52 +95,6 @@ public abstract class SIPRequestProcessorParent { | @@ -93,52 +95,6 @@ public abstract class SIPRequestProcessorParent { | ||
| 93 | return responseAck(sipRequest, statusCode, msg, null); | 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 | public SIPResponse responseAck(SIPRequest sipRequest, int statusCode, String msg, ResponseAckExtraParam responseAckExtraParam) throws SipException, InvalidArgumentException, ParseException { | 99 | public SIPResponse responseAck(SIPRequest sipRequest, int statusCode, String msg, ResponseAckExtraParam responseAckExtraParam) throws SipException, InvalidArgumentException, ParseException { |
| 144 | if (sipRequest.getToHeader().getTag() == null) { | 100 | if (sipRequest.getToHeader().getTag() == null) { |
| @@ -182,6 +138,8 @@ public abstract class SIPRequestProcessorParent { | @@ -182,6 +138,8 @@ public abstract class SIPRequestProcessorParent { | ||
| 182 | return response; | 138 | return response; |
| 183 | } | 139 | } |
| 184 | 140 | ||
| 141 | + | ||
| 142 | + | ||
| 185 | /** | 143 | /** |
| 186 | * 回复带sdp的200 | 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,10 +152,10 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In | ||
| 152 | } else if (jsonObject.getInteger("code") == 0) { | 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")); | 153 | logger.info("RTP推流成功[ {}/{} ],{}->{}:{}, ", param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port")); |
| 154 | } else { | 154 | } else { |
| 155 | - logger.error("RTP推流失败: {}, 参数:{}", jsonObject.getString("msg"), JSONObject.toJSON(param)); | 155 | + logger.error("RTP推流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSON(param)); |
| 156 | if (sendRtpItem.isOnlyAudio()) { | 156 | if (sendRtpItem.isOnlyAudio()) { |
| 157 | // 语音对讲 | 157 | // 语音对讲 |
| 158 | - Device device = deviceService.queryDevice(platformGbId); | 158 | + Device device = deviceService.getDevice(platformGbId); |
| 159 | if (device != null) { | 159 | if (device != null) { |
| 160 | try { | 160 | try { |
| 161 | cmder.streamByeCmd(device, sendRtpItem.getChannelId(), sendRtpItem.getStreamId(), null); | 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,7 +111,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In | ||
| 111 | if (totalReaderCount <= 0) { | 111 | if (totalReaderCount <= 0) { |
| 112 | logger.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId); | 112 | logger.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId); |
| 113 | if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) { | 113 | if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) { |
| 114 | - Device device = deviceService.queryDevice(sendRtpItem.getDeviceId()); | 114 | + Device device = deviceService.getDevice(sendRtpItem.getDeviceId()); |
| 115 | if (device == null) { | 115 | if (device == null) { |
| 116 | logger.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId); | 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,19 +4,14 @@ import com.alibaba.fastjson2.JSONObject; | ||
| 4 | import com.genersoft.iot.vmp.conf.DynamicTask; | 4 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 5 | import com.genersoft.iot.vmp.conf.SipConfig; | 5 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 6 | import com.genersoft.iot.vmp.conf.UserSetting; | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; | ||
| 8 | import com.genersoft.iot.vmp.gb28181.bean.*; | 7 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 9 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 8 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 10 | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; | 9 | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; |
| 11 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; | 10 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 12 | 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; | ||
| 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.callback.RequestMessage; | ||
| 15 | -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; | ||
| 16 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | 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 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; | 15 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| 21 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 16 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 22 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; | 17 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| @@ -25,11 +20,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | @@ -25,11 +20,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | ||
| 25 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; | 20 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 26 | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | 21 | import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; |
| 27 | import com.genersoft.iot.vmp.media.zlm.dto.*; | 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 | import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; | 24 | import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; |
| 34 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 25 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 35 | import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener; | 26 | import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener; |
| @@ -37,8 +28,6 @@ import com.genersoft.iot.vmp.service.redisMsg.RedisPushStreamResponseListener; | @@ -37,8 +28,6 @@ import com.genersoft.iot.vmp.service.redisMsg.RedisPushStreamResponseListener; | ||
| 37 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 28 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 38 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 29 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 39 | import com.genersoft.iot.vmp.utils.DateUtil; | 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 | import gov.nist.javax.sdp.TimeDescriptionImpl; | 31 | import gov.nist.javax.sdp.TimeDescriptionImpl; |
| 43 | import gov.nist.javax.sdp.fields.TimeField; | 32 | import gov.nist.javax.sdp.fields.TimeField; |
| 44 | import gov.nist.javax.sip.message.SIPRequest; | 33 | import gov.nist.javax.sip.message.SIPRequest; |
| @@ -530,10 +519,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -530,10 +519,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 530 | 519 | ||
| 531 | // 写入redis, 超时时回复 | 520 | // 写入redis, 超时时回复 |
| 532 | redisCatchStorage.updateSendRTPSever(sendRtpItem); | 521 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| 533 | - MediaServerItem finalMediaServerItem = mediaServerItem; | ||
| 534 | playService.play(mediaServerItem, ssrcInfo, device, channelId, hookEvent, errorEvent, (code, msg) -> { | 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 | } else { | 526 | } else { |
| 539 | sendRtpItem.setStreamId(playTransaction.getStream()); | 527 | sendRtpItem.setStreamId(playTransaction.getStream()); |
| @@ -908,13 +896,12 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -908,13 +896,12 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 908 | if (audioBroadcastCatch == null) { | 896 | if (audioBroadcastCatch == null) { |
| 909 | logger.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId); | 897 | logger.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId); |
| 910 | try { | 898 | try { |
| 911 | - responseAck(serverTransaction, Response.FORBIDDEN); | 899 | + responseAck(request, Response.FORBIDDEN); |
| 912 | } catch (SipException | InvalidArgumentException | ParseException e) { | 900 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 913 | logger.error("[命令发送失败] 来自设备的Invite请求非语音广播 FORBIDDEN: {}", e.getMessage()); | 901 | logger.error("[命令发送失败] 来自设备的Invite请求非语音广播 FORBIDDEN: {}", e.getMessage()); |
| 914 | } | 902 | } |
| 915 | return; | 903 | return; |
| 916 | } | 904 | } |
| 917 | - Request request = serverTransaction.getRequest(); | ||
| 918 | if (device != null) { | 905 | if (device != null) { |
| 919 | logger.info("收到设备" + requesterId + "的语音广播Invite请求"); | 906 | logger.info("收到设备" + requesterId + "的语音广播Invite请求"); |
| 920 | try { | 907 | try { |
| @@ -985,7 +972,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -985,7 +972,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 985 | if (mediaServerItem == null) { | 972 | if (mediaServerItem == null) { |
| 986 | logger.warn("未找到可用的zlm"); | 973 | logger.warn("未找到可用的zlm"); |
| 987 | try { | 974 | try { |
| 988 | - responseAck(serverTransaction, Response.BUSY_HERE); | 975 | + responseAck(request, Response.BUSY_HERE); |
| 989 | } catch (SipException | InvalidArgumentException | ParseException e) { | 976 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 990 | logger.error("[命令发送失败] invite 未找到可用的zlm: {}", e.getMessage()); | 977 | logger.error("[命令发送失败] invite 未找到可用的zlm: {}", e.getMessage()); |
| 991 | } | 978 | } |
| @@ -997,7 +984,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -997,7 +984,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 997 | if (sendRtpItem == null) { | 984 | if (sendRtpItem == null) { |
| 998 | logger.warn("服务器端口资源不足"); | 985 | logger.warn("服务器端口资源不足"); |
| 999 | try { | 986 | try { |
| 1000 | - responseAck(serverTransaction, Response.BUSY_HERE); | 987 | + responseAck(request, Response.BUSY_HERE); |
| 1001 | } catch (SipException | InvalidArgumentException | ParseException e) { | 988 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 1002 | logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); | 989 | logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); |
| 1003 | } | 990 | } |
| @@ -1024,7 +1011,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -1024,7 +1011,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 1024 | 1011 | ||
| 1025 | Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream); | 1012 | Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream); |
| 1026 | if (streamReady) { | 1013 | if (streamReady) { |
| 1027 | - sendOk(device, sendRtpItem, sdp, serverTransaction, mediaServerItem, mediaTransmissionTCP, ssrc); | 1014 | + sendOk(device, sendRtpItem, sdp, request, mediaServerItem, mediaTransmissionTCP, ssrc); |
| 1028 | }else { | 1015 | }else { |
| 1029 | logger.warn("[语音通话], 未发现待推送的流,app={},stream={}", app, stream); | 1016 | logger.warn("[语音通话], 未发现待推送的流,app={},stream={}", app, stream); |
| 1030 | playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId()); | 1017 | playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId()); |
| @@ -1042,7 +1029,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -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 | try { | 1033 | try { |
| 1047 | sendRtpItem.setStatus(2); | 1034 | sendRtpItem.setStatus(2); |
| 1048 | redisCatchStorage.updateSendRTPSever(sendRtpItem); | 1035 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| @@ -1078,7 +1065,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -1078,7 +1065,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 1078 | parentPlatform.setServerPort(device.getPort()); | 1065 | parentPlatform.setServerPort(device.getPort()); |
| 1079 | parentPlatform.setServerGBId(device.getDeviceId()); | 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 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(device.getDeviceId(), sendRtpItem.getChannelId()); | 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,33 +101,38 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements | ||
| 101 | if (!taskQueueHandlerRun) { | 101 | if (!taskQueueHandlerRun) { |
| 102 | taskQueueHandlerRun = true; | 102 | taskQueueHandlerRun = true; |
| 103 | taskExecutor.execute(()-> { | 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,13 +120,6 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen | ||
| 120 | 120 | ||
| 121 | if (request.getExpires() == null) { | 121 | if (request.getExpires() == null) { |
| 122 | response = getMessageFactory().createResponse(Response.BAD_REQUEST, request); | 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 | sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); | 123 | sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); |
| 131 | return; | 124 | return; |
| 132 | } | 125 | } |
| @@ -185,12 +178,4 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen | @@ -185,12 +178,4 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen | ||
| 185 | e.printStackTrace(); | 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,15 +3,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message; | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 3 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 5 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 6 | -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.AckRequestProcessor; | 6 | +import gov.nist.javax.sip.message.SIPRequest; |
| 7 | import org.dom4j.Element; | 7 | import org.dom4j.Element; |
| 8 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
| 9 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 10 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | 10 | ||
| 12 | import javax.sip.InvalidArgumentException; | 11 | import javax.sip.InvalidArgumentException; |
| 13 | import javax.sip.RequestEvent; | 12 | import javax.sip.RequestEvent; |
| 14 | -import javax.sip.ServerTransaction; | ||
| 15 | import javax.sip.SipException; | 13 | import javax.sip.SipException; |
| 16 | import javax.sip.message.Response; | 14 | import javax.sip.message.Response; |
| 17 | import java.text.ParseException; | 15 | import java.text.ParseException; |
| @@ -34,7 +32,11 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i | @@ -34,7 +32,11 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i | ||
| 34 | public void handForDevice(RequestEvent evt, Device device, Element element) { | 32 | public void handForDevice(RequestEvent evt, Device device, Element element) { |
| 35 | String cmd = getText(element, "CmdType"); | 33 | String cmd = getText(element, "CmdType"); |
| 36 | if (cmd == null) { | 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 | return; | 40 | return; |
| 39 | } | 41 | } |
| 40 | IMessageHandler messageHandler = messageHandlerMap.get(cmd); | 42 | IMessageHandler messageHandler = messageHandlerMap.get(cmd); |
| @@ -51,13 +53,4 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i | @@ -51,13 +53,4 @@ public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent i | ||
| 51 | messageHandler.handForPlatform(evt, parentPlatform, element); | 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 | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; | 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 | import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch; | 4 | import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatch; |
| 5 | import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatchStatus; | 5 | import com.genersoft.iot.vmp.gb28181.bean.AudioBroadcastCatchStatus; |
| 6 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 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,4 +122,21 @@ public class SipUtils { | ||
| 122 | public static String getNewCallId() { | 122 | public static String getNewCallId() { |
| 123 | return (int) Math.floor(Math.random() * 10000) + ""; | 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,21 +9,16 @@ import com.genersoft.iot.vmp.gb28181.bean.*; | ||
| 9 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 9 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 10 | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; | 10 | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; |
| 11 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; | 11 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 12 | +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | ||
| 12 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | 13 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 13 | -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; | ||
| 14 | import com.genersoft.iot.vmp.media.zlm.dto.HookType; | 14 | import com.genersoft.iot.vmp.media.zlm.dto.HookType; |
| 15 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 15 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 16 | import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; | 16 | import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; |
| 17 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; | 17 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 18 | import com.genersoft.iot.vmp.media.zlm.dto.hook.*; | 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 | import com.genersoft.iot.vmp.service.*; | 19 | import com.genersoft.iot.vmp.service.*; |
| 23 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 20 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 24 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 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 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
| 28 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
| 29 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -294,9 +289,9 @@ public class ZLMHttpHookListener { | @@ -294,9 +289,9 @@ public class ZLMHttpHookListener { | ||
| 294 | 289 | ||
| 295 | 290 | ||
| 296 | JSONObject json = (JSONObject) JSON.toJSON(param); | 291 | JSONObject json = (JSONObject) JSON.toJSON(param); |
| 297 | - taskExecutor.execute(()->{ | 292 | + taskExecutor.execute(()-> { |
| 298 | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); | 293 | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); |
| 299 | - if (subscribe != null ) { | 294 | + if (subscribe != null) { |
| 300 | MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); | 295 | MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); |
| 301 | if (mediaInfo != null) { | 296 | if (mediaInfo != null) { |
| 302 | subscribe.response(mediaInfo, json); | 297 | subscribe.response(mediaInfo, json); |
| @@ -312,15 +307,16 @@ public class ZLMHttpHookListener { | @@ -312,15 +307,16 @@ public class ZLMHttpHookListener { | ||
| 312 | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); | 307 | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); |
| 313 | if (streamAuthorityInfo == null) { | 308 | if (streamAuthorityInfo == null) { |
| 314 | streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param); | 309 | streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param); |
| 315 | - }else { | 310 | + } else { |
| 316 | streamAuthorityInfo.setOriginType(param.getOriginType()); | 311 | streamAuthorityInfo.setOriginType(param.getOriginType()); |
| 317 | streamAuthorityInfo.setOriginTypeStr(param.getOriginTypeStr()); | 312 | streamAuthorityInfo.setOriginTypeStr(param.getOriginTypeStr()); |
| 318 | } | 313 | } |
| 319 | redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); | 314 | redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); |
| 320 | } | 315 | } |
| 321 | - }else { | 316 | + } else { |
| 322 | redisCatchStorage.removeStreamAuthorityInfo(param.getApp(), param.getStream()); | 317 | redisCatchStorage.removeStreamAuthorityInfo(param.getApp(), param.getStream()); |
| 323 | } | 318 | } |
| 319 | + }); | ||
| 324 | 320 | ||
| 325 | if ("rtsp".equals(param.getSchema())){ | 321 | if ("rtsp".equals(param.getSchema())){ |
| 326 | logger.info("on_stream_changed:注册->{}, app->{}, stream->{}", param.isRegist(), param.getApp(), param.getStream()); | 322 | logger.info("on_stream_changed:注册->{}, app->{}, stream->{}", param.isRegist(), param.getApp(), param.getStream()); |
| @@ -329,12 +325,12 @@ public class ZLMHttpHookListener { | @@ -329,12 +325,12 @@ public class ZLMHttpHookListener { | ||
| 329 | }else { | 325 | }else { |
| 330 | mediaServerService.removeCount(param.getMediaServerId()); | 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 | StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(param.getStream()); | 334 | StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(param.getStream()); |
| 339 | if (streamInfo!=null){ | 335 | if (streamInfo!=null){ |
| 340 | redisCatchStorage.stopPlay(streamInfo); | 336 | redisCatchStorage.stopPlay(streamInfo); |
| @@ -346,47 +342,49 @@ public class ZLMHttpHookListener { | @@ -346,47 +342,49 @@ public class ZLMHttpHookListener { | ||
| 346 | streamInfo.getStream(), null); | 342 | streamInfo.getStream(), null); |
| 347 | } | 343 | } |
| 348 | } | 344 | } |
| 349 | - }else if ("broadcast".equals(app)){ | 345 | + }else if ("broadcast".equals(param.getApp())){ |
| 350 | // 语音对讲推流 stream需要满足格式deviceId_channelId | 346 | // 语音对讲推流 stream需要满足格式deviceId_channelId |
| 351 | - if (regist && param.getStream().indexOf("_") > 0) { | 347 | + if (param.isRegist() && param.getStream().indexOf("_") > 0) { |
| 352 | String[] streamArray = param.getStream().split("_"); | 348 | String[] streamArray = param.getStream().split("_"); |
| 353 | if (streamArray.length == 2) { | 349 | if (streamArray.length == 2) { |
| 354 | String deviceId = streamArray[0]; | 350 | String deviceId = streamArray[0]; |
| 355 | String channelId = streamArray[1]; | 351 | String channelId = streamArray[1]; |
| 356 | - Device device = deviceService.queryDevice(deviceId); | 352 | + Device device = deviceService.getDevice(deviceId); |
| 357 | if (device != null) { | 353 | if (device != null) { |
| 358 | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); | 354 | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); |
| 359 | if (deviceChannel != null) { | 355 | if (deviceChannel != null) { |
| 360 | if (audioBroadcastManager.exit(deviceId, channelId)) { | 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 | if (sendRtpItem == null) { | 359 | if (sendRtpItem == null) { |
| 364 | // TODO 可能数据错误,重新开启语音通道 | 360 | // TODO 可能数据错误,重新开启语音通道 |
| 365 | }else { | 361 | }else { |
| 366 | String is_Udp = sendRtpItem.isTcp() ? "0" : "1"; | 362 | String is_Udp = sendRtpItem.isTcp() ? "0" : "1"; |
| 367 | MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); | 363 | MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); |
| 368 | logger.info("rtp/{}开始向上级推流, 目标={}:{},SSRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc()); | 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 | JSONObject jsonObject; | 375 | JSONObject jsonObject; |
| 380 | if (sendRtpItem.isTcpActive()) { | 376 | if (sendRtpItem.isTcpActive()) { |
| 381 | - jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param); | 377 | + jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, sendParam); |
| 382 | } else { | 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 | if (jsonObject != null && jsonObject.getInteger("code") == 0) { | 384 | if (jsonObject != null && jsonObject.getInteger("code") == 0) { |
| 389 | logger.info("[语音对讲] 自动推流成功, device: {}, channel: {}", deviceId, channelId); | 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,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 | // 语音对讲推流 stream需要满足格式deviceId_channelId | 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 | if (streamArray.length == 2) { | 411 | if (streamArray.length == 2) { |
| 414 | String deviceId = streamArray[0]; | 412 | String deviceId = streamArray[0]; |
| 415 | String channelId = streamArray[1]; | 413 | String channelId = streamArray[1]; |
| 416 | - Device device = deviceService.queryDevice(deviceId); | 414 | + Device device = deviceService.getDevice(deviceId); |
| 417 | if (device != null) { | 415 | if (device != null) { |
| 418 | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); | 416 | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); |
| 419 | if (deviceChannel != null) { | 417 | if (deviceChannel != null) { |
| 420 | if (audioBroadcastManager.exit(deviceId, channelId)) { | 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 | if (sendRtpItem == null) { | 421 | if (sendRtpItem == null) { |
| 424 | // TODO 可能数据错误,重新开启语音通道 | 422 | // TODO 可能数据错误,重新开启语音通道 |
| 425 | }else { | 423 | }else { |
| 426 | MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); | 424 | MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); |
| 427 | logger.info("rtp/{}开始向上级推流, 目标={}:{},SSRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc()); | 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 | JSONObject jsonObject; | 436 | JSONObject jsonObject; |
| 439 | if (sendRtpItem.isTcpActive()) { | 437 | if (sendRtpItem.isTcpActive()) { |
| 440 | - jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, param); | 438 | + jsonObject = zlmrtpServerFactory.startSendRtpPassive(mediaInfo, sendParam); |
| 441 | } else { | 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 | if (jsonObject != null && jsonObject.getInteger("code") == 0) { | 445 | if (jsonObject != null && jsonObject.getInteger("code") == 0) { |
| 448 | logger.info("[语音对讲] 自动推流成功, device: {}, channel: {}", deviceId, channelId); | 446 | logger.info("[语音对讲] 自动推流成功, device: {}, channel: {}", deviceId, channelId); |
| @@ -450,7 +448,7 @@ public class ZLMHttpHookListener { | @@ -450,7 +448,7 @@ public class ZLMHttpHookListener { | ||
| 450 | } | 448 | } |
| 451 | }else { | 449 | }else { |
| 452 | // 开启语音对讲通道 | 450 | // 开启语音对讲通道 |
| 453 | - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); | 451 | + MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); |
| 454 | playService.talk(mediaServerItem, device, channelId, (mediaServer, jsonObject)->{ | 452 | playService.talk(mediaServerItem, device, channelId, (mediaServer, jsonObject)->{ |
| 455 | System.out.println("开始推流"); | 453 | System.out.println("开始推流"); |
| 456 | }, eventResult -> { | 454 | }, eventResult -> { |
| @@ -466,9 +464,9 @@ public class ZLMHttpHookListener { | @@ -466,9 +464,9 @@ public class ZLMHttpHookListener { | ||
| 466 | } | 464 | } |
| 467 | 465 | ||
| 468 | }else{ | 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 | if (mediaServerItem != null){ | 471 | if (mediaServerItem != null){ |
| 474 | if (param.isRegist()) { | 472 | if (param.isRegist()) { |
| @@ -478,7 +476,7 @@ public class ZLMHttpHookListener { | @@ -478,7 +476,7 @@ public class ZLMHttpHookListener { | ||
| 478 | callId = streamAuthorityInfo.getCallId(); | 476 | callId = streamAuthorityInfo.getCallId(); |
| 479 | } | 477 | } |
| 480 | StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem, | 478 | StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem, |
| 481 | - param.getApp(), param.getStream(), tracks, callId); | 479 | + param.getApp(), param.getStream(), param.getTracks(), callId); |
| 482 | param.setStreamInfo(streamInfoByAppAndStream); | 480 | param.setStreamInfo(streamInfoByAppAndStream); |
| 483 | redisCatchStorage.addStream(mediaServerItem, type, param.getApp(), param.getStream(), param); | 481 | redisCatchStorage.addStream(mediaServerItem, type, param.getApp(), param.getStream(), param); |
| 484 | if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal() | 482 | if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal() |
| @@ -489,7 +487,8 @@ public class ZLMHttpHookListener { | @@ -489,7 +487,8 @@ public class ZLMHttpHookListener { | ||
| 489 | } | 487 | } |
| 490 | }else { | 488 | }else { |
| 491 | // 兼容流注销时类型从redis记录获取 | 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 | if (onStreamChangedHookParam != null) { | 492 | if (onStreamChangedHookParam != null) { |
| 494 | type = OriginType.values()[onStreamChangedHookParam.getOriginType()].getType(); | 493 | type = OriginType.values()[onStreamChangedHookParam.getOriginType()].getType(); |
| 495 | redisCatchStorage.removeStream(mediaServerItem.getId(), type, param.getApp(), param.getStream()); | 494 | redisCatchStorage.removeStream(mediaServerItem.getId(), type, param.getApp(), param.getStream()); |
| @@ -526,13 +525,13 @@ public class ZLMHttpHookListener { | @@ -526,13 +525,13 @@ public class ZLMHttpHookListener { | ||
| 526 | if (platform != null) { | 525 | if (platform != null) { |
| 527 | commanderFroPlatform.streamByeCmd(platform, sendRtpItem); | 526 | commanderFroPlatform.streamByeCmd(platform, sendRtpItem); |
| 528 | }else { | 527 | }else { |
| 529 | - if ("talk".equals(app) && sendRtpItem.isOnlyAudio()) { | 528 | + if ("talk".equals(param.getApp()) && sendRtpItem.isOnlyAudio()) { |
| 530 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); | 529 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); |
| 531 | if (device != null && audioBroadcastCatch != null) { | 530 | if (device != null && audioBroadcastCatch != null) { |
| 532 | // cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null); | 531 | // cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null); |
| 533 | } | 532 | } |
| 534 | }else { | 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,6 +574,9 @@ public class ZLMHttpHookListener { | ||
| 575 | if (sendRtpItems.size() > 0) { | 574 | if (sendRtpItems.size() > 0) { |
| 576 | for (SendRtpItem sendRtpItem : sendRtpItems) { | 575 | for (SendRtpItem sendRtpItem : sendRtpItems) { |
| 577 | ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); | 576 | ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); |
| 577 | + if (parentPlatform == null) { | ||
| 578 | + continue; | ||
| 579 | + } | ||
| 578 | try { | 580 | try { |
| 579 | commanderFroPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId()); | 581 | commanderFroPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId()); |
| 580 | } catch (SipException | InvalidArgumentException | ParseException e) { | 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,6 +78,7 @@ public class ZLMRESTfulUtils { | ||
| 78 | if (callback == null) { | 78 | if (callback == null) { |
| 79 | try { | 79 | try { |
| 80 | Response response = client.newCall(request).execute(); | 80 | Response response = client.newCall(request).execute(); |
| 81 | + | ||
| 81 | if (response.isSuccessful()) { | 82 | if (response.isSuccessful()) { |
| 82 | ResponseBody responseBody = response.body(); | 83 | ResponseBody responseBody = response.body(); |
| 83 | if (responseBody != null) { | 84 | if (responseBody != null) { |
| @@ -85,6 +86,8 @@ public class ZLMRESTfulUtils { | @@ -85,6 +86,8 @@ public class ZLMRESTfulUtils { | ||
| 85 | responseJSON = JSON.parseObject(responseStr); | 86 | responseJSON = JSON.parseObject(responseStr); |
| 86 | } | 87 | } |
| 87 | }else { | 88 | }else { |
| 89 | + System.out.println( 2222); | ||
| 90 | + System.out.println( response.code()); | ||
| 88 | response.close(); | 91 | response.close(); |
| 89 | Objects.requireNonNull(response.body()).close(); | 92 | Objects.requireNonNull(response.body()).close(); |
| 90 | } | 93 | } |
| @@ -93,11 +96,11 @@ public class ZLMRESTfulUtils { | @@ -93,11 +96,11 @@ public class ZLMRESTfulUtils { | ||
| 93 | 96 | ||
| 94 | if(e instanceof SocketTimeoutException){ | 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 | if(e instanceof ConnectException){ | 101 | if(e instanceof ConnectException){ |
| 99 | //判断连接异常,我这里是报Failed to connect to 10.7.5.144 | 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 | }catch (Exception e){ | 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,9 +5,9 @@ import com.alibaba.fastjson2.JSONArray; | ||
| 5 | import com.alibaba.fastjson2.JSONObject; | 5 | import com.alibaba.fastjson2.JSONObject; |
| 6 | import com.genersoft.iot.vmp.conf.UserSetting; | 6 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 7 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | 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 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 10 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 10 | -import com.genersoft.iot.vmp.media.zlm.dto.*; | ||
| 11 | import org.slf4j.Logger; | 11 | import org.slf4j.Logger; |
| 12 | import org.slf4j.LoggerFactory; | 12 | import org.slf4j.LoggerFactory; |
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -346,23 +346,4 @@ public class ZLMRTPServerFactory { | @@ -346,23 +346,4 @@ public class ZLMRTPServerFactory { | ||
| 346 | return result; | 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,7 +37,7 @@ public class HookSubscribeFactory { | ||
| 37 | 37 | ||
| 38 | public static HookSubscribeForStreamPush on_publish(String app, String stream, String scheam, String mediaServerId) { | 38 | public static HookSubscribeForStreamPush on_publish(String app, String stream, String scheam, String mediaServerId) { |
| 39 | HookSubscribeForStreamPush hookSubscribe = new HookSubscribeForStreamPush(); | 39 | HookSubscribeForStreamPush hookSubscribe = new HookSubscribeForStreamPush(); |
| 40 | - JSONObject subscribeKey = new com.alibaba.fastjson.JSONObject(); | 40 | + JSONObject subscribeKey = new JSONObject(); |
| 41 | subscribeKey.put("app", app); | 41 | subscribeKey.put("app", app); |
| 42 | subscribeKey.put("stream", stream); | 42 | subscribeKey.put("stream", stream); |
| 43 | if (scheam != null) { | 43 | if (scheam != null) { |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamPush.java
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaServerItemLite.java
| 1 | package com.genersoft.iot.vmp.media.zlm.dto; | 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 | * 精简的MediaServerItem信息,方便给前端返回数据 | 5 | * 精简的MediaServerItem信息,方便给前端返回数据 |
| 12 | */ | 6 | */ |
| @@ -38,8 +32,6 @@ public class MediaServerItemLite { | @@ -38,8 +32,6 @@ public class MediaServerItemLite { | ||
| 38 | 32 | ||
| 39 | private String secret; | 33 | private String secret; |
| 40 | 34 | ||
| 41 | - private int hookAliveInterval; | ||
| 42 | - | ||
| 43 | private int recordAssistPort; | 35 | private int recordAssistPort; |
| 44 | 36 | ||
| 45 | 37 | ||
| @@ -58,7 +50,6 @@ public class MediaServerItemLite { | @@ -58,7 +50,6 @@ public class MediaServerItemLite { | ||
| 58 | this.rtspPort = mediaServerItem.getRtspPort(); | 50 | this.rtspPort = mediaServerItem.getRtspPort(); |
| 59 | this.rtspSSLPort = mediaServerItem.getRtspSSLPort(); | 51 | this.rtspSSLPort = mediaServerItem.getRtspSSLPort(); |
| 60 | this.secret = mediaServerItem.getSecret(); | 52 | this.secret = mediaServerItem.getSecret(); |
| 61 | - this.hookAliveInterval = mediaServerItem.getHookAliveInterval(); | ||
| 62 | this.recordAssistPort = mediaServerItem.getRecordAssistPort(); | 53 | this.recordAssistPort = mediaServerItem.getRecordAssistPort(); |
| 63 | } | 54 | } |
| 64 | 55 | ||
| @@ -167,14 +158,6 @@ public class MediaServerItemLite { | @@ -167,14 +158,6 @@ public class MediaServerItemLite { | ||
| 167 | this.secret = secret; | 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 | public int getRecordAssistPort() { | 161 | public int getRecordAssistPort() { |
| 179 | return recordAssistPort; | 162 | return recordAssistPort; |
| 180 | } | 163 | } |
src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java
| 1 | package com.genersoft.iot.vmp.service; | 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 | import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; | 3 | import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; |
| 7 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 4 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 8 | import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; | 5 | import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; |
| 9 | import com.genersoft.iot.vmp.service.bean.MediaServerLoad; | 6 | import com.genersoft.iot.vmp.service.bean.MediaServerLoad; |
| 10 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; | 7 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 11 | -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | ||
| 12 | 8 | ||
| 13 | import java.util.List; | 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,21 +4,18 @@ import com.alibaba.fastjson2.JSON; | ||
| 4 | import com.alibaba.fastjson2.JSONArray; | 4 | import com.alibaba.fastjson2.JSONArray; |
| 5 | import com.alibaba.fastjson2.JSONObject; | 5 | import com.alibaba.fastjson2.JSONObject; |
| 6 | import com.genersoft.iot.vmp.common.StreamInfo; | 6 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 7 | -import com.genersoft.iot.vmp.common.StreamURL; | ||
| 8 | import com.genersoft.iot.vmp.conf.MediaConfig; | 7 | import com.genersoft.iot.vmp.conf.MediaConfig; |
| 9 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | 8 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 10 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 9 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 11 | import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; | 10 | import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; |
| 12 | import com.genersoft.iot.vmp.service.IMediaServerService; | 11 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 12 | +import com.genersoft.iot.vmp.service.IMediaService; | ||
| 13 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 13 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 14 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 14 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 15 | -import com.genersoft.iot.vmp.service.IMediaService; | ||
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 18 | import org.springframework.util.ObjectUtils; | 17 | import org.springframework.util.ObjectUtils; |
| 19 | 18 | ||
| 20 | -import java.net.URL; | ||
| 21 | - | ||
| 22 | @Service | 19 | @Service |
| 23 | public class MediaServiceImpl implements IMediaService { | 20 | public class MediaServiceImpl implements IMediaService { |
| 24 | 21 | ||
| @@ -104,7 +101,7 @@ public class MediaServiceImpl implements IMediaService { | @@ -104,7 +101,7 @@ public class MediaServiceImpl implements IMediaService { | ||
| 104 | streamInfoResult.setFmp4(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | 101 | streamInfoResult.setFmp4(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); |
| 105 | streamInfoResult.setHls(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | 102 | streamInfoResult.setHls(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); |
| 106 | streamInfoResult.setTs(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); | 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 | streamInfoResult.setTracks(tracks); | 106 | streamInfoResult.setTracks(tracks); |
| 110 | return streamInfoResult; | 107 | return streamInfoResult; |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| 1 | package com.genersoft.iot.vmp.service.impl; | 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 | import com.alibaba.fastjson2.JSON; | 3 | import com.alibaba.fastjson2.JSON; |
| 15 | import com.alibaba.fastjson2.JSONArray; | 4 | import com.alibaba.fastjson2.JSONArray; |
| 16 | import com.alibaba.fastjson2.JSONObject; | 5 | import com.alibaba.fastjson2.JSONObject; |
| 17 | import com.genersoft.iot.vmp.common.StreamInfo; | 6 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 18 | import com.genersoft.iot.vmp.conf.DynamicTask; | 7 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 8 | +import com.genersoft.iot.vmp.conf.SipConfig; | ||
| 19 | import com.genersoft.iot.vmp.conf.UserSetting; | 9 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 20 | import com.genersoft.iot.vmp.conf.exception.ControllerException; | 10 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 21 | import com.genersoft.iot.vmp.conf.exception.ServiceException; | 11 | import com.genersoft.iot.vmp.conf.exception.ServiceException; |
| 22 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; | 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 | import com.genersoft.iot.vmp.gb28181.bean.*; | 13 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 49 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 14 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 50 | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; | 15 | import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; |
| 51 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; | 16 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 52 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 17 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 53 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | 18 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| 19 | +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | ||
| 54 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | 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 | import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; | 22 | import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; |
| 57 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | 23 | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| 58 | -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | ||
| 59 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; | 24 | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| 25 | +import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; | ||
| 60 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; | 26 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| 61 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; | 27 | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; |
| 62 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | 28 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| @@ -72,10 +38,10 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | @@ -72,10 +38,10 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | ||
| 72 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 38 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 73 | import com.genersoft.iot.vmp.utils.DateUtil; | 39 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 74 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; | 40 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 41 | +import com.genersoft.iot.vmp.vmanager.bean.AudioBroadcastResult; | ||
| 75 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; | 42 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 76 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | 43 | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| 77 | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.AudioBroadcastEvent; | 44 | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.AudioBroadcastEvent; |
| 78 | -import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; | ||
| 79 | import org.slf4j.Logger; | 45 | import org.slf4j.Logger; |
| 80 | import org.slf4j.LoggerFactory; | 46 | import org.slf4j.LoggerFactory; |
| 81 | import org.springframework.beans.factory.annotation.Autowired; | 47 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -91,7 +57,9 @@ import javax.sip.SipException; | @@ -91,7 +57,9 @@ import javax.sip.SipException; | ||
| 91 | import java.math.BigDecimal; | 57 | import java.math.BigDecimal; |
| 92 | import java.math.RoundingMode; | 58 | import java.math.RoundingMode; |
| 93 | import java.text.ParseException; | 59 | import java.text.ParseException; |
| 60 | +import java.util.HashMap; | ||
| 94 | import java.util.List; | 61 | import java.util.List; |
| 62 | +import java.util.Map; | ||
| 95 | import java.util.UUID; | 63 | import java.util.UUID; |
| 96 | 64 | ||
| 97 | @SuppressWarnings(value = {"rawtypes", "unchecked"}) | 65 | @SuppressWarnings(value = {"rawtypes", "unchecked"}) |
| @@ -1092,7 +1060,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -1092,7 +1060,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 1092 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId); | 1060 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId); |
| 1093 | if (audioBroadcastCatch != null) { | 1061 | if (audioBroadcastCatch != null) { |
| 1094 | 1062 | ||
| 1095 | - Device device = deviceService.queryDevice(deviceId); | 1063 | + Device device = deviceService.getDevice(deviceId); |
| 1096 | if (device == null) { | 1064 | if (device == null) { |
| 1097 | return; | 1065 | return; |
| 1098 | } | 1066 | } |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
| @@ -111,22 +111,25 @@ public class PlayController { | @@ -111,22 +111,25 @@ public class PlayController { | ||
| 111 | resultHolder.invokeResult(msg); | 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 | // 录像查询以channelId作为deviceId查询 | 134 | // 录像查询以channelId作为deviceId查询 |
| 132 | resultHolder.put(key, uuid, deferredResultEx); | 135 | resultHolder.put(key, uuid, deferredResultEx); |
web_src/src/components/dialog/devicePlayer.vue
| @@ -302,15 +302,13 @@ | @@ -302,15 +302,13 @@ | ||
| 302 | <script> | 302 | <script> |
| 303 | import rtcPlayer from '../dialog/rtcPlayer.vue' | 303 | import rtcPlayer from '../dialog/rtcPlayer.vue' |
| 304 | import crypto from 'crypto' | 304 | import crypto from 'crypto' |
| 305 | -// import LivePlayer from '@liveqing/liveplayer' | ||
| 306 | -// import player from '../dialog/easyPlayer.vue' | ||
| 307 | import jessibucaPlayer from '../common/jessibuca.vue' | 305 | import jessibucaPlayer from '../common/jessibuca.vue' |
| 308 | import recordDownload from '../dialog/recordDownload.vue' | 306 | import recordDownload from '../dialog/recordDownload.vue' |
| 309 | export default { | 307 | export default { |
| 310 | name: 'devicePlayer', | 308 | name: 'devicePlayer', |
| 311 | props: {}, | 309 | props: {}, |
| 312 | components: { | 310 | components: { |
| 313 | - LivePlayer, jessibucaPlayer, rtcPlayer, recordDownload, | 311 | + jessibucaPlayer, rtcPlayer, recordDownload, |
| 314 | }, | 312 | }, |
| 315 | computed: { | 313 | computed: { |
| 316 | getPlayerShared: function () { | 314 | getPlayerShared: function () { |
| @@ -864,9 +862,9 @@ export default { | @@ -864,9 +862,9 @@ export default { | ||
| 864 | if (res.data.code == 0) { | 862 | if (res.data.code == 0) { |
| 865 | let streamInfo = res.data.data.streamInfo; | 863 | let streamInfo = res.data.data.streamInfo; |
| 866 | if (document.location.protocol.includes("https")) { | 864 | if (document.location.protocol.includes("https")) { |
| 867 | - this.startBroadcast(streamInfo.rtcs) | 865 | + this.startBroadcast(streamInfo.rtcs.url) |
| 868 | }else { | 866 | }else { |
| 869 | - this.startBroadcast(streamInfo.rtc) | 867 | + this.startBroadcast(streamInfo.rtc.url) |
| 870 | } | 868 | } |
| 871 | 869 | ||
| 872 | }else { | 870 | }else { |