123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- 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<string>("ObtainWifiInfo");
- #endif
- return "";
- }
- //调节他人音量
- public double GetaudioMe()
- {
- double d = 0.0f;
- return d;
- #if UNITY_ANDROID && !UNITY_EDITOR
- d = CurrentRtcActivity.Call<double>("GetaudioMe");
- #endif
- return d;
- }
- //调节他人音量
- public double GetaudioPeer(string consumerId)
- {
- double d = 0.0f;
- return d;
- #if UNITY_ANDROID && !UNITY_EDITOR
- d = CurrentRtcActivity.Call<double>("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)
- {
- 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;
-
- }
- }
- }
- }
|