[ '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']; $patientId = RoomModel::query() ->where('id', $roomId) ->value('patient_id'); $transcribeType=1; if (empty($patientId)){ $patientId = MeetingCentre::query() ->where('room_id',$roomId) ->value('patient_id'); if (!empty($patientId)){ $transcribeType=2; } } // 录制机器人的UserId,用于进房发起录制任务 $recordUserId = 'recorder_'.$roomId.'_'.$userId; $this->storageParams['CloudVod']['TencentVod']['UserDefineRecordId'] = $recordUserId; $sign = new SignTencent(); $userSign = $sign->genUserSign($recordUserId); $recordInsertData = [ 'room_id' => $roomId, 'room_name' => $roomName, 'user_id' => $userId, 'record_user_id' => $recordUserId, 'user_sign' => $userSign, 'patient_id' => $patientId, 'transcribe_type'=>$transcribeType, ]; $maxDurationLimit = config('tencent.web.max_duration_limit.region'); $tParams = [ 'RecordUrl' => $this->webRecordUrl($recordInsertData, $otherParams), 'MaxDurationLimit' => $maxDurationLimit, 'StorageParams' => $this->storageParams, ]; $tRoom = new TrtcTencent('StartWebRecord', $tParams); $retData = $tRoom->resultArr; $taskId = $retData['data']['TaskId'] ?? ''; if (!$taskId) { return false; } $recordInsertData['task_id'] = $taskId; $roomRecord = new RoomWebRecord(); $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 TencentTrtcTencent('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'], 'room_id' => (string) $data['room_id'], 'room_name' => $data['room_name'], 'user_sign' => $data['user_sign'], 'sdk_app_id' => config('tencent.trtc.app_id'), 'room_exist' => false, 'is_record' => true, ]; $extraInfo = [ 'patient_id' => $data['patient_id'], ]; // 其他参数,主要控制页面录制时,页面需要渲染成什么样子 if (\is_array($otherParams)) { foreach ($otherParams as $k => $v) { $params[$k] = $v; } } $url .= 'roomInfo='.urlencode(json_encode($params, JSON_UNESCAPED_UNICODE)); $url .= '&extraInfo='.urlencode(json_encode($extraInfo, JSON_UNESCAPED_UNICODE)); return $url; } }