| | |
| | | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| | | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| | | import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; |
| | | import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; |
| | | import com.genersoft.iot.vmp.media.zlm.*; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; |
| | | import com.genersoft.iot.vmp.service.IInviteStreamService; |
| | |
| | | private UserSetting userSetting; |
| | | |
| | | @Autowired |
| | | private SendRtpPortManager sendRtpPortManager; |
| | | |
| | | @Autowired |
| | | private AssistRESTfulUtils assistRESTfulUtils; |
| | | |
| | | @Autowired |
| | |
| | | |
| | | |
| | | @Autowired |
| | | private ZLMRTPServerFactory zlmrtpServerFactory; |
| | | private ZLMServerFactory zlmServerFactory; |
| | | |
| | | @Autowired |
| | | private EventPublisher publisher; |
| | |
| | | if (ssrcFactory.hasMediaServerSSRC(mediaServerItem.getId())) { |
| | | ssrcFactory.initMediaServerSSRC(mediaServerItem.getId(), null); |
| | | } |
| | | if (userSetting.getGbSendStreamStrict()) { |
| | | int startPort = 50000; |
| | | int endPort = 60000; |
| | | String sendRtpPortRange = mediaServerItem.getSendRtpPortRange(); |
| | | if (sendRtpPortRange == null) { |
| | | logger.warn("[zlm] ] 未配置发流端口范围,默认使用50000到60000"); |
| | | }else { |
| | | String[] sendRtpPortRangeArray = sendRtpPortRange.trim().split(","); |
| | | if (sendRtpPortRangeArray.length != 2) { |
| | | logger.warn("[zlm] ] 发流端口范围错误,默认使用50000到60000"); |
| | | }else { |
| | | try { |
| | | startPort = Integer.parseInt(sendRtpPortRangeArray[0]); |
| | | endPort = Integer.parseInt(sendRtpPortRangeArray[1]); |
| | | if (endPort <= startPort) { |
| | | logger.warn("[zlm] ] 发流端口范围错误,结束端口应大于开始端口,使用默认端口"); |
| | | startPort = 50000; |
| | | endPort = 60000; |
| | | } |
| | | |
| | | }catch (NumberFormatException e) { |
| | | logger.warn("[zlm] ] 发流端口范围错误,默认使用50000到60000"); |
| | | } |
| | | } |
| | | } |
| | | logger.info("[[zlm] ] 配置发流端口范围,{}-{}", startPort, endPort); |
| | | sendRtpPortManager.initServerPort(mediaServerItem.getId(), startPort, endPort); |
| | | } |
| | | // 查询redis是否存在此mediaServer |
| | | String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId(); |
| | | Boolean hasKey = redisTemplate.hasKey(key); |
| | | if (hasKey != null && ! hasKey) { |
| | | redisTemplate.opsForValue().set(key, mediaServerItem); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | int rtpServerPort; |
| | | if (mediaServerItem.isRtpEnable()) { |
| | | rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0, port, reUsePort, tcpMode); |
| | | rtpServerPort = zlmServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0, port, reUsePort, tcpMode); |
| | | } else { |
| | | rtpServerPort = mediaServerItem.getRtpProxyPort(); |
| | | } |
| | |
| | | if (mediaServerItem == null) { |
| | | return; |
| | | } |
| | | zlmrtpServerFactory.closeRtpServer(mediaServerItem, streamId); |
| | | zlmServerFactory.closeRtpServer(mediaServerItem, streamId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | callback.run(false); |
| | | return; |
| | | } |
| | | zlmrtpServerFactory.closeRtpServer(mediaServerItem, streamId, callback); |
| | | zlmServerFactory.closeRtpServer(mediaServerItem, streamId, callback); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public Boolean updateRtpServerSSRC(MediaServerItem mediaServerItem, String streamId, String ssrc) { |
| | | return zlmrtpServerFactory.updateRtpServerSSRC(mediaServerItem, streamId, ssrc); |
| | | return zlmServerFactory.updateRtpServerSSRC(mediaServerItem, streamId, ssrc); |
| | | } |
| | | |
| | | @Override |