SCRtcPeer.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using LitJson;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. public class SCRtcPeer:BaseConfig
  9. {
  10. [DllImport("NativeCameraPlugin")]
  11. public static extern void SetTextureFromUnity(System.IntPtr texture);
  12. [DllImport("NativeCameraPlugin")]
  13. private static extern IntPtr GetRenderEventFunc();
  14. public string name;
  15. public string peerId;
  16. public string cIdV="";
  17. public bool isAudio;
  18. public bool isVideo;
  19. public string cIdA="";
  20. public Texture2D tex;
  21. public int FPS = 0;
  22. public int volumn = 0;
  23. private int TextureID;
  24. public virtual void setTexture(JsonData data)
  25. {
  26. this.tex = new Texture2D(int.Parse(data["data"]["data"]["w"].ToString()), int.Parse(data["data"]["data"]["h"].ToString()), TextureFormat.RGB24, false);
  27. TextureID = this.tex.GetNativeTexturePtr().ToInt32();
  28. SetTextureFromUnity(this.tex.GetNativeTexturePtr());
  29. SCRtcFactory.Instance.mSCRtcHandle.addTextureID(this.cIdV, TextureID);
  30. }
  31. public virtual void changeVolumn(int v)
  32. {
  33. volumn = v;
  34. }
  35. public virtual void setName(string n)
  36. {
  37. name = n;
  38. }
  39. public virtual void changeTexture(JsonData data)
  40. {
  41. setTexture(data);
  42. }
  43. public virtual void updateTexture()
  44. {
  45. if (TextureID != 0)
  46. {
  47. GL.IssuePluginEvent(GetRenderEventFunc(), TextureID);
  48. }
  49. }
  50. public virtual void setInfo(string type, string id,bool isOpen)
  51. {
  52. if (type == "video")
  53. {
  54. this.cIdV = id;
  55. isVideo = isOpen;
  56. }
  57. else
  58. {
  59. this.cIdA = id;
  60. isAudio = isOpen;
  61. }
  62. }
  63. }