支持合并录像使用https
parent
85f20df9de
commit
cf8a1261b5
|
@ -2,7 +2,9 @@ package com.genersoft.iot.vmp.media.zlm;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
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.media.zlm.dto.MediaServerItem;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
import okhttp3.logging.HttpLoggingInterceptor;
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -13,7 +15,9 @@ import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -148,13 +152,14 @@ public class AssistRESTfulUtils {
|
||||||
return responseJSON;
|
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);
|
OkHttpClient client = getClient(readTimeOut);
|
||||||
|
|
||||||
if (mediaServerItem == null) {
|
if (mediaServerItem == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String url = String.format("http://%s:%s/%s", mediaServerItem.getIp(), mediaServerItem.getRecordAssistPort(), api);
|
|
||||||
JSONObject responseJSON = new JSONObject();
|
JSONObject responseJSON = new JSONObject();
|
||||||
//-2自定义流媒体 调用错误码
|
//-2自定义流媒体 调用错误码
|
||||||
responseJSON.put("code",-2);
|
responseJSON.put("code",-2);
|
||||||
|
@ -253,8 +258,8 @@ public class AssistRESTfulUtils {
|
||||||
if (!ObjectUtils.isEmpty(remoteHost)) {
|
if (!ObjectUtils.isEmpty(remoteHost)) {
|
||||||
videoTaskInfoJSON.put("remoteHost", remoteHost);
|
videoTaskInfoJSON.put("remoteHost", remoteHost);
|
||||||
}
|
}
|
||||||
|
String urlStr = String.format("%s/api/record/file/download/task/add", remoteHost);;
|
||||||
return sendPost(mediaServerItem, "api/record/file/download/task/add", videoTaskInfoJSON, null, 30);
|
return sendPost(mediaServerItem, urlStr, videoTaskInfoJSON, null, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject queryTaskList(MediaServerItem mediaServerItem, String app, String stream, String callId, String taskId, Boolean isEnd) {
|
public JSONObject queryTaskList(MediaServerItem mediaServerItem, String app, String stream, String callId, String taskId, Boolean isEnd) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ public interface ICloudRecordService {
|
||||||
/**
|
/**
|
||||||
* 添加合并任务
|
* 添加合并任务
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -107,23 +107,10 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 app != null;
|
||||||
assert stream != 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) {
|
if (mediaServerItem.getRecordAssistPort() == 0) {
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "为配置Assist服务");
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "为配置Assist服务");
|
||||||
}
|
}
|
||||||
|
@ -163,7 +150,7 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
||||||
}
|
}
|
||||||
JSONObject result = assistRESTfulUtils.queryTaskList(mediaServerItem, app, stream, callId, taskId, isEnd);
|
JSONObject result = assistRESTfulUtils.queryTaskList(mediaServerItem, app, stream, callId, taskId, isEnd);
|
||||||
if (result == null || result.getInteger("code") != 0) {
|
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");
|
return result.getJSONArray("data");
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -154,6 +155,7 @@ public class CloudRecordController {
|
||||||
@Parameter(name = "callId", description = "鉴权ID", required = false)
|
@Parameter(name = "callId", description = "鉴权ID", required = false)
|
||||||
@Parameter(name = "remoteHost", description = "返回地址时的远程地址", required = false)
|
@Parameter(name = "remoteHost", description = "返回地址时的远程地址", required = false)
|
||||||
public String addTask(
|
public String addTask(
|
||||||
|
HttpServletRequest request,
|
||||||
@RequestParam(required = false) String app,
|
@RequestParam(required = false) String app,
|
||||||
@RequestParam(required = false) String stream,
|
@RequestParam(required = false) String stream,
|
||||||
@RequestParam(required = false) String mediaServerId,
|
@RequestParam(required = false) String mediaServerId,
|
||||||
|
@ -162,7 +164,24 @@ public class CloudRecordController {
|
||||||
@RequestParam(required = false) String callId,
|
@RequestParam(required = false) String callId,
|
||||||
@RequestParam(required = false) String remoteHost
|
@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
|
@ResponseBody
|
||||||
|
|
Loading…
Reference in New Issue