Merge branch '2.6.9' into wvp-28181-2.0
| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import okhttp3.*; |
| | | import okhttp3.logging.HttpLoggingInterceptor; |
| | | import org.jetbrains.annotations.NotNull; |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.net.ConnectException; |
| | | import java.net.MalformedURLException; |
| | | import java.net.SocketTimeoutException; |
| | | import java.net.URL; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | return responseJSON; |
| | | } |
| | | |
| | | public JSONObject sendPost(MediaServerItem mediaServerItem, String api, JSONObject param, ZLMRESTfulUtils.RequestCallback callback, Integer readTimeOut) { |
| | | public JSONObject sendPost(MediaServerItem mediaServerItem, String url, |
| | | JSONObject param, ZLMRESTfulUtils.RequestCallback callback, |
| | | Integer readTimeOut) { |
| | | OkHttpClient client = getClient(readTimeOut); |
| | | |
| | | if (mediaServerItem == null) { |
| | | return null; |
| | | } |
| | | String url = String.format("http://%s:%s/%s", mediaServerItem.getIp(), mediaServerItem.getRecordAssistPort(), api); |
| | | JSONObject responseJSON = new JSONObject(); |
| | | //-2自定义流媒体 调用错误码 |
| | | responseJSON.put("code",-2); |
| | |
| | | if (!ObjectUtils.isEmpty(remoteHost)) { |
| | | videoTaskInfoJSON.put("remoteHost", remoteHost); |
| | | } |
| | | |
| | | return sendPost(mediaServerItem, "api/record/file/download/task/add", videoTaskInfoJSON, null, 30); |
| | | String urlStr = String.format("%s/api/record/file/download/task/add", remoteHost);; |
| | | return sendPost(mediaServerItem, urlStr, videoTaskInfoJSON, null, 30); |
| | | } |
| | | |
| | | public JSONObject queryTaskList(MediaServerItem mediaServerItem, String app, String stream, String callId, String taskId, Boolean isEnd) { |
| | |
| | | /** |
| | | * 添加合并任务 |
| | | */ |
| | | String addTask(String app, String stream, String mediaServerId, String startTime, String endTime, String callId, String remoteHost); |
| | | String addTask(String app, String stream, MediaServerItem mediaServerItem, String startTime, String endTime, String callId, String remoteHost); |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String addTask(String app, String stream, String mediaServerId, String startTime, String endTime, String callId, String remoteHost) { |
| | | public String addTask(String app, String stream, MediaServerItem mediaServerItem, String startTime, String endTime, String callId, String remoteHost) { |
| | | // 参数校验 |
| | | assert app != null; |
| | | assert stream != null; |
| | | MediaServerItem mediaServerItem = null; |
| | | if (mediaServerId == null) { |
| | | mediaServerItem = mediaServerService.getDefaultMediaServer(); |
| | | }else { |
| | | mediaServerItem = mediaServerService.getOne(mediaServerId); |
| | | } |
| | | if (mediaServerItem == null) { |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的流媒体"); |
| | | }else { |
| | | if (remoteHost == null) { |
| | | remoteHost = "http://" + mediaServerItem.getStreamIp() + ":" + mediaServerItem.getRecordAssistPort(); |
| | | } |
| | | } |
| | | if (mediaServerItem.getRecordAssistPort() == 0) { |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), "为配置Assist服务"); |
| | | } |
| | |
| | | } |
| | | JSONObject result = assistRESTfulUtils.queryTaskList(mediaServerItem, app, stream, callId, taskId, isEnd); |
| | | if (result == null || result.getInteger("code") != 0) { |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), result.getString("msg")); |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), result == null ? "查询任务列表失败" : result.getString("msg")); |
| | | } |
| | | return result.getJSONArray("data"); |
| | | } |
| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | |
| | | @Parameter(name = "callId", description = "鉴权ID", required = false) |
| | | @Parameter(name = "remoteHost", description = "返回地址时的远程地址", required = false) |
| | | public String addTask( |
| | | HttpServletRequest request, |
| | | @RequestParam(required = false) String app, |
| | | @RequestParam(required = false) String stream, |
| | | @RequestParam(required = false) String mediaServerId, |
| | |
| | | @RequestParam(required = false) String callId, |
| | | @RequestParam(required = false) String remoteHost |
| | | ){ |
| | | return cloudRecordService.addTask(app, stream, mediaServerId, startTime, endTime, callId, remoteHost); |
| | | System.out.println(request.getScheme()); |
| | | System.out.println(request.getLocalAddr()); |
| | | System.out.println(request.getRemoteAddr()); |
| | | System.out.println(request.getRequestURI()); |
| | | MediaServerItem mediaServerItem; |
| | | if (mediaServerId == null) { |
| | | mediaServerItem = mediaServerService.getDefaultMediaServer(); |
| | | }else { |
| | | mediaServerItem = mediaServerService.getOne(mediaServerId); |
| | | } |
| | | if (mediaServerItem == null) { |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的流媒体"); |
| | | }else { |
| | | if (remoteHost == null) { |
| | | remoteHost = request.getScheme() + "://" + request.getLocalAddr() + ":" + mediaServerItem.getRecordAssistPort(); |
| | | } |
| | | } |
| | | return cloudRecordService.addTask(app, stream, mediaServerItem, startTime, endTime, callId, remoteHost); |
| | | } |
| | | |
| | | @ResponseBody |