RtcEngineEventHandlerNative.cs 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504
  1. using System;
  2. using System.Runtime.InteropServices;
  3. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  4. using AOT;
  5. #endif
  6. namespace Agora.Rtc
  7. {
  8. internal static class RtcEngineEventHandlerNative
  9. {
  10. internal static IRtcEngineEventHandler EngineEventHandler = null;
  11. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  12. internal static AgoraCallbackObject CallbackObject = null;
  13. #endif
  14. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  15. [MonoPInvokeCallback(typeof(Func_Event_Native))]
  16. #endif
  17. internal static void OnEvent(string @event, string data, IntPtr buffer, IntPtr length, uint buffer_count)
  18. {
  19. if (EngineEventHandler == null) return;
  20. LitJson.JsonData jsonData = AgoraJson.ToObject(data);
  21. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  22. if (CallbackObject == null || CallbackObject._CallbackQueue == null) return;
  23. #endif
  24. switch (@event)
  25. {
  26. #region no buffer start
  27. case "onError":
  28. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  29. CallbackObject._CallbackQueue.EnQueue(() =>
  30. {
  31. #endif
  32. if (EngineEventHandler == null) return;
  33. EngineEventHandler.OnError(
  34. (int)AgoraJson.GetData<int>(jsonData, "err"),
  35. (string)AgoraJson.GetData<string>(jsonData, "msg")
  36. );
  37. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  38. });
  39. #endif
  40. break;
  41. case "onJoinChannelSuccessEx":
  42. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  43. CallbackObject._CallbackQueue.EnQueue(() =>
  44. {
  45. #endif
  46. if (EngineEventHandler == null) return;
  47. EngineEventHandler.OnJoinChannelSuccess(
  48. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  49. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  50. );
  51. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  52. });
  53. #endif
  54. break;
  55. case "onRejoinChannelSuccessEx":
  56. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  57. CallbackObject._CallbackQueue.EnQueue(() =>
  58. {
  59. #endif
  60. if (EngineEventHandler == null) return;
  61. EngineEventHandler.OnRejoinChannelSuccess(
  62. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  63. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  64. );
  65. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  66. });
  67. #endif
  68. break;
  69. case "onProxyConnected":
  70. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  71. CallbackObject._CallbackQueue.EnQueue(() =>
  72. {
  73. #endif
  74. if (EngineEventHandler == null) return;
  75. EngineEventHandler.OnProxyConnected(
  76. (string)AgoraJson.GetData<string>(jsonData, "channel"),
  77. (uint)AgoraJson.GetData<uint>(jsonData, "uid"),
  78. (PROXY_TYPE)AgoraJson.GetData<int>(jsonData, "proxyType"),
  79. (string)AgoraJson.GetData<string>(jsonData, "localProxyIp"),
  80. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  81. );
  82. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  83. });
  84. #endif
  85. break;
  86. case "onAudioQualityEx":
  87. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  88. CallbackObject._CallbackQueue.EnQueue(() =>
  89. {
  90. #endif
  91. if (EngineEventHandler == null) return;
  92. EngineEventHandler.OnAudioQuality(
  93. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  94. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  95. (int)AgoraJson.GetData<int>(jsonData, "elapsed"),
  96. (UInt16)AgoraJson.GetData<UInt16>(jsonData, "delay"),
  97. (UInt16)AgoraJson.GetData<UInt16>(jsonData, "lost")
  98. );
  99. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  100. });
  101. #endif
  102. break;
  103. case "onLeaveChannelEx":
  104. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  105. CallbackObject._CallbackQueue.EnQueue(() =>
  106. {
  107. #endif
  108. if (EngineEventHandler == null) return;
  109. EngineEventHandler.OnLeaveChannel(
  110. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  111. AgoraJson.JsonToStruct<RtcStats>(jsonData, "stats")
  112. );
  113. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  114. });
  115. #endif
  116. break;
  117. case "onClientRoleChangedEx":
  118. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  119. CallbackObject._CallbackQueue.EnQueue(() =>
  120. {
  121. #endif
  122. if (EngineEventHandler == null) return;
  123. EngineEventHandler.OnClientRoleChanged(
  124. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  125. (CLIENT_ROLE_TYPE)AgoraJson.GetData<int>(jsonData, "oldRole"),
  126. (CLIENT_ROLE_TYPE)AgoraJson.GetData<int>(jsonData, "newRole")
  127. );
  128. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  129. });
  130. #endif
  131. break;
  132. case "onClientRoleChangeFailedEx":
  133. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  134. CallbackObject._CallbackQueue.EnQueue(() =>
  135. {
  136. #endif
  137. if (EngineEventHandler == null) return;
  138. EngineEventHandler.OnClientRoleChangeFailed(
  139. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  140. (CLIENT_ROLE_CHANGE_FAILED_REASON)AgoraJson.GetData<int>(jsonData, "reason"),
  141. (CLIENT_ROLE_TYPE)AgoraJson.GetData<int>(jsonData, "currentRole")
  142. );
  143. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  144. });
  145. #endif
  146. break;
  147. case "onUserJoinedEx":
  148. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  149. CallbackObject._CallbackQueue.EnQueue(() =>
  150. {
  151. #endif
  152. if (EngineEventHandler == null) return;
  153. EngineEventHandler.OnUserJoined(
  154. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  155. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  156. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  157. );
  158. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  159. });
  160. #endif
  161. break;
  162. case "onUserOfflineEx":
  163. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  164. CallbackObject._CallbackQueue.EnQueue(() =>
  165. {
  166. #endif
  167. if (EngineEventHandler == null) return;
  168. EngineEventHandler.OnUserOffline(
  169. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  170. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  171. (USER_OFFLINE_REASON_TYPE)AgoraJson.GetData<int>(jsonData, "reason")
  172. );
  173. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  174. });
  175. #endif
  176. break;
  177. case "onLastmileQuality":
  178. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  179. CallbackObject._CallbackQueue.EnQueue(() =>
  180. {
  181. #endif
  182. if (EngineEventHandler == null) return;
  183. EngineEventHandler.OnLastmileQuality(
  184. (int)AgoraJson.GetData<int>(jsonData, "quality")
  185. );
  186. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  187. });
  188. #endif
  189. break;
  190. case "onLastmileProbeResult":
  191. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  192. CallbackObject._CallbackQueue.EnQueue(() =>
  193. {
  194. #endif
  195. if (EngineEventHandler == null) return;
  196. EngineEventHandler.OnLastmileProbeResult(
  197. AgoraJson.JsonToStruct<LastmileProbeResult>(jsonData, "result")
  198. );
  199. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  200. });
  201. #endif
  202. break;
  203. case "onConnectionInterruptedEx":
  204. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  205. CallbackObject._CallbackQueue.EnQueue(() =>
  206. {
  207. #endif
  208. if (EngineEventHandler == null) return;
  209. EngineEventHandler.OnConnectionInterrupted(
  210. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection")
  211. );
  212. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  213. });
  214. #endif
  215. break;
  216. case "onConnectionLostEx":
  217. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  218. CallbackObject._CallbackQueue.EnQueue(() =>
  219. {
  220. #endif
  221. if (EngineEventHandler == null) return;
  222. EngineEventHandler.OnConnectionLost(
  223. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection")
  224. );
  225. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  226. });
  227. #endif
  228. break;
  229. case "onConnectionBannedEx":
  230. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  231. CallbackObject._CallbackQueue.EnQueue(() =>
  232. {
  233. #endif
  234. if (EngineEventHandler == null) return;
  235. EngineEventHandler.OnConnectionBanned(
  236. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection")
  237. );
  238. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  239. });
  240. #endif
  241. break;
  242. case "onApiCallExecuted":
  243. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  244. CallbackObject._CallbackQueue.EnQueue(() =>
  245. {
  246. #endif
  247. if (EngineEventHandler == null) return;
  248. EngineEventHandler.OnApiCallExecuted(
  249. (int)AgoraJson.GetData<int>(jsonData, "err"),
  250. (string)AgoraJson.GetData<string>(jsonData, "api"),
  251. (string)AgoraJson.GetData<string>(jsonData, "result")
  252. );
  253. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  254. });
  255. #endif
  256. break;
  257. case "onRequestTokenEx":
  258. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  259. CallbackObject._CallbackQueue.EnQueue(() =>
  260. {
  261. #endif
  262. if (EngineEventHandler == null) return;
  263. EngineEventHandler.OnRequestToken(
  264. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection")
  265. );
  266. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  267. });
  268. #endif
  269. break;
  270. case "onTokenPrivilegeWillExpireEx":
  271. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  272. CallbackObject._CallbackQueue.EnQueue(() =>
  273. {
  274. #endif
  275. if (EngineEventHandler == null) return;
  276. EngineEventHandler.OnTokenPrivilegeWillExpire(
  277. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  278. (string)AgoraJson.GetData<string>(jsonData, "token")
  279. );
  280. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  281. });
  282. #endif
  283. break;
  284. case "onRtcStatsEx":
  285. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  286. CallbackObject._CallbackQueue.EnQueue(() =>
  287. {
  288. #endif
  289. if (EngineEventHandler == null) return;
  290. EngineEventHandler.OnRtcStats(
  291. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  292. AgoraJson.JsonToStruct<RtcStats>(jsonData, "stats")
  293. );
  294. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  295. });
  296. #endif
  297. break;
  298. case "onNetworkQualityEx":
  299. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  300. CallbackObject._CallbackQueue.EnQueue(() =>
  301. {
  302. #endif
  303. if (EngineEventHandler == null) return;
  304. EngineEventHandler.OnNetworkQuality(
  305. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  306. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  307. (int)AgoraJson.GetData<int>(jsonData, "txQuality"),
  308. (int)AgoraJson.GetData<int>(jsonData, "rxQuality")
  309. );
  310. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  311. });
  312. #endif
  313. break;
  314. case "onLocalVideoStatsEx":
  315. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  316. CallbackObject._CallbackQueue.EnQueue(() =>
  317. {
  318. #endif
  319. if (EngineEventHandler == null) return;
  320. EngineEventHandler.OnLocalVideoStats(
  321. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  322. AgoraJson.JsonToStruct<LocalVideoStats>(jsonData, "stats")
  323. );
  324. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  325. });
  326. #endif
  327. break;
  328. case "onRemoteVideoStatsEx":
  329. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  330. CallbackObject._CallbackQueue.EnQueue(() =>
  331. {
  332. #endif
  333. if (EngineEventHandler == null) return;
  334. EngineEventHandler.OnRemoteVideoStats(
  335. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  336. AgoraJson.JsonToStruct<RemoteVideoStats>(jsonData, "stats")
  337. );
  338. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  339. });
  340. #endif
  341. break;
  342. case "onLocalAudioStatsEx":
  343. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  344. CallbackObject._CallbackQueue.EnQueue(() =>
  345. {
  346. #endif
  347. if (EngineEventHandler == null) return;
  348. EngineEventHandler.OnLocalAudioStats(
  349. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  350. AgoraJson.JsonToStruct<LocalAudioStats>(jsonData, "stats")
  351. );
  352. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  353. });
  354. #endif
  355. break;
  356. case "onRemoteAudioStatsEx":
  357. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  358. CallbackObject._CallbackQueue.EnQueue(() =>
  359. {
  360. #endif
  361. if (EngineEventHandler == null) return;
  362. EngineEventHandler.OnRemoteAudioStats(
  363. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  364. AgoraJson.JsonToStruct<RemoteAudioStats>(jsonData, "stats")
  365. );
  366. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  367. });
  368. #endif
  369. break;
  370. case "onLocalAudioStateChangedEx":
  371. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  372. CallbackObject._CallbackQueue.EnQueue(() =>
  373. {
  374. #endif
  375. if (EngineEventHandler == null) return;
  376. EngineEventHandler.OnLocalAudioStateChanged(
  377. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  378. (LOCAL_AUDIO_STREAM_STATE)AgoraJson.GetData<int>(jsonData, "state"),
  379. (LOCAL_AUDIO_STREAM_ERROR)AgoraJson.GetData<int>(jsonData, "error")
  380. );
  381. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  382. });
  383. #endif
  384. break;
  385. case "onRemoteAudioStateChangedEx":
  386. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  387. CallbackObject._CallbackQueue.EnQueue(() =>
  388. {
  389. #endif
  390. if (EngineEventHandler == null) return;
  391. EngineEventHandler.OnRemoteAudioStateChanged(
  392. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  393. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  394. (REMOTE_AUDIO_STATE)AgoraJson.GetData<int>(jsonData, "state"),
  395. (REMOTE_AUDIO_STATE_REASON)AgoraJson.GetData<int>(jsonData, "reason"),
  396. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  397. );
  398. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  399. });
  400. #endif
  401. break;
  402. case "onAudioPublishStateChanged":
  403. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  404. CallbackObject._CallbackQueue.EnQueue(() =>
  405. {
  406. #endif
  407. if (EngineEventHandler == null) return;
  408. EngineEventHandler.OnAudioPublishStateChanged(
  409. (string)AgoraJson.GetData<string>(jsonData, "channel"),
  410. (STREAM_PUBLISH_STATE)AgoraJson.GetData<int>(jsonData, "oldState"),
  411. (STREAM_PUBLISH_STATE)AgoraJson.GetData<int>(jsonData, "newState"),
  412. (int)AgoraJson.GetData<int>(jsonData, "elapseSinceLastState")
  413. );
  414. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  415. });
  416. #endif
  417. break;
  418. case "onVideoPublishStateChanged":
  419. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  420. CallbackObject._CallbackQueue.EnQueue(() =>
  421. {
  422. #endif
  423. if (EngineEventHandler == null) return;
  424. EngineEventHandler.OnVideoPublishStateChanged(
  425. (VIDEO_SOURCE_TYPE)AgoraJson.GetData<int>(jsonData, "source"),
  426. (string)AgoraJson.GetData<string>(jsonData, "channel"),
  427. (STREAM_PUBLISH_STATE)AgoraJson.GetData<int>(jsonData, "oldState"),
  428. (STREAM_PUBLISH_STATE)AgoraJson.GetData<int>(jsonData, "newState"),
  429. (int)AgoraJson.GetData<int>(jsonData, "elapseSinceLastState")
  430. );
  431. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  432. });
  433. #endif
  434. break;
  435. case "onAudioSubscribeStateChanged":
  436. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  437. CallbackObject._CallbackQueue.EnQueue(() =>
  438. {
  439. #endif
  440. if (EngineEventHandler == null) return;
  441. EngineEventHandler.OnAudioSubscribeStateChanged(
  442. (string)AgoraJson.GetData<string>(jsonData, "channel"),
  443. (uint)AgoraJson.GetData<uint>(jsonData, "uid"),
  444. (STREAM_SUBSCRIBE_STATE)AgoraJson.GetData<int>(jsonData, "oldState"),
  445. (STREAM_SUBSCRIBE_STATE)AgoraJson.GetData<int>(jsonData, "newState"),
  446. (int)AgoraJson.GetData<int>(jsonData, "elapseSinceLastState")
  447. );
  448. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  449. });
  450. #endif
  451. break;
  452. case "onVideoSubscribeStateChanged":
  453. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  454. CallbackObject._CallbackQueue.EnQueue(() =>
  455. {
  456. #endif
  457. if (EngineEventHandler == null) return;
  458. EngineEventHandler.OnVideoSubscribeStateChanged(
  459. (string)AgoraJson.GetData<string>(jsonData, "channel"),
  460. (uint)AgoraJson.GetData<uint>(jsonData, "uid"),
  461. (STREAM_SUBSCRIBE_STATE)AgoraJson.GetData<int>(jsonData, "oldState"),
  462. (STREAM_SUBSCRIBE_STATE)AgoraJson.GetData<int>(jsonData, "newState"),
  463. (int)AgoraJson.GetData<int>(jsonData, "elapseSinceLastState")
  464. );
  465. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  466. });
  467. #endif
  468. break;
  469. case "onAudioVolumeIndicationEx":
  470. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  471. CallbackObject._CallbackQueue.EnQueue(() =>
  472. {
  473. #endif
  474. if (EngineEventHandler == null) return;
  475. var speakerNumber = (uint)AgoraJson.GetData<uint>(jsonData, "speakerNumber");
  476. var speakers = AgoraJson.JsonToStructArray<AudioVolumeInfo>(jsonData, "speakers", speakerNumber);
  477. var totalVolume = (int)AgoraJson.GetData<int>(jsonData, "totalVolume");
  478. EngineEventHandler.OnAudioVolumeIndication(
  479. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  480. speakers,
  481. speakerNumber,
  482. totalVolume
  483. );
  484. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  485. });
  486. #endif
  487. break;
  488. case "onActiveSpeakerEx":
  489. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  490. CallbackObject._CallbackQueue.EnQueue(() =>
  491. {
  492. #endif
  493. if (EngineEventHandler == null) return;
  494. EngineEventHandler.OnActiveSpeaker(
  495. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  496. (uint)AgoraJson.GetData<uint>(jsonData, "uid")
  497. );
  498. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  499. });
  500. #endif
  501. break;
  502. case "onVideoStopped":
  503. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  504. CallbackObject._CallbackQueue.EnQueue(() =>
  505. {
  506. #endif
  507. if (EngineEventHandler == null) return;
  508. EngineEventHandler.OnVideoStopped();
  509. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  510. });
  511. #endif
  512. break;
  513. case "onFirstLocalVideoFrameEx":
  514. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  515. CallbackObject._CallbackQueue.EnQueue(() =>
  516. {
  517. #endif
  518. if (EngineEventHandler == null) return;
  519. EngineEventHandler.OnFirstLocalVideoFrame(
  520. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  521. (int)AgoraJson.GetData<int>(jsonData, "width"),
  522. (int)AgoraJson.GetData<int>(jsonData, "height"),
  523. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  524. );
  525. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  526. });
  527. #endif
  528. break;
  529. case "onFirstLocalVideoFramePublishedEx":
  530. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  531. CallbackObject._CallbackQueue.EnQueue(() =>
  532. {
  533. #endif
  534. if (EngineEventHandler == null) return;
  535. EngineEventHandler.OnFirstLocalVideoFramePublished(
  536. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  537. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  538. );
  539. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  540. });
  541. #endif
  542. break;
  543. case "onFirstRemoteVideoFrameEx":
  544. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  545. CallbackObject._CallbackQueue.EnQueue(() =>
  546. {
  547. #endif
  548. if (EngineEventHandler == null) return;
  549. EngineEventHandler.OnFirstRemoteVideoFrame(
  550. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  551. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  552. (int)AgoraJson.GetData<int>(jsonData, "width"),
  553. (int)AgoraJson.GetData<int>(jsonData, "height"),
  554. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  555. );
  556. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  557. });
  558. #endif
  559. break;
  560. case "onFirstRemoteVideoDecodedEx":
  561. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  562. CallbackObject._CallbackQueue.EnQueue(() =>
  563. {
  564. #endif
  565. if (EngineEventHandler == null) return;
  566. EngineEventHandler.OnFirstRemoteVideoDecoded(
  567. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  568. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  569. (int)AgoraJson.GetData<int>(jsonData, "width"),
  570. (int)AgoraJson.GetData<int>(jsonData, "height"),
  571. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  572. );
  573. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  574. });
  575. #endif
  576. break;
  577. case "onAudioDeviceStateChanged":
  578. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  579. CallbackObject._CallbackQueue.EnQueue(() =>
  580. {
  581. #endif
  582. if (EngineEventHandler == null) return;
  583. EngineEventHandler.OnAudioDeviceStateChanged(
  584. (string)AgoraJson.GetData<string>(jsonData, "deviceId"),
  585. (MEDIA_DEVICE_TYPE)AgoraJson.GetData<int>(jsonData, "deviceType"),
  586. (MEDIA_DEVICE_STATE_TYPE)AgoraJson.GetData<int>(jsonData, "deviceState")
  587. );
  588. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  589. });
  590. #endif
  591. break;
  592. case "onAudioDeviceVolumeChanged":
  593. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  594. CallbackObject._CallbackQueue.EnQueue(() =>
  595. {
  596. #endif
  597. if (EngineEventHandler == null) return;
  598. EngineEventHandler.OnAudioDeviceVolumeChanged(
  599. (MEDIA_DEVICE_TYPE)AgoraJson.GetData<int>(jsonData, "deviceType"),
  600. (int)AgoraJson.GetData<int>(jsonData, "volume"),
  601. (bool)AgoraJson.GetData<bool>(jsonData, "muted")
  602. );
  603. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  604. });
  605. #endif
  606. break;
  607. case "onCameraReady":
  608. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  609. CallbackObject._CallbackQueue.EnQueue(() =>
  610. {
  611. #endif
  612. if (EngineEventHandler == null) return;
  613. EngineEventHandler.OnCameraReady();
  614. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  615. });
  616. #endif
  617. break;
  618. case "onCameraFocusAreaChanged":
  619. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  620. CallbackObject._CallbackQueue.EnQueue(() =>
  621. {
  622. #endif
  623. if (EngineEventHandler == null) return;
  624. EngineEventHandler.OnCameraFocusAreaChanged(
  625. (int)AgoraJson.GetData<int>(jsonData, "x"),
  626. (int)AgoraJson.GetData<int>(jsonData, "y"),
  627. (int)AgoraJson.GetData<int>(jsonData, "width"),
  628. (int)AgoraJson.GetData<int>(jsonData, "height")
  629. );
  630. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  631. });
  632. #endif
  633. break;
  634. case "onFacePositionChanged":
  635. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  636. CallbackObject._CallbackQueue.EnQueue(() =>
  637. {
  638. #endif
  639. if (EngineEventHandler == null) return;
  640. var numFaces = (int)AgoraJson.GetData<int>(jsonData, "numFaces");
  641. EngineEventHandler.OnFacePositionChanged(
  642. (int)AgoraJson.GetData<int>(jsonData, "imageWidth"),
  643. (int)AgoraJson.GetData<int>(jsonData, "imageHeight"),
  644. AgoraJson.JsonToStruct<Rectangle>(
  645. (string)AgoraJson.GetData<string>(jsonData, "vecRectangle")),
  646. AgoraJson.JsonToStructArray<int>(jsonData, "vecDistance", (uint)numFaces), numFaces);
  647. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  648. });
  649. #endif
  650. break;
  651. case "onCameraExposureAreaChanged":
  652. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  653. CallbackObject._CallbackQueue.EnQueue(() =>
  654. {
  655. #endif
  656. if (EngineEventHandler == null) return;
  657. EngineEventHandler.OnCameraExposureAreaChanged(
  658. (int)AgoraJson.GetData<int>(jsonData, "x"),
  659. (int)AgoraJson.GetData<int>(jsonData, "y"),
  660. (int)AgoraJson.GetData<int>(jsonData, "width"),
  661. (int)AgoraJson.GetData<int>(jsonData, "height")
  662. );
  663. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  664. });
  665. #endif
  666. break;
  667. case "onAudioMixingFinished":
  668. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  669. CallbackObject._CallbackQueue.EnQueue(() =>
  670. {
  671. #endif
  672. if (EngineEventHandler == null) return;
  673. EngineEventHandler.OnAudioMixingFinished();
  674. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  675. });
  676. #endif
  677. break;
  678. case "onAudioMixingStateChanged":
  679. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  680. CallbackObject._CallbackQueue.EnQueue(() =>
  681. {
  682. #endif
  683. if (EngineEventHandler == null) return;
  684. EngineEventHandler.OnAudioMixingStateChanged(
  685. (AUDIO_MIXING_STATE_TYPE)AgoraJson.GetData<int>(jsonData, "state"),
  686. (AUDIO_MIXING_REASON_TYPE)AgoraJson.GetData<int>(jsonData, "reason")
  687. );
  688. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  689. });
  690. #endif
  691. break;
  692. case "onRhythmPlayerStateChanged":
  693. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  694. CallbackObject._CallbackQueue.EnQueue(() =>
  695. {
  696. #endif
  697. if (EngineEventHandler == null) return;
  698. EngineEventHandler.OnRhythmPlayerStateChanged(
  699. (RHYTHM_PLAYER_STATE_TYPE)AgoraJson.GetData<int>(jsonData, "state"),
  700. (RHYTHM_PLAYER_ERROR_TYPE)AgoraJson.GetData<int>(jsonData, "errorCode")
  701. );
  702. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  703. });
  704. #endif
  705. break;
  706. case "onAudioEffectFinished":
  707. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  708. CallbackObject._CallbackQueue.EnQueue(() =>
  709. {
  710. #endif
  711. if (EngineEventHandler == null) return;
  712. EngineEventHandler.OnAudioEffectFinished(
  713. (int)AgoraJson.GetData<int>(jsonData, "soundId")
  714. );
  715. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  716. });
  717. #endif
  718. break;
  719. case "onVideoDeviceStateChanged":
  720. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  721. CallbackObject._CallbackQueue.EnQueue(() =>
  722. {
  723. #endif
  724. if (EngineEventHandler == null) return;
  725. EngineEventHandler.OnVideoDeviceStateChanged(
  726. (string)AgoraJson.GetData<string>(jsonData, "deviceId"),
  727. (MEDIA_DEVICE_TYPE)AgoraJson.GetData<int>(jsonData, "deviceType"),
  728. (MEDIA_DEVICE_STATE_TYPE)AgoraJson.GetData<int>(jsonData, "deviceState")
  729. );
  730. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  731. });
  732. #endif
  733. break;
  734. case "onLocalVideoStateChanged":
  735. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  736. CallbackObject._CallbackQueue.EnQueue(() =>
  737. {
  738. #endif
  739. if (EngineEventHandler == null) return;
  740. EngineEventHandler.OnLocalVideoStateChanged(
  741. (VIDEO_SOURCE_TYPE)AgoraJson.GetData<int>(jsonData, "source"),
  742. (LOCAL_VIDEO_STREAM_STATE)AgoraJson.GetData<int>(jsonData, "state"),
  743. (LOCAL_VIDEO_STREAM_ERROR)AgoraJson.GetData<int>(jsonData, "error")
  744. );
  745. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  746. });
  747. #endif
  748. break;
  749. case "onLocalVideoStateChangedEx":
  750. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  751. CallbackObject._CallbackQueue.EnQueue(() =>
  752. {
  753. #endif
  754. if (EngineEventHandler == null) return;
  755. EngineEventHandler.OnLocalVideoStateChanged(
  756. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  757. (LOCAL_VIDEO_STREAM_STATE)AgoraJson.GetData<int>(jsonData, "state"),
  758. (LOCAL_VIDEO_STREAM_ERROR)AgoraJson.GetData<int>(jsonData, "errorCode")
  759. );
  760. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  761. });
  762. #endif
  763. break;
  764. case "onVideoSizeChangedEx":
  765. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  766. CallbackObject._CallbackQueue.EnQueue(() =>
  767. {
  768. #endif
  769. if (EngineEventHandler == null) return;
  770. EngineEventHandler.OnVideoSizeChanged(
  771. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  772. (VIDEO_SOURCE_TYPE)AgoraJson.GetData<int>(jsonData, "sourceType"),
  773. (uint)AgoraJson.GetData<uint>(jsonData, "uid"),
  774. (int)AgoraJson.GetData<int>(jsonData, "width"),
  775. (int)AgoraJson.GetData<int>(jsonData, "height"),
  776. (int)AgoraJson.GetData<int>(jsonData, "rotation")
  777. );
  778. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  779. });
  780. #endif
  781. break;
  782. case "onContentInspectResult":
  783. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  784. CallbackObject._CallbackQueue.EnQueue(() =>
  785. {
  786. #endif
  787. if (EngineEventHandler == null) return;
  788. EngineEventHandler.OnContentInspectResult(
  789. (CONTENT_INSPECT_RESULT)AgoraJson.GetData<int>(jsonData, "result")
  790. );
  791. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  792. });
  793. #endif
  794. break;
  795. case "onSnapshotTakenEx":
  796. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  797. CallbackObject._CallbackQueue.EnQueue(() =>
  798. {
  799. #endif
  800. if (EngineEventHandler == null) return;
  801. EngineEventHandler.OnSnapshotTaken(
  802. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  803. (uint)AgoraJson.GetData<uint>(jsonData, "uid"),
  804. (string)AgoraJson.GetData<string>(jsonData, "filePath"),
  805. (int)AgoraJson.GetData<int>(jsonData, "width"),
  806. (int)AgoraJson.GetData<int>(jsonData, "height"),
  807. (int)AgoraJson.GetData<int>(jsonData, "errCode")
  808. );
  809. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  810. });
  811. #endif
  812. break;
  813. case "onRemoteVideoStateChangedEx":
  814. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  815. CallbackObject._CallbackQueue.EnQueue(() =>
  816. {
  817. #endif
  818. if (EngineEventHandler == null) return;
  819. EngineEventHandler.OnRemoteVideoStateChanged(
  820. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  821. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  822. (REMOTE_VIDEO_STATE)AgoraJson.GetData<int>(jsonData, "state"),
  823. (REMOTE_VIDEO_STATE_REASON)AgoraJson.GetData<int>(jsonData, "reason"),
  824. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  825. );
  826. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  827. });
  828. #endif
  829. break;
  830. case "onUserStateChangedEx":
  831. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  832. CallbackObject._CallbackQueue.EnQueue(() =>
  833. {
  834. #endif
  835. if (EngineEventHandler == null) return;
  836. EngineEventHandler.OnUserStateChanged(
  837. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  838. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  839. (uint)AgoraJson.GetData<uint>(jsonData, "state")
  840. );
  841. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  842. });
  843. #endif
  844. break;
  845. case "onStreamMessageErrorEx":
  846. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  847. CallbackObject._CallbackQueue.EnQueue(() =>
  848. {
  849. #endif
  850. if (EngineEventHandler == null) return;
  851. EngineEventHandler.OnStreamMessageError(
  852. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  853. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  854. (int)AgoraJson.GetData<int>(jsonData, "streamId"),
  855. (int)AgoraJson.GetData<int>(jsonData, "code"),
  856. (int)AgoraJson.GetData<int>(jsonData, "missed"),
  857. (int)AgoraJson.GetData<int>(jsonData, "cached")
  858. );
  859. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  860. });
  861. #endif
  862. break;
  863. case "onChannelMediaRelayStateChanged":
  864. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  865. CallbackObject._CallbackQueue.EnQueue(() =>
  866. {
  867. #endif
  868. if (EngineEventHandler == null) return;
  869. EngineEventHandler.OnChannelMediaRelayStateChanged(
  870. (int)AgoraJson.GetData<int>(jsonData, "state"),
  871. (int)AgoraJson.GetData<int>(jsonData, "code") // int ?
  872. );
  873. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  874. });
  875. #endif
  876. break;
  877. case "onChannelMediaRelayEvent":
  878. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  879. CallbackObject._CallbackQueue.EnQueue(() =>
  880. {
  881. #endif
  882. if (EngineEventHandler == null) return;
  883. EngineEventHandler.OnChannelMediaRelayEvent(
  884. (int)AgoraJson.GetData<int>(jsonData, "code") // int ?
  885. );
  886. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  887. });
  888. #endif
  889. break;
  890. case "onFirstLocalAudioFramePublishedEx":
  891. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  892. CallbackObject._CallbackQueue.EnQueue(() =>
  893. {
  894. #endif
  895. if (EngineEventHandler == null) return;
  896. EngineEventHandler.OnFirstLocalAudioFramePublished(
  897. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  898. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  899. );
  900. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  901. });
  902. #endif
  903. break;
  904. case "onFirstRemoteAudioFrameEx":
  905. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  906. CallbackObject._CallbackQueue.EnQueue(() =>
  907. {
  908. #endif
  909. if (EngineEventHandler == null) return;
  910. EngineEventHandler.OnFirstRemoteAudioFrame(
  911. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  912. (uint)AgoraJson.GetData<uint>(jsonData, "uid"),
  913. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  914. );
  915. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  916. });
  917. #endif
  918. break;
  919. case "onFirstRemoteAudioDecodedEx":
  920. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  921. CallbackObject._CallbackQueue.EnQueue(() =>
  922. {
  923. #endif
  924. if (EngineEventHandler == null) return;
  925. EngineEventHandler.OnFirstRemoteAudioDecoded(
  926. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  927. (uint)AgoraJson.GetData<uint>(jsonData, "uid"),
  928. (int)AgoraJson.GetData<int>(jsonData, "elapsed")
  929. );
  930. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  931. });
  932. #endif
  933. break;
  934. case "onRtmpStreamingStateChanged":
  935. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  936. CallbackObject._CallbackQueue.EnQueue(() =>
  937. {
  938. #endif
  939. if (EngineEventHandler == null) return;
  940. EngineEventHandler.OnRtmpStreamingStateChanged(
  941. (string)AgoraJson.GetData<string>(jsonData, "url"),
  942. (RTMP_STREAM_PUBLISH_STATE)AgoraJson.GetData<int>(jsonData, "state"),
  943. (RTMP_STREAM_PUBLISH_ERROR_TYPE)AgoraJson.GetData<int>(jsonData, "errCode")
  944. );
  945. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  946. });
  947. #endif
  948. break;
  949. case "onRtmpStreamingEvent":
  950. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  951. CallbackObject._CallbackQueue.EnQueue(() =>
  952. {
  953. #endif
  954. if (EngineEventHandler == null) return;
  955. EngineEventHandler.OnRtmpStreamingEvent(
  956. (string)AgoraJson.GetData<string>(jsonData, "url"),
  957. (RTMP_STREAMING_EVENT)AgoraJson.GetData<int>(jsonData, "eventCode")
  958. );
  959. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  960. });
  961. #endif
  962. break;
  963. // case "onStreamPublished":
  964. //#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  965. // CallbackObject._CallbackQueue.EnQueue(() =>
  966. // {
  967. //#endif
  968. // if (EngineEventHandler == null) return;
  969. // EngineEventHandler.OnStreamPublished(
  970. // (string)AgoraJson.GetData<string>(data, "url"),
  971. // (int)AgoraJson.GetData<int>(data, "error")
  972. // );
  973. //#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  974. // });
  975. //#endif
  976. // break;
  977. // case "onStreamUnpublished":
  978. //#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  979. // CallbackObject._CallbackQueue.EnQueue(() =>
  980. // {
  981. //#endif
  982. // if (EngineEventHandler == null) return;
  983. // EngineEventHandler.OnStreamUnpublished(
  984. // (string)AgoraJson.GetData<string>(data, "url")
  985. // );
  986. //#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  987. // });
  988. //#endif
  989. // break;
  990. case "onTranscodingUpdated":
  991. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  992. CallbackObject._CallbackQueue.EnQueue(() =>
  993. {
  994. #endif
  995. if (EngineEventHandler == null) return;
  996. EngineEventHandler.OnTranscodingUpdated();
  997. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  998. });
  999. #endif
  1000. break;
  1001. case "onLocalPublishFallbackToAudioOnly":
  1002. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1003. CallbackObject._CallbackQueue.EnQueue(() =>
  1004. {
  1005. #endif
  1006. if (EngineEventHandler == null) return;
  1007. EngineEventHandler.OnLocalPublishFallbackToAudioOnly(
  1008. (bool)AgoraJson.GetData<bool>(jsonData, "isFallbackOrRecover")
  1009. );
  1010. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1011. });
  1012. #endif
  1013. break;
  1014. case "onRemoteSubscribeFallbackToAudioOnly":
  1015. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1016. CallbackObject._CallbackQueue.EnQueue(() =>
  1017. {
  1018. #endif
  1019. if (EngineEventHandler == null) return;
  1020. EngineEventHandler.OnRemoteSubscribeFallbackToAudioOnly(
  1021. (uint)AgoraJson.GetData<uint>(jsonData, "uid"),
  1022. (bool)AgoraJson.GetData<bool>(jsonData, "isFallbackOrRecover")
  1023. );
  1024. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1025. });
  1026. #endif
  1027. break;
  1028. case "onRemoteAudioTransportStatsEx":
  1029. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1030. CallbackObject._CallbackQueue.EnQueue(() =>
  1031. {
  1032. #endif
  1033. if (EngineEventHandler == null) return;
  1034. EngineEventHandler.OnRemoteAudioTransportStats(
  1035. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1036. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  1037. (UInt16)AgoraJson.GetData<UInt16>(jsonData, "delay"),
  1038. (UInt16)AgoraJson.GetData<UInt16>(jsonData, "lost"),
  1039. (UInt16)AgoraJson.GetData<UInt16>(jsonData, "rxKBitRate")
  1040. );
  1041. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1042. });
  1043. #endif
  1044. break;
  1045. case "onRemoteVideoTransportStatsEx":
  1046. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1047. CallbackObject._CallbackQueue.EnQueue(() =>
  1048. {
  1049. #endif
  1050. if (EngineEventHandler == null) return;
  1051. EngineEventHandler.OnRemoteVideoTransportStats(
  1052. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1053. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  1054. (UInt16)AgoraJson.GetData<UInt16>(jsonData, "delay"),
  1055. (UInt16)AgoraJson.GetData<UInt16>(jsonData, "lost"),
  1056. (UInt16)AgoraJson.GetData<UInt16>(jsonData, "rxKBitRate")
  1057. );
  1058. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1059. });
  1060. #endif
  1061. break;
  1062. case "onConnectionStateChangedEx":
  1063. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1064. CallbackObject._CallbackQueue.EnQueue(() =>
  1065. {
  1066. #endif
  1067. if (EngineEventHandler == null) return;
  1068. EngineEventHandler.OnConnectionStateChanged(
  1069. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1070. (CONNECTION_STATE_TYPE)AgoraJson.GetData<int>(jsonData, "state"),
  1071. (CONNECTION_CHANGED_REASON_TYPE)AgoraJson.GetData<int>(jsonData, "reason")
  1072. );
  1073. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1074. });
  1075. #endif
  1076. break;
  1077. case "onWlAccMessageEx":
  1078. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1079. CallbackObject._CallbackQueue.EnQueue(() =>
  1080. {
  1081. #endif
  1082. if (EngineEventHandler == null) return;
  1083. EngineEventHandler.OnWlAccMessage(
  1084. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1085. (WLACC_MESSAGE_REASON)AgoraJson.GetData<int>(jsonData, "reason"),
  1086. (WLACC_SUGGEST_ACTION)AgoraJson.GetData<int>(jsonData, "action"),
  1087. (string)AgoraJson.GetData<string>(jsonData, "wlAccMsg")
  1088. );
  1089. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1090. });
  1091. #endif
  1092. break;
  1093. case "onWlAccStatsEx":
  1094. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1095. CallbackObject._CallbackQueue.EnQueue(() =>
  1096. {
  1097. #endif
  1098. if (EngineEventHandler == null) return;
  1099. EngineEventHandler.OnWlAccStats(
  1100. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1101. (WlAccStats)AgoraJson.JsonToStruct<WlAccStats>(jsonData, "currentStats"),
  1102. (WlAccStats)AgoraJson.JsonToStruct<WlAccStats>(jsonData, "averageStats")
  1103. );
  1104. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1105. });
  1106. #endif
  1107. break;
  1108. case "onNetworkTypeChangedEx":
  1109. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1110. CallbackObject._CallbackQueue.EnQueue(() =>
  1111. {
  1112. #endif
  1113. if (EngineEventHandler == null) return;
  1114. EngineEventHandler.OnNetworkTypeChanged(
  1115. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1116. (NETWORK_TYPE)AgoraJson.GetData<int>(jsonData, "type")
  1117. );
  1118. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1119. });
  1120. #endif
  1121. break;
  1122. case "onLocalUserRegistered":
  1123. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1124. CallbackObject._CallbackQueue.EnQueue(() =>
  1125. {
  1126. #endif
  1127. if (EngineEventHandler == null) return;
  1128. EngineEventHandler.OnLocalUserRegistered(
  1129. (uint)AgoraJson.GetData<uint>(jsonData, "uid"),
  1130. (string)AgoraJson.GetData<string>(jsonData, "userAccount")
  1131. );
  1132. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1133. });
  1134. #endif
  1135. break;
  1136. case "onUserInfoUpdated":
  1137. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1138. CallbackObject._CallbackQueue.EnQueue(() =>
  1139. {
  1140. #endif
  1141. if (EngineEventHandler == null) return;
  1142. EngineEventHandler.OnUserInfoUpdated(
  1143. (uint)AgoraJson.GetData<uint>(jsonData, "uid"),
  1144. AgoraJson.JsonToStruct<UserInfo>(jsonData, "info")
  1145. );
  1146. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1147. });
  1148. #endif
  1149. break;
  1150. case "onMediaDeviceChanged":
  1151. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1152. CallbackObject._CallbackQueue.EnQueue(() =>
  1153. {
  1154. #endif
  1155. if (EngineEventHandler == null) return;
  1156. EngineEventHandler.OnMediaDeviceChanged(
  1157. (MEDIA_DEVICE_TYPE)AgoraJson.GetData<int>(jsonData, "deviceType")
  1158. );
  1159. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1160. });
  1161. #endif
  1162. break;
  1163. case "onIntraRequestReceivedEx":
  1164. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1165. CallbackObject._CallbackQueue.EnQueue(() =>
  1166. {
  1167. #endif
  1168. if (EngineEventHandler == null) return;
  1169. EngineEventHandler.OnIntraRequestReceived(
  1170. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection")
  1171. );
  1172. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1173. });
  1174. #endif
  1175. break;
  1176. case "onUplinkNetworkInfoUpdated":
  1177. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1178. CallbackObject._CallbackQueue.EnQueue(() =>
  1179. {
  1180. #endif
  1181. if (EngineEventHandler == null) return;
  1182. EngineEventHandler.OnUplinkNetworkInfoUpdated(
  1183. AgoraJson.JsonToStruct<UplinkNetworkInfo>(jsonData, "info")
  1184. );
  1185. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1186. });
  1187. #endif
  1188. break;
  1189. case "onDownlinkNetworkInfoUpdated":
  1190. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1191. CallbackObject._CallbackQueue.EnQueue(() =>
  1192. {
  1193. #endif
  1194. if (EngineEventHandler == null) return;
  1195. EngineEventHandler.OnDownlinkNetworkInfoUpdated(
  1196. AgoraJson.JsonToStruct<DownlinkNetworkInfo>(jsonData, "info")
  1197. );
  1198. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1199. });
  1200. #endif
  1201. break;
  1202. case "onVideoSourceFrameSizeChangedEx":
  1203. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1204. CallbackObject._CallbackQueue.EnQueue(() =>
  1205. {
  1206. #endif
  1207. if (EngineEventHandler == null) return;
  1208. EngineEventHandler.OnVideoSourceFrameSizeChanged(
  1209. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1210. (VIDEO_SOURCE_TYPE)AgoraJson.GetData<int>(jsonData, "sourceType"),
  1211. (int)AgoraJson.GetData<int>(jsonData, "width"),
  1212. (int)AgoraJson.GetData<int>(jsonData, "height")
  1213. );
  1214. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1215. });
  1216. #endif
  1217. break;
  1218. case "onEncryptionErrorEx":
  1219. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1220. CallbackObject._CallbackQueue.EnQueue(() =>
  1221. {
  1222. #endif
  1223. if (EngineEventHandler == null) return;
  1224. EngineEventHandler.OnEncryptionError(
  1225. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1226. (ENCRYPTION_ERROR_TYPE)AgoraJson.GetData<int>(jsonData, "errorType")
  1227. );
  1228. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1229. });
  1230. #endif
  1231. break;
  1232. case "onUploadLogResultEx":
  1233. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1234. CallbackObject._CallbackQueue.EnQueue(() =>
  1235. {
  1236. #endif
  1237. if (EngineEventHandler == null) return;
  1238. EngineEventHandler.OnUploadLogResult(
  1239. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1240. (string)AgoraJson.GetData<string>(jsonData, "requestId"),
  1241. (bool)AgoraJson.GetData<bool>(jsonData, "success"),
  1242. (UPLOAD_ERROR_REASON)AgoraJson.GetData<int>(jsonData, "reason")
  1243. );
  1244. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1245. });
  1246. #endif
  1247. break;
  1248. case "onUserAccountUpdatedEx":
  1249. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1250. CallbackObject._CallbackQueue.EnQueue(() =>
  1251. {
  1252. #endif
  1253. if (EngineEventHandler == null) return;
  1254. EngineEventHandler.OnUserAccountUpdated(
  1255. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1256. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  1257. (string)AgoraJson.GetData<string>(jsonData, "userAccount")
  1258. );
  1259. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1260. });
  1261. #endif
  1262. break;
  1263. case "onAudioRoutingChanged":
  1264. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1265. CallbackObject._CallbackQueue.EnQueue(() =>
  1266. {
  1267. #endif
  1268. if (EngineEventHandler == null) return;
  1269. EngineEventHandler.OnAudioRoutingChanged(
  1270. (int)AgoraJson.GetData<int>(jsonData, "routing")
  1271. );
  1272. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1273. });
  1274. #endif
  1275. break;
  1276. case "onPermissionError":
  1277. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1278. CallbackObject._CallbackQueue.EnQueue(() =>
  1279. {
  1280. #endif
  1281. if (EngineEventHandler == null) return;
  1282. EngineEventHandler.OnPermissionError(
  1283. (PERMISSION_TYPE)AgoraJson.GetData<int>(jsonData, "permissionType")
  1284. );
  1285. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1286. });
  1287. #endif
  1288. break;
  1289. case "onExtensionEvent":
  1290. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1291. CallbackObject._CallbackQueue.EnQueue(() =>
  1292. {
  1293. #endif
  1294. if (EngineEventHandler == null) return;
  1295. EngineEventHandler.OnExtensionEvent(
  1296. (string)AgoraJson.GetData<string>(jsonData, "provider"),
  1297. (string)AgoraJson.GetData<string>(jsonData, "extension"),
  1298. (string)AgoraJson.GetData<string>(jsonData, "key"),
  1299. (string)AgoraJson.GetData<string>(jsonData, "value")
  1300. );
  1301. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1302. });
  1303. #endif
  1304. break;
  1305. case "onExtensionStarted":
  1306. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1307. CallbackObject._CallbackQueue.EnQueue(() =>
  1308. {
  1309. #endif
  1310. if (EngineEventHandler == null) return;
  1311. EngineEventHandler.OnExtensionStarted(
  1312. (string)AgoraJson.GetData<string>(jsonData, "provider"),
  1313. (string)AgoraJson.GetData<string>(jsonData, "extension")
  1314. );
  1315. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1316. });
  1317. #endif
  1318. break;
  1319. case "onExtensionStopped":
  1320. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1321. CallbackObject._CallbackQueue.EnQueue(() =>
  1322. {
  1323. #endif
  1324. if (EngineEventHandler == null) return;
  1325. EngineEventHandler.OnExtensionStopped(
  1326. (string)AgoraJson.GetData<string>(jsonData, "provider"),
  1327. (string)AgoraJson.GetData<string>(jsonData, "extension")
  1328. );
  1329. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1330. });
  1331. #endif
  1332. break;
  1333. case "onExtensionError":
  1334. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1335. CallbackObject._CallbackQueue.EnQueue(() =>
  1336. {
  1337. #endif
  1338. if (EngineEventHandler == null) return;
  1339. EngineEventHandler.OnExtensionError(
  1340. (string)AgoraJson.GetData<string>(jsonData, "provider"),
  1341. (string)AgoraJson.GetData<string>(jsonData, "extension"),
  1342. (int)AgoraJson.GetData<int>(jsonData, "error"),
  1343. (string)AgoraJson.GetData<string>(jsonData, "message")
  1344. );
  1345. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1346. });
  1347. #endif
  1348. break;
  1349. case "DirectCdnStreamingEventHandler_onDirectCdnStreamingStateChanged":
  1350. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1351. CallbackObject._CallbackQueue.EnQueue(() =>
  1352. {
  1353. #endif
  1354. if (EngineEventHandler == null) return;
  1355. EngineEventHandler.OnDirectCdnStreamingStateChanged(
  1356. (DIRECT_CDN_STREAMING_STATE)AgoraJson.GetData<int>(jsonData, "state"),
  1357. (DIRECT_CDN_STREAMING_ERROR)AgoraJson.GetData<int>(jsonData, "error"),
  1358. (string)AgoraJson.GetData<string>(jsonData, "message")
  1359. );
  1360. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1361. });
  1362. #endif
  1363. break;
  1364. case "DirectCdnStreamingEventHandler_onDirectCdnStreamingStats":
  1365. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1366. CallbackObject._CallbackQueue.EnQueue(() =>
  1367. {
  1368. #endif
  1369. if (EngineEventHandler == null) return;
  1370. EngineEventHandler.OnDirectCdnStreamingStats(
  1371. AgoraJson.JsonToStruct<DirectCdnStreamingStats>(jsonData, "stats")
  1372. );
  1373. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1374. });
  1375. #endif
  1376. break;
  1377. #endregion no buffer end
  1378. #region withBuffer start
  1379. case "onStreamMessageEx":
  1380. var byteLength = (uint)AgoraJson.GetData<uint>(jsonData, "length");
  1381. var bufferPtr = (IntPtr)(UInt64)AgoraJson.GetData<UInt64>(jsonData, "data");
  1382. var byteData = new byte[byteLength];
  1383. if (byteLength != 0)
  1384. {
  1385. Marshal.Copy(bufferPtr, byteData, 0, (int)byteLength);
  1386. }
  1387. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1388. CallbackObject._CallbackQueue.EnQueue(() =>
  1389. {
  1390. #endif
  1391. if (EngineEventHandler == null) return;
  1392. EngineEventHandler.OnStreamMessage(
  1393. AgoraJson.JsonToStruct<RtcConnection>(jsonData, "connection"),
  1394. (uint)AgoraJson.GetData<uint>(jsonData, "remoteUid"),
  1395. (int)AgoraJson.GetData<int>(jsonData, "streamId"),
  1396. byteData,
  1397. byteLength,
  1398. (UInt64)AgoraJson.GetData<UInt64>(jsonData, "sentTs"));
  1399. #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID
  1400. });
  1401. #endif
  1402. break;
  1403. #endregion withBuffer end
  1404. }
  1405. }
  1406. }
  1407. }