Commit 6b03568c5dd128a3d71c02fb1a3a76a4344a4920
1 parent
ecf84bb0
优化rtcp判断
Showing
10 changed files
with
81 additions
and
39 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java
| 1 | package com.genersoft.iot.vmp.gb28181.bean; | 1 | package com.genersoft.iot.vmp.gb28181.bean; |
| 2 | 2 | ||
| 3 | -import gov.nist.javax.sip.message.SIPRequest; | ||
| 4 | - | ||
| 5 | public class SendRtpItem { | 3 | public class SendRtpItem { |
| 6 | 4 | ||
| 7 | /** | 5 | /** |
| @@ -108,6 +106,11 @@ public class SendRtpItem { | @@ -108,6 +106,11 @@ public class SendRtpItem { | ||
| 108 | */ | 106 | */ |
| 109 | private boolean onlyAudio = false; | 107 | private boolean onlyAudio = false; |
| 110 | 108 | ||
| 109 | + /** | ||
| 110 | + * 是否开启rtcp保活 | ||
| 111 | + */ | ||
| 112 | + private boolean rtcp = false; | ||
| 113 | + | ||
| 111 | 114 | ||
| 112 | /** | 115 | /** |
| 113 | * 播放类型 | 116 | * 播放类型 |
| @@ -281,4 +284,12 @@ public class SendRtpItem { | @@ -281,4 +284,12 @@ public class SendRtpItem { | ||
| 281 | public void setToTag(String toTag) { | 284 | public void setToTag(String toTag) { |
| 282 | this.toTag = toTag; | 285 | this.toTag = toTag; |
| 283 | } | 286 | } |
| 287 | + | ||
| 288 | + public boolean isRtcp() { | ||
| 289 | + return rtcp; | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + public void setRtcp(boolean rtcp) { | ||
| 293 | + this.rtcp = rtcp; | ||
| 294 | + } | ||
| 284 | } | 295 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
| 1 | package com.genersoft.iot.vmp.gb28181.session; | 1 | package com.genersoft.iot.vmp.gb28181.session; |
| 2 | 2 | ||
| 3 | -import java.util.ArrayList; | ||
| 4 | -import java.util.List; | ||
| 5 | - | 3 | +import com.alibaba.fastjson2.JSON; |
| 6 | import com.genersoft.iot.vmp.common.VideoManagerConstants; | 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 7 | import com.genersoft.iot.vmp.conf.UserSetting; | 5 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 8 | import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; | 6 | import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; |
| @@ -13,6 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -13,6 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | import org.springframework.stereotype.Component; | 11 | import org.springframework.stereotype.Component; |
| 14 | import org.springframework.util.ObjectUtils; | 12 | import org.springframework.util.ObjectUtils; |
| 15 | 13 | ||
| 14 | +import java.util.ArrayList; | ||
| 15 | +import java.util.List; | ||
| 16 | + | ||
| 16 | /** | 17 | /** |
| 17 | * @description:视频流session管理器,管理视频预览、预览回放的通信句柄 | 18 | * @description:视频流session管理器,管理视频预览、预览回放的通信句柄 |
| 18 | * @author: swwheihei | 19 | * @author: swwheihei |
| @@ -27,7 +28,8 @@ public class VideoStreamSessionManager { | @@ -27,7 +28,8 @@ public class VideoStreamSessionManager { | ||
| 27 | public enum SessionType { | 28 | public enum SessionType { |
| 28 | play, | 29 | play, |
| 29 | playback, | 30 | playback, |
| 30 | - download | 31 | + download, |
| 32 | + broadcast | ||
| 31 | } | 33 | } |
| 32 | 34 | ||
| 33 | /** | 35 | /** |
| @@ -50,9 +52,8 @@ public class VideoStreamSessionManager { | @@ -50,9 +52,8 @@ public class VideoStreamSessionManager { | ||
| 50 | ssrcTransaction.setSsrc(ssrc); | 52 | ssrcTransaction.setSsrc(ssrc); |
| 51 | ssrcTransaction.setMediaServerId(mediaServerId); | 53 | ssrcTransaction.setMediaServerId(mediaServerId); |
| 52 | ssrcTransaction.setType(type); | 54 | ssrcTransaction.setType(type); |
| 53 | - | ||
| 54 | - RedisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() | ||
| 55 | - + "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction); | 55 | + System.out.println(22222); |
| 56 | + System.out.println(JSON.toJSONString(ssrcTransaction)); | ||
| 56 | RedisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() | 57 | RedisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() |
| 57 | + "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction); | 58 | + "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction); |
| 58 | } | 59 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -646,7 +646,7 @@ public class SIPCommander implements ISIPCommander { | @@ -646,7 +646,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 646 | * 视频流停止, 不使用回调 | 646 | * 视频流停止, 不使用回调 |
| 647 | */ | 647 | */ |
| 648 | @Override | 648 | @Override |
| 649 | - public synchronized void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException { | 649 | + public void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException { |
| 650 | streamByeCmd(device, channelId, stream, callId, null); | 650 | streamByeCmd(device, channelId, stream, callId, null); |
| 651 | } | 651 | } |
| 652 | 652 | ||
| @@ -654,7 +654,7 @@ public class SIPCommander implements ISIPCommander { | @@ -654,7 +654,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 654 | * 视频流停止 | 654 | * 视频流停止 |
| 655 | */ | 655 | */ |
| 656 | @Override | 656 | @Override |
| 657 | - public synchronized void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { | 657 | + public void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { |
| 658 | SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, callId, stream); | 658 | SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), channelId, callId, stream); |
| 659 | if (ssrcTransaction == null) { | 659 | if (ssrcTransaction == null) { |
| 660 | throw new SsrcTransactionNotFoundException(device.getDeviceId(), channelId, callId, stream); | 660 | throw new SsrcTransactionNotFoundException(device.getDeviceId(), channelId, callId, stream); |
| @@ -669,7 +669,7 @@ public class SIPCommander implements ISIPCommander { | @@ -669,7 +669,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 669 | } | 669 | } |
| 670 | 670 | ||
| 671 | @Override | 671 | @Override |
| 672 | - public synchronized void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { | 672 | + public void streamByeCmd(Device device, String channelId, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { |
| 673 | Request byteRequest = headerProvider.createByteRequest(device, channelId, sipTransactionInfo); | 673 | Request byteRequest = headerProvider.createByteRequest(device, channelId, sipTransactionInfo); |
| 674 | sipSender.transmitRequest(device.getTransport(), byteRequest, null, okEvent); | 674 | sipSender.transmitRequest(device.getTransport(), byteRequest, null, okEvent); |
| 675 | } | 675 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java
| @@ -4,10 +4,10 @@ import com.alibaba.fastjson2.JSON; | @@ -4,10 +4,10 @@ import com.alibaba.fastjson2.JSON; | ||
| 4 | import com.alibaba.fastjson2.JSONObject; | 4 | import com.alibaba.fastjson2.JSONObject; |
| 5 | import com.genersoft.iot.vmp.conf.DynamicTask; | 5 | import com.genersoft.iot.vmp.conf.DynamicTask; |
| 6 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; | 6 | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| 7 | -import com.genersoft.iot.vmp.gb28181.bean.*; | ||
| 8 | -import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; | 7 | +import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 9 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 8 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 10 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; | 9 | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| 10 | +import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; | ||
| 11 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; | 11 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| 12 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; | 12 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; |
| 13 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | 13 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| @@ -22,15 +22,12 @@ import com.genersoft.iot.vmp.service.bean.RequestPushStreamMsg; | @@ -22,15 +22,12 @@ import com.genersoft.iot.vmp.service.bean.RequestPushStreamMsg; | ||
| 22 | import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener; | 22 | import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener; |
| 23 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 23 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 24 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 24 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 25 | -import gov.nist.javax.sip.message.SIPRequest; | ||
| 26 | -import gov.nist.javax.sip.stack.SIPDialog; | ||
| 27 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
| 28 | import org.slf4j.LoggerFactory; | 26 | import org.slf4j.LoggerFactory; |
| 29 | import org.springframework.beans.factory.InitializingBean; | 27 | import org.springframework.beans.factory.InitializingBean; |
| 30 | import org.springframework.beans.factory.annotation.Autowired; | 28 | import org.springframework.beans.factory.annotation.Autowired; |
| 31 | import org.springframework.stereotype.Component; | 29 | import org.springframework.stereotype.Component; |
| 32 | 30 | ||
| 33 | -import javax.sip.*; | ||
| 34 | import javax.sip.InvalidArgumentException; | 31 | import javax.sip.InvalidArgumentException; |
| 35 | import javax.sip.RequestEvent; | 32 | import javax.sip.RequestEvent; |
| 36 | import javax.sip.SipException; | 33 | import javax.sip.SipException; |
| @@ -38,7 +35,6 @@ import javax.sip.address.SipURI; | @@ -38,7 +35,6 @@ import javax.sip.address.SipURI; | ||
| 38 | import javax.sip.header.CallIdHeader; | 35 | import javax.sip.header.CallIdHeader; |
| 39 | import javax.sip.header.FromHeader; | 36 | import javax.sip.header.FromHeader; |
| 40 | import javax.sip.header.HeaderAddress; | 37 | import javax.sip.header.HeaderAddress; |
| 41 | -import java.text.ParseException; | ||
| 42 | import javax.sip.header.ToHeader; | 38 | import javax.sip.header.ToHeader; |
| 43 | import java.text.ParseException; | 39 | import java.text.ParseException; |
| 44 | import java.util.HashMap; | 40 | import java.util.HashMap; |
| @@ -122,7 +118,8 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In | @@ -122,7 +118,8 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In | ||
| 122 | } | 118 | } |
| 123 | String is_Udp = sendRtpItem.isTcp() ? "0" : "1"; | 119 | String is_Udp = sendRtpItem.isTcp() ? "0" : "1"; |
| 124 | MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); | 120 | MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); |
| 125 | - logger.info("收到ACK,rtp/{}开始向上级推流, 目标={}:{},SSRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc()); | 121 | + logger.info("收到ACK,rtp/{}开始向上级推流, 目标={}:{},SSRC={}, RTCP={}", sendRtpItem.getStreamId(), |
| 122 | + sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc(), sendRtpItem.isRtcp()); | ||
| 126 | Map<String, Object> param = new HashMap<>(12); | 123 | Map<String, Object> param = new HashMap<>(12); |
| 127 | param.put("vhost","__defaultVhost__"); | 124 | param.put("vhost","__defaultVhost__"); |
| 128 | param.put("app",sendRtpItem.getApp()); | 125 | param.put("app",sendRtpItem.getApp()); |
| @@ -132,9 +129,9 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In | @@ -132,9 +129,9 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In | ||
| 132 | param.put("pt", sendRtpItem.getPt()); | 129 | param.put("pt", sendRtpItem.getPt()); |
| 133 | param.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0"); | 130 | param.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0"); |
| 134 | param.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0"); | 131 | param.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0"); |
| 135 | - if (!sendRtpItem.isTcp() && parentPlatform != null && parentPlatform.isRtcp()) { | 132 | + if (!sendRtpItem.isTcp()) { |
| 136 | // 开启rtcp保活 | 133 | // 开启rtcp保活 |
| 137 | - param.put("udp_rtcp_timeout", "1"); | 134 | + param.put("udp_rtcp_timeout", sendRtpItem.isRtcp()? "1":"0"); |
| 138 | } | 135 | } |
| 139 | 136 | ||
| 140 | JSONObject jsonObject; | 137 | JSONObject jsonObject; |
| @@ -145,6 +142,9 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In | @@ -145,6 +142,9 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In | ||
| 145 | param.put("dst_url", sendRtpItem.getIp()); | 142 | param.put("dst_url", sendRtpItem.getIp()); |
| 146 | param.put("dst_port", sendRtpItem.getPort()); | 143 | param.put("dst_port", sendRtpItem.getPort()); |
| 147 | jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param); | 144 | jsonObject = zlmrtpServerFactory.startSendRtpStream(mediaInfo, param); |
| 145 | + System.out.println(JSON.toJSONString(param)); | ||
| 146 | + System.out.println(); | ||
| 147 | + System.out.println(jsonObject); | ||
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | if (jsonObject == null) { | 150 | if (jsonObject == null) { |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| @@ -126,6 +126,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -126,6 +126,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 126 | @Autowired | 126 | @Autowired |
| 127 | private SipConfig config; | 127 | private SipConfig config; |
| 128 | 128 | ||
| 129 | + @Autowired | ||
| 130 | + private VideoStreamSessionManager streamSession; | ||
| 131 | + | ||
| 129 | 132 | ||
| 130 | 133 | ||
| 131 | @Autowired | 134 | @Autowired |
| @@ -383,7 +386,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -383,7 +386,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 383 | } | 386 | } |
| 384 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, | 387 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, |
| 385 | device.getDeviceId(), channelId, | 388 | device.getDeviceId(), channelId, |
| 386 | - mediaTransmissionTCP); | 389 | + mediaTransmissionTCP, platform.isRtcp()); |
| 387 | 390 | ||
| 388 | if (tcpActive != null) { | 391 | if (tcpActive != null) { |
| 389 | sendRtpItem.setTcpActive(tcpActive); | 392 | sendRtpItem.setTcpActive(tcpActive); |
| @@ -579,7 +582,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -579,7 +582,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 579 | // 自平台内容 | 582 | // 自平台内容 |
| 580 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, | 583 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, |
| 581 | gbStream.getApp(), gbStream.getStream(), channelId, | 584 | gbStream.getApp(), gbStream.getStream(), channelId, |
| 582 | - mediaTransmissionTCP); | 585 | + mediaTransmissionTCP, platform.isRtcp()); |
| 583 | 586 | ||
| 584 | if (sendRtpItem == null) { | 587 | if (sendRtpItem == null) { |
| 585 | logger.warn("服务器端口资源不足"); | 588 | logger.warn("服务器端口资源不足"); |
| @@ -619,7 +622,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -619,7 +622,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 619 | // 自平台内容 | 622 | // 自平台内容 |
| 620 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, | 623 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, |
| 621 | gbStream.getApp(), gbStream.getStream(), channelId, | 624 | gbStream.getApp(), gbStream.getStream(), channelId, |
| 622 | - mediaTransmissionTCP); | 625 | + mediaTransmissionTCP, platform.isRtcp()); |
| 623 | 626 | ||
| 624 | if (sendRtpItem == null) { | 627 | if (sendRtpItem == null) { |
| 625 | logger.warn("服务器端口资源不足"); | 628 | logger.warn("服务器端口资源不足"); |
| @@ -736,7 +739,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -736,7 +739,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 736 | dynamicTask.stop(callIdHeader.getCallId()); | 739 | dynamicTask.stop(callIdHeader.getCallId()); |
| 737 | if (serverId.equals(userSetting.getServerId())) { | 740 | if (serverId.equals(userSetting.getServerId())) { |
| 738 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, finalPort, ssrc, requesterId, | 741 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, finalPort, ssrc, requesterId, |
| 739 | - app, stream, channelId, mediaTransmissionTCP); | 742 | + app, stream, channelId, mediaTransmissionTCP, platform.isRtcp()); |
| 740 | 743 | ||
| 741 | if (sendRtpItem == null) { | 744 | if (sendRtpItem == null) { |
| 742 | logger.warn("上级点时创建sendRTPItem失败,可能是服务器端口资源不足"); | 745 | logger.warn("上级点时创建sendRTPItem失败,可能是服务器端口资源不足"); |
| @@ -798,7 +801,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -798,7 +801,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 798 | // 发送redis消息 | 801 | // 发送redis消息 |
| 799 | redisGbPlayMsgListener.sendMsg(streamPushItem.getServerId(), streamPushItem.getMediaServerId(), | 802 | redisGbPlayMsgListener.sendMsg(streamPushItem.getServerId(), streamPushItem.getMediaServerId(), |
| 800 | streamPushItem.getApp(), streamPushItem.getStream(), addressStr, port, ssrc, requesterId, | 803 | streamPushItem.getApp(), streamPushItem.getStream(), addressStr, port, ssrc, requesterId, |
| 801 | - channelId, mediaTransmissionTCP, null, responseSendItemMsg -> { | 804 | + channelId, mediaTransmissionTCP, platform.isRtcp(), null, responseSendItemMsg -> { |
| 802 | SendRtpItem sendRtpItem = responseSendItemMsg.getSendRtpItem(); | 805 | SendRtpItem sendRtpItem = responseSendItemMsg.getSendRtpItem(); |
| 803 | if (sendRtpItem == null || responseSendItemMsg.getMediaServerItem() == null) { | 806 | if (sendRtpItem == null || responseSendItemMsg.getMediaServerItem() == null) { |
| 804 | logger.warn("服务器端口资源不足"); | 807 | logger.warn("服务器端口资源不足"); |
| @@ -904,6 +907,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -904,6 +907,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 904 | } | 907 | } |
| 905 | if (device != null) { | 908 | if (device != null) { |
| 906 | logger.info("收到设备" + requesterId + "的语音广播Invite请求"); | 909 | logger.info("收到设备" + requesterId + "的语音广播Invite请求"); |
| 910 | + | ||
| 907 | try { | 911 | try { |
| 908 | responseAck(request, Response.TRYING); | 912 | responseAck(request, Response.TRYING); |
| 909 | } catch (SipException | InvalidArgumentException | ParseException e) { | 913 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| @@ -980,7 +984,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -980,7 +984,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 980 | } | 984 | } |
| 981 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, | 985 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, |
| 982 | device.getDeviceId(), audioBroadcastCatch.getChannelId(), | 986 | device.getDeviceId(), audioBroadcastCatch.getChannelId(), |
| 983 | - mediaTransmissionTCP); | 987 | + mediaTransmissionTCP, false); |
| 988 | + | ||
| 984 | if (sendRtpItem == null) { | 989 | if (sendRtpItem == null) { |
| 985 | logger.warn("服务器端口资源不足"); | 990 | logger.warn("服务器端口资源不足"); |
| 986 | try { | 991 | try { |
| @@ -1006,12 +1011,16 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -1006,12 +1011,16 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 1006 | sendRtpItem.setStreamId(stream); | 1011 | sendRtpItem.setStreamId(stream); |
| 1007 | sendRtpItem.setPt(8); | 1012 | sendRtpItem.setPt(8); |
| 1008 | sendRtpItem.setUsePs(false); | 1013 | sendRtpItem.setUsePs(false); |
| 1014 | + sendRtpItem.setRtcp(false); | ||
| 1009 | sendRtpItem.setOnlyAudio(true); | 1015 | sendRtpItem.setOnlyAudio(true); |
| 1010 | redisCatchStorage.updateSendRTPSever(sendRtpItem); | 1016 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| 1011 | 1017 | ||
| 1012 | Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream); | 1018 | Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream); |
| 1013 | if (streamReady) { | 1019 | if (streamReady) { |
| 1014 | - sendOk(device, sendRtpItem, sdp, request, mediaServerItem, mediaTransmissionTCP, ssrc); | 1020 | + SIPResponse sipResponse = sendOk(device, sendRtpItem, sdp, request, mediaServerItem, mediaTransmissionTCP, ssrc); |
| 1021 | + // 添加事务信息 | ||
| 1022 | + streamSession.put(device.getDeviceId(), audioBroadcastCatch.getChannelId(), request.getCallIdHeader().getCallId() | ||
| 1023 | + , stream, sendRtpItem.getSsrc(), mediaServerItem.getId(), sipResponse, VideoStreamSessionManager.SessionType.broadcast ); | ||
| 1015 | }else { | 1024 | }else { |
| 1016 | logger.warn("[语音通话], 未发现待推送的流,app={},stream={}", app, stream); | 1025 | logger.warn("[语音通话], 未发现待推送的流,app={},stream={}", app, stream); |
| 1017 | playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId()); | 1026 | playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId()); |
| @@ -1029,7 +1038,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -1029,7 +1038,8 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 1029 | } | 1038 | } |
| 1030 | } | 1039 | } |
| 1031 | 1040 | ||
| 1032 | - void sendOk(Device device, SendRtpItem sendRtpItem, SessionDescription sdp, SIPRequest request, MediaServerItem mediaServerItem, boolean mediaTransmissionTCP, String ssrc){ | 1041 | + SIPResponse sendOk(Device device, SendRtpItem sendRtpItem, SessionDescription sdp, SIPRequest request, MediaServerItem mediaServerItem, boolean mediaTransmissionTCP, String ssrc){ |
| 1042 | + SIPResponse sipResponse = null; | ||
| 1033 | try { | 1043 | try { |
| 1034 | sendRtpItem.setStatus(2); | 1044 | sendRtpItem.setStatus(2); |
| 1035 | redisCatchStorage.updateSendRTPSever(sendRtpItem); | 1045 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| @@ -1065,15 +1075,17 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -1065,15 +1075,17 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 1065 | parentPlatform.setServerPort(device.getPort()); | 1075 | parentPlatform.setServerPort(device.getPort()); |
| 1066 | parentPlatform.setServerGBId(device.getDeviceId()); | 1076 | parentPlatform.setServerGBId(device.getDeviceId()); |
| 1067 | 1077 | ||
| 1068 | - SIPResponse sipResponse = responseSdpAck(request, content.toString(), parentPlatform); | 1078 | + sipResponse = responseSdpAck(request, content.toString(), parentPlatform); |
| 1069 | 1079 | ||
| 1070 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(device.getDeviceId(), sendRtpItem.getChannelId()); | 1080 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(device.getDeviceId(), sendRtpItem.getChannelId()); |
| 1071 | 1081 | ||
| 1072 | audioBroadcastCatch.setStatus(AudioBroadcastCatchStatus.Ok); | 1082 | audioBroadcastCatch.setStatus(AudioBroadcastCatchStatus.Ok); |
| 1073 | audioBroadcastCatch.setSipTransactionInfoByRequset(sipResponse); | 1083 | audioBroadcastCatch.setSipTransactionInfoByRequset(sipResponse); |
| 1074 | audioBroadcastManager.update(audioBroadcastCatch); | 1084 | audioBroadcastManager.update(audioBroadcastCatch); |
| 1085 | + | ||
| 1075 | } catch (SipException | InvalidArgumentException | ParseException | SdpParseException e) { | 1086 | } catch (SipException | InvalidArgumentException | ParseException | SdpParseException e) { |
| 1076 | logger.error("[命令发送失败] 语音对讲 回复200OK(SDP): {}", e.getMessage()); | 1087 | logger.error("[命令发送失败] 语音对讲 回复200OK(SDP): {}", e.getMessage()); |
| 1077 | } | 1088 | } |
| 1089 | + return sipResponse; | ||
| 1078 | } | 1090 | } |
| 1079 | } | 1091 | } |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -531,7 +531,7 @@ public class ZLMHttpHookListener { | @@ -531,7 +531,7 @@ public class ZLMHttpHookListener { | ||
| 531 | // cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null); | 531 | // cmder.streamByeCmd(device, sendRtpItem.getChannelId(), audioBroadcastCatch.getSipTransactionInfo(), null); |
| 532 | } | 532 | } |
| 533 | }else { | 533 | }else { |
| 534 | - cmder.streamByeCmd(device, sendRtpItem.getChannelId(), param.getStream(), sendRtpItem.getCallId()); | 534 | + cmder.streamByeCmd(device, null, null, sendRtpItem.getCallId()); |
| 535 | } | 535 | } |
| 536 | 536 | ||
| 537 | } | 537 | } |
| @@ -771,7 +771,7 @@ public class ZLMHttpHookListener { | @@ -771,7 +771,7 @@ public class ZLMHttpHookListener { | ||
| 771 | @ResponseBody | 771 | @ResponseBody |
| 772 | @PostMapping(value = "/on_rtp_server_timeout", produces = "application/json;charset=UTF-8") | 772 | @PostMapping(value = "/on_rtp_server_timeout", produces = "application/json;charset=UTF-8") |
| 773 | public JSONObject onRtpServerTimeout(HttpServletRequest request, @RequestBody OnRtpServerTimeoutHookParam param){ | 773 | public JSONObject onRtpServerTimeout(HttpServletRequest request, @RequestBody OnRtpServerTimeoutHookParam param){ |
| 774 | - logger.info("[ZLM HOOK] rtpServer收流超时:{}->{}({})", param.getMediaServerId(), param.getStream_id(), param.getSsrc()); | 774 | + logger.info("[ZLM HOOK] rtpServer rtp超时:{}->{}({})", param.getMediaServerId(), param.getStream_id(), param.getSsrc()); |
| 775 | 775 | ||
| 776 | JSONObject ret = new JSONObject(); | 776 | JSONObject ret = new JSONObject(); |
| 777 | ret.put("code", 0); | 777 | ret.put("code", 0); |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
| @@ -177,7 +177,7 @@ public class ZLMRTPServerFactory { | @@ -177,7 +177,7 @@ public class ZLMRTPServerFactory { | ||
| 177 | * @param tcp 是否为tcp | 177 | * @param tcp 是否为tcp |
| 178 | * @return SendRtpItem | 178 | * @return SendRtpItem |
| 179 | */ | 179 | */ |
| 180 | - public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId, String deviceId, String channelId, boolean tcp){ | 180 | + public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId, String deviceId, String channelId, boolean tcp, boolean rtcp){ |
| 181 | 181 | ||
| 182 | // 默认为随机端口 | 182 | // 默认为随机端口 |
| 183 | int localPort = 0; | 183 | int localPort = 0; |
| @@ -197,6 +197,7 @@ public class ZLMRTPServerFactory { | @@ -197,6 +197,7 @@ public class ZLMRTPServerFactory { | ||
| 197 | sendRtpItem.setDeviceId(deviceId); | 197 | sendRtpItem.setDeviceId(deviceId); |
| 198 | sendRtpItem.setChannelId(channelId); | 198 | sendRtpItem.setChannelId(channelId); |
| 199 | sendRtpItem.setTcp(tcp); | 199 | sendRtpItem.setTcp(tcp); |
| 200 | + sendRtpItem.setRtcp(rtcp); | ||
| 200 | sendRtpItem.setApp("rtp"); | 201 | sendRtpItem.setApp("rtp"); |
| 201 | sendRtpItem.setLocalPort(localPort); | 202 | sendRtpItem.setLocalPort(localPort); |
| 202 | sendRtpItem.setServerId(userSetting.getServerId()); | 203 | sendRtpItem.setServerId(userSetting.getServerId()); |
| @@ -214,7 +215,7 @@ public class ZLMRTPServerFactory { | @@ -214,7 +215,7 @@ public class ZLMRTPServerFactory { | ||
| 214 | * @param tcp 是否为tcp | 215 | * @param tcp 是否为tcp |
| 215 | * @return SendRtpItem | 216 | * @return SendRtpItem |
| 216 | */ | 217 | */ |
| 217 | - public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId, String app, String stream, String channelId, boolean tcp){ | 218 | + public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId, String app, String stream, String channelId, boolean tcp, boolean rtcp){ |
| 218 | // 默认为随机端口 | 219 | // 默认为随机端口 |
| 219 | int localPort = 0; | 220 | int localPort = 0; |
| 220 | if (userSetting.getGbSendStreamStrict()) { | 221 | if (userSetting.getGbSendStreamStrict()) { |
| @@ -235,6 +236,7 @@ public class ZLMRTPServerFactory { | @@ -235,6 +236,7 @@ public class ZLMRTPServerFactory { | ||
| 235 | sendRtpItem.setLocalPort(localPort); | 236 | sendRtpItem.setLocalPort(localPort); |
| 236 | sendRtpItem.setServerId(userSetting.getServerId()); | 237 | sendRtpItem.setServerId(userSetting.getServerId()); |
| 237 | sendRtpItem.setMediaServerId(serverItem.getId()); | 238 | sendRtpItem.setMediaServerId(serverItem.getId()); |
| 239 | + sendRtpItem.setRtcp(rtcp); | ||
| 238 | return sendRtpItem; | 240 | return sendRtpItem; |
| 239 | } | 241 | } |
| 240 | 242 |
src/main/java/com/genersoft/iot/vmp/service/bean/RequestSendItemMsg.java
| @@ -63,10 +63,16 @@ public class RequestSendItemMsg { | @@ -63,10 +63,16 @@ public class RequestSendItemMsg { | ||
| 63 | private Boolean isTcp; | 63 | private Boolean isTcp; |
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | + /** | ||
| 67 | + * 是否使用TCP | ||
| 68 | + */ | ||
| 69 | + private Boolean rtcp; | ||
| 70 | + | ||
| 71 | + | ||
| 66 | 72 | ||
| 67 | 73 | ||
| 68 | public static RequestSendItemMsg getInstance(String serverId, String mediaServerId, String app, String stream, String ip, int port, | 74 | public static RequestSendItemMsg getInstance(String serverId, String mediaServerId, String app, String stream, String ip, int port, |
| 69 | - String ssrc, String platformId, String channelId, Boolean isTcp, String platformName) { | 75 | + String ssrc, String platformId, String channelId, Boolean isTcp, Boolean rtcp, String platformName) { |
| 70 | RequestSendItemMsg requestSendItemMsg = new RequestSendItemMsg(); | 76 | RequestSendItemMsg requestSendItemMsg = new RequestSendItemMsg(); |
| 71 | requestSendItemMsg.setServerId(serverId); | 77 | requestSendItemMsg.setServerId(serverId); |
| 72 | requestSendItemMsg.setMediaServerId(mediaServerId); | 78 | requestSendItemMsg.setMediaServerId(mediaServerId); |
| @@ -79,6 +85,7 @@ public class RequestSendItemMsg { | @@ -79,6 +85,7 @@ public class RequestSendItemMsg { | ||
| 79 | requestSendItemMsg.setPlatformName(platformName); | 85 | requestSendItemMsg.setPlatformName(platformName); |
| 80 | requestSendItemMsg.setChannelId(channelId); | 86 | requestSendItemMsg.setChannelId(channelId); |
| 81 | requestSendItemMsg.setTcp(isTcp); | 87 | requestSendItemMsg.setTcp(isTcp); |
| 88 | + requestSendItemMsg.setRtcp(rtcp); | ||
| 82 | 89 | ||
| 83 | return requestSendItemMsg; | 90 | return requestSendItemMsg; |
| 84 | } | 91 | } |
| @@ -170,4 +177,12 @@ public class RequestSendItemMsg { | @@ -170,4 +177,12 @@ public class RequestSendItemMsg { | ||
| 170 | public void setTcp(Boolean tcp) { | 177 | public void setTcp(Boolean tcp) { |
| 171 | isTcp = tcp; | 178 | isTcp = tcp; |
| 172 | } | 179 | } |
| 180 | + | ||
| 181 | + public Boolean getRtcp() { | ||
| 182 | + return rtcp; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + public void setRtcp(Boolean rtcp) { | ||
| 186 | + this.rtcp = rtcp; | ||
| 187 | + } | ||
| 173 | } | 188 | } |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -347,7 +347,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -347,7 +347,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 347 | // } | 347 | // } |
| 348 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, ip, port, ssrcInfo.getSsrc(), device.getDeviceId(), | 348 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, ip, port, ssrcInfo.getSsrc(), device.getDeviceId(), |
| 349 | device.getDeviceId(), channelId, | 349 | device.getDeviceId(), channelId, |
| 350 | - false); | 350 | + false, false); |
| 351 | 351 | ||
| 352 | 352 | ||
| 353 | // if (sendRtpItem.getLocalPort() == 0) { | 353 | // if (sendRtpItem.getLocalPort() == 0) { |
| @@ -375,6 +375,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -375,6 +375,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 375 | sendRtpItem.setStreamId("1000"); | 375 | sendRtpItem.setStreamId("1000"); |
| 376 | sendRtpItem.setSsrc(ssrc); | 376 | sendRtpItem.setSsrc(ssrc); |
| 377 | sendRtpItem.setOnlyAudio(true); | 377 | sendRtpItem.setOnlyAudio(true); |
| 378 | + sendRtpItem.setRtcp(false); | ||
| 378 | redisCatchStorage.updateSendRTPSever(sendRtpItem); | 379 | redisCatchStorage.updateSendRTPSever(sendRtpItem); |
| 379 | 380 | ||
| 380 | Map<String, Object> param = new HashMap<>(12); | 381 | Map<String, Object> param = new HashMap<>(12); |
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGbPlayMsgListener.java
| @@ -318,7 +318,7 @@ public class RedisGbPlayMsgListener implements MessageListener { | @@ -318,7 +318,7 @@ public class RedisGbPlayMsgListener implements MessageListener { | ||
| 318 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, content.getIp(), | 318 | SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, content.getIp(), |
| 319 | content.getPort(), content.getSsrc(), content.getPlatformId(), | 319 | content.getPort(), content.getSsrc(), content.getPlatformId(), |
| 320 | content.getApp(), content.getStream(), content.getChannelId(), | 320 | content.getApp(), content.getStream(), content.getChannelId(), |
| 321 | - content.getTcp()); | 321 | + content.getTcp(), content.getRtcp()); |
| 322 | 322 | ||
| 323 | WVPResult<ResponseSendItemMsg> result = new WVPResult<>(); | 323 | WVPResult<ResponseSendItemMsg> result = new WVPResult<>(); |
| 324 | result.setCode(0); | 324 | result.setCode(0); |
| @@ -348,9 +348,9 @@ public class RedisGbPlayMsgListener implements MessageListener { | @@ -348,9 +348,9 @@ public class RedisGbPlayMsgListener implements MessageListener { | ||
| 348 | * @param callback 得到信息的回调 | 348 | * @param callback 得到信息的回调 |
| 349 | */ | 349 | */ |
| 350 | public void sendMsg(String serverId, String mediaServerId, String app, String stream, String ip, int port, String ssrc, | 350 | public void sendMsg(String serverId, String mediaServerId, String app, String stream, String ip, int port, String ssrc, |
| 351 | - String platformId, String channelId, boolean isTcp, String platformName, PlayMsgCallback callback, PlayMsgErrorCallback errorCallback) { | 351 | + String platformId, String channelId, boolean isTcp, boolean rtcp, String platformName, PlayMsgCallback callback, PlayMsgErrorCallback errorCallback) { |
| 352 | RequestSendItemMsg requestSendItemMsg = RequestSendItemMsg.getInstance( | 352 | RequestSendItemMsg requestSendItemMsg = RequestSendItemMsg.getInstance( |
| 353 | - serverId, mediaServerId, app, stream, ip, port, ssrc, platformId, channelId, isTcp, platformName); | 353 | + serverId, mediaServerId, app, stream, ip, port, ssrc, platformId, channelId, isTcp, rtcp, platformName); |
| 354 | requestSendItemMsg.setServerId(serverId); | 354 | requestSendItemMsg.setServerId(serverId); |
| 355 | String key = UUID.randomUUID().toString(); | 355 | String key = UUID.randomUUID().toString(); |
| 356 | WvpRedisMsg redisMsg = WvpRedisMsg.getRequestInstance(userSetting.getServerId(), serverId, WvpRedisMsgCmd.GET_SEND_ITEM, | 356 | WvpRedisMsg redisMsg = WvpRedisMsg.getRequestInstance(userSetting.getServerId(), serverId, WvpRedisMsgCmd.GET_SEND_ITEM, |