视频录制修改 #210
+38
-28
@@ -198,7 +198,7 @@ public class VideoServiceImpl implements VideoService {
|
||||
*/
|
||||
req.setUserId(userId);
|
||||
|
||||
TLSSigAPIv2 api = new TLSSigAPIv2(Long.valueOf(sdkAppId), sdkSecretKey);
|
||||
TLSSigAPIv2 api = new TLSSigAPIv2(sdkAppId, sdkSecretKey);
|
||||
String userSign = api.genUserSig(userId, 60 * 60 * 10);
|
||||
req.setUserSig(userSign); // 录制机器人用于进入TRTC房间拉流的用户签名,当前 UserId 对应的验证签名,相当于登录密码
|
||||
RecordParams recordParams = new RecordParams();
|
||||
@@ -207,23 +207,27 @@ public class VideoServiceImpl implements VideoService {
|
||||
recordParams.setStreamType(0L); // 0:录制音频+视频流(默认); 1:仅录制音频流; 2:仅录制视频流
|
||||
recordParams.setRecordMode(2L); // 1:单流录制,分别录制房间的订阅UserId的音频和视频,将录制文件上传至云存储; 2:混流录制,将房间内订阅UserId的音视频混录成一个音视频文件,将录制文件上传至云存储;
|
||||
recordParams.setOutputFormat(0L); // 0:(默认)输出文件为hls格式。1:输出文件格式为hls+mp4。2:输出文件格式为hls+aac
|
||||
MixLayoutParams mixLayoutParams = new MixLayoutParams();
|
||||
// 布局模式: 1:悬浮布局;2:屏幕分享布局;3:九宫格布局(默认);4:自定义布局;
|
||||
mixLayoutParams.setMixLayoutMode(1L);
|
||||
req.setMixLayoutParams(mixLayoutParams);
|
||||
|
||||
StorageParams storageParams1 = new StorageParams();
|
||||
CloudVod cloudVod1 = new CloudVod();
|
||||
TencentVod tencentVod1 = new TencentVod();
|
||||
CloudVod cloudVod = new CloudVod();
|
||||
TencentVod tencentVod = new TencentVod();
|
||||
tencentVod.setSubAppId(1304001529L);
|
||||
// 录制的文件永久保存
|
||||
tencentVod1.setExpireTime(0L);
|
||||
tencentVod.setExpireTime(0L);
|
||||
// 录制文件名拼接前缀
|
||||
tencentVod1.setUserDefineRecordId(caseId+"@");
|
||||
cloudVod1.setTencentVod(tencentVod1); // 腾讯云点播相关参数。
|
||||
storageParams1.setCloudVod(cloudVod1); // 必填】腾讯云云点播的账号信息,目前仅支持存储至腾讯云点播VOD。
|
||||
tencentVod.setUserDefineRecordId(caseId+"");
|
||||
cloudVod.setTencentVod(tencentVod); // 腾讯云点播相关参数。
|
||||
storageParams1.setCloudVod(cloudVod); // 必填】腾讯云云点播的账号信息,目前仅支持存储至腾讯云点播VOD。
|
||||
req.setRecordParams(recordParams); // 云端录制控制参数
|
||||
req.setStorageParams(storageParams1); // 云端录制文件上传到云存储的参数(目前只支持使用腾讯云点播作为存储)
|
||||
// 返回的resp是一个CreateCloudRecordingResponse的实例,与请求对象对应
|
||||
CreateCloudRecordingResponse resp = client.CreateCloudRecording(req);
|
||||
// 输出json格式的字符串回包
|
||||
String s = JSON.toJSONString(resp);
|
||||
return AjaxResult.success(s);
|
||||
|
||||
return AjaxResult.success((JSONObject) JSON.toJSON(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
return AjaxResult.error(e.toString());
|
||||
}
|
||||
@@ -231,29 +235,35 @@ public class VideoServiceImpl implements VideoService {
|
||||
|
||||
@Override
|
||||
public AjaxResult closeDeleteCloudRecording(String taskId) {
|
||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
||||
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
||||
Credential cred = new Credential(secretId, secretKey);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("trtc.tencentcloudapi.com");
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
TrtcClient client = new TrtcClient(cred, "ap-beijing", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
DeleteCloudRecordingRequest req = new DeleteCloudRecordingRequest();
|
||||
|
||||
// 返回的resp是一个DeleteCloudRecordingResponse的实例,与请求对象对应
|
||||
DeleteCloudRecordingResponse resp = null;
|
||||
try {
|
||||
resp = client.DeleteCloudRecording(req);
|
||||
if (taskId != null) {
|
||||
taskId = taskId.replaceAll(" ", "+");
|
||||
}
|
||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
||||
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
||||
Credential cred = new Credential(secretId, secretKey);
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("trtc.tencentcloudapi.com");
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
TrtcClient client = new TrtcClient(cred, "ap-beijing", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
DeleteCloudRecordingRequest req = new DeleteCloudRecordingRequest();
|
||||
req.setSdkAppId(sdkAppId); // SdkAppId – TRTC的SDKAppId,和录制的房间所对应的SDKAppId相同
|
||||
req.setTaskId(taskId); // TaskId – 录制任务的唯一Id,在启动录制成功后会返回
|
||||
// 返回的resp是一个DeleteCloudRecordingResponse的实例,与请求对象对应
|
||||
DeleteCloudRecordingResponse resp = client.DeleteCloudRecording(req);
|
||||
// 输出json格式的字符串回包
|
||||
return AjaxResult.success((JSONObject) JSON.toJSON(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
return AjaxResult.error(e.toString());
|
||||
}
|
||||
return AjaxResult.success(DeleteCloudRecordingResponse.toJsonString(resp));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user