[ 'TencentVod' => [ 'StorageRegion' => 'ap-chongqing', 'Procedure' => 'STD-H264-MP4-1080P', 'ClassId' => 1174322, 'SubAppId' => 1327013090, 'UserDefineRecordId' => '', ], ], ]; public function startWebRecord($request) { $roomId = $request['room_id']; $roomName = $request['room_name']; $otherParams = $request['other_params']; $userId = $request['account_id']; // 录制机器人的UserId,用于进房发起录制任务 $recordUserId = 'recorder_'.$roomId.'_'.$userId; $this->storageParams['CloudVod']['TencentVod']['UserDefineRecordId'] = $recordUserId; $sign = new SignTencent(); $userSign = $sign->genUserSign($recordUserId); $recordInsertData = [ 'lecture_id' => $roomId, 'room_name' => $roomName, 'user_id' => $userId, 'record_user_id' => $recordUserId, 'user_sign' => $userSign, ]; $maxDurationLimit = config('tencent.web.max_duration_limit.region'); $tParams = [ 'RecordUrl' => $this->webRecordUrl($recordInsertData, $otherParams), 'MaxDurationLimit' => $maxDurationLimit, 'StorageParams' => $this->storageParams, ]; // print_r($tParams);exit; $tRoom = new TrtcTencent('StartWebRecord', $tParams); $retData = $tRoom->resultArr; $taskId = $retData['data']['TaskId'] ?? ''; if (!$taskId) { return false; } $recordInsertData['task_id'] = $taskId; $roomRecord = new LectureRecord(); $roomRecord->fill($recordInsertData)->save(); return $taskId; } public function describeWebRecord($taskId) { $params['TaskId'] = $taskId; $tRoom = new TrtcTencent('DescribeWebRecord', $params); $retData = $tRoom->resultArr; return $retData['data']; } public function stopWebRecord($taskId) { $params['TaskId'] = $taskId; $tRoom = new TrtcTencent('StopWebRecord', $params); $retData = $tRoom->resultArr; return $retData['data']; } public function deleteMedia($fileId) { if (!$fileId) { return false; } $params['FileId'] = $fileId; $tMedia = new MediaTencent('DeleteMedia', $params); $retData = $tMedia->resultArr; return $retData['data']; } // 构建Web录制页面的URL public function webRecordUrl($data, $otherParams): string { $url = getenv('WEB_URL').'Room?'; $params = [ 'user_id' => $data['record_user_id'], 'username' => $data['record_user_id'], 'room_id' => (string) $data['lecture_id'], 'room_name' => $data['room_name'], 'user_sign' => $data['user_sign'], 'sdk_app_id' => (int)config('tencent.trtc.app_id'), 'room_exist' => true, 'is_record' => true, ]; $extraInfo = [ ]; // 其他参数,主要控制页面录制时,页面需要渲染成什么样子 if (\is_array($otherParams)) { foreach ($otherParams as $k => $v) { $params[$k] = $v; } } // print_r($params);exit; $url .= 'roomInfo='.urlencode(json_encode($params, JSON_UNESCAPED_UNICODE)); $url .= '&extraInfo='.urlencode(json_encode($extraInfo, JSON_UNESCAPED_UNICODE)); $url.='&is_record=true&room_id='.$data['lecture_id']; return $url; } }