|
@@ -8,6 +8,7 @@ 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;
|
|
|
import com.ym.mec.biz.service.ImLiveRoomVideoService;
|
|
|
import com.ym.mec.common.entity.ImRoomMessage;
|
|
@@ -333,16 +334,15 @@ public class LiveRoomServiceImpl implements LiveRoomService {
|
|
|
* @param streamId 推流Id
|
|
|
*/
|
|
|
@Override
|
|
|
- public void strartTencentLiveVideoRecord(String streamId) {
|
|
|
-
|
|
|
- // 直播间ROOM_UID
|
|
|
- String roomId = streamId.split("_")[0];
|
|
|
+ public void startTencentLiveVideoRecord(String streamId) {
|
|
|
|
|
|
+ DateTime now = DateTime.now();
|
|
|
// 创建直播录制
|
|
|
RTCRequest.RecordStart recordStart = RTCRequest.RecordStart.builder()
|
|
|
.streamName(streamId)
|
|
|
.extra("")
|
|
|
- .endTime(DateTime.now().plusHours(23).getMillis() / 1000)
|
|
|
+ .startTime(now.getMillis())
|
|
|
+ .endTime(now.plusDays(1).getMillis())
|
|
|
.build();
|
|
|
// 创建录制任务失败,重试3次后,发送IM消息通知主播老师
|
|
|
int maxRetry = 0;
|
|
@@ -365,7 +365,11 @@ public class LiveRoomServiceImpl implements LiveRoomService {
|
|
|
}
|
|
|
} 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)
|
|
@@ -403,4 +407,30 @@ public class LiveRoomServiceImpl implements LiveRoomService {
|
|
|
} while (maxRetry++ < 3);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成直播录制信息
|
|
|
+ *
|
|
|
+ * @param event TencentData.CallbackSteamRecordEvent
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void createLiveRoomVideoRecord(TencentData.CallbackSteamRecordEvent event) {
|
|
|
+
|
|
|
+ // 直播间ROOM_UID
|
|
|
+ String roomId = event.getStreamId().split("_")[0];
|
|
|
+
|
|
|
+ //云端录制文件地址
|
|
|
+ String fileUrl = storagePluginContext.getPublicUrl(event.getVideoUrl(),"live-rewind");
|
|
|
+
|
|
|
+ // 录制开始时间
|
|
|
+ long startTime = (event.getEndTime() - event.getDuration()) * 1000L;
|
|
|
+ //保存切片
|
|
|
+ ImLiveRoomVideo imLiveRoomVideo = initImLiveRoomVideo(roomId, event.getTaskId(), DateTime.now().toDate());
|
|
|
+ imLiveRoomVideo.setStartTime(new DateTime(startTime).toDate());
|
|
|
+ imLiveRoomVideo.setEndTime(new DateTime(event.getEndTime() * 1000L).toDate());
|
|
|
+ imLiveRoomVideo.setUrl(fileUrl);
|
|
|
+ imLiveRoomVideo.setType(2);
|
|
|
+
|
|
|
+ imLiveRoomVideoService.save(imLiveRoomVideo);
|
|
|
+ }
|
|
|
}
|