using LitJson; using System.Collections.Generic; using UnityEngine; public class SCRtcAndroidEngine : SCRtcEngine { //调节他人音量 public double GetaudioMe() { double d = 0.0f; #if UNITY_ANDROID && !UNITY_EDITOR d = CurrentActivity.Call("GetaudioMe"); #endif return d; } //调节他人音量 public double GetaudioPeer(string consumerId) { double d = 0.0f; #if UNITY_ANDROID && !UNITY_EDITOR d = CurrentActivity.Call("GetaudioPeer", consumerId); #endif return d; } SDKCallbackListener sdk; //增加监听 public void addListener() { if (sdk == null) { sdk = new SDKCallbackListener(); UnityEngine.Debug.Log("addListener"); #if UNITY_ANDROID&& !UNITY_EDITOR CurrentActivity.Call("initSDK", sdk); #endif Debug.Log("addListenerEND"); ; } } override public void send(Queue jsondata) { JsonData data; if (jsondata.Count > 0) { Debug.Log("close22222333"); data = jsondata.Dequeue(); Debug.Log("close22222" + data["action"].ToString()); switch (data["action"].ToString()) { case "InitRTC": #if UNITY_ANDROID && !UNITY_EDITOR addListener(); CurrentActivity.Call("SetConfig", data["data"]["RoomId"].ToString(), data["data"]["roomPwd"].ToString(),bool.Parse(data["data"]["isSendAudio"].ToString()), bool.Parse(data["data"]["isSendVideo"].ToString()), bool.Parse(data["data"]["isRevAllAudio"].ToString()), bool.Parse(data["data"]["isRevAllVideo"].ToString()), int.Parse(data["data"]["mWidth"].ToString()), int.Parse(data["data"]["mHight"].ToString()), int.Parse(data["data"]["FPS"].ToString())); CurrentActivity.Call("InitSocket", data["data"]["Url"].ToString(), int.Parse(data["data"]["Post"].ToString())); #endif break; case "changeVideo": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("changeVideo",int.Parse(data["data"]["w"].ToString()),int.Parse(data["data"]["h"].ToString()),int.Parse(data["data"]["fps"].ToString())); #endif break; case "setMute": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("setMute",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "sendVideo": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("sendVideo",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "enableVideoOnly": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("enableVideoOnly",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "enableAudioOnly": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("enableAudioOnly",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "openSpeaker": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("openSpeaker",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "closeSpeaker": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("closeSpeaker",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "setVolume": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("setVolume",int.Parse(data["data"]["i"].ToString())); #endif break; case "sendMic": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("sendMic",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "openRev": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("openRev",data["data"]["consumerId"].ToString()); #endif break; case "closeRev": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("closeRev",data["data"]["consumerId"].ToString()); #endif break; case "Close": Debug.Log("退出房间Start"); #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("close"); #endif Debug.Log("退出房间End"); SCRtcFactory.Instance.isClose = true; break; case "addTextureID": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("addTextureID", data["data"]["peerId"].ToString(), int.Parse(data["data"]["textureID"].ToString())); #endif break; case "audioPeerChange": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("audioPeerChange", data["data"]["consumerId"].ToString(), double.Parse(data["data"]["d"].ToString())); #endif break; case "audioMeChange": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("audioMeChange", double.Parse(data["data"]["d"].ToString())); #endif break; case "changePeerVideo": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("changePeerVideo", data["data"]["consumerId"].ToString(), int.Parse(data["data"]["fps"].ToString())); #endif break; case "changeName": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("changeName", data["data"]["name"].ToString()); #endif break; case "joinRoom": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("joinRoom", data["data"]["req"].ToString()); #endif break; case "GetaudioMe": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("GetaudioMe"); #endif break; case "GetaudioPeer": #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call("GetaudioPeer"); #endif break; } } } }