|
|
|
|
|
|
198
|
*/
|
198
|
*/
|
|
199
|
req.setUserId(userId);
|
199
|
req.setUserId(userId);
|
|
200
|
|
200
|
|
|
201
|
- TLSSigAPIv2 api = new TLSSigAPIv2(Long.valueOf(sdkAppId), sdkSecretKey);
|
|
|
|
|
|
201
|
+ TLSSigAPIv2 api = new TLSSigAPIv2(sdkAppId, sdkSecretKey);
|
|
202
|
String userSign = api.genUserSig(userId, 60 * 60 * 10);
|
202
|
String userSign = api.genUserSig(userId, 60 * 60 * 10);
|
|
203
|
req.setUserSig(userSign); // 录制机器人用于进入TRTC房间拉流的用户签名,当前 UserId 对应的验证签名,相当于登录密码
|
203
|
req.setUserSig(userSign); // 录制机器人用于进入TRTC房间拉流的用户签名,当前 UserId 对应的验证签名,相当于登录密码
|
|
204
|
RecordParams recordParams = new RecordParams();
|
204
|
RecordParams recordParams = new RecordParams();
|
|
|
|
|
|
|
207
|
recordParams.setStreamType(0L); // 0:录制音频+视频流(默认); 1:仅录制音频流; 2:仅录制视频流
|
207
|
recordParams.setStreamType(0L); // 0:录制音频+视频流(默认); 1:仅录制音频流; 2:仅录制视频流
|
|
208
|
recordParams.setRecordMode(2L); // 1:单流录制,分别录制房间的订阅UserId的音频和视频,将录制文件上传至云存储; 2:混流录制,将房间内订阅UserId的音视频混录成一个音视频文件,将录制文件上传至云存储;
|
208
|
recordParams.setRecordMode(2L); // 1:单流录制,分别录制房间的订阅UserId的音频和视频,将录制文件上传至云存储; 2:混流录制,将房间内订阅UserId的音视频混录成一个音视频文件,将录制文件上传至云存储;
|
|
209
|
recordParams.setOutputFormat(0L); // 0:(默认)输出文件为hls格式。1:输出文件格式为hls+mp4。2:输出文件格式为hls+aac
|
209
|
recordParams.setOutputFormat(0L); // 0:(默认)输出文件为hls格式。1:输出文件格式为hls+mp4。2:输出文件格式为hls+aac
|
|
|
|
210
|
+ MixLayoutParams mixLayoutParams = new MixLayoutParams();
|
|
|
|
211
|
+ // 布局模式: 1:悬浮布局;2:屏幕分享布局;3:九宫格布局(默认);4:自定义布局;
|
|
|
|
212
|
+ mixLayoutParams.setMixLayoutMode(1L);
|
|
|
|
213
|
+ req.setMixLayoutParams(mixLayoutParams);
|
|
210
|
|
214
|
|
|
211
|
StorageParams storageParams1 = new StorageParams();
|
215
|
StorageParams storageParams1 = new StorageParams();
|
|
212
|
- CloudVod cloudVod1 = new CloudVod();
|
|
|
|
213
|
- TencentVod tencentVod1 = new TencentVod();
|
|
|
|
|
|
216
|
+ CloudVod cloudVod = new CloudVod();
|
|
|
|
217
|
+ TencentVod tencentVod = new TencentVod();
|
|
|
|
218
|
+ tencentVod.setSubAppId(1304001529L);
|
|
214
|
// 录制的文件永久保存
|
219
|
// 录制的文件永久保存
|
|
215
|
- tencentVod1.setExpireTime(0L);
|
|
|
|
|
|
220
|
+ tencentVod.setExpireTime(0L);
|
|
216
|
// 录制文件名拼接前缀
|
221
|
// 录制文件名拼接前缀
|
|
217
|
- tencentVod1.setUserDefineRecordId(caseId+"@");
|
|
|
|
218
|
- cloudVod1.setTencentVod(tencentVod1); // 腾讯云点播相关参数。
|
|
|
|
219
|
- storageParams1.setCloudVod(cloudVod1); // 必填】腾讯云云点播的账号信息,目前仅支持存储至腾讯云点播VOD。
|
|
|
|
|
|
222
|
+ tencentVod.setUserDefineRecordId(caseId+"");
|
|
|
|
223
|
+ cloudVod.setTencentVod(tencentVod); // 腾讯云点播相关参数。
|
|
|
|
224
|
+ storageParams1.setCloudVod(cloudVod); // 必填】腾讯云云点播的账号信息,目前仅支持存储至腾讯云点播VOD。
|
|
220
|
req.setRecordParams(recordParams); // 云端录制控制参数
|
225
|
req.setRecordParams(recordParams); // 云端录制控制参数
|
|
221
|
req.setStorageParams(storageParams1); // 云端录制文件上传到云存储的参数(目前只支持使用腾讯云点播作为存储)
|
226
|
req.setStorageParams(storageParams1); // 云端录制文件上传到云存储的参数(目前只支持使用腾讯云点播作为存储)
|
|
222
|
// 返回的resp是一个CreateCloudRecordingResponse的实例,与请求对象对应
|
227
|
// 返回的resp是一个CreateCloudRecordingResponse的实例,与请求对象对应
|
|
223
|
CreateCloudRecordingResponse resp = client.CreateCloudRecording(req);
|
228
|
CreateCloudRecordingResponse resp = client.CreateCloudRecording(req);
|
|
224
|
- // 输出json格式的字符串回包
|
|
|
|
225
|
- String s = JSON.toJSONString(resp);
|
|
|
|
226
|
- return AjaxResult.success(s);
|
|
|
|
|
|
229
|
+
|
|
|
|
230
|
+ return AjaxResult.success((JSONObject) JSON.toJSON(resp));
|
|
227
|
} catch (TencentCloudSDKException e) {
|
231
|
} catch (TencentCloudSDKException e) {
|
|
228
|
return AjaxResult.error(e.toString());
|
232
|
return AjaxResult.error(e.toString());
|
|
229
|
}
|
233
|
}
|
|
|
|
|
|
|
231
|
|
235
|
|
|
232
|
@Override
|
236
|
@Override
|
|
233
|
public AjaxResult closeDeleteCloudRecording(String taskId) {
|
237
|
public AjaxResult closeDeleteCloudRecording(String taskId) {
|
|
234
|
- // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
|
|
|
235
|
- // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
|
|
|
236
|
- // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
|
|
|
237
|
- Credential cred = new Credential(secretId, secretKey);
|
|
|
|
238
|
- // 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
|
|
239
|
- HttpProfile httpProfile = new HttpProfile();
|
|
|
|
240
|
- httpProfile.setEndpoint("trtc.tencentcloudapi.com");
|
|
|
|
241
|
- // 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
|
|
242
|
- ClientProfile clientProfile = new ClientProfile();
|
|
|
|
243
|
- clientProfile.setHttpProfile(httpProfile);
|
|
|
|
244
|
- // 实例化要请求产品的client对象,clientProfile是可选的
|
|
|
|
245
|
- TrtcClient client = new TrtcClient(cred, "ap-beijing", clientProfile);
|
|
|
|
246
|
- // 实例化一个请求对象,每个接口都会对应一个request对象
|
|
|
|
247
|
- DeleteCloudRecordingRequest req = new DeleteCloudRecordingRequest();
|
|
|
|
248
|
|
238
|
|
|
249
|
- // 返回的resp是一个DeleteCloudRecordingResponse的实例,与请求对象对应
|
|
|
|
250
|
- DeleteCloudRecordingResponse resp = null;
|
|
|
|
251
|
try {
|
239
|
try {
|
|
252
|
- resp = client.DeleteCloudRecording(req);
|
|
|
|
|
|
240
|
+ if (taskId != null) {
|
|
|
|
241
|
+ taskId = taskId.replaceAll(" ", "+");
|
|
|
|
242
|
+ }
|
|
|
|
243
|
+ // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
|
|
|
244
|
+ // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
|
|
|
245
|
+ // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
|
|
|
246
|
+ Credential cred = new Credential(secretId, secretKey);
|
|
|
|
247
|
+ // 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
|
|
248
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
|
249
|
+ httpProfile.setEndpoint("trtc.tencentcloudapi.com");
|
|
|
|
250
|
+ // 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
|
|
251
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
|
252
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
|
253
|
+ // 实例化要请求产品的client对象,clientProfile是可选的
|
|
|
|
254
|
+ TrtcClient client = new TrtcClient(cred, "ap-beijing", clientProfile);
|
|
|
|
255
|
+ // 实例化一个请求对象,每个接口都会对应一个request对象
|
|
|
|
256
|
+ DeleteCloudRecordingRequest req = new DeleteCloudRecordingRequest();
|
|
|
|
257
|
+ req.setSdkAppId(sdkAppId); // SdkAppId – TRTC的SDKAppId,和录制的房间所对应的SDKAppId相同
|
|
|
|
258
|
+ req.setTaskId(taskId); // TaskId – 录制任务的唯一Id,在启动录制成功后会返回
|
|
|
|
259
|
+ // 返回的resp是一个DeleteCloudRecordingResponse的实例,与请求对象对应
|
|
|
|
260
|
+ DeleteCloudRecordingResponse resp = client.DeleteCloudRecording(req);
|
|
|
|
261
|
+ // 输出json格式的字符串回包
|
|
|
|
262
|
+ return AjaxResult.success((JSONObject) JSON.toJSON(resp));
|
|
253
|
} catch (TencentCloudSDKException e) {
|
263
|
} catch (TencentCloudSDKException e) {
|
|
254
|
return AjaxResult.error(e.toString());
|
264
|
return AjaxResult.error(e.toString());
|
|
255
|
}
|
265
|
}
|
|
256
|
- return AjaxResult.success(DeleteCloudRecordingResponse.toJsonString(resp));
|
|
|
|
|
|
266
|
+
|
|
257
|
}
|
267
|
}
|
|
258
|
|
268
|
|
|
259
|
|
269
|
|