|
@@ -1,12 +1,7 @@
|
|
|
package com.ym.service.Impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.microsvc.toolkit.middleware.live.LivePluginContext;
|
|
|
-import com.microsvc.toolkit.middleware.live.impl.TencentCloudLivePlugin;
|
|
|
-import com.microsvc.toolkit.middleware.live.message.RTCRequest;
|
|
|
-import com.microsvc.toolkit.middleware.live.message.RTCRoom;
|
|
|
import com.ym.http.HttpHelper;
|
|
|
import com.ym.mec.biz.dal.dto.TencentData;
|
|
|
import com.ym.mec.biz.dal.entity.ImLiveRoomVideo;
|
|
@@ -50,8 +45,6 @@ public class LiveRoomServiceImpl implements LiveRoomService {
|
|
|
private ImLiveRoomVideoService imLiveRoomVideoService;
|
|
|
@Autowired
|
|
|
private StoragePluginContext storagePluginContext;
|
|
|
- @Autowired
|
|
|
- private LivePluginContext livePluginContext;
|
|
|
|
|
|
/**
|
|
|
* 创建房间-聊天室
|
|
@@ -327,87 +320,6 @@ public class LiveRoomServiceImpl implements LiveRoomService {
|
|
|
return sessionId;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建tencent云直播录制记录
|
|
|
- *
|
|
|
- * @param streamId 推流Id
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void startTencentLiveVideoRecord(String streamId) {
|
|
|
-
|
|
|
- DateTime now = DateTime.now();
|
|
|
- // 创建直播录制
|
|
|
- RTCRequest.RecordStart recordStart = RTCRequest.RecordStart.builder()
|
|
|
- .streamName(streamId)
|
|
|
- .extra("")
|
|
|
- .startTime(now.getMillis())
|
|
|
- .endTime(now.plusDays(1).getMillis())
|
|
|
- .build();
|
|
|
- // 创建录制任务失败,重试3次后,发送IM消息通知主播老师
|
|
|
- int maxRetry = 0;
|
|
|
- // 录制任务ID
|
|
|
- String taskId = "";
|
|
|
- do {
|
|
|
- try {
|
|
|
-
|
|
|
- // 创建录制任务
|
|
|
- RTCRoom.RecordResp resp = livePluginContext.getPluginService(TencentCloudLivePlugin.PLUGIN_NAME)
|
|
|
- .rtcRoomRecordStart(recordStart);
|
|
|
-
|
|
|
- taskId = resp.getRecordId();
|
|
|
- if (StringUtils.isNotBlank(taskId)) {
|
|
|
- maxRetry = 3;
|
|
|
- }
|
|
|
- log.info("createTencentLiveRoomVideoRecord resp={}", JSON.toJSONString(resp));
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("创建直播录制失败", e);
|
|
|
- }
|
|
|
- } while (maxRetry++ < 3);
|
|
|
-
|
|
|
- log.info("startTencentLiveVideoRecord taskId={}", taskId);
|
|
|
- // 生成录制记录
|
|
|
- // 直播间ROOM_UID
|
|
|
- String roomId = streamId.split("_")[0];
|
|
|
-
|
|
|
- ImLiveRoomVideo video = imLiveRoomVideoService.getOne(new QueryWrapper<ImLiveRoomVideo>()
|
|
|
- .eq("room_uid_", roomId)
|
|
|
- .eq("record_id_", taskId)
|
|
|
- .eq("type", 0));
|
|
|
- if (Objects.nonNull(video)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- imLiveRoomVideoService.save(initImLiveRoomVideo(roomId, taskId, new Date()));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 关闭tencent云直播录制记录
|
|
|
- *
|
|
|
- * @param streamId 推流Id
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void stopTencentLiveVideoRecord(String streamId) {
|
|
|
-
|
|
|
- // 关闭录制任务失败,重试3次后,发送IM消息通知主播老师
|
|
|
- int maxRetry = 0;
|
|
|
- do {
|
|
|
- try {
|
|
|
-
|
|
|
- // 关闭直播录制
|
|
|
- RTCRoom.RecordResp ret = livePluginContext.getPluginService(TencentCloudLivePlugin.PLUGIN_NAME)
|
|
|
- .rtcRoomRecordStop(streamId);
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(ret.getRequestId())) {
|
|
|
- // 重试最大次数
|
|
|
- maxRetry = 3;
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("关闭直播录制失败", e);
|
|
|
- }
|
|
|
- } while (maxRetry++ < 3);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 生成直播录制信息
|
|
|
*
|