|
@@ -19,7 +19,6 @@ import org.springframework.stereotype.Component;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by weiqinxiao on 2019/2/28.
|
|
@@ -237,8 +236,7 @@ public class IMHelper {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- @Async
|
|
|
- public IMApiResultInfo startRecord(String roomId, Long registrationId, List<RoomMember> roomMembers) throws Exception {
|
|
|
+ public void startRecord(String roomId, Long registrationId, List<RoomMember> roomMembers) throws Exception {
|
|
|
if (roomId == null) {
|
|
|
throw new IllegalArgumentException("Paramer 'roomId' is required");
|
|
|
}
|
|
@@ -269,16 +267,37 @@ public class IMHelper {
|
|
|
config.put("input",getInput(roomMembers));
|
|
|
paramJson.put("config",config);
|
|
|
String body = paramJson.toJSONString();
|
|
|
+ againRecord(body,registrationId,roomId);
|
|
|
+ }
|
|
|
|
|
|
+ @Async
|
|
|
+ public void againRecord(String body,Long registrationId,String roomId) throws Exception {
|
|
|
HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/start.json", "application/json",roomId);
|
|
|
httpHelper.setBodyParameter(body, conn);
|
|
|
IMApiResultInfo resultInfo = JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class);
|
|
|
if(resultInfo.getResultCode() == 10000){
|
|
|
redisTemplate.opsForValue().set(resultInfo.getRecordId(),registrationId.toString());
|
|
|
}else {
|
|
|
- log.error("直播视频录制失败:body : {},resultInfo : {}",body,resultInfo);
|
|
|
+ log.error("直播视频录制失败:body : {},resultInfo : {} 准备重试",body,resultInfo);
|
|
|
+ int i = 1;
|
|
|
+ while (i<=3){
|
|
|
+ Thread.sleep(5000l);
|
|
|
+ HttpURLConnection connection = httpHelper.createIMRtcPostHttpConnection("/rtc/record/start.json", "application/json", roomId);
|
|
|
+ httpHelper.setBodyParameter(body, connection);
|
|
|
+ IMApiResultInfo imApiResultInfo = JSON.parseObject(httpHelper.returnResult(connection, body), IMApiResultInfo.class);
|
|
|
+ log.error("直播视频录制失败:resultInfo : {} 第{}次重试",imApiResultInfo,i);
|
|
|
+ i++;
|
|
|
+ if(imApiResultInfo.getResultCode() == 10000){
|
|
|
+ redisTemplate.opsForValue().set(imApiResultInfo.getRecordId(),registrationId.toString());
|
|
|
+ log.info("直播视频录制成功:第{}次重试",i);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(i > 3){
|
|
|
+ log.error("直播视频录制失败:resultInfo : {} 重试结束",imApiResultInfo);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return resultInfo;
|
|
|
}
|
|
|
|
|
|
/**
|