|
@@ -1,13 +1,9 @@
|
|
package com.ym.service.Impl;
|
|
package com.ym.service.Impl;
|
|
|
|
|
|
-import com.ym.mec.common.entity.ImRoomMessage;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.ym.http.HttpHelper;
|
|
import com.ym.http.HttpHelper;
|
|
-import com.ym.mec.biz.dal.dao.ImLiveBroadcastRoomDao;
|
|
|
|
-import com.ym.mec.biz.dal.entity.ImLiveBroadcastRoom;
|
|
|
|
-import com.ym.mec.biz.dal.entity.TenantAssetsInfo;
|
|
|
|
|
|
+import com.ym.mec.common.entity.ImRoomMessage;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.im.IMHelper;
|
|
import com.ym.mec.im.IMHelper;
|
|
import com.ym.pojo.IMApiResultInfo;
|
|
import com.ym.pojo.IMApiResultInfo;
|
|
@@ -39,8 +35,6 @@ public class LiveRoomServiceImpl implements LiveRoomService {
|
|
private HttpHelper httpHelper;
|
|
private HttpHelper httpHelper;
|
|
@Autowired
|
|
@Autowired
|
|
private RedissonClient redissonClient;
|
|
private RedissonClient redissonClient;
|
|
- @Autowired
|
|
|
|
- private ImLiveBroadcastRoomDao imLiveBroadcastRoomDao;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建房间-聊天室
|
|
* 创建房间-聊天室
|
|
@@ -90,8 +84,6 @@ public class LiveRoomServiceImpl implements LiveRoomService {
|
|
/**
|
|
/**
|
|
* 发送消息
|
|
* 发送消息
|
|
*
|
|
*
|
|
- * @param fromUserId 发送者id
|
|
|
|
- * @param toChatroomId 房间id
|
|
|
|
* @param message
|
|
* @param message
|
|
*/
|
|
*/
|
|
public IMApiResultInfo publishRoomMessage(ImRoomMessage message) {
|
|
public IMApiResultInfo publishRoomMessage(ImRoomMessage message) {
|
|
@@ -110,35 +102,34 @@ public class LiveRoomServiceImpl implements LiveRoomService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void startRecord(String roomId) throws Exception {
|
|
public void startRecord(String roomId) throws Exception {
|
|
- log.error("开始录制直播:roomId : {} ",roomId);
|
|
|
|
|
|
+ log.error("开始录制直播:roomId : {} ", roomId);
|
|
JSONObject paramJson = new JSONObject();
|
|
JSONObject paramJson = new JSONObject();
|
|
- paramJson.put("sessionId",getRoomSessionId(roomId));
|
|
|
|
- paramJson.put("config",new RecordConfig());
|
|
|
|
|
|
+ paramJson.put("sessionId", getRoomSessionId(roomId));
|
|
|
|
+ paramJson.put("config", new RecordConfig());
|
|
String body = paramJson.toJSONString();
|
|
String body = paramJson.toJSONString();
|
|
- HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/start.json", "application/json",roomId);
|
|
|
|
|
|
+ HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/start.json", "application/json", roomId);
|
|
httpHelper.setBodyParameter(body, conn);
|
|
httpHelper.setBodyParameter(body, conn);
|
|
IMApiResultInfo resultInfo = JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class);
|
|
IMApiResultInfo resultInfo = JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class);
|
|
- if(resultInfo.getCode() != 200){
|
|
|
|
- log.error("直播视频录制失败:resultInfo : {} ",resultInfo);
|
|
|
|
|
|
+ if (resultInfo.getCode() != 200) {
|
|
|
|
+ log.error("直播视频录制失败:resultInfo : {} ", resultInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void stopRecord(String roomId) throws Exception {
|
|
public void stopRecord(String roomId) throws Exception {
|
|
JSONObject paramJson = new JSONObject();
|
|
JSONObject paramJson = new JSONObject();
|
|
- paramJson.put("sessionId",getRoomSessionId(roomId));
|
|
|
|
|
|
+ paramJson.put("sessionId", getRoomSessionId(roomId));
|
|
String body = paramJson.toJSONString();
|
|
String body = paramJson.toJSONString();
|
|
- HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/stop.json", "application/json",roomId);
|
|
|
|
|
|
+ HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/stop.json", "application/json", roomId);
|
|
httpHelper.setBodyParameter(body, conn);
|
|
httpHelper.setBodyParameter(body, conn);
|
|
- RBucket<String> bucket = redissonClient.getBucket("sessionId:" + roomId);
|
|
|
|
- bucket.delete();
|
|
|
|
- log.info("结束录制直播 roomId :{},{}",roomId,httpHelper.returnResult(conn, body));
|
|
|
|
|
|
+ redissonClient.getBucket("sessionId:" + roomId).delete();
|
|
|
|
+ log.info("结束录制直播 roomId :{},{}", roomId, httpHelper.returnResult(conn, body));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void recordSync(RecordNotify recordNotify) {
|
|
public void recordSync(RecordNotify recordNotify) {
|
|
- if(recordNotify.getCode().equals(200)){
|
|
|
|
- if(recordNotify.getType() != null && recordNotify.getType() == 4){
|
|
|
|
|
|
+ if (recordNotify.getCode().equals(200)) {
|
|
|
|
+ if (recordNotify.getType() != null && recordNotify.getType() == 4) {
|
|
// TODO 云端录制文件地址
|
|
// TODO 云端录制文件地址
|
|
String fileUrl = recordNotify.getOutput().getFileUrl();
|
|
String fileUrl = recordNotify.getOutput().getFileUrl();
|
|
String roomId = recordNotify.getRoomId();
|
|
String roomId = recordNotify.getRoomId();
|
|
@@ -147,27 +138,27 @@ public class LiveRoomServiceImpl implements LiveRoomService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public String getRoomSessionId(String roomId){
|
|
|
|
|
|
+ public String getRoomSessionId(String roomId) {
|
|
RBucket<String> bucket = redissonClient.getBucket("sessionId:" + roomId);
|
|
RBucket<String> bucket = redissonClient.getBucket("sessionId:" + roomId);
|
|
String sessionId = bucket.get();
|
|
String sessionId = bucket.get();
|
|
- if(StringUtils.isNotEmpty(sessionId)){
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(sessionId)) {
|
|
return sessionId;
|
|
return sessionId;
|
|
}
|
|
}
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
- jsonObject.put("roomId",roomId);
|
|
|
|
|
|
+ jsonObject.put("roomId", roomId);
|
|
|
|
|
|
HttpURLConnection conn = null;
|
|
HttpURLConnection conn = null;
|
|
try {
|
|
try {
|
|
- conn = httpHelper.createIMRtcPostHttpConnection("/rtc/room/query.json", "application/json",null);
|
|
|
|
|
|
+ conn = httpHelper.createIMRtcPostHttpConnection("/rtc/room/query.json", "application/json", null);
|
|
httpHelper.setBodyParameter(jsonObject.toJSONString(), conn);
|
|
httpHelper.setBodyParameter(jsonObject.toJSONString(), conn);
|
|
String returnResult = httpHelper.returnResult(conn, jsonObject.toJSONString());
|
|
String returnResult = httpHelper.returnResult(conn, jsonObject.toJSONString());
|
|
JSONObject resultObject = JSONObject.parseObject(returnResult);
|
|
JSONObject resultObject = JSONObject.parseObject(returnResult);
|
|
String code = resultObject.get("code").toString();
|
|
String code = resultObject.get("code").toString();
|
|
- if("200".equals(code)){
|
|
|
|
|
|
+ if ("200".equals(code)) {
|
|
sessionId = resultObject.get("sessionId").toString();
|
|
sessionId = resultObject.get("sessionId").toString();
|
|
bucket.set(sessionId);
|
|
bucket.set(sessionId);
|
|
- }else {
|
|
|
|
- log.error("获取sessionId失败 returnResult:{}",returnResult);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ log.error("获取sessionId失败 returnResult:{}", returnResult);
|
|
throw new BizException("获取sessionId失败");
|
|
throw new BizException("获取sessionId失败");
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|