| | |
| | | if (callback == null) { |
| | | try { |
| | | Response response = client.newCall(request).execute(); |
| | | |
| | | if (response.isSuccessful()) { |
| | | ResponseBody responseBody = response.body(); |
| | | if (responseBody != null) { |
| | |
| | | responseJSON = JSON.parseObject(responseStr); |
| | | } |
| | | }else { |
| | | System.out.println( 2222); |
| | | System.out.println( response.code()); |
| | | response.close(); |
| | | Objects.requireNonNull(response.body()).close(); |
| | | } |
| | |
| | | |
| | | if(e instanceof SocketTimeoutException){ |
| | | //读取超时超时异常 |
| | | logger.error(String.format("读取ZLM数据失败: %s, %s", url, e.getMessage())); |
| | | logger.error(String.format("读取ZLM数据超时失败: %s, %s", url, e.getMessage())); |
| | | } |
| | | if(e instanceof ConnectException){ |
| | | //判断连接异常,我这里是报Failed to connect to 10.7.5.144 |
| | | logger.error(String.format("连接ZLM失败: %s, %s", url, e.getMessage())); |
| | | logger.error(String.format("连接ZLM连接失败: %s, %s", url, e.getMessage())); |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | |
| | | |
| | | public void sendGetForImg(MediaServerItem mediaServerItem, String api, Map<String, Object> params, String targetPath, String fileName) { |
| | | String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api); |
| | | logger.debug(url); |
| | | HttpUrl parseUrl = HttpUrl.parse(url); |
| | | if (parseUrl == null) { |
| | | return; |
| | |
| | | } else { |
| | | logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message())); |
| | | } |
| | | Objects.requireNonNull(response.body()).close(); |
| | | } else { |
| | | logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message())); |
| | | } |
| | | Objects.requireNonNull(response.body()).close(); |
| | | } catch (ConnectException e) { |
| | | logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage())); |
| | | logger.info("请检查media配置并确认ZLM已启动..."); |
| | |
| | | return sendPost(mediaServerItem, "startSendRtp",param, null); |
| | | } |
| | | |
| | | public JSONObject startSendRtpPassive(MediaServerItem mediaServerItem, Map<String, Object> param) { |
| | | return sendPost(mediaServerItem, "startSendRtpPassive",param, null); |
| | | } |
| | | |
| | | public JSONObject startSendRtpPassive(MediaServerItem mediaServerItem, Map<String, Object> param, RequestCallback callback) { |
| | | return sendPost(mediaServerItem, "startSendRtpPassive",param, callback); |
| | | } |
| | | |
| | | public JSONObject stopSendRtp(MediaServerItem mediaServerItem, Map<String, Object> param) { |
| | | return sendPost(mediaServerItem, "stopSendRtp",param, null); |
| | | } |