SCRtcAndroidEngine.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. using LitJson;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SCRtcAndroidEngine : SCRtcEngine
  5. {
  6. public void setProduce(string msg)
  7. {
  8. return;
  9. #if UNITY_ANDROID && !UNITY_EDITOR
  10. CurrentRtcActivity.Call("setProduce", msg);
  11. #endif
  12. }
  13. public string getwifi()
  14. {
  15. return "";
  16. #if UNITY_ANDROID && !UNITY_EDITOR
  17. return CurrentRtcActivity.Call<string>("ObtainWifiInfo");
  18. #endif
  19. return "";
  20. }
  21. //调节他人音量
  22. public double GetaudioMe()
  23. {
  24. double d = 0.0f;
  25. return d;
  26. #if UNITY_ANDROID && !UNITY_EDITOR
  27. d = CurrentRtcActivity.Call<double>("GetaudioMe");
  28. #endif
  29. return d;
  30. }
  31. //调节他人音量
  32. public double GetaudioPeer(string consumerId)
  33. {
  34. double d = 0.0f;
  35. return d;
  36. #if UNITY_ANDROID && !UNITY_EDITOR
  37. d = CurrentRtcActivity.Call<double>("GetaudioPeer", consumerId);
  38. #endif
  39. return d;
  40. }
  41. SDKCallbackListener sdk;
  42. //增加监听
  43. public void addListener()
  44. {
  45. if (sdk == null)
  46. {
  47. sdk = new SDKCallbackListener();
  48. #if UNITY_ANDROID&& !UNITY_EDITOR
  49. // CurrentRtcActivity.Call("initSDK", sdk);
  50. #endif
  51. }
  52. }
  53. override public void send(Queue<JsonData> jsondata)
  54. {
  55. JsonData data;
  56. if (jsondata.Count > 0)
  57. {
  58. data = jsondata.Dequeue();
  59. switch (data["action"].ToString())
  60. {
  61. case "InitRTC":
  62. #if UNITY_ANDROID && !UNITY_EDITOR
  63. // addListener();
  64. // CurrentRtcActivity.Call("SetConfig", data["data"]["RoomId"].ToString(), data["data"]["roomPwd"].ToString(),bool.Parse(data["data"]["isSendAudio"].ToString()), bool.Parse(data["data"]["isSendVideo"].ToString()), bool.Parse(data["data"]["isRevAllAudio"].ToString()), bool.Parse(data["data"]["isRevAllVideo"].ToString()), int.Parse(data["data"]["mWidth"].ToString()), int.Parse(data["data"]["mHight"].ToString()), int.Parse(data["data"]["FPS"].ToString()),false);
  65. // CurrentRtcActivity.Call("InitSocket", data["data"]["Url"].ToString());
  66. #endif
  67. break;
  68. case "changeVideo":
  69. #if UNITY_ANDROID && !UNITY_EDITOR
  70. // CurrentRtcActivity.Call("changeVideo",int.Parse(data["data"]["w"].ToString()),int.Parse(data["data"]["h"].ToString()),int.Parse(data["data"]["fps"].ToString()));
  71. #endif
  72. break;
  73. case "setMute":
  74. #if UNITY_ANDROID && !UNITY_EDITOR
  75. // CurrentRtcActivity.Call("setMute",bool.Parse(data["data"]["boo"].ToString()));
  76. #endif
  77. break;
  78. case "sendVideo":
  79. #if UNITY_ANDROID && !UNITY_EDITOR
  80. // CurrentRtcActivity.Call("sendVideo",bool.Parse(data["data"]["boo"].ToString()));
  81. #endif
  82. break;
  83. case "enableVideoOnly":
  84. #if UNITY_ANDROID && !UNITY_EDITOR
  85. // CurrentRtcActivity.Call("enableVideoOnly",bool.Parse(data["data"]["boo"].ToString()));
  86. #endif
  87. break;
  88. case "enableAudioOnly":
  89. #if UNITY_ANDROID && !UNITY_EDITOR
  90. // CurrentRtcActivity.Call("enableAudioOnly",bool.Parse(data["data"]["boo"].ToString()));
  91. #endif
  92. break;
  93. case "openSpeaker":
  94. #if UNITY_ANDROID && !UNITY_EDITOR
  95. // CurrentRtcActivity.Call("openSpeaker",bool.Parse(data["data"]["boo"].ToString()));
  96. #endif
  97. break;
  98. case "closeSpeaker":
  99. #if UNITY_ANDROID && !UNITY_EDITOR
  100. // CurrentRtcActivity.Call("closeSpeaker",bool.Parse(data["data"]["boo"].ToString()));
  101. #endif
  102. break;
  103. case "setVolume":
  104. #if UNITY_ANDROID && !UNITY_EDITOR
  105. CurrentRtcActivity.Call("setVolume",int.Parse(data["data"]["i"].ToString()));
  106. #endif
  107. break;
  108. case "sendMic":
  109. #if UNITY_ANDROID && !UNITY_EDITOR
  110. // CurrentRtcActivity.Call("sendMic",bool.Parse(data["data"]["boo"].ToString()));
  111. #endif
  112. break;
  113. case "openRev":
  114. #if UNITY_ANDROID && !UNITY_EDITOR
  115. // CurrentRtcActivity.Call("openRev",data["data"]["consumerId"].ToString());
  116. #endif
  117. break;
  118. case "closeRev":
  119. #if UNITY_ANDROID && !UNITY_EDITOR
  120. // CurrentRtcActivity.Call("closeRev",data["data"]["consumerId"].ToString());
  121. #endif
  122. break;
  123. case "Close":
  124. #if UNITY_ANDROID && !UNITY_EDITOR
  125. // CurrentRtcActivity.Call("close");
  126. #endif
  127. SCRtcFactory.Instance.isClose = true;
  128. break;
  129. case "addTextureID":
  130. #if UNITY_ANDROID && !UNITY_EDITOR
  131. // CurrentRtcActivity.Call("addTextureID", data["data"]["peerId"].ToString(), int.Parse(data["data"]["textureID"].ToString()));
  132. #endif
  133. break;
  134. case "audioPeerChange":
  135. #if UNITY_ANDROID && !UNITY_EDITOR
  136. // CurrentRtcActivity.Call("audioPeerChange", data["data"]["consumerId"].ToString(), double.Parse(data["data"]["d"].ToString()));
  137. #endif
  138. break;
  139. case "audioMeChange":
  140. #if UNITY_ANDROID && !UNITY_EDITOR
  141. // CurrentRtcActivity.Call("audioMeChange", double.Parse(data["data"]["d"].ToString()));
  142. #endif
  143. break;
  144. case "changePeerVideo":
  145. #if UNITY_ANDROID && !UNITY_EDITOR
  146. // CurrentRtcActivity.Call("changePeerVideo", data["data"]["consumerId"].ToString(), int.Parse(data["data"]["fps"].ToString()));
  147. #endif
  148. break;
  149. case "changeName":
  150. #if UNITY_ANDROID && !UNITY_EDITOR
  151. CurrentRtcActivity.Call("changeName", data["data"]["name"].ToString());
  152. #endif
  153. break;
  154. case "joinRoom":
  155. #if UNITY_ANDROID && !UNITY_EDITOR
  156. // CurrentRtcActivity.Call("joinRoom", data["data"]["req"].ToString());
  157. #endif
  158. break;
  159. case "GetaudioMe":
  160. #if UNITY_ANDROID && !UNITY_EDITOR
  161. // CurrentRtcActivity.Call("GetaudioMe");
  162. #endif
  163. break;
  164. case "GetaudioPeer":
  165. #if UNITY_ANDROID && !UNITY_EDITOR
  166. // CurrentRtcActivity.Call("GetaudioPeer");
  167. #endif
  168. break;
  169. case "onSocketMesseage":
  170. #if UNITY_ANDROID && !UNITY_EDITOR
  171. // CurrentRtcActivity.Call("onSocketMesseage", data["data"].ToString());
  172. #endif
  173. break;
  174. case "initRtpCapabilities":
  175. #if UNITY_ANDROID && !UNITY_EDITOR
  176. // CurrentRtcActivity.Call("initRtpCapabilities", data["data"].ToString());
  177. #endif
  178. break;
  179. case "createRecvTransport":
  180. #if UNITY_ANDROID && !UNITY_EDITOR
  181. // CurrentRtcActivity.Call("createRecvTransport", data["data"].ToString());
  182. #endif
  183. break;
  184. case "createSendTransport":
  185. #if UNITY_ANDROID && !UNITY_EDITOR
  186. // CurrentRtcActivity.Call("createSendTransport", data["data"].ToString());
  187. #endif
  188. break;
  189. case "onNewConsumer":
  190. #if UNITY_ANDROID && !UNITY_EDITOR
  191. // CurrentRtcActivity.Call("onNewConsumer", data["data"].ToString(), data["id"].ToString());
  192. #endif
  193. break;
  194. case "getDevice":
  195. #if UNITY_ANDROID && !UNITY_EDITOR
  196. // CurrentRtcActivity.Call("getDevice");
  197. #endif
  198. break;
  199. case "setProduce":
  200. #if UNITY_ANDROID && !UNITY_EDITOR
  201. // CurrentRtcActivity.Call("setProduce", data["data"].ToString());
  202. #endif
  203. break;
  204. case "startCamera":
  205. #if UNITY_ANDROID && !UNITY_EDITOR
  206. // CurrentRtcActivity.Call("startCamera");
  207. #endif
  208. break;
  209. case "stopCamera":
  210. #if UNITY_ANDROID && !UNITY_EDITOR
  211. // CurrentRtcActivity.Call("stopCamera");
  212. #endif
  213. break;
  214. case "addCameraLocal":
  215. #if UNITY_ANDROID && !UNITY_EDITOR
  216. // CurrentRtcActivity.Call("addCameraLocal", int.Parse(data["L"].ToString()));
  217. #endif
  218. break;
  219. }
  220. }
  221. }
  222. }