|
@@ -891,7 +891,13 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
|
|
|
|
|
|
// 用户进入直播间,发送统计数据
|
|
|
- sendLiveRoomStatMessage(userid, roomVo);
|
|
|
+ // sendLiveRoomStatMessage(userid, roomVo);
|
|
|
+
|
|
|
+ // 直播间统计数据
|
|
|
+ getRoomData(roomVo);
|
|
|
+ // 设置群组属性
|
|
|
+ setGroupDefinedData(roomVo,EGroupDefinedDataType.MEMBER_ONLINE,roomVo.getLookNum().toString());
|
|
|
+ setGroupDefinedData(roomVo,EGroupDefinedDataType.MEMBER_TOTAL,roomVo.getTotalLookNum().toString());
|
|
|
log.debug("opsRoom>>>> user enter room, userState: {}", JSON.toJSONString(userState));
|
|
|
return;
|
|
|
}
|
|
@@ -964,13 +970,6 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
*/
|
|
|
private void sendLiveRoomStatMessage(String userid, ImLiveBroadcastRoomVo roomVo) {
|
|
|
|
|
|
- // 直播间统计数据
|
|
|
- getRoomData(roomVo);
|
|
|
-
|
|
|
- // 设置群组属性
|
|
|
- setGroupDefinedData(roomVo,EGroupDefinedDataType.MEMBER_ONLINE,roomVo.getLookNum().toString());
|
|
|
- setGroupDefinedData(roomVo,EGroupDefinedDataType.MEMBER_TOTAL,roomVo.getTotalLookNum().toString());
|
|
|
-
|
|
|
// 消息发送用户
|
|
|
LiveRoomMessage.MessageUser messageUser = null;
|
|
|
SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
@@ -1002,7 +1001,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
|
|
|
//发送消息
|
|
|
try {
|
|
|
- livePluginContext.getPluginService(roomVo.getServiceProvider()).sendChatRoomMessage(message);
|
|
|
+ // livePluginContext.getPluginService(roomVo.getServiceProvider()).sendChatRoomMessage(message);
|
|
|
log.info("sendLiveRoomStatMessage>>>> message: {}", JSONObject.toJSONString(message));
|
|
|
} catch (Exception e) {
|
|
|
log.error("sendLiveRoomStatMessage>>>> error {}", e.getMessage());
|
|
@@ -1463,7 +1462,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
*
|
|
|
* @param roomUid 房间uid
|
|
|
*/
|
|
|
+
|
|
|
+
|
|
|
public void startLive(String roomUid, Integer userId, String videoResolution) {
|
|
|
+ startLive(roomUid, userId, videoResolution, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void startLive(String roomUid, Integer userId, String videoResolution, String sequence) {
|
|
|
//查询房间信息
|
|
|
RBucket<RoomSpeakerInfo> speakerCache = getRoomSpeakerInfoCache(roomUid, userId.toString());
|
|
|
if (!speakerCache.isExists()) {
|
|
@@ -1520,6 +1526,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
Date now = new Date();
|
|
|
//开始直播
|
|
|
roomSpeakerInfo.setState(0);
|
|
|
+ roomSpeakerInfo.setSequence(sequence);
|
|
|
roomSpeakerInfo.setStartLiveTime(now);
|
|
|
speakerCache.set(roomSpeakerInfo);
|
|
|
log.info("startLive>>>> roomSpeakerInfo: {}", JSONObject.toJSONString(roomSpeakerInfo));
|
|
@@ -1533,15 +1540,21 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
* @param roomUid 房间uid
|
|
|
* @param userId 老师id
|
|
|
*/
|
|
|
+
|
|
|
public void closeLive(String roomUid, Integer userId) {
|
|
|
+ closeLive(roomUid, userId, null);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void closeLive(String roomUid, Integer userId, String sequence) {
|
|
|
//查询房间主播信息
|
|
|
RBucket<RoomSpeakerInfo> speakerCache = getRoomSpeakerInfoCache(roomUid, userId.toString());
|
|
|
if (!speakerCache.isExists()) {
|
|
|
return;
|
|
|
}
|
|
|
RoomSpeakerInfo roomSpeakerInfo = speakerCache.get();
|
|
|
+
|
|
|
//关闭直播
|
|
|
- closeLive(roomSpeakerInfo);
|
|
|
+ closeLive(roomSpeakerInfo,sequence);
|
|
|
speakerCache.set(roomSpeakerInfo);
|
|
|
}
|
|
|
|
|
@@ -1551,6 +1564,9 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
* @param roomSpeakerInfo 房间主播信息
|
|
|
*/
|
|
|
private void closeLive(RoomSpeakerInfo roomSpeakerInfo) {
|
|
|
+ closeLive(roomSpeakerInfo,null);
|
|
|
+ }
|
|
|
+ private void closeLive(RoomSpeakerInfo roomSpeakerInfo,String sequence) {
|
|
|
//直播状态 true 直播中 false关闭直播
|
|
|
boolean stateFlag = intEquals(roomSpeakerInfo.getState(), 0);
|
|
|
//是否录像 true允许 false不允许
|
|
@@ -1558,7 +1574,34 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
|
|
|
|
|
|
// 设置推流状态房间信息
|
|
|
- setPushStatus(roomSpeakerInfo.getRoomUid(), 0);
|
|
|
+ // 查询房间信息
|
|
|
+ ImLiveBroadcastRoomVo imLiveBroadcastRoomVo = getImLiveBroadcastRoomVo(roomSpeakerInfo.getRoomUid());
|
|
|
+
|
|
|
+ if (imLiveBroadcastRoomVo == null) {
|
|
|
+ log.warn("closeLive imLiveBroadcastRoomVo is null");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//允许录像并在直播中
|
|
|
if (whetherVideoFlag && stateFlag) {
|
|
@@ -1566,13 +1609,6 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
//停止录制视频
|
|
|
// imFeignService.stopRecord(roomSpeakerInfo.getRoomUid());
|
|
|
|
|
|
- // 查询房间信息
|
|
|
- ImLiveBroadcastRoomVo imLiveBroadcastRoomVo = getImLiveBroadcastRoomVo(roomSpeakerInfo.getRoomUid());
|
|
|
- if (imLiveBroadcastRoomVo == null) {
|
|
|
- log.warn("closeLive imLiveBroadcastRoomVo is null");
|
|
|
- return;
|
|
|
- }
|
|
|
- LivePluginService pluginService = livePluginContext.getPluginService(imLiveBroadcastRoomVo.getServiceProvider());
|
|
|
RTCRoom rtcRoom = pluginService.rtcRoomInfo(roomSpeakerInfo.getRoomUid());
|
|
|
if (rtcRoom == null) {
|
|
|
log.warn("closeLive rtcRoom is null");
|
|
@@ -2746,6 +2782,9 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
private Integer state;
|
|
|
//房间uid
|
|
|
private String roomUid;
|
|
|
+ // 直播流sequence
|
|
|
+ private String sequence;
|
|
|
+
|
|
|
//房间创建时间
|
|
|
private Date createRoomTime;
|
|
|
//进入房间时间
|
|
@@ -2772,6 +2811,14 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
// 腾讯视频模板 0: 没有 1:有
|
|
|
private Integer videoTemplate;
|
|
|
|
|
|
+ public String getSequence() {
|
|
|
+ return sequence;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSequence(String sequence) {
|
|
|
+ this.sequence = sequence;
|
|
|
+ }
|
|
|
+
|
|
|
public Integer getVideoTemplate() {
|
|
|
return videoTemplate;
|
|
|
}
|