|  | @@ -1,6 +1,8 @@
 | 
	
		
			
				|  |  |  package com.keao.edu.im.mec.im;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | +import com.google.gson.JsonObject;
 | 
	
		
			
				|  |  |  import com.keao.edu.im.http.HttpHelper;
 | 
	
		
			
				|  |  |  import com.keao.edu.im.pojo.IMApiResultInfo;
 | 
	
		
			
				|  |  |  import com.keao.edu.im.pojo.IMTokenInfo;
 | 
	
	
		
			
				|  | @@ -216,6 +218,76 @@ public class IMHelper {
 | 
	
		
			
				|  |  |          return JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 开始录制
 | 
	
		
			
				|  |  | +     * @param hostUserId
 | 
	
		
			
				|  |  | +     * @param sessionId
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     * @throws Exception
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public IMApiResultInfo startRecord(String hostUserId, String sessionId, String roomId) throws Exception {
 | 
	
		
			
				|  |  | +        if (hostUserId == null) {
 | 
	
		
			
				|  |  | +            throw new IllegalArgumentException("Paramer 'userId' is required");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (hostUserId == null) {
 | 
	
		
			
				|  |  | +            throw new IllegalArgumentException("Paramer 'groupId' is required");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  | +        jsonObject.put("mode","3");
 | 
	
		
			
				|  |  | +        jsonObject.put("videoFormat","mp4");
 | 
	
		
			
				|  |  | +        jsonObject.put("audioFormat","mp3");
 | 
	
		
			
				|  |  | +        jsonObject.put("videoResolution","640x480");
 | 
	
		
			
				|  |  | +        jsonObject.put("mixLayout","3");
 | 
	
		
			
				|  |  | +        jsonObject.put("sliceMin","60");
 | 
	
		
			
				|  |  | +        jsonObject.put("hostUserId",hostUserId);
 | 
	
		
			
				|  |  | +        JSONObject json = new JSONObject();
 | 
	
		
			
				|  |  | +        json.put("sessionId",sessionId);
 | 
	
		
			
				|  |  | +        json.put("config",jsonObject);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String body = json.toJSONString();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/start.json", "application/x-www-form-urlencoded",roomId);
 | 
	
		
			
				|  |  | +        httpHelper.setBodyParameter(body, conn);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 结束录制
 | 
	
		
			
				|  |  | +     * @param hostUserId
 | 
	
		
			
				|  |  | +     * @param sessionId
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     * @throws Exception
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public IMApiResultInfo stopRecord(String hostUserId, String sessionId, String roomId) throws Exception {
 | 
	
		
			
				|  |  | +        if (hostUserId == null) {
 | 
	
		
			
				|  |  | +            throw new IllegalArgumentException("Paramer 'userId' is required");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (hostUserId == null) {
 | 
	
		
			
				|  |  | +            throw new IllegalArgumentException("Paramer 'groupId' is required");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  | +        jsonObject.put("mode","3");
 | 
	
		
			
				|  |  | +        jsonObject.put("videoFormat","mp4");
 | 
	
		
			
				|  |  | +        jsonObject.put("audioFormat","mp3");
 | 
	
		
			
				|  |  | +        jsonObject.put("videoResolution","640x480");
 | 
	
		
			
				|  |  | +        jsonObject.put("mixLayout","3");
 | 
	
		
			
				|  |  | +        jsonObject.put("sliceMin","60");
 | 
	
		
			
				|  |  | +        jsonObject.put("hostUserId",hostUserId);
 | 
	
		
			
				|  |  | +        JSONObject json = new JSONObject();
 | 
	
		
			
				|  |  | +        json.put("sessionId",sessionId);
 | 
	
		
			
				|  |  | +        json.put("config",jsonObject);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String body = json.toJSONString();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/stop.json", "application/x-www-form-urlencoded",roomId);
 | 
	
		
			
				|  |  | +        httpHelper.setBodyParameter(body, conn);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 发送群组消息方法(以一个用户身份向群组发送消息,单条消息最大 128k.每秒钟最多发送 20 条消息,每次最多向 3 个群组发送,如:一次向 3 个群组发送消息,示为 3 条消息。)
 |