Просмотр исходного кода

实时音视频增加后台服务

sakuya 3 лет назад
Родитель
Сommit
542554ae48

+ 67 - 43
eladmin-system/src/main/java/me/zhengjie/application/admin/controller/TencentPushController.java

@@ -4,10 +4,15 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import me.zhengjie.base.AppBaseResponse;
+import me.zhengjie.base.sms.CreateCloudRecording;
+import me.zhengjie.base.sms.TrtcVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import com.alibaba.fastjson.JSON;
@@ -24,9 +29,10 @@ import me.zhengjie.dao.mybatis.mapper.PushDataMapper;
 
 @Controller
 @RequiredArgsConstructor
-public class TencentPushController {
+@RequestMapping("${fqgz.admin.web.url-prefix}/note-video")
+public class AdminNoteVideoController {
 
-	private static final Logger log = LoggerFactory.getLogger(TencentPushController.class);
+	private static final Logger log = LoggerFactory.getLogger(AdminNoteVideoController.class);
 	private final PushDataMapper pushDataMapper;
 	private final OrderRoomIdMapper orderRoomIdMapper;
 
@@ -106,18 +112,57 @@ public class TencentPushController {
 		return result;
 	}
 
-	@AnonymousPostMapping("/nt")
+	/**
+	 * 录制PC端面谈笔录视频
+	 *
+	 * @param trtc
+	 * @return
+	 */
+	@ResponseBody
+	@AnonymousPostMapping("/recording-pc")
+	public AppBaseResponse<?> recordingPc(@RequestBody TrtcVo trtc) {
+		return AppBaseResponse.succ(CreateCloudRecording.recordingPc(trtc));
+	}
+
+	/**
+	 * 修改录制视频
+	 *
+	 * @param trtc
+	 * @return
+	 */
+	@ResponseBody
+	@AnonymousPostMapping("/recording-modify")
+	public AppBaseResponse<?> recordingModify(@RequestBody TrtcVo trtc) {
+		try {
+			return AppBaseResponse.succ(CreateCloudRecording.modifyRecording(trtc));
+		} catch (TencentCloudSDKException e) {
+			//e.printStackTrace();
+			AppBaseResponse<?> aa = new AppBaseResponse<>();
+			aa.setCode("10000");
+			aa.setMsg(e.getMessage() + ":" + e.getRequestId());
+			return aa;
+		}
+	}
+
 	@ResponseBody
-	public Map<String, Object> nt(@RequestBody JSONObject json) throws Exception {
+	@AnonymousPostMapping("/recording-stop")
+	public AppBaseResponse<?> recordingStop(@RequestBody Map<String, String> map) {
+		return AppBaseResponse.succ(CreateCloudRecording.recordingStop(map.get("taskId")));
+	}
+
+	@AnonymousPostMapping("/recording-receiver")
+	@ResponseBody
+	public Map<String, Object> recordingReceiver(@RequestBody JSONObject json) throws Exception {
 		Object data = JSON.toJSON(json);
 		log.info("############################推送信息[start]##############################################");
 		log.info("推送信息:" + JSON.toJSON(data));
 		log.info("############################推送信息[end]##############################################");
 
+		String eventType = json.getString("EventType");
 		JSONObject jsonObj = json.getJSONObject("EventInfo");
+		String userId = jsonObj.getString("UserId");
 		String roomId = jsonObj.getString("RoomId");
 		jsonObj = jsonObj.getJSONObject("Payload");
-
 		jsonObj = jsonObj.getJSONObject("TencentVod");
 		if (jsonObj == null) {
 			Map<String, Object> result = new HashMap<>();
@@ -127,44 +172,29 @@ public class TencentPushController {
 			return result;
 		}
 		String mediaId = jsonObj.getString("MediaId");
-
 		String fileId = jsonObj.getString("FileId");
 		String videoUrl = jsonObj.getString("VideoUrl");
-
-		String userId = jsonObj.getString("UserId");
-		// app的推送
-		if (mediaId.contains("aux")) {
-			QueryWrapper<OrderRoomIdEntity> orderRoomQuery = new QueryWrapper<>();
-			orderRoomQuery.eq("roomId", roomId);
-			orderRoomQuery.orderByDesc("create_time");
-			List<OrderRoomIdEntity> orderRoomId = orderRoomIdMapper.selectList(orderRoomQuery);
-			// 这里通过订单查询相关信息
-			if (orderRoomId != null && orderRoomId.size() > 0) {
-				OrderRoomIdEntity orderRoomIdEntity = orderRoomId.get(0);
-				String filePath = orderRoomIdEntity.getBusinessNo();
-				String fileName = filePath + "/APP" + fileId + ".mp4";
-				DownloadUtils.downloadFile(videoUrl, fileName);
-				OrderRoomIdEntity update = new OrderRoomIdEntity();
-				update.setAppFileId(fileId);
-				update.setAppVideoUrl(fileName);
-				update.setId(orderRoomIdEntity.getId());
-				orderRoomIdMapper.updateById(update);
-			}
-		} else if (userId.contains("share")) {
+		if ("311".equals(eventType) && mediaId.equals("mix")) {
 			QueryWrapper<OrderRoomIdEntity> orderRoomQuery = new QueryWrapper<>();
 			orderRoomQuery.eq("roomId", roomId);
 			orderRoomQuery.orderByDesc("create_time");
 			List<OrderRoomIdEntity> orderRoomId = orderRoomIdMapper.selectList(orderRoomQuery);
-			// 这里通过订单查询相关信息
 			if (orderRoomId != null && orderRoomId.size() > 0) {
 				OrderRoomIdEntity orderRoomIdEntity = orderRoomId.get(0);
 				String filePath = orderRoomIdEntity.getBusinessNo();
-				String fileName = filePath + "/PC" + fileId + ".mp4";
-				DownloadUtils.downloadFile(videoUrl, fileName);
 				OrderRoomIdEntity update = new OrderRoomIdEntity();
-				update.setPcFileId(fileId);
-				update.setPcVideoUrl(fileName);
 				update.setId(orderRoomIdEntity.getId());
+				if (userId.startsWith("app")) {
+					String fileName = filePath + "/app-" + fileId + ".mp4";
+					DownloadUtils.downloadFile(videoUrl, fileName);
+					update.setAppFileId(fileId);
+					update.setAppVideoUrl(fileName);
+				} else if (userId.startsWith("pc")) {
+					String fileName = filePath + "/pc-" + fileId + ".mp4";
+					DownloadUtils.downloadFile(videoUrl, fileName);
+					update.setPcFileId(fileId);
+					update.setPcVideoUrl(fileName);
+				}
 				orderRoomIdMapper.updateById(update);
 			}
 		}
@@ -174,21 +204,11 @@ public class TencentPushController {
 		return result;
 	}
 
-	public static void main(String[] args) {
-
-		Map<String, String> map = new HashMap<String, String>();
-
-		map.put("EventType", "ProcedureStateChanged");
-		map.put("FileUploadEvent", null);
-
-		System.out.println(JSON.toJSON(map));
-	}
-
 	/**
 	 * @param urlparam 带分隔的url参数
 	 * @return
 	 */
-	public static Map<String, String> split(String urlparam) {
+	private Map<String, String> split(String urlparam) {
 		Map<String, String> map = new HashMap<String, String>();
 		String[] param = urlparam.split("&");
 		for (String keyvalue : param) {
@@ -206,4 +226,8 @@ public class TencentPushController {
 
 		return "ok";
 	}
+
+	public static void main(String[] args) {
+		System.out.println("app_166375560_1663755604877".startsWith("app"));
+	}
 }

+ 3 - 41
eladmin-system/src/main/java/me/zhengjie/application/admin/controller/DemoController.java

@@ -56,44 +56,6 @@ public class DemoController {
 		return "success";
 	}
 
-	@ResponseBody
-	@AnonymousPostMapping("/app")
-	public AppBaseResponse<?> app(@RequestBody TrtcVo trtc) {
-		return AppBaseResponse.succ(CreateCloudRecording.recordingApp(trtc));
-
-	}
-
-	@ResponseBody
-	@AnonymousPostMapping("/modify")
-	public AppBaseResponse<?> modifyRecording(@RequestBody TrtcVo trtc) {
-
-		try {
-			return AppBaseResponse.succ(CreateCloudRecording.modifyRecording(trtc));
-		} catch (TencentCloudSDKException e) {
-			//e.printStackTrace();
-			AppBaseResponse<?> aa = new AppBaseResponse<>();
-			aa.setCode("10000");
-			aa.setMsg(e.getMessage()+":"+e.getRequestId());
-			return aa;
-		}
-
-	}
-
-	@ResponseBody
-	@AnonymousPostMapping("/pc")
-	public AppBaseResponse<?> pc(@RequestBody TrtcVo trtc) {
-
-		return AppBaseResponse.succ(CreateCloudRecording.recordingPc(trtc));
-
-	}
-
-	@ResponseBody
-	@AnonymousPostMapping("/stop")
-	public AppBaseResponse<?> stop(@RequestBody Map<String, String> map) {
-
-		return AppBaseResponse.succ(CreateCloudRecording.stop(map.get("taskId")));
-	}
-
 	/**
 	 * 机构 查询 银行+公证处
 	 *
@@ -102,9 +64,9 @@ public class DemoController {
 	@ResponseBody
 	@RequestMapping("/getUserSig")
 	public BaseResponse<?> getUserSig(@RequestBody Map<String, String> map) {
-		System.out.println("SDK_APP_ID: " + AppConfigInfo.SDK_APP_ID);
-		System.out.println("TTL_SIG_KEY: " + AppConfigInfo.TTL_SIG_KEY);
-		TLSSigAPIv2 api = new TLSSigAPIv2(AppConfigInfo.SDK_APP_ID, AppConfigInfo.TTL_SIG_KEY);
+		System.out.println("SDK_APP_ID: " + AppConfigInfo.TENCENT_SDK_APP_ID);
+		System.out.println("TTL_SIG_KEY: " + AppConfigInfo.TENCENT_TTL_SIG_KEY);
+		TLSSigAPIv2 api = new TLSSigAPIv2(AppConfigInfo.TENCENT_SDK_APP_ID, AppConfigInfo.TENCENT_TTL_SIG_KEY);
 		BaseResponse<String> response = new BaseResponse<>();
 		String s = api.genUserSig(map.get("userId"), 604800);
 		response.setData(new ResultData<String>(s));

+ 47 - 0
eladmin-system/src/main/java/me/zhengjie/application/bank/controller/BankNoteVideoController.java

@@ -0,0 +1,47 @@
+package me.zhengjie.application.bank.controller;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.zhengjie.annotation.rest.AnonymousPostMapping;
+import me.zhengjie.base.ResponseDTO;
+import me.zhengjie.base.sms.CreateCloudRecording;
+import me.zhengjie.base.sms.TrtcVo;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+@Validated
+@RestController
+@RequestMapping("${fqgz.bank.app.url-prefix}/note-video")
+@Slf4j
+@RequiredArgsConstructor
+public class BankNoteVideoController {
+
+    /**
+     * 录制App端视频
+     *
+     * @param trtc
+     * @return
+     */
+    @ResponseBody
+    @AnonymousPostMapping("/recording-app")
+    public ResponseDTO<?> recordingApp(@RequestBody TrtcVo trtc) {
+        return ResponseDTO.success(CreateCloudRecording.recordingApp(trtc));
+    }
+
+    /**
+     * 停止录制
+     *
+     * @param map
+     * @return
+     */
+    @ResponseBody
+    @AnonymousPostMapping("/recording-stop")
+    public ResponseDTO<?> recordingStop(@RequestBody Map<String, String> map) {
+        return ResponseDTO.success(CreateCloudRecording.recordingStop(map.get("taskId")));
+    }
+}

+ 1 - 0
eladmin-system/src/main/java/me/zhengjie/application/bank/service/impl/BankNotarizeServiceImpl.java

@@ -38,6 +38,7 @@ public class BankNotarizeServiceImpl implements BankNotarizeService {
         JSONObject jsonObject = JSONObject.parseObject(json);
         String businessNo = jsonObject.getString("businessNo");
         String roomId = jsonObject.getString("roomId");
+
         OrderRoomIdEntity orderRoomId = new OrderRoomIdEntity();
         // 业务流水
         orderRoomId.setBusinessNo(businessNo);

+ 3 - 0
eladmin-system/src/main/java/me/zhengjie/application/user/app/mq/WebSocketReceiver.java

@@ -51,6 +51,7 @@ public class WebSocketReceiver implements MessageListener {
 		String roomId = jsonObj.getString("roomId");
 		String businessNo = jsonObj.getString("businessNo");
 		String appUserId = jsonObj.getString("appUserId");
+		String taskId = jsonObj.getString("taskId");
 		List<OnlineUserDto> users = onlineUserService.getAllLoginUser();
 		// share_userId
 		ContractOrderEntity notaryOrder = contractOrderRepository.getContractOrderWithBizNo(businessNo);
@@ -82,6 +83,7 @@ public class WebSocketReceiver implements MessageListener {
 						obj.put("customerName", sysUser.getNickName());
 						obj.put("customerName", sysUser.getNickName());
 						obj.put("appUserId",appUserId);
+						obj.put("taskId",taskId);
 						list.add(obj);
 						// 重新实例化
 						obj = new JSONObject();
@@ -92,6 +94,7 @@ public class WebSocketReceiver implements MessageListener {
 						obj.put("consultNo", notaryOrder.getConsultNo());
 						obj.put("bankName", notaryOrder.getBankName());
 						obj.put("appUserId",appUserId);
+						obj.put("taskId",taskId);
 						log.info("socket数据的推送给页面:" + notaryId);
 						AppSocketServer.sendInfo(webSocket, obj.toString(), userDto.getUsername());
 					}

+ 20 - 6
eladmin-system/src/main/java/me/zhengjie/base/config/AppConfigInfo.java

@@ -18,18 +18,32 @@ public class AppConfigInfo {
 	// 背景图片
 	public static String APP_BACKGROUND_PICTURE;
 
-	public static Long SDK_APP_ID;
+	public static Long TENCENT_SDK_APP_ID;
 
-	public static String TTL_SIG_KEY;
+	public static String TENCENT_TTL_SIG_KEY;
+
+	public static String TENCENT_SECRET_ID;
+
+	public static String TENCENT_SECRET_KEY;
 
 	@Value("${tencent.ttlsig.sdkappid}")
-	public void setSdkAppId(Long sdkAppId) {
-		SDK_APP_ID = sdkAppId;
+	public void setTencentSdkAppId(Long sdkAppId) {
+		TENCENT_SDK_APP_ID = sdkAppId;
 	}
 
 	@Value("${tencent.ttlsig.key}")
-	public void setTtlSigKey(String ttlSigKey) {
-		TTL_SIG_KEY = ttlSigKey;
+	public void setTencentTtlSigKey(String ttlSigKey) {
+		TENCENT_TTL_SIG_KEY = ttlSigKey;
+	}
+
+	@Value("${tencent.account.secretId}")
+	public void setTencentSecretId(String secretId) {
+		TENCENT_SECRET_ID = secretId;
+	}
+
+	@Value("${tencent.account.secretKey}")
+	public void setTencentSecretKey(String secretKey) {
+		TENCENT_SECRET_KEY = secretKey;
 	}
 
 	@Value("${spring.profiles.active}")

+ 50 - 52
eladmin-system/src/main/java/me/zhengjie/base/sms/CreateCloudRecording.java

@@ -1,23 +1,29 @@
 package me.zhengjie.base.sms;
 
-import org.springframework.stereotype.Component;
-
 import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
 import com.tencentcloudapi.common.profile.ClientProfile;
 import com.tencentcloudapi.common.profile.HttpProfile;
-import com.tencentcloudapi.common.exception.TencentCloudSDKException;
 import com.tencentcloudapi.trtc.v20190722.TrtcClient;
 import com.tencentcloudapi.trtc.v20190722.models.*;
 import com.tencentyun.TLSSigAPIv2;
+import me.zhengjie.base.config.AppConfigInfo;
+import org.springframework.stereotype.Component;
 
 @Component
 public class CreateCloudRecording {
-	public static String stop(String taskId) {
+
+	/**
+	 * 停止录制
+	 *
+	 * @param taskId
+	 * @return
+	 */
+	public static String recordingStop(String taskId) {
 		try {
 			// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
 			// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
-			Credential cred = new Credential("AKIDO7duvhh3xb0C9G5i38xcGftrbBWvZCxY",
-					"ZN7sVvAAzaw4Viz9AwSiiQtAD4g2B5tR");
+			Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);
 			// 实例化一个http选项,可选的,没有特殊需求可以跳过
 			HttpProfile httpProfile = new HttpProfile();
 			httpProfile.setEndpoint("trtc.tencentcloudapi.com");
@@ -28,7 +34,7 @@ public class CreateCloudRecording {
 			TrtcClient client = new TrtcClient(cred, "ap-beijing", clientProfile);
 			// 实例化一个请求对象,每个接口都会对应一个request对象
 			DeleteCloudRecordingRequest req = new DeleteCloudRecordingRequest();
-			req.setSdkAppId(1400669249L);
+			req.setSdkAppId(AppConfigInfo.TENCENT_SDK_APP_ID);
 			req.setTaskId(taskId);
 			// 返回的resp是一个DeleteCloudRecordingResponse的实例,与请求对象对应
 			DeleteCloudRecordingResponse resp = client.DeleteCloudRecording(req);
@@ -41,16 +47,22 @@ public class CreateCloudRecording {
 		return null;
 	}
 
+	/**
+	 * 修改录制视频
+	 *
+	 * @param trtc
+	 * @return
+	 * @throws TencentCloudSDKException
+	 */
 	public static ModifyCloudRecordingResponse modifyRecording(TrtcVo trtc) throws TencentCloudSDKException {
-
-		Credential cred = new Credential("AKIDO7duvhh3xb0C9G5i38xcGftrbBWvZCxY", "ZN7sVvAAzaw4Viz9AwSiiQtAD4g2B5tR");
+		Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);
 		HttpProfile httpProfile = new HttpProfile();
 		httpProfile.setEndpoint("trtc.tencentcloudapi.com");
 		ClientProfile clientProfile = new ClientProfile();
 		clientProfile.setHttpProfile(httpProfile);
 		TrtcClient client = new TrtcClient(cred, "ap-shanghai", clientProfile);
 		ModifyCloudRecordingRequest req = new ModifyCloudRecordingRequest();
-		req.setSdkAppId(1400669249L);
+		req.setSdkAppId(AppConfigInfo.TENCENT_SDK_APP_ID);
 		req.setTaskId(trtc.getTaskId());
 		MixLayoutParams mixLayoutParams1 = new MixLayoutParams();
 		MixLayout[] mixLayouts1 = new MixLayout[1];
@@ -66,9 +78,9 @@ public class CreateCloudRecording {
 		mixLayoutParams1.setMixLayoutMode(4L);
 		req.setMixLayoutParams(mixLayoutParams1);
 		SubscribeStreamUserIds subscribeStreamUserIds1 = new SubscribeStreamUserIds();
-		String[] subscribeAudioUserIds1 = { trtc.getAppUserId(), trtc.getPcUserId() };
+		String[] subscribeAudioUserIds1 = {trtc.getAppUserId(), trtc.getPcUserId()};
 		subscribeStreamUserIds1.setSubscribeAudioUserIds(subscribeAudioUserIds1);
-		String[] subscribeVideoUserIds1 = { trtc.getAppUserId() };
+		String[] subscribeVideoUserIds1 = {trtc.getAppUserId()};
 		subscribeStreamUserIds1.setSubscribeVideoUserIds(subscribeVideoUserIds1);
 		req.setSubscribeStreamUserIds(subscribeStreamUserIds1);
 		// 返回的resp是一个ModifyCloudRecordingResponse的实例,与请求对象对应
@@ -78,14 +90,17 @@ public class CreateCloudRecording {
 		return resp;
 	}
 
+	/**
+	 * 录制PC端视频
+	 *
+	 * @param trtc
+	 * @return
+	 */
 	public static CreateCloudRecordingResponse recordingPc(TrtcVo trtc) {
-
 		try {
-
 			// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
 			// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
-			Credential cred = new Credential("AKIDO7duvhh3xb0C9G5i38xcGftrbBWvZCxY",
-					"ZN7sVvAAzaw4Viz9AwSiiQtAD4g2B5tR");
+			Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);
 			// 实例化一个http选项,可选的,没有特殊需求可以跳过
 			HttpProfile httpProfile = new HttpProfile();
 			httpProfile.setEndpoint("trtc.tencentcloudapi.com");
@@ -96,13 +111,12 @@ public class CreateCloudRecording {
 			TrtcClient client = new TrtcClient(cred, "ap-shanghai", clientProfile);
 			// 实例化一个请求对象,每个接口都会对应一个request对象
 			CreateCloudRecordingRequest req = new CreateCloudRecordingRequest();
-			req.setSdkAppId(1400669249L);
+			req.setSdkAppId(AppConfigInfo.TENCENT_SDK_APP_ID);
 			req.setRoomId(trtc.getRoomId());
 			req.setRoomIdType(1L);
-			String robot = trtc.getRoomId() + "_" + 123;
+			String robot = "pc_" + trtc.getRoomId() + "_" + System.currentTimeMillis();
 			req.setUserId(robot);
-			TLSSigAPIv2 api = new TLSSigAPIv2(1400669249,
-					"e8c1ae74615d6f9cdb692a7b7577b1a63f5f892ff60949b9200b97947834fb2e");
+			TLSSigAPIv2 api = new TLSSigAPIv2(AppConfigInfo.TENCENT_SDK_APP_ID, AppConfigInfo.TENCENT_TTL_SIG_KEY);
 			String s = api.genUserSig(robot, 604800);
 
 			req.setUserSig(s);
@@ -111,15 +125,11 @@ public class CreateCloudRecording {
 			recordParams1.setRecordMode(2L);
 			recordParams1.setStreamType(0L);
 			SubscribeStreamUserIds subscribeStreamUserIds1 = new SubscribeStreamUserIds();
-
-			String[] subscribeAudioUserIds1 = { trtc.getPcUserId(), trtc.getAppUserId() };
+			String[] subscribeAudioUserIds1 = {trtc.getPcUserId(), trtc.getAppUserId()};
 			subscribeStreamUserIds1.setSubscribeAudioUserIds(subscribeAudioUserIds1);
-
-			String[] subscribeVideoUserIds1 = { "share_" + trtc.getPcUserId() };
+			String[] subscribeVideoUserIds1 = {"share_" + trtc.getPcUserId()};
 			subscribeStreamUserIds1.setSubscribeVideoUserIds(subscribeVideoUserIds1);
-
 			recordParams1.setSubscribeStreamUserIds(subscribeStreamUserIds1);
-
 			recordParams1.setOutputFormat(0L);
 			req.setRecordParams(recordParams1);
 
@@ -131,9 +141,7 @@ public class CreateCloudRecording {
 			tencentVod1.setClassId(0L);
 			tencentVod1.setMediaType(0L);
 			cloudVod1.setTencentVod(tencentVod1);
-
 			storageParams1.setCloudVod(cloudVod1);
-
 			req.setStorageParams(storageParams1);
 
 			MixTranscodeParams mixTranscodeParams1 = new MixTranscodeParams();
@@ -146,9 +154,7 @@ public class CreateCloudRecording {
 			mixTranscodeParams1.setVideoParams(videoParams1);
 
 			req.setMixTranscodeParams(mixTranscodeParams1);
-
 			MixLayoutParams mixLayoutParams1 = new MixLayoutParams();
-
 			MixLayout[] mixLayouts1 = new MixLayout[1];
 			MixLayout mixLayout1 = new MixLayout();
 			mixLayout1.setUserId("share_" + trtc.getPcUserId());
@@ -156,11 +162,9 @@ public class CreateCloudRecording {
 			mixLayout1.setLeft(0L);
 			mixLayout1.setWidth(1280L);
 			mixLayout1.setHeight(720L);
-
+			mixLayout1.setRenderMode(2L);
 			mixLayouts1[0] = mixLayout1;
-
 			mixLayoutParams1.setMixLayoutList(mixLayouts1);
-
 			mixLayoutParams1.setMixLayoutMode(4L);
 			req.setMixLayoutParams(mixLayoutParams1);
 
@@ -175,14 +179,17 @@ public class CreateCloudRecording {
 		return null;
 	}
 
+	/**
+	 * 录制App端视频
+	 *
+	 * @param trtc
+	 * @return
+	 */
 	public static CreateCloudRecordingResponse recordingApp(TrtcVo trtc) {
-
 		try {
-
 			// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
 			// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
-			Credential cred = new Credential("AKIDO7duvhh3xb0C9G5i38xcGftrbBWvZCxY",
-					"ZN7sVvAAzaw4Viz9AwSiiQtAD4g2B5tR");
+			Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);
 			// 实例化一个http选项,可选的,没有特殊需求可以跳过
 			HttpProfile httpProfile = new HttpProfile();
 			httpProfile.setEndpoint("trtc.tencentcloudapi.com");
@@ -193,13 +200,12 @@ public class CreateCloudRecording {
 			TrtcClient client = new TrtcClient(cred, "ap-shanghai", clientProfile);
 			// 实例化一个请求对象,每个接口都会对应一个request对象
 			CreateCloudRecordingRequest req = new CreateCloudRecordingRequest();
-			req.setSdkAppId(1400669249L);
+			req.setSdkAppId(AppConfigInfo.TENCENT_SDK_APP_ID);
 			req.setRoomId(trtc.getRoomId());
 			req.setRoomIdType(1L);
-			String robot = trtc.getRoomId() + "_" + 223;
+			String robot = "app_" + trtc.getRoomId() + "_" + System.currentTimeMillis();
 			req.setUserId(robot);
-			TLSSigAPIv2 api = new TLSSigAPIv2(1400669249,
-					"e8c1ae74615d6f9cdb692a7b7577b1a63f5f892ff60949b9200b97947834fb2e");
+			TLSSigAPIv2 api = new TLSSigAPIv2(AppConfigInfo.TENCENT_SDK_APP_ID, AppConfigInfo.TENCENT_TTL_SIG_KEY);
 			String s = api.genUserSig(robot, 604800);
 
 			req.setUserSig(s);
@@ -209,14 +215,12 @@ public class CreateCloudRecording {
 			recordParams1.setStreamType(0L);
 			SubscribeStreamUserIds subscribeStreamUserIds1 = new SubscribeStreamUserIds();
 
-			String[] subscribeAudioUserIds1 = { trtc.getAppUserId() };
+			String[] subscribeAudioUserIds1 = {trtc.getAppUserId()};
 			subscribeStreamUserIds1.setSubscribeAudioUserIds(subscribeAudioUserIds1);
-
-			String[] subscribeVideoUserIds1 = { trtc.getAppUserId() };
+			String[] subscribeVideoUserIds1 = {trtc.getAppUserId()};
 			subscribeStreamUserIds1.setSubscribeVideoUserIds(subscribeVideoUserIds1);
 
 			recordParams1.setSubscribeStreamUserIds(subscribeStreamUserIds1);
-
 			recordParams1.setOutputFormat(0L);
 			req.setRecordParams(recordParams1);
 
@@ -230,7 +234,6 @@ public class CreateCloudRecording {
 			cloudVod1.setTencentVod(tencentVod1);
 
 			storageParams1.setCloudVod(cloudVod1);
-
 			req.setStorageParams(storageParams1);
 
 			MixTranscodeParams mixTranscodeParams1 = new MixTranscodeParams();
@@ -241,11 +244,9 @@ public class CreateCloudRecording {
 			videoParams1.setBitRate(64000L);
 			videoParams1.setGop(1L);
 			mixTranscodeParams1.setVideoParams(videoParams1);
-
 			req.setMixTranscodeParams(mixTranscodeParams1);
 
 			MixLayoutParams mixLayoutParams1 = new MixLayoutParams();
-
 			MixLayout[] mixLayouts1 = new MixLayout[1];
 			MixLayout mixLayout1 = new MixLayout();
 			mixLayout1.setUserId(trtc.getAppUserId());
@@ -256,12 +257,9 @@ public class CreateCloudRecording {
 			mixLayout1.setMediaId(1l);
 
 			mixLayouts1[0] = mixLayout1;
-
 			mixLayoutParams1.setMixLayoutList(mixLayouts1);
-
 			mixLayoutParams1.setMixLayoutMode(4L);
 			req.setMixLayoutParams(mixLayoutParams1);
-
 			// 返回的resp是一个CreateCloudRecordingResponse的实例,与请求对象对应
 			CreateCloudRecordingResponse resp = client.CreateCloudRecording(req);
 			// 输出json格式的字符串回包
@@ -275,6 +273,6 @@ public class CreateCloudRecording {
 
 	public static void main(String[] args) throws TencentCloudSDKException {
 		// recording();
-		stop("D1lp+PBRsphvDfxHcYdxmSux9BVtnCMfVKMu5LFuGKN2++Iq9bMn-miAa4E4wGkdxBa2AA..");
+		recordingStop("D1lp+PBRsphvDfxHcYdxmSux9BVtnCMfVKMu5LFuGKN2++Iq9bMn-miAa4E4wGkdxBa2AA..");
 	}
 }

+ 9 - 17
eladmin-system/src/main/java/me/zhengjie/base/util/TencentServiceUtil.java

@@ -2,9 +2,9 @@ package me.zhengjie.base.util;
 
 import com.alibaba.fastjson.JSONObject;
 import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
 import com.tencentcloudapi.common.profile.ClientProfile;
 import com.tencentcloudapi.common.profile.HttpProfile;
-import com.tencentcloudapi.common.exception.TencentCloudSDKException;
 import com.tencentcloudapi.faceid.v20180301.FaceidClient;
 import com.tencentcloudapi.faceid.v20180301.models.*;
 import com.tencentcloudapi.iai.v20200303.IaiClient;
@@ -12,14 +12,10 @@ import com.tencentcloudapi.iai.v20200303.models.CompareFaceRequest;
 import com.tencentcloudapi.iai.v20200303.models.CompareFaceResponse;
 import com.tencentcloudapi.ocr.v20181119.OcrClient;
 import com.tencentcloudapi.ocr.v20181119.models.*;
-import com.tencentcloudapi.sms.v20210111.SmsClient;
-import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
-import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
 import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.base.config.AppConfigInfo;
 import me.zhengjie.utils.FileUtil;
 import org.springframework.web.multipart.MultipartFile;
-import sun.misc.BASE64Encoder;
 
 import javax.imageio.IIOImage;
 import javax.imageio.ImageIO;
@@ -33,17 +29,13 @@ import java.util.Iterator;
 @Slf4j
 public class TencentServiceUtil {
 
-    // 软控配置
-    private static final String SECRET_ID = "AKIDO7duvhh3xb0C9G5i38xcGftrbBWvZCxY";
-    private static final String SECRET_KEY = "ZN7sVvAAzaw4Viz9AwSiiQtAD4g2B5tR";
-
     /**
      * 手写签名识别(已使用)
      * @param content
      * @return
      */
     public static String getHandwritingText(String content) {
-        Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+        Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);
         // 实例化一个http选项,可选的,没有特殊需求可以跳过
         HttpProfile httpProfile = new HttpProfile();
         httpProfile.setEndpoint("ocr.tencentcloudapi.com");
@@ -74,7 +66,7 @@ public class TencentServiceUtil {
      */
     public static boolean isNameMatchedWithCardNo(String cardNo, String name){
         try{
-            Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+            Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);
             // 实例化一个http选项,可选的,没有特殊需求可以跳过
             HttpProfile httpProfile = new HttpProfile();
             httpProfile.setEndpoint("faceid.tencentcloudapi.com");
@@ -108,7 +100,7 @@ public class TencentServiceUtil {
      */
     public static boolean isRightOnCom4Atrributes(String idCard, String name, String enterpriseName, String enterpriseMark){
         try{
-            Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+            Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);
             // 实例化一个http选项,可选的,没有特殊需求可以跳过
             HttpProfile httpProfile = new HttpProfile();
             httpProfile.setEndpoint("ocr.tencentcloudapi.com");
@@ -146,7 +138,7 @@ public class TencentServiceUtil {
 
             // 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
             // 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
-            Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+            Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);
             // 实例化一个http选项,可选的,没有特殊需求可以跳过
             HttpProfile httpProfile = new HttpProfile();
             httpProfile.setEndpoint("ocr.tencentcloudapi.com");
@@ -179,7 +171,7 @@ public class TencentServiceUtil {
     public static String compareFace(String imageA, String urlB) {
         try {
 
-            Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+            Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);
 
             HttpProfile httpProfile = new HttpProfile();
             httpProfile.setEndpoint("iai.tencentcloudapi.com");
@@ -220,7 +212,7 @@ public class TencentServiceUtil {
         obj.put("LivenessType", "ACTION");
         obj.put("ValidateData", "1,2");
         try {
-            Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+            Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);
             HttpProfile httpProfile = new HttpProfile();
             httpProfile.setEndpoint("faceid.tencentcloudapi.com");
 
@@ -250,7 +242,7 @@ public class TencentServiceUtil {
      */
     public static String FaceImageBody(String idCard, String name, String ImageBase64) {
         try {
-            Credential cred = new Credential(SECRET_ID, SECRET_KEY);;
+            Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);;
             HttpProfile httpProfile = new HttpProfile();
             httpProfile.setEndpoint("faceid.tencentcloudapi.com");
 
@@ -286,7 +278,7 @@ public class TencentServiceUtil {
         obj.put("LivenessType", "ACTION");
         obj.put("ValidateData", "1,2");
         try {
-            Credential cred = new Credential(SECRET_ID, SECRET_KEY);;
+            Credential cred = new Credential(AppConfigInfo.TENCENT_SECRET_ID, AppConfigInfo.TENCENT_SECRET_KEY);;
 
             HttpProfile httpProfile = new HttpProfile();
             httpProfile.setEndpoint("faceid.tencentcloudapi.com");