|
@@ -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())
|
|
@@ -1706,24 +1705,51 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
return false;
|
|
|
}
|
|
|
if (pluginService.pluginName().equals(TencentCloudLivePlugin.PLUGIN_NAME)) {
|
|
|
+// TencentWrapper.LiveStreamState liveStreamState = pluginService.liveStreamState(
|
|
|
+// getStreamId(liveRoom.getRoomUid(), liveRoom.getSpeakerId()));
|
|
|
+// if (liveStreamState == null) {
|
|
|
+// log.error("查询直播间流失败,返回结果为空");
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// log.info("查询直播间流状态:{},roomUid:{}", JSON.toJSONString(liveStreamState), liveRoom.getRoomUid());
|
|
|
+// if (!"active".equals(liveStreamState.getStreamState())) {
|
|
|
+// pluginService.liveStreamStop(getStreamId(liveRoom.getRoomUid(), liveRoom.getSpeakerId()));
|
|
|
+// }
|
|
|
+
|
|
|
+ //销毁直播间
|
|
|
+ pluginService.chatRoomDestroy(liveRoom.getRoomUid());
|
|
|
+
|
|
|
TencentWrapper.LiveStreamState liveStreamState = pluginService.liveStreamState(
|
|
|
getStreamId(liveRoom.getRoomUid(), liveRoom.getSpeakerId()));
|
|
|
if (liveStreamState == null) {
|
|
|
log.error("查询直播间流失败,返回结果为空");
|
|
|
- return false;
|
|
|
- }
|
|
|
- log.info("查询直播间流状态:{},roomUid:{}", JSON.toJSONString(liveStreamState), liveRoom.getRoomUid());
|
|
|
- if (!"active".equals(liveStreamState.getStreamState())) {
|
|
|
+ } else if ("active".equals(liveStreamState.getStreamState())) {
|
|
|
pluginService.liveStreamStop(getStreamId(liveRoom.getRoomUid(), liveRoom.getSpeakerId()));
|
|
|
}
|
|
|
+
|
|
|
+ // 录制任务Id
|
|
|
+ if (liveRoom.getServiceProvider().equals(TencentCloudLivePlugin.PLUGIN_NAME)) {
|
|
|
+
|
|
|
+ List<String> collect = liveRoomService.lambdaQuery()
|
|
|
+ .eq(LiveRoom::getRoomUid, liveRoom.getRoomUid()).list().stream()
|
|
|
+ .map(LiveRoom::getVideoRecord)
|
|
|
+ .filter(StringUtils::isNotEmpty)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (String taskId : collect) {
|
|
|
+ // 删除录制任务
|
|
|
+ pluginService.rtcRoomRecordStop(taskId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} else if (pluginService.pluginName().equals(RongCloudLivePlugin.PLUGIN_NAME)) {
|
|
|
// 融云走原有逻辑 融云自动销毁
|
|
|
- // 销毁状态改为2
|
|
|
- LiveRoom liveRoomUpdate = new LiveRoom();
|
|
|
- liveRoomUpdate.setId(liveRoom.getId());
|
|
|
- liveRoomUpdate.setRoomState(2);
|
|
|
- liveRoomService.updateById(liveRoomUpdate);
|
|
|
}
|
|
|
+ // 销毁状态改为2
|
|
|
+ LiveRoom liveRoomUpdate = new LiveRoom();
|
|
|
+ liveRoomUpdate.setId(liveRoom.getId());
|
|
|
+ liveRoomUpdate.setRoomState(2);
|
|
|
+ liveRoomService.updateById(liveRoomUpdate);
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("查询直播间流失败", e);
|
|
@@ -1733,7 +1759,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 +1984,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 +2238,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();
|
|
@@ -2313,7 +2358,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
RoomSpeakerInfo roomSpeakerInfo = speakerCache.get();
|
|
|
|
|
|
//关闭直播
|
|
|
- if (sequence.equals(roomSpeakerInfo.getSequence())) {
|
|
|
+ if (StringUtils.isNotBlank(sequence) && sequence.equals(roomSpeakerInfo.getSequence())) {
|
|
|
setPushStatus(roomSpeakerInfo.getRoomUid(), 0);
|
|
|
}
|
|
|
|