|
|
@@ -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..");
|
|
|
}
|
|
|
}
|