using LitJson; using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine; using UnityEngine.UI; public class SCRtcPeer { [DllImport("NativeCameraPlugin")] public static extern void SetTextureFromUnity(System.IntPtr texture); [DllImport("NativeCameraPlugin")] private static extern IntPtr GetRenderEventFunc(); public string name; public string peerId; public string cIdV=""; public string cIdA=""; public Texture2D tex; public int FPS = 0; private int TextureID; public virtual void setTexture(JsonData data) { this.tex = new Texture2D(int.Parse(data["data"]["data"]["w"].ToString()), int.Parse(data["data"]["data"]["h"].ToString()), TextureFormat.RGB24, false); TextureID = this.tex.GetNativeTexturePtr().ToInt32(); SetTextureFromUnity(this.tex.GetNativeTexturePtr()); SCRtcFactory.Instance.mSCRtcHandle.addTextureID(this.cIdV, TextureID); } public virtual void setName(string n) { name = n; } public virtual void changeTexture(JsonData data) { setTexture(data); } public virtual void updateTexture() { if (TextureID != 0) { GL.IssuePluginEvent(GetRenderEventFunc(), TextureID); } } public virtual void setInfo(string type, string id) { if (type == "video") { this.cIdV = id; } else { this.cIdA = id; } } }