|
@@ -756,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());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1705,51 +1735,25 @@ 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("查询直播间流失败,返回结果为空");
|
|
|
- } else if ("active".equals(liveStreamState.getStreamState())) {
|
|
|
- pluginService.liveStreamStop(getStreamId(liveRoom.getRoomUid(), liveRoom.getSpeakerId()));
|
|
|
+ return false;
|
|
|
}
|
|
|
-
|
|
|
- // 录制任务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);
|
|
|
- }
|
|
|
+ log.info("查询直播间流状态:{},roomUid:{}", JSON.toJSONString(liveStreamState), liveRoom.getRoomUid());
|
|
|
+ if (!"active".equals(liveStreamState.getStreamState())) {
|
|
|
+ destroyLiveRoom(liveRoom);
|
|
|
}
|
|
|
|
|
|
} 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);
|