using System; using System.Runtime.InteropServices; #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID using AOT; #endif namespace Agora.Rtc { internal static class RtcEngineEventHandlerNative { internal static IRtcEngineEventHandler EngineEventHandler = null; #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID internal static AgoraCallbackObject CallbackObject = null; #endif #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID [MonoPInvokeCallback(typeof(Func_Event_Native))] #endif internal static void OnEvent(string @event, string data, IntPtr buffer, IntPtr length, uint buffer_count) { if (EngineEventHandler == null) return; LitJson.JsonData jsonData = AgoraJson.ToObject(data); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID if (CallbackObject == null || CallbackObject._CallbackQueue == null) return; #endif switch (@event) { #region no buffer start case "onError": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnError( (int)AgoraJson.GetData(jsonData, "err"), (string)AgoraJson.GetData(jsonData, "msg") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onJoinChannelSuccessEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnJoinChannelSuccess( AgoraJson.JsonToStruct(jsonData, "connection"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRejoinChannelSuccessEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRejoinChannelSuccess( AgoraJson.JsonToStruct(jsonData, "connection"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onProxyConnected": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnProxyConnected( (string)AgoraJson.GetData(jsonData, "channel"), (uint)AgoraJson.GetData(jsonData, "uid"), (PROXY_TYPE)AgoraJson.GetData(jsonData, "proxyType"), (string)AgoraJson.GetData(jsonData, "localProxyIp"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onAudioQualityEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnAudioQuality( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (int)AgoraJson.GetData(jsonData, "elapsed"), (UInt16)AgoraJson.GetData(jsonData, "delay"), (UInt16)AgoraJson.GetData(jsonData, "lost") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onLeaveChannelEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnLeaveChannel( AgoraJson.JsonToStruct(jsonData, "connection"), AgoraJson.JsonToStruct(jsonData, "stats") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onClientRoleChangedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnClientRoleChanged( AgoraJson.JsonToStruct(jsonData, "connection"), (CLIENT_ROLE_TYPE)AgoraJson.GetData(jsonData, "oldRole"), (CLIENT_ROLE_TYPE)AgoraJson.GetData(jsonData, "newRole") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onClientRoleChangeFailedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnClientRoleChangeFailed( AgoraJson.JsonToStruct(jsonData, "connection"), (CLIENT_ROLE_CHANGE_FAILED_REASON)AgoraJson.GetData(jsonData, "reason"), (CLIENT_ROLE_TYPE)AgoraJson.GetData(jsonData, "currentRole") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onUserJoinedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnUserJoined( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onUserOfflineEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnUserOffline( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (USER_OFFLINE_REASON_TYPE)AgoraJson.GetData(jsonData, "reason") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onLastmileQuality": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnLastmileQuality( (int)AgoraJson.GetData(jsonData, "quality") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onLastmileProbeResult": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnLastmileProbeResult( AgoraJson.JsonToStruct(jsonData, "result") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onConnectionInterruptedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnConnectionInterrupted( AgoraJson.JsonToStruct(jsonData, "connection") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onConnectionLostEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnConnectionLost( AgoraJson.JsonToStruct(jsonData, "connection") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onConnectionBannedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnConnectionBanned( AgoraJson.JsonToStruct(jsonData, "connection") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onApiCallExecuted": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnApiCallExecuted( (int)AgoraJson.GetData(jsonData, "err"), (string)AgoraJson.GetData(jsonData, "api"), (string)AgoraJson.GetData(jsonData, "result") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRequestTokenEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRequestToken( AgoraJson.JsonToStruct(jsonData, "connection") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onTokenPrivilegeWillExpireEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnTokenPrivilegeWillExpire( AgoraJson.JsonToStruct(jsonData, "connection"), (string)AgoraJson.GetData(jsonData, "token") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRtcStatsEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRtcStats( AgoraJson.JsonToStruct(jsonData, "connection"), AgoraJson.JsonToStruct(jsonData, "stats") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onNetworkQualityEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnNetworkQuality( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (int)AgoraJson.GetData(jsonData, "txQuality"), (int)AgoraJson.GetData(jsonData, "rxQuality") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onLocalVideoStatsEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnLocalVideoStats( AgoraJson.JsonToStruct(jsonData, "connection"), AgoraJson.JsonToStruct(jsonData, "stats") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRemoteVideoStatsEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRemoteVideoStats( AgoraJson.JsonToStruct(jsonData, "connection"), AgoraJson.JsonToStruct(jsonData, "stats") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onLocalAudioStatsEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnLocalAudioStats( AgoraJson.JsonToStruct(jsonData, "connection"), AgoraJson.JsonToStruct(jsonData, "stats") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRemoteAudioStatsEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRemoteAudioStats( AgoraJson.JsonToStruct(jsonData, "connection"), AgoraJson.JsonToStruct(jsonData, "stats") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onLocalAudioStateChangedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnLocalAudioStateChanged( AgoraJson.JsonToStruct(jsonData, "connection"), (LOCAL_AUDIO_STREAM_STATE)AgoraJson.GetData(jsonData, "state"), (LOCAL_AUDIO_STREAM_ERROR)AgoraJson.GetData(jsonData, "error") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRemoteAudioStateChangedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRemoteAudioStateChanged( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (REMOTE_AUDIO_STATE)AgoraJson.GetData(jsonData, "state"), (REMOTE_AUDIO_STATE_REASON)AgoraJson.GetData(jsonData, "reason"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onAudioPublishStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnAudioPublishStateChanged( (string)AgoraJson.GetData(jsonData, "channel"), (STREAM_PUBLISH_STATE)AgoraJson.GetData(jsonData, "oldState"), (STREAM_PUBLISH_STATE)AgoraJson.GetData(jsonData, "newState"), (int)AgoraJson.GetData(jsonData, "elapseSinceLastState") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onVideoPublishStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnVideoPublishStateChanged( (VIDEO_SOURCE_TYPE)AgoraJson.GetData(jsonData, "source"), (string)AgoraJson.GetData(jsonData, "channel"), (STREAM_PUBLISH_STATE)AgoraJson.GetData(jsonData, "oldState"), (STREAM_PUBLISH_STATE)AgoraJson.GetData(jsonData, "newState"), (int)AgoraJson.GetData(jsonData, "elapseSinceLastState") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onAudioSubscribeStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnAudioSubscribeStateChanged( (string)AgoraJson.GetData(jsonData, "channel"), (uint)AgoraJson.GetData(jsonData, "uid"), (STREAM_SUBSCRIBE_STATE)AgoraJson.GetData(jsonData, "oldState"), (STREAM_SUBSCRIBE_STATE)AgoraJson.GetData(jsonData, "newState"), (int)AgoraJson.GetData(jsonData, "elapseSinceLastState") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onVideoSubscribeStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnVideoSubscribeStateChanged( (string)AgoraJson.GetData(jsonData, "channel"), (uint)AgoraJson.GetData(jsonData, "uid"), (STREAM_SUBSCRIBE_STATE)AgoraJson.GetData(jsonData, "oldState"), (STREAM_SUBSCRIBE_STATE)AgoraJson.GetData(jsonData, "newState"), (int)AgoraJson.GetData(jsonData, "elapseSinceLastState") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onAudioVolumeIndicationEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; var speakerNumber = (uint)AgoraJson.GetData(jsonData, "speakerNumber"); var speakers = AgoraJson.JsonToStructArray(jsonData, "speakers", speakerNumber); var totalVolume = (int)AgoraJson.GetData(jsonData, "totalVolume"); EngineEventHandler.OnAudioVolumeIndication( AgoraJson.JsonToStruct(jsonData, "connection"), speakers, speakerNumber, totalVolume ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onActiveSpeakerEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnActiveSpeaker( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "uid") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onVideoStopped": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnVideoStopped(); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onFirstLocalVideoFrameEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnFirstLocalVideoFrame( AgoraJson.JsonToStruct(jsonData, "connection"), (int)AgoraJson.GetData(jsonData, "width"), (int)AgoraJson.GetData(jsonData, "height"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onFirstLocalVideoFramePublishedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnFirstLocalVideoFramePublished( AgoraJson.JsonToStruct(jsonData, "connection"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onFirstRemoteVideoFrameEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnFirstRemoteVideoFrame( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (int)AgoraJson.GetData(jsonData, "width"), (int)AgoraJson.GetData(jsonData, "height"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onFirstRemoteVideoDecodedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnFirstRemoteVideoDecoded( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (int)AgoraJson.GetData(jsonData, "width"), (int)AgoraJson.GetData(jsonData, "height"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onAudioDeviceStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnAudioDeviceStateChanged( (string)AgoraJson.GetData(jsonData, "deviceId"), (MEDIA_DEVICE_TYPE)AgoraJson.GetData(jsonData, "deviceType"), (MEDIA_DEVICE_STATE_TYPE)AgoraJson.GetData(jsonData, "deviceState") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onAudioDeviceVolumeChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnAudioDeviceVolumeChanged( (MEDIA_DEVICE_TYPE)AgoraJson.GetData(jsonData, "deviceType"), (int)AgoraJson.GetData(jsonData, "volume"), (bool)AgoraJson.GetData(jsonData, "muted") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onCameraReady": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnCameraReady(); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onCameraFocusAreaChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnCameraFocusAreaChanged( (int)AgoraJson.GetData(jsonData, "x"), (int)AgoraJson.GetData(jsonData, "y"), (int)AgoraJson.GetData(jsonData, "width"), (int)AgoraJson.GetData(jsonData, "height") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onFacePositionChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; var numFaces = (int)AgoraJson.GetData(jsonData, "numFaces"); EngineEventHandler.OnFacePositionChanged( (int)AgoraJson.GetData(jsonData, "imageWidth"), (int)AgoraJson.GetData(jsonData, "imageHeight"), AgoraJson.JsonToStruct( (string)AgoraJson.GetData(jsonData, "vecRectangle")), AgoraJson.JsonToStructArray(jsonData, "vecDistance", (uint)numFaces), numFaces); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onCameraExposureAreaChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnCameraExposureAreaChanged( (int)AgoraJson.GetData(jsonData, "x"), (int)AgoraJson.GetData(jsonData, "y"), (int)AgoraJson.GetData(jsonData, "width"), (int)AgoraJson.GetData(jsonData, "height") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onAudioMixingFinished": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnAudioMixingFinished(); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onAudioMixingStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnAudioMixingStateChanged( (AUDIO_MIXING_STATE_TYPE)AgoraJson.GetData(jsonData, "state"), (AUDIO_MIXING_REASON_TYPE)AgoraJson.GetData(jsonData, "reason") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRhythmPlayerStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRhythmPlayerStateChanged( (RHYTHM_PLAYER_STATE_TYPE)AgoraJson.GetData(jsonData, "state"), (RHYTHM_PLAYER_ERROR_TYPE)AgoraJson.GetData(jsonData, "errorCode") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onAudioEffectFinished": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnAudioEffectFinished( (int)AgoraJson.GetData(jsonData, "soundId") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onVideoDeviceStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnVideoDeviceStateChanged( (string)AgoraJson.GetData(jsonData, "deviceId"), (MEDIA_DEVICE_TYPE)AgoraJson.GetData(jsonData, "deviceType"), (MEDIA_DEVICE_STATE_TYPE)AgoraJson.GetData(jsonData, "deviceState") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onLocalVideoStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnLocalVideoStateChanged( (VIDEO_SOURCE_TYPE)AgoraJson.GetData(jsonData, "source"), (LOCAL_VIDEO_STREAM_STATE)AgoraJson.GetData(jsonData, "state"), (LOCAL_VIDEO_STREAM_ERROR)AgoraJson.GetData(jsonData, "error") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onLocalVideoStateChangedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnLocalVideoStateChanged( AgoraJson.JsonToStruct(jsonData, "connection"), (LOCAL_VIDEO_STREAM_STATE)AgoraJson.GetData(jsonData, "state"), (LOCAL_VIDEO_STREAM_ERROR)AgoraJson.GetData(jsonData, "errorCode") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onVideoSizeChangedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnVideoSizeChanged( AgoraJson.JsonToStruct(jsonData, "connection"), (VIDEO_SOURCE_TYPE)AgoraJson.GetData(jsonData, "sourceType"), (uint)AgoraJson.GetData(jsonData, "uid"), (int)AgoraJson.GetData(jsonData, "width"), (int)AgoraJson.GetData(jsonData, "height"), (int)AgoraJson.GetData(jsonData, "rotation") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onContentInspectResult": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnContentInspectResult( (CONTENT_INSPECT_RESULT)AgoraJson.GetData(jsonData, "result") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onSnapshotTakenEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnSnapshotTaken( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "uid"), (string)AgoraJson.GetData(jsonData, "filePath"), (int)AgoraJson.GetData(jsonData, "width"), (int)AgoraJson.GetData(jsonData, "height"), (int)AgoraJson.GetData(jsonData, "errCode") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRemoteVideoStateChangedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRemoteVideoStateChanged( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (REMOTE_VIDEO_STATE)AgoraJson.GetData(jsonData, "state"), (REMOTE_VIDEO_STATE_REASON)AgoraJson.GetData(jsonData, "reason"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onUserStateChangedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnUserStateChanged( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (uint)AgoraJson.GetData(jsonData, "state") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onStreamMessageErrorEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnStreamMessageError( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (int)AgoraJson.GetData(jsonData, "streamId"), (int)AgoraJson.GetData(jsonData, "code"), (int)AgoraJson.GetData(jsonData, "missed"), (int)AgoraJson.GetData(jsonData, "cached") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onChannelMediaRelayStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnChannelMediaRelayStateChanged( (int)AgoraJson.GetData(jsonData, "state"), (int)AgoraJson.GetData(jsonData, "code") // int ? ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onChannelMediaRelayEvent": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnChannelMediaRelayEvent( (int)AgoraJson.GetData(jsonData, "code") // int ? ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onFirstLocalAudioFramePublishedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnFirstLocalAudioFramePublished( AgoraJson.JsonToStruct(jsonData, "connection"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onFirstRemoteAudioFrameEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnFirstRemoteAudioFrame( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "uid"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onFirstRemoteAudioDecodedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnFirstRemoteAudioDecoded( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "uid"), (int)AgoraJson.GetData(jsonData, "elapsed") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRtmpStreamingStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRtmpStreamingStateChanged( (string)AgoraJson.GetData(jsonData, "url"), (RTMP_STREAM_PUBLISH_STATE)AgoraJson.GetData(jsonData, "state"), (RTMP_STREAM_PUBLISH_ERROR_TYPE)AgoraJson.GetData(jsonData, "errCode") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRtmpStreamingEvent": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRtmpStreamingEvent( (string)AgoraJson.GetData(jsonData, "url"), (RTMP_STREAMING_EVENT)AgoraJson.GetData(jsonData, "eventCode") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; // case "onStreamPublished": //#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID // CallbackObject._CallbackQueue.EnQueue(() => // { //#endif // if (EngineEventHandler == null) return; // EngineEventHandler.OnStreamPublished( // (string)AgoraJson.GetData(data, "url"), // (int)AgoraJson.GetData(data, "error") // ); //#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID // }); //#endif // break; // case "onStreamUnpublished": //#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID // CallbackObject._CallbackQueue.EnQueue(() => // { //#endif // if (EngineEventHandler == null) return; // EngineEventHandler.OnStreamUnpublished( // (string)AgoraJson.GetData(data, "url") // ); //#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID // }); //#endif // break; case "onTranscodingUpdated": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnTranscodingUpdated(); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onLocalPublishFallbackToAudioOnly": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnLocalPublishFallbackToAudioOnly( (bool)AgoraJson.GetData(jsonData, "isFallbackOrRecover") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRemoteSubscribeFallbackToAudioOnly": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRemoteSubscribeFallbackToAudioOnly( (uint)AgoraJson.GetData(jsonData, "uid"), (bool)AgoraJson.GetData(jsonData, "isFallbackOrRecover") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRemoteAudioTransportStatsEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRemoteAudioTransportStats( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (UInt16)AgoraJson.GetData(jsonData, "delay"), (UInt16)AgoraJson.GetData(jsonData, "lost"), (UInt16)AgoraJson.GetData(jsonData, "rxKBitRate") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onRemoteVideoTransportStatsEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnRemoteVideoTransportStats( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (UInt16)AgoraJson.GetData(jsonData, "delay"), (UInt16)AgoraJson.GetData(jsonData, "lost"), (UInt16)AgoraJson.GetData(jsonData, "rxKBitRate") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onConnectionStateChangedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnConnectionStateChanged( AgoraJson.JsonToStruct(jsonData, "connection"), (CONNECTION_STATE_TYPE)AgoraJson.GetData(jsonData, "state"), (CONNECTION_CHANGED_REASON_TYPE)AgoraJson.GetData(jsonData, "reason") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onWlAccMessageEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnWlAccMessage( AgoraJson.JsonToStruct(jsonData, "connection"), (WLACC_MESSAGE_REASON)AgoraJson.GetData(jsonData, "reason"), (WLACC_SUGGEST_ACTION)AgoraJson.GetData(jsonData, "action"), (string)AgoraJson.GetData(jsonData, "wlAccMsg") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onWlAccStatsEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnWlAccStats( AgoraJson.JsonToStruct(jsonData, "connection"), (WlAccStats)AgoraJson.JsonToStruct(jsonData, "currentStats"), (WlAccStats)AgoraJson.JsonToStruct(jsonData, "averageStats") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onNetworkTypeChangedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnNetworkTypeChanged( AgoraJson.JsonToStruct(jsonData, "connection"), (NETWORK_TYPE)AgoraJson.GetData(jsonData, "type") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onLocalUserRegistered": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnLocalUserRegistered( (uint)AgoraJson.GetData(jsonData, "uid"), (string)AgoraJson.GetData(jsonData, "userAccount") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onUserInfoUpdated": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnUserInfoUpdated( (uint)AgoraJson.GetData(jsonData, "uid"), AgoraJson.JsonToStruct(jsonData, "info") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onMediaDeviceChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnMediaDeviceChanged( (MEDIA_DEVICE_TYPE)AgoraJson.GetData(jsonData, "deviceType") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onIntraRequestReceivedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnIntraRequestReceived( AgoraJson.JsonToStruct(jsonData, "connection") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onUplinkNetworkInfoUpdated": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnUplinkNetworkInfoUpdated( AgoraJson.JsonToStruct(jsonData, "info") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onDownlinkNetworkInfoUpdated": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnDownlinkNetworkInfoUpdated( AgoraJson.JsonToStruct(jsonData, "info") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onVideoSourceFrameSizeChangedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnVideoSourceFrameSizeChanged( AgoraJson.JsonToStruct(jsonData, "connection"), (VIDEO_SOURCE_TYPE)AgoraJson.GetData(jsonData, "sourceType"), (int)AgoraJson.GetData(jsonData, "width"), (int)AgoraJson.GetData(jsonData, "height") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onEncryptionErrorEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnEncryptionError( AgoraJson.JsonToStruct(jsonData, "connection"), (ENCRYPTION_ERROR_TYPE)AgoraJson.GetData(jsonData, "errorType") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onUploadLogResultEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnUploadLogResult( AgoraJson.JsonToStruct(jsonData, "connection"), (string)AgoraJson.GetData(jsonData, "requestId"), (bool)AgoraJson.GetData(jsonData, "success"), (UPLOAD_ERROR_REASON)AgoraJson.GetData(jsonData, "reason") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onUserAccountUpdatedEx": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnUserAccountUpdated( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (string)AgoraJson.GetData(jsonData, "userAccount") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onAudioRoutingChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnAudioRoutingChanged( (int)AgoraJson.GetData(jsonData, "routing") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onPermissionError": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnPermissionError( (PERMISSION_TYPE)AgoraJson.GetData(jsonData, "permissionType") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onExtensionEvent": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnExtensionEvent( (string)AgoraJson.GetData(jsonData, "provider"), (string)AgoraJson.GetData(jsonData, "extension"), (string)AgoraJson.GetData(jsonData, "key"), (string)AgoraJson.GetData(jsonData, "value") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onExtensionStarted": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnExtensionStarted( (string)AgoraJson.GetData(jsonData, "provider"), (string)AgoraJson.GetData(jsonData, "extension") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onExtensionStopped": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnExtensionStopped( (string)AgoraJson.GetData(jsonData, "provider"), (string)AgoraJson.GetData(jsonData, "extension") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "onExtensionError": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnExtensionError( (string)AgoraJson.GetData(jsonData, "provider"), (string)AgoraJson.GetData(jsonData, "extension"), (int)AgoraJson.GetData(jsonData, "error"), (string)AgoraJson.GetData(jsonData, "message") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "DirectCdnStreamingEventHandler_onDirectCdnStreamingStateChanged": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnDirectCdnStreamingStateChanged( (DIRECT_CDN_STREAMING_STATE)AgoraJson.GetData(jsonData, "state"), (DIRECT_CDN_STREAMING_ERROR)AgoraJson.GetData(jsonData, "error"), (string)AgoraJson.GetData(jsonData, "message") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; case "DirectCdnStreamingEventHandler_onDirectCdnStreamingStats": #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnDirectCdnStreamingStats( AgoraJson.JsonToStruct(jsonData, "stats") ); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; #endregion no buffer end #region withBuffer start case "onStreamMessageEx": var byteLength = (uint)AgoraJson.GetData(jsonData, "length"); var bufferPtr = (IntPtr)(UInt64)AgoraJson.GetData(jsonData, "data"); var byteData = new byte[byteLength]; if (byteLength != 0) { Marshal.Copy(bufferPtr, byteData, 0, (int)byteLength); } #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID CallbackObject._CallbackQueue.EnQueue(() => { #endif if (EngineEventHandler == null) return; EngineEventHandler.OnStreamMessage( AgoraJson.JsonToStruct(jsonData, "connection"), (uint)AgoraJson.GetData(jsonData, "remoteUid"), (int)AgoraJson.GetData(jsonData, "streamId"), byteData, byteLength, (UInt64)AgoraJson.GetData(jsonData, "sentTs")); #if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_IOS || UNITY_ANDROID }); #endif break; #endregion withBuffer end } } } }