Browse Source

修改移动端云端录像的分辨率问题

hgw 3 years ago
parent
commit
b30563ab7c

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveBroadcastRoomService.java

@@ -72,7 +72,7 @@ public interface ImLiveBroadcastRoomService extends IService<ImLiveBroadcastRoom
 
     void joinRoom(String roomUid, Integer userId);
 
-    void startLive(String roomUid, Integer userId);
+    void startLive(String roomUid, Integer userId,String videoResolution);
 
     void closeLive(String roomUid, Integer userId);
 

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java

@@ -925,7 +925,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
      *
      * @param roomUid 房间uid
      */
-    public void startLive(String roomUid, Integer userId) {
+    public void startLive(String roomUid, Integer userId, String videoResolution) {
         //查询房间信息
         RBucket<RoomSpeakerInfo> speakerCache = getRoomSpeakerInfoCache(roomUid, userId.toString());
         if (!speakerCache.isExists()) {
@@ -940,7 +940,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         if (intEquals(roomSpeakerInfo.getWhetherVideo(), 0)) {
             //开始录制视频
             try {
-                imFeignService.startRecord(roomUid);
+                imFeignService.startRecord(roomUid, videoResolution);
             } catch (Exception e) {
                 log.error("startRecord error: {}", e.getMessage());
             }

+ 1 - 1
mec-client-api/src/main/java/com/ym/mec/im/ImFeignService.java

@@ -160,7 +160,7 @@ public interface ImFeignService {
      * @date 2022/2/25 13:52
      */
     @PostMapping(value = "/liveRoom/startRecord")
-    void startRecord(@RequestParam("roomId") String roomId);
+    void startRecord(@RequestParam("roomId") String roomId, @RequestParam("videoResolution") String videoResolution);
 
     /**
      * @param roomId

+ 1 - 1
mec-client-api/src/main/java/com/ym/mec/im/fallback/ImFeignServiceFallback.java

@@ -91,7 +91,7 @@ public class ImFeignServiceFallback implements ImFeignService {
     }
 
     @Override
-    public void startRecord(String roomId) {
+    public void startRecord(String roomId, String videoResolution) {
 
     }
 

+ 3 - 3
mec-im/src/main/java/com/ym/controller/LiveRoomController.java

@@ -53,8 +53,8 @@ public class LiveRoomController {
 
     @ApiOperation("录制直播")
     @RequestMapping(value = "/startRecord")
-    public void startRecord(String roomId) throws Exception {
-        liveRoomService.startRecord(roomId);
+    public void startRecord(String roomId, String videoResolution) throws Exception {
+        liveRoomService.startRecord(roomId, videoResolution);
     }
 
     @ApiOperation("结束录制直播")
@@ -83,5 +83,5 @@ public class LiveRoomController {
     public void syncChatRoomStatus(@RequestBody String body) {
         log.info("syncChatRoomStatus body:{}", body);
     }
-    
+
 }

+ 5 - 2
mec-im/src/main/java/com/ym/service/Impl/LiveRoomServiceImpl.java

@@ -107,11 +107,14 @@ public class LiveRoomServiceImpl implements LiveRoomService {
     }
 
     @Override
-    public void startRecord(String roomId) throws Exception {
+    public void startRecord(String roomId,String videoResolution) throws Exception {
         log.error("开始录制直播:roomId : {} ", roomId);
         JSONObject paramJson = new JSONObject();
         paramJson.put("sessionId", getRoomSessionId(roomId));
-        paramJson.put("config", new RecordConfig());
+        RecordConfig recordConfig = new RecordConfig();
+        Optional.ofNullable(videoResolution)
+                .ifPresent(recordConfig::setVideoResolution);
+        paramJson.put("config", recordConfig);
         String body = paramJson.toJSONString();
         HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/start.json", "application/json", roomId);
         httpHelper.setBodyParameter(body, conn);

+ 1 - 1
mec-im/src/main/java/com/ym/service/LiveRoomService.java

@@ -23,7 +23,7 @@ public interface LiveRoomService {
     * @author zx
     * @date 2022/2/25 10:00
     */
-    void startRecord(String roomId) throws Exception;
+    void startRecord(String roomId, String videoResolution) throws Exception;
 
     /**
     * @description: 结束录制直播

+ 5 - 2
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherImLiveBroadcastRoomController.java

@@ -18,6 +18,7 @@ import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 
 /**
  * 直播房间管理表(ImLiveBroadcastRoom)表控制层
@@ -91,9 +92,11 @@ public class TeacherImLiveBroadcastRoomController extends BaseController {
     @GetMapping("/opsLiveVideo")
     public HttpResponseResult<Object> opsLiveVideo(@ApiParam(value = "房间uid", required = true) String roomUid,
                                                    @ApiParam(value = "用户id", required = true) Integer userId,
-                                                   @ApiParam(value = "type 1:开始直播-开始录像     2:关闭直播关闭录像", required = true) Integer type) {
+                                                   @ApiParam(value = "type 1:开始直播-开始录像     2:关闭直播关闭录像", required = true) Integer type,
+                                                   @ApiParam(value = "录制视频的尺寸-默认值是720x1280") String videoResolution) {
         if (type == 1) {
-            imLiveBroadcastRoomService.startLive(roomUid, userId);
+            videoResolution = Optional.ofNullable(videoResolution).orElse("720x1280");
+            imLiveBroadcastRoomService.startLive(roomUid, userId, videoResolution);
         } else if (type == 2) {
             imLiveBroadcastRoomService.closeLive(roomUid, userId);
         } else {

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/ImLiveBroadcastRoomController.java

@@ -190,7 +190,7 @@ public class ImLiveBroadcastRoomController extends BaseController {
                                                    @ApiParam(value = "用户id", required = true) Integer userId,
                                                    @ApiParam(value = "type 1:开始直播-开始录像     2:关闭直播关闭录像", required = true) Integer type) {
         if (type == 1) {
-            imLiveBroadcastRoomService.startLive(roomUid, userId);
+            imLiveBroadcastRoomService.startLive(roomUid, userId, null);
         } else if (type == 2) {
             imLiveBroadcastRoomService.closeLive(roomUid, userId);
         } else {