using LitJson; using System.Collections.Generic; using UnityEngine; public class SCRtcAndroidEngine : SCRtcEngine { public void setProduce(string msg) { return; #if UNITY_ANDROID && !UNITY_EDITOR CurrentRtcActivity.Call("setProduce", msg); #endif } public string getwifi() { return ""; #if UNITY_ANDROID && !UNITY_EDITOR return CurrentRtcActivity.Call("ObtainWifiInfo"); #endif return ""; } //调节他人音量 public double GetaudioMe() { double d = 0.0f; return d; #if UNITY_ANDROID && !UNITY_EDITOR d = CurrentRtcActivity.Call("GetaudioMe"); #endif return d; } //调节他人音量 public double GetaudioPeer(string consumerId) { double d = 0.0f; return d; #if UNITY_ANDROID && !UNITY_EDITOR d = CurrentRtcActivity.Call("GetaudioPeer", consumerId); #endif return d; } SDKCallbackListener sdk; //增加监听 public void addListener() { if (sdk == null) { sdk = new SDKCallbackListener(); #if UNITY_ANDROID&& !UNITY_EDITOR // CurrentRtcActivity.Call("initSDK", sdk); #endif } } override public void send(Queue jsondata) { JsonData data; if (jsondata.Count > 0) { data = jsondata.Dequeue(); switch (data["action"].ToString()) { case "InitRTC": #if UNITY_ANDROID && !UNITY_EDITOR // addListener(); // CurrentRtcActivity.Call("SetConfig", data["data"]["RoomId"].ToString(), data["data"]["roomPwd"].ToString(),bool.Parse(data["data"]["isSendAudio"].ToString()), bool.Parse(data["data"]["isSendVideo"].ToString()), bool.Parse(data["data"]["isRevAllAudio"].ToString()), bool.Parse(data["data"]["isRevAllVideo"].ToString()), int.Parse(data["data"]["mWidth"].ToString()), int.Parse(data["data"]["mHight"].ToString()), int.Parse(data["data"]["FPS"].ToString()),false); // CurrentRtcActivity.Call("InitSocket", data["data"]["Url"].ToString()); #endif break; case "changeVideo": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.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 // CurrentRtcActivity.Call("setMute",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "sendVideo": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("sendVideo",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "enableVideoOnly": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("enableVideoOnly",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "enableAudioOnly": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("enableAudioOnly",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "openSpeaker": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("openSpeaker",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "closeSpeaker": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("closeSpeaker",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "setVolume": #if UNITY_ANDROID && !UNITY_EDITOR CurrentRtcActivity.Call("setVolume",int.Parse(data["data"]["i"].ToString())); #endif break; case "sendMic": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("sendMic",bool.Parse(data["data"]["boo"].ToString())); #endif break; case "openRev": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("openRev",data["data"]["consumerId"].ToString()); #endif break; case "closeRev": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("closeRev",data["data"]["consumerId"].ToString()); #endif break; case "Close": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("close"); #endif SCRtcFactory.Instance.isClose = true; break; case "addTextureID": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("addTextureID", data["data"]["peerId"].ToString(), int.Parse(data["data"]["textureID"].ToString())); #endif break; case "audioPeerChange": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("audioPeerChange", data["data"]["consumerId"].ToString(), double.Parse(data["data"]["d"].ToString())); #endif break; case "audioMeChange": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("audioMeChange", double.Parse(data["data"]["d"].ToString())); #endif break; case "changePeerVideo": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("changePeerVideo", data["data"]["consumerId"].ToString(), int.Parse(data["data"]["fps"].ToString())); #endif break; case "changeName": #if UNITY_ANDROID && !UNITY_EDITOR CurrentRtcActivity.Call("changeName", data["data"]["name"].ToString()); #endif break; case "joinRoom": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("joinRoom", data["data"]["req"].ToString()); #endif break; case "GetaudioMe": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("GetaudioMe"); #endif break; case "GetaudioPeer": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("GetaudioPeer"); #endif break; case "onSocketMesseage": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("onSocketMesseage", data["data"].ToString()); #endif break; case "initRtpCapabilities": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("initRtpCapabilities", data["data"].ToString()); #endif break; case "createRecvTransport": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("createRecvTransport", data["data"].ToString()); #endif break; case "createSendTransport": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("createSendTransport", data["data"].ToString()); #endif break; case "onNewConsumer": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("onNewConsumer", data["data"].ToString(), data["id"].ToString()); #endif break; case "getDevice": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("getDevice"); #endif break; case "setProduce": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("setProduce", data["data"].ToString()); #endif break; case "startCamera": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("startCamera"); #endif break; case "stopCamera": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("stopCamera"); #endif break; case "addCameraLocal": #if UNITY_ANDROID && !UNITY_EDITOR // CurrentRtcActivity.Call("addCameraLocal", int.Parse(data["L"].ToString())); #endif break; } } } }