using SUIFW; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using XRTool.Util; public class RemoteRtc : SCRtcManager { public Texture2D NoView; public Texture2D NoUser; public Camera cam; public RawImage meshRender; public static RemoteRtc Instance; public List fileConfiglist = new List(); // Start is called before the first frame update void Start() { WSHandler.Rtc.onRtcState += onRtcState; DontDestroyOnLoad(this.gameObject); Instance = this; } void onRtcState(string state) { if (state == "joinRoom") { string baseUIFormsName = UIManager.GetInstance().GetCurrentShowUIForms(); if (baseUIFormsName != "") { UIManager.GetInstance().CloseOrReturnUIForms(baseUIFormsName); UIManager.GetInstance().ShowUIForms(SysConst.RoomMainForms); } } if (state == "joined" || state == "closed") { if (RoomOtherUser.Instance) { RoomOtherUser.Instance.UpdateList(); } } } public void setVolume(float f) { // SCRtcFactory.Instance.mSCRtcHandle.audioMeChange(f); } public void setVolume(string cid, float f) { // SCRtcFactory.Instance.mSCRtcHandle.audioPeerChange(cid, f); } public void sendMic(bool boo) { SCRtcFactory.Instance.mSCRtcHandle.sendMic(boo); } public void sendVideo(bool boo) { SCRtcFactory.Instance.mSCRtcHandle.sendVideo(boo); } public void muteVideo(bool boo) { SCRtcFactory.Instance.mSCRtcHandle.sendVideo(boo); } public void muteAudio(bool boo) { SCRtcFactory.Instance.mSCRtcHandle.sendVideo(boo); } public void closeRev(string id) { SCRtcFactory.Instance.mSCRtcHandle.closeRev(id); } public void startRev(string id) { SCRtcFactory.Instance.mSCRtcHandle.openRev(id); } public RenderTexture rt; public void startCamera() { if (rt == null) { rt = new RenderTexture(CustomInfo.mWidth, CustomInfo.mHight, 1); } cam.targetTexture = rt; me.setMyCamera(rt); meshRender.gameObject.SetActive(true); } public void stopCamera() { meshRender.gameObject.SetActive(false); } public void openSpeaker() { SCRtcFactory.Instance.mSCRtcHandle.openSpeaker(); } public CustomMe me; public CustomPeerList customPeerList; public void start(string roomID) { CustomInfo.RoomId = roomID; InitListener(); SCRtcConfig sconfig = new SCRtcConfig(); sconfig.Url = CustomInfo.url; sconfig.Post = CustomInfo.POST; sconfig.RoomId = CustomInfo.RoomId; sconfig.Token = UserInfo.User_Token; sconfig.disPlayName = UserInfo.Account; sconfig.roomPwd = CustomInfo.roomPwd; sconfig.isRevAllAudio = true; sconfig.isRevAllVideo = true; sconfig.isSendAudio = false; sconfig.isSendVideo = false; sconfig.mWidth = CustomInfo.mWidth; sconfig.mHight = CustomInfo.mHight; sconfig.FPS = CustomInfo.FPS; me = new CustomMe(); customPeerList = new CustomPeerList(); SCRtcFactory.Instance.init(sconfig, this, me, customPeerList); } //关闭RTC public void Close() { SCRtcFactory.Instance.Close(); if (SCRtcFactory.Instance != null && SCRtcFactory.Instance.mSCRtcPeers != null) { SCRtcFactory.Instance.mSCRtcPeers.initPeers(); } } void Update() { SCRtcFactory.Instance.Update(); } //public void changeViewClose() //{ // CustomInfo.isCloseView = true; // cam.cullingMask = 1 << 9; // WSHandler.Rtc.onRtcState("changeView"); //} //public void changeViewOpen() //{ // CustomInfo.isCloseView = false; // cam.cullingMask = -1; // WSHandler.Rtc.onRtcState("changeView"); //} private void OnDestroy() { WSHandler.Rtc.onRtcState -= onRtcState; } }