Commit f6320c7dd3dfd25e98bb63f41d79a33af5009a93
1 parent
82fd369c
合并主线
Showing
4 changed files
with
95 additions
and
88 deletions
sql/update.sql
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| ... | ... | @@ -896,7 +896,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 896 | 896 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(requesterId, channelId); |
| 897 | 897 | if (audioBroadcastCatch == null) { |
| 898 | 898 | logger.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId); |
| 899 | - responseAck(serverTransaction, Response.FORBIDDEN); | |
| 899 | + try { | |
| 900 | + responseAck(serverTransaction, Response.FORBIDDEN); | |
| 901 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 902 | + logger.error("[命令发送失败] 来自设备的Invite请求非语音广播 FORBIDDEN: {}", e.getMessage()); | |
| 903 | + } | |
| 900 | 904 | return; |
| 901 | 905 | } |
| 902 | 906 | Request request = serverTransaction.getRequest(); |
| ... | ... | @@ -920,86 +924,102 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 920 | 924 | if (ssrcIndex > 0) { |
| 921 | 925 | substring = contentString.substring(0, ssrcIndex); |
| 922 | 926 | } |
| 923 | - SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(substring); | |
| 924 | - | |
| 925 | - // 获取支持的格式 | |
| 926 | - Vector mediaDescriptions = sdp.getMediaDescriptions(true); | |
| 927 | - | |
| 928 | - // 查看是否支持PS 负载96 | |
| 929 | - int port = -1; | |
| 930 | - boolean mediaTransmissionTCP = false; | |
| 931 | - Boolean tcpActive = null; | |
| 932 | - for (int i = 0; i < mediaDescriptions.size(); i++) { | |
| 933 | - MediaDescription mediaDescription = (MediaDescription)mediaDescriptions.get(i); | |
| 934 | - Media media = mediaDescription.getMedia(); | |
| 935 | - | |
| 936 | - Vector mediaFormats = media.getMediaFormats(false); | |
| 937 | - if (mediaFormats.contains("8")) { | |
| 938 | - port = media.getMediaPort(); | |
| 939 | - String protocol = media.getProtocol(); | |
| 940 | - // 区分TCP发流还是udp, 当前默认udp | |
| 941 | - if ("TCP/RTP/AVP".equals(protocol)) { | |
| 942 | - String setup = mediaDescription.getAttribute("setup"); | |
| 943 | - if (setup != null) { | |
| 944 | - mediaTransmissionTCP = true; | |
| 945 | - if ("active".equals(setup)) { | |
| 946 | - tcpActive = true; | |
| 947 | - } else if ("passive".equals(setup)) { | |
| 948 | - tcpActive = false; | |
| 927 | + try { | |
| 928 | + SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(substring); | |
| 929 | + | |
| 930 | + // 获取支持的格式 | |
| 931 | + Vector mediaDescriptions = sdp.getMediaDescriptions(true); | |
| 932 | + | |
| 933 | + // 查看是否支持PS 负载96 | |
| 934 | + int port = -1; | |
| 935 | + boolean mediaTransmissionTCP = false; | |
| 936 | + Boolean tcpActive = null; | |
| 937 | + for (int i = 0; i < mediaDescriptions.size(); i++) { | |
| 938 | + MediaDescription mediaDescription = (MediaDescription)mediaDescriptions.get(i); | |
| 939 | + Media media = mediaDescription.getMedia(); | |
| 940 | + | |
| 941 | + Vector mediaFormats = media.getMediaFormats(false); | |
| 942 | + if (mediaFormats.contains("8")) { | |
| 943 | + port = media.getMediaPort(); | |
| 944 | + String protocol = media.getProtocol(); | |
| 945 | + // 区分TCP发流还是udp, 当前默认udp | |
| 946 | + if ("TCP/RTP/AVP".equals(protocol)) { | |
| 947 | + String setup = mediaDescription.getAttribute("setup"); | |
| 948 | + if (setup != null) { | |
| 949 | + mediaTransmissionTCP = true; | |
| 950 | + if ("active".equals(setup)) { | |
| 951 | + tcpActive = true; | |
| 952 | + } else if ("passive".equals(setup)) { | |
| 953 | + tcpActive = false; | |
| 954 | + } | |
| 949 | 955 | } |
| 950 | 956 | } |
| 957 | + break; | |
| 951 | 958 | } |
| 952 | - break; | |
| 953 | 959 | } |
| 954 | - } | |
| 955 | - if (port == -1) { | |
| 956 | - logger.info("不支持的媒体格式,返回415"); | |
| 957 | - // 回复不支持的格式 | |
| 958 | - responseAck(serverTransaction, Response.UNSUPPORTED_MEDIA_TYPE); // 不支持的格式,发415 | |
| 959 | - return; | |
| 960 | - } | |
| 961 | - String addressStr = sdp.getOrigin().getAddress(); | |
| 962 | - logger.info("设备{}请求语音流,地址:{}:{},ssrc:{}", requesterId, addressStr, port, ssrc); | |
| 960 | + if (port == -1) { | |
| 961 | + logger.info("不支持的媒体格式,返回415"); | |
| 962 | + // 回复不支持的格式 | |
| 963 | + try { | |
| 964 | + responseAck(serverTransaction, Response.UNSUPPORTED_MEDIA_TYPE); // 不支持的格式,发415 | |
| 965 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 966 | + logger.error("[命令发送失败] invite 不支持的媒体格式: {}", e.getMessage()); | |
| 967 | + } | |
| 968 | + return; | |
| 969 | + } | |
| 970 | + String addressStr = sdp.getOrigin().getAddress(); | |
| 971 | + logger.info("设备{}请求语音流,地址:{}:{},ssrc:{}", requesterId, addressStr, port, ssrc); | |
| 963 | 972 | |
| 964 | - MediaServerItem mediaServerItem = playService.getNewMediaServerItem(device); | |
| 965 | - if (mediaServerItem == null) { | |
| 966 | - logger.warn("未找到可用的zlm"); | |
| 967 | - responseAck(serverTransaction, Response.BUSY_HERE); | |
| 968 | - return; | |
| 969 | - } | |
| 970 | - SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, | |
| 971 | - device.getDeviceId(), audioBroadcastCatch.getChannelId(), | |
| 972 | - mediaTransmissionTCP); | |
| 973 | - if (sendRtpItem == null) { | |
| 974 | - logger.warn("服务器端口资源不足"); | |
| 975 | - responseAck(serverTransaction, Response.BUSY_HERE); | |
| 976 | - return; | |
| 977 | - } | |
| 978 | - sendRtpItem.setTcp(mediaTransmissionTCP); | |
| 979 | - if (tcpActive != null) { | |
| 980 | - sendRtpItem.setTcpActive(tcpActive); | |
| 981 | - } | |
| 982 | - String app = "broadcast"; | |
| 983 | - String stream = device.getDeviceId() + "_" + audioBroadcastCatch.getChannelId(); | |
| 973 | + MediaServerItem mediaServerItem = playService.getNewMediaServerItem(device); | |
| 974 | + if (mediaServerItem == null) { | |
| 975 | + logger.warn("未找到可用的zlm"); | |
| 976 | + try { | |
| 977 | + responseAck(serverTransaction, Response.BUSY_HERE); | |
| 978 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 979 | + logger.error("[命令发送失败] invite 未找到可用的zlm: {}", e.getMessage()); | |
| 980 | + } | |
| 981 | + return; | |
| 982 | + } | |
| 983 | + SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, | |
| 984 | + device.getDeviceId(), audioBroadcastCatch.getChannelId(), | |
| 985 | + mediaTransmissionTCP); | |
| 986 | + if (sendRtpItem == null) { | |
| 987 | + logger.warn("服务器端口资源不足"); | |
| 988 | + try { | |
| 989 | + responseAck(serverTransaction, Response.BUSY_HERE); | |
| 990 | + } catch (SipException | InvalidArgumentException | ParseException e) { | |
| 991 | + logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); | |
| 992 | + } | |
| 993 | + return; | |
| 994 | + } | |
| 995 | + sendRtpItem.setTcp(mediaTransmissionTCP); | |
| 996 | + if (tcpActive != null) { | |
| 997 | + sendRtpItem.setTcpActive(tcpActive); | |
| 998 | + } | |
| 999 | + String app = "broadcast"; | |
| 1000 | + String stream = device.getDeviceId() + "_" + audioBroadcastCatch.getChannelId(); | |
| 984 | 1001 | |
| 985 | - CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); | |
| 986 | - sendRtpItem.setPlayType(InviteStreamType.PLAY); | |
| 987 | - sendRtpItem.setCallId(callIdHeader.getCallId()); | |
| 988 | - sendRtpItem.setPlatformId(requesterId); | |
| 989 | - sendRtpItem.setStatus(1); | |
| 990 | - sendRtpItem.setApp(app); | |
| 991 | - sendRtpItem.setStreamId(stream); | |
| 992 | - sendRtpItem.setPt(8); | |
| 993 | - sendRtpItem.setUsePs(false); | |
| 994 | - sendRtpItem.setOnlyAudio(true); | |
| 995 | - redisCatchStorage.updateSendRTPSever(sendRtpItem); | |
| 1002 | + CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); | |
| 1003 | + sendRtpItem.setPlayType(InviteStreamType.PLAY); | |
| 1004 | + sendRtpItem.setCallId(callIdHeader.getCallId()); | |
| 1005 | + sendRtpItem.setPlatformId(requesterId); | |
| 1006 | + sendRtpItem.setStatus(1); | |
| 1007 | + sendRtpItem.setApp(app); | |
| 1008 | + sendRtpItem.setStreamId(stream); | |
| 1009 | + sendRtpItem.setPt(8); | |
| 1010 | + sendRtpItem.setUsePs(false); | |
| 1011 | + sendRtpItem.setOnlyAudio(true); | |
| 1012 | + redisCatchStorage.updateSendRTPSever(sendRtpItem); | |
| 996 | 1013 | |
| 997 | - Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream); | |
| 998 | - if (streamReady) { | |
| 999 | - sendOk(device, sendRtpItem, sdp, serverTransaction, mediaServerItem, mediaTransmissionTCP, ssrc); | |
| 1000 | - }else { | |
| 1001 | - logger.warn("[语音通话], 未发现待推送的流,app={},stream={}", app, stream); | |
| 1002 | - playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId()); | |
| 1014 | + Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream); | |
| 1015 | + if (streamReady) { | |
| 1016 | + sendOk(device, sendRtpItem, sdp, serverTransaction, mediaServerItem, mediaTransmissionTCP, ssrc); | |
| 1017 | + }else { | |
| 1018 | + logger.warn("[语音通话], 未发现待推送的流,app={},stream={}", app, stream); | |
| 1019 | + playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId()); | |
| 1020 | + } | |
| 1021 | + } catch (SdpException e) { | |
| 1022 | + logger.error("[SDP解析异常]", e); | |
| 1003 | 1023 | } |
| 1004 | 1024 | } else { |
| 1005 | 1025 | logger.warn("来自无效设备/平台的请求"); | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java
| ... | ... | @@ -11,7 +11,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 11 | 11 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 12 | 12 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| 13 | 13 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 14 | -import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; | |
| 15 | 14 | import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; |
| 16 | 15 | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| 17 | 16 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaServerItemLite.java
| ... | ... | @@ -38,8 +38,6 @@ public class MediaServerItemLite { |
| 38 | 38 | |
| 39 | 39 | private String secret; |
| 40 | 40 | |
| 41 | - private int streamNoneReaderDelayMS; | |
| 42 | - | |
| 43 | 41 | private int hookAliveInterval; |
| 44 | 42 | |
| 45 | 43 | private int recordAssistPort; |
| ... | ... | @@ -60,9 +58,7 @@ public class MediaServerItemLite { |
| 60 | 58 | this.rtspPort = mediaServerItem.getRtspPort(); |
| 61 | 59 | this.rtspSSLPort = mediaServerItem.getRtspSSLPort(); |
| 62 | 60 | this.secret = mediaServerItem.getSecret(); |
| 63 | - this.streamNoneReaderDelayMS = mediaServerItem.getStreamNoneReaderDelayMS(); | |
| 64 | 61 | this.hookAliveInterval = mediaServerItem.getHookAliveInterval(); |
| 65 | - this.streamNoneReaderDelayMS = mediaServerItem.getStreamNoneReaderDelayMS(); | |
| 66 | 62 | this.recordAssistPort = mediaServerItem.getRecordAssistPort(); |
| 67 | 63 | } |
| 68 | 64 | |
| ... | ... | @@ -171,14 +167,6 @@ public class MediaServerItemLite { |
| 171 | 167 | this.secret = secret; |
| 172 | 168 | } |
| 173 | 169 | |
| 174 | - public int getStreamNoneReaderDelayMS() { | |
| 175 | - return streamNoneReaderDelayMS; | |
| 176 | - } | |
| 177 | - | |
| 178 | - public void setStreamNoneReaderDelayMS(int streamNoneReaderDelayMS) { | |
| 179 | - this.streamNoneReaderDelayMS = streamNoneReaderDelayMS; | |
| 180 | - } | |
| 181 | - | |
| 182 | 170 | public int getHookAliveInterval() { |
| 183 | 171 | return hookAliveInterval; |
| 184 | 172 | } | ... | ... |