| | |
| | | |
| | | |
| | | @Autowired |
| | | private ZLMRTPServerFactory zlmrtpServerFactory; |
| | | private ZLMServerFactory zlmServerFactory; |
| | | |
| | | @Autowired |
| | | private EventPublisher publisher; |
| | |
| | | private RedisTemplate<Object, Object> redisTemplate; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 初始化 |
| | | */ |
| | |
| | | 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); |
| | |
| | | |
| | | @Override |
| | | public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String presetSsrc, boolean ssrcCheck, |
| | | boolean isPlayback, Integer port, Boolean reUsePort, Integer tcpMode) { |
| | | boolean isPlayback, Integer port, Boolean onlyAuto, Boolean reUsePort, Integer tcpMode) { |
| | | if (mediaServerItem == null || mediaServerItem.getId() == null) { |
| | | logger.info("[openRTPServer] 失败, mediaServerItem == null || mediaServerItem.getId() == null"); |
| | | return null; |
| | |
| | | if (streamId == null) { |
| | | streamId = String.format("%08x", Integer.parseInt(ssrc)).toUpperCase(); |
| | | } |
| | | int ssrcCheckParam = 0; |
| | | if (ssrcCheck && tcpMode > 1) { |
| | | // 目前zlm不支持 tcp模式更新ssrc,暂时关闭ssrc校验 |
| | | logger.warn("[openRTPServer] TCP被动/TCP主动收流时,默认关闭ssrc检验"); |
| | | } |
| | | int rtpServerPort; |
| | | if (mediaServerItem.isRtpEnable()) { |
| | | rtpServerPort = zlmrtpServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck?Integer.parseInt(ssrc):0, port, reUsePort, tcpMode); |
| | | rtpServerPort = zlmServerFactory.createRTPServer(mediaServerItem, streamId, (ssrcCheck && tcpMode == 0)?Integer.parseInt(ssrc):0, port, onlyAuto, reUsePort, tcpMode); |
| | | } else { |
| | | rtpServerPort = mediaServerItem.getRtpProxyPort(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, boolean isPlayback, Integer port, Boolean onlyAuto) { |
| | | return openRTPServer(mediaServerItem, streamId, ssrc, ssrcCheck, isPlayback, port, onlyAuto, null, 0); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void closeRTPServer(MediaServerItem mediaServerItem, String streamId) { |
| | | 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 |
| | |
| | | return JsonUtil.redisJsonToObject(redisTemplate, key, MediaServerItem.class); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public MediaServerItem getDefaultMediaServer() { |
| | | |