| 
														
															@@ -2,7 +2,7 @@ package com.keao.edu.im.mec.im; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.alibaba.fastjson.JSON; 
														 | 
														
														 | 
														
															 import com.alibaba.fastjson.JSON; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.alibaba.fastjson.JSONObject; 
														 | 
														
														 | 
														
															 import com.alibaba.fastjson.JSONObject; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import com.google.gson.JsonObject; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.keao.edu.common.exception.BizException; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.keao.edu.im.http.HttpHelper; 
														 | 
														
														 | 
														
															 import com.keao.edu.im.http.HttpHelper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.keao.edu.im.pojo.IMApiResultInfo; 
														 | 
														
														 | 
														
															 import com.keao.edu.im.pojo.IMApiResultInfo; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.keao.edu.im.pojo.IMTokenInfo; 
														 | 
														
														 | 
														
															 import com.keao.edu.im.pojo.IMTokenInfo; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -222,11 +222,10 @@ public class IMHelper { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /** 
														 | 
														
														 | 
														
															     /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * 开始录制 
														 | 
														
														 | 
														
															      * 开始录制 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * @param hostUserId 
														 | 
														
														 | 
														
															      * @param hostUserId 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * @param sessionId 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * @return 
														 | 
														
														 | 
														
															      * @return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * @throws Exception 
														 | 
														
														 | 
														
															      * @throws Exception 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      */ 
														 | 
														
														 | 
														
															      */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    public IMApiResultInfo startRecord(String hostUserId, String sessionId, String roomId) throws Exception { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public IMApiResultInfo startRecord(String hostUserId, String roomId) throws Exception { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (hostUserId == null) { 
														 | 
														
														 | 
														
															         if (hostUserId == null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             throw new IllegalArgumentException("Paramer 'userId' is required"); 
														 | 
														
														 | 
														
															             throw new IllegalArgumentException("Paramer 'userId' is required"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -243,12 +242,12 @@ public class IMHelper { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         jsonObject.put("sliceMin","60"); 
														 | 
														
														 | 
														
															         jsonObject.put("sliceMin","60"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         jsonObject.put("hostUserId",hostUserId); 
														 | 
														
														 | 
														
															         jsonObject.put("hostUserId",hostUserId); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         JSONObject json = new JSONObject(); 
														 | 
														
														 | 
														
															         JSONObject json = new JSONObject(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        json.put("sessionId",sessionId); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        json.put("sessionId",roomQuery(roomId)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         json.put("config",jsonObject); 
														 | 
														
														 | 
														
															         json.put("config",jsonObject); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         String body = json.toJSONString(); 
														 | 
														
														 | 
														
															         String body = json.toJSONString(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/start.json", "application/x-www-form-urlencoded",roomId); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/start.json", "application/json",roomId); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         httpHelper.setBodyParameter(body, conn); 
														 | 
														
														 | 
														
															         httpHelper.setBodyParameter(body, conn); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class); 
														 | 
														
														 | 
														
															         return JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -257,11 +256,10 @@ public class IMHelper { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     /** 
														 | 
														
														 | 
														
															     /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * 结束录制 
														 | 
														
														 | 
														
															      * 结束录制 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * @param hostUserId 
														 | 
														
														 | 
														
															      * @param hostUserId 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     * @param sessionId 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * @return 
														 | 
														
														 | 
														
															      * @return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * @throws Exception 
														 | 
														
														 | 
														
															      * @throws Exception 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      */ 
														 | 
														
														 | 
														
															      */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    public IMApiResultInfo stopRecord(String hostUserId, String sessionId, String roomId) throws Exception { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public IMApiResultInfo stopRecord(String hostUserId, String roomId) throws Exception { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (hostUserId == null) { 
														 | 
														
														 | 
														
															         if (hostUserId == null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             throw new IllegalArgumentException("Paramer 'userId' is required"); 
														 | 
														
														 | 
														
															             throw new IllegalArgumentException("Paramer 'userId' is required"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -278,12 +276,12 @@ public class IMHelper { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         jsonObject.put("sliceMin","60"); 
														 | 
														
														 | 
														
															         jsonObject.put("sliceMin","60"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         jsonObject.put("hostUserId",hostUserId); 
														 | 
														
														 | 
														
															         jsonObject.put("hostUserId",hostUserId); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         JSONObject json = new JSONObject(); 
														 | 
														
														 | 
														
															         JSONObject json = new JSONObject(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        json.put("sessionId",sessionId); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        json.put("sessionId",roomQuery(roomId)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         json.put("config",jsonObject); 
														 | 
														
														 | 
														
															         json.put("config",jsonObject); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         String body = json.toJSONString(); 
														 | 
														
														 | 
														
															         String body = json.toJSONString(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/stop.json", "application/x-www-form-urlencoded",roomId); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/stop.json", "application/json",roomId); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         httpHelper.setBodyParameter(body, conn); 
														 | 
														
														 | 
														
															         httpHelper.setBodyParameter(body, conn); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class); 
														 | 
														
														 | 
														
															         return JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -295,19 +293,23 @@ public class IMHelper { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * @return 
														 | 
														
														 | 
														
															      * @return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      * @throws Exception 
														 | 
														
														 | 
														
															      * @throws Exception 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      */ 
														 | 
														
														 | 
														
															      */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    public IMApiResultInfo roomQuery(String roomId) throws Exception { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public String roomQuery(String roomId) throws Exception { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (StringUtils.isEmpty(roomId)) { 
														 | 
														
														 | 
														
															         if (StringUtils.isEmpty(roomId)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             throw new IllegalArgumentException("Paramer 'roomId' is required"); 
														 | 
														
														 | 
														
															             throw new IllegalArgumentException("Paramer 'roomId' is required"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        StringBuilder sb = new StringBuilder(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        sb.append("roomId=").append(URLEncoder.encode(roomId, UTF8)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        String body = sb.toString(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/room/query", "application/x-www-form-urlencoded",null); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        httpHelper.setBodyParameter(body, conn); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        String returnResult = httpHelper.returnResult(conn, body); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        return null; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        JSONObject jsonObject = new JSONObject(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        jsonObject.put("roomId",roomId); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/room/query.json", "application/json",null); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        httpHelper.setBodyParameter(jsonObject.toJSONString(), conn); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String returnResult = httpHelper.returnResult(conn, jsonObject.toJSONString()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        JSONObject resultObject = JSONObject.parseObject(returnResult); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String code = resultObject.get("code").toString(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if("200".equals(code)){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            return resultObject.get("sessionId").toString(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        }else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            throw new BizException("获取sessionId失败"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 |