|
@@ -481,8 +481,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
DateTime now = DateTime.now();
|
|
|
|
|
|
RTCRequest.RecordStart recordStart = RTCRequest.RecordStart.builder()
|
|
|
- .streamName(MessageFormat.format("{0}_{1}", room.getRoomUid(),
|
|
|
- imGroupService.getImUserId(room.getSpeakerId().toString(),ClientEnum.TEACHER.getCode())))
|
|
|
+ .streamName(getStreamId(room.getRoomUid(),room.getSpeakerId()))
|
|
|
.extra("")
|
|
|
.startTime(now.toDateTime().getMillis())
|
|
|
.endTime(now.plusDays(1).toDateTime().getMillis())
|
|
@@ -757,7 +756,37 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
CompletableFuture.runAsync(() -> insertAndCleanLiveData(room.getRoomUid(), room.getSpeakerId()));
|
|
|
log.info("roomDestroy>>>> insertAndCleanLiveData {}", JSONObject.toJSONString(room));
|
|
|
|
|
|
- tryDestroyLiveRoom(room);
|
|
|
+ try {
|
|
|
+ LivePluginService pluginService = livePluginContext.getPluginService(room.getServiceProvider());
|
|
|
+
|
|
|
+ //销毁直播间
|
|
|
+ pluginService.chatRoomDestroy(roomUid);
|
|
|
+
|
|
|
+ TencentWrapper.LiveStreamState liveStreamState = pluginService.liveStreamState(
|
|
|
+ getStreamId(room.getRoomUid(), room.getSpeakerId()));
|
|
|
+ if (liveStreamState == null) {
|
|
|
+ log.error("查询直播间流失败,返回结果为空");
|
|
|
+ } else if ("active".equals(liveStreamState.getStreamState())) {
|
|
|
+ pluginService.liveStreamStop(getStreamId(room.getRoomUid(), room.getSpeakerId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 录制任务Id
|
|
|
+ if (room.getServiceProvider().equals(TencentCloudLivePlugin.PLUGIN_NAME)) {
|
|
|
+
|
|
|
+ List<String> collect = liveRoomService.lambdaQuery()
|
|
|
+ .eq(LiveRoom::getRoomUid, roomUid).list().stream()
|
|
|
+ .map(LiveRoom::getVideoRecord)
|
|
|
+ .filter(StringUtils::isNotEmpty)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (String taskId : collect) {
|
|
|
+ // 删除录制任务
|
|
|
+ pluginService.rtcRoomRecordStop(taskId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("roomDestroy>>>> errorMsg{}", e.getMessage(), e.getCause());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1083,7 +1112,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
|
|
|
appDefinedData.add(TencentRequest.ChatRoomGroupDefinedData.builder()
|
|
|
.key(EGroupDefinedDataType.UPDATE_INFO.getCode())
|
|
|
- .value(StringUtils.join(EGroupDefinedDataType.MEMBER_ONLINE.getCode(),EGroupDefinedDataType.MEMBER_TOTAL.getCode(),","))
|
|
|
+ .value(StringUtils.join(EGroupDefinedDataType.MEMBER_ONLINE.getCode(),",",EGroupDefinedDataType.MEMBER_TOTAL.getCode()))
|
|
|
.build());
|
|
|
try {
|
|
|
livePluginContext.getPluginService(roomVo.getServiceProvider())
|
|
@@ -1714,8 +1743,9 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
}
|
|
|
log.info("查询直播间流状态:{},roomUid:{}", JSON.toJSONString(liveStreamState), liveRoom.getRoomUid());
|
|
|
if (!"active".equals(liveStreamState.getStreamState())) {
|
|
|
- pluginService.liveStreamStop(getStreamId(liveRoom.getRoomUid(), liveRoom.getSpeakerId()));
|
|
|
+ destroyLiveRoom(liveRoom);
|
|
|
}
|
|
|
+
|
|
|
} else if (pluginService.pluginName().equals(RongCloudLivePlugin.PLUGIN_NAME)) {
|
|
|
// 融云走原有逻辑 融云自动销毁
|
|
|
// 销毁状态改为2
|
|
@@ -1733,7 +1763,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
}
|
|
|
|
|
|
private String getStreamId(String roomUid, Long speakerId) {
|
|
|
- return roomUid + "_" + speakerId;
|
|
|
+ return roomUid + "_" + imGroupService.getImUserId(speakerId,ClientEnum.TEACHER);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1958,6 +1988,16 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
.map(this::getSysUser)
|
|
|
.orElseGet(this::getSysUser);
|
|
|
|
|
|
+
|
|
|
+ // 如果是直播课程,判断是否已经结束
|
|
|
+ Integer count = courseScheduleService.lambdaQuery()
|
|
|
+ .eq(CourseSchedule::getRoomUid, roomUid)
|
|
|
+ .eq(CourseSchedule::getStatus, "COMPLETE")
|
|
|
+ .count();
|
|
|
+ if (count >0 ) {
|
|
|
+ throw new BizException("直播课已结束");
|
|
|
+ }
|
|
|
+
|
|
|
// 默认学生端查询
|
|
|
osType = Optional.ofNullable(osType).orElse(1);
|
|
|
ClientEnum clientEnum = ClientEnum.TEACHER;
|
|
@@ -2202,6 +2242,15 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
Optional.ofNullable(roomUid).orElseThrow(() -> new BizException("房间编号不能为空!"));
|
|
|
Optional.ofNullable(userId).orElseThrow(() -> new BizException("人员编号不能为空!"));
|
|
|
|
|
|
+ // 如果是直播课程,判断是否已经结束
|
|
|
+ Integer count = courseScheduleService.lambdaQuery()
|
|
|
+ .eq(CourseSchedule::getRoomUid, roomUid)
|
|
|
+ .eq(CourseSchedule::getStatus, "COMPLETE")
|
|
|
+ .count();
|
|
|
+ if (count >0 ) {
|
|
|
+ throw new BizException("直播课已结束");
|
|
|
+ }
|
|
|
+
|
|
|
// 设置进入时间
|
|
|
RBucket<Long> userStateTimeCache = redissonClient.getBucket(LIVE_USER_LAST_TIME.replace(USER_ID, userId.toString()));
|
|
|
long time = DateTime.now().plusSeconds(1).getMillis();
|
|
@@ -2311,9 +2360,31 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
return;
|
|
|
}
|
|
|
RoomSpeakerInfo roomSpeakerInfo = speakerCache.get();
|
|
|
+ // 设置推流状态房间信息
|
|
|
+ // 查询房间信息
|
|
|
+ LiveRoom imLiveBroadcastRoomVo = getByRoomUid(roomSpeakerInfo.getRoomUid());
|
|
|
|
|
|
+ if (imLiveBroadcastRoomVo == null) {
|
|
|
+ log.warn("closeLive imLiveBroadcastRoomVo is null");
|
|
|
+ return;
|
|
|
+ }
|
|
|
//关闭直播
|
|
|
- if (StringUtils.isNotBlank(sequence) && sequence.equals(roomSpeakerInfo.getSequence())) {
|
|
|
+ LivePluginService pluginService = livePluginContext.getPluginService(imLiveBroadcastRoomVo.getServiceProvider());
|
|
|
+ if (StringUtils.isBlank(sequence)) {
|
|
|
+ try {
|
|
|
+ TencentWrapper.LiveStreamState liveStreamState = pluginService.liveStreamState(getStreamId(imLiveBroadcastRoomVo.getRoomUid(), imLiveBroadcastRoomVo.getSpeakerId()));
|
|
|
+ if (liveStreamState == null) {
|
|
|
+ log.error("查询直播间流失败,返回结果为空");
|
|
|
+ } else {
|
|
|
+ log.info("查询直播间流状态:{},roomUid:{}", JSON.toJSONString(liveStreamState), imLiveBroadcastRoomVo.getRoomUid());
|
|
|
+ if (!"active".equals(liveStreamState.getStreamState())) {
|
|
|
+ setPushStatus(roomSpeakerInfo.getRoomUid(), 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询直播间流失败,roomUid:{}", imLiveBroadcastRoomVo.getRoomUid(), e);
|
|
|
+ }
|
|
|
+ } else if (sequence.equals(roomSpeakerInfo.getSequence())) {
|
|
|
setPushStatus(roomSpeakerInfo.getRoomUid(), 0);
|
|
|
}
|
|
|
|