123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- 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<FileConfig> fileConfiglist = new List<FileConfig>();
- // 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;
- }
- }
|