| | |
| | | MediaServer mediaServer = new MediaServer(); |
| | | mediaServer.setIp(ip); |
| | | mediaServer.setHttpPort(port); |
| | | mediaServer.setFlvPort(port); |
| | | mediaServer.setWsFlvPort(port); |
| | | mediaServer.setSecret(secret); |
| | | JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServer); |
| | | if (responseJSON == null) { |
| | |
| | | } |
| | | mediaServer.setId(zlmServerConfig.getGeneralMediaServerId()); |
| | | mediaServer.setHttpSSlPort(zlmServerConfig.getHttpPort()); |
| | | mediaServer.setFlvSSLPort(zlmServerConfig.getHttpPort()); |
| | | mediaServer.setWsFlvSSLPort(zlmServerConfig.getHttpPort()); |
| | | mediaServer.setRtmpPort(zlmServerConfig.getRtmpPort()); |
| | | mediaServer.setRtmpSSlPort(zlmServerConfig.getRtmpSslPort()); |
| | | mediaServer.setRtspPort(zlmServerConfig.getRtspPort()); |
| | | mediaServer.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); |
| | | mediaServer.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); |
| | | mediaServer.setStreamIp(ip); |
| | | |
| | | mediaServer.setHookIp(sipIp.split(",")[0]); |
| | | mediaServer.setSdpIp(ip); |
| | | mediaServer.setType("zlm"); |
| | |
| | | param.put("ssrc", ssrc); |
| | | } |
| | | JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(mediaInfo, param); |
| | | return (jsonObject != null && jsonObject.getInteger("code") == 0); |
| | | if (jsonObject == null || jsonObject.getInteger("code") != 0 ) { |
| | | logger.error("停止发流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSONString(param)); |
| | | throw new ControllerException(jsonObject.getInteger("code"), jsonObject.getString("msg")); |
| | | } |
| | | return true; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public boolean initStopSendRtp(MediaServer mediaInfo, String app, String stream, String ssrc) { |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("vhost", "__defaultVhost__"); |
| | | param.put("app", app); |
| | | param.put("stream", stream); |
| | | if (!ObjectUtils.isEmpty(ssrc)) { |
| | | param.put("ssrc", ssrc); |
| | | } |
| | | JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(mediaInfo, param); |
| | | if (jsonObject == null || jsonObject.getInteger("code") != 0 ) { |
| | | logger.error("停止发流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSONString(param)); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (timeout != null) { |
| | | param.put("close_delay_ms", timeout); |
| | | } |
| | | if (!sendRtpItem.isTcp()) { |
| | | // 开启rtcp保活 |
| | | param.put("udp_rtcp_timeout", sendRtpItem.isRtcp()? "1":"0"); |
| | | } |
| | | if (!sendRtpItem.isTcpActive()) { |
| | | param.put("dst_url",sendRtpItem.getIp()); |
| | | param.put("dst_port", sendRtpItem.getPort()); |
| | | } |
| | | |
| | | JSONObject jsonObject = zlmServerFactory.startSendRtpPassive(mediaServer, param, null); |
| | | if (jsonObject == null || jsonObject.getInteger("code") != 0 ) { |
| | | logger.error("启动监听TCP被动推流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSONString(param)); |
| | | throw new ControllerException(jsonObject.getInteger("code"), jsonObject.getString("msg")); |
| | | } |
| | | logger.info("调用ZLM-TCP被动推流接口, 结果: {}", jsonObject); |
| | | logger.info("启动监听TCP被动推流成功[ {}/{} ],{}->{}:{}, " , sendRtpItem.getApp(), sendRtpItem.getStream(), |
| | | jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port")); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | param.put("dst_url", sendRtpItem.getIp()); |
| | | param.put("dst_port", sendRtpItem.getPort()); |
| | | JSONObject jsonObject = zlmServerFactory.startSendRtpStream(mediaServer, param); |
| | | JSONObject jsonObject = zlmresTfulUtils.startSendRtp(mediaServer, param); |
| | | if (jsonObject == null || jsonObject.getInteger("code") != 0 ) { |
| | | throw new ControllerException(jsonObject.getInteger("code"), jsonObject.getString("msg")); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Long updateDownloadProcess(MediaServer mediaServer, String app, String stream) { |
| | | MediaInfo mediaInfo = getMediaInfo(mediaServer, app, stream); |
| | | if (mediaInfo == null) { |
| | | logger.warn("[获取下载进度] 查询进度失败, 节点Id: {}, {}/{}", mediaServer.getId(), app, stream); |
| | | return null; |
| | | } |
| | | return mediaInfo.getDuration(); |
| | | } |
| | | } |