SCRtcPeer.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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
  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 avater;
  17. public bool isSn;
  18. public string cIdV="";
  19. public bool isAudio;
  20. public bool isVideo;
  21. public string cIdA="";
  22. public Texture2D tex;
  23. public int FPS = 0;
  24. public float volumn = 0.5f;
  25. private int TextureID;
  26. public virtual void setTexture(JsonData data)
  27. {
  28. this.tex = new Texture2D(int.Parse(data["data"]["data"]["w"].ToString()), int.Parse(data["data"]["data"]["h"].ToString()), TextureFormat.RGB24, false);
  29. TextureID = this.tex.GetNativeTexturePtr().ToInt32();
  30. SetTextureFromUnity(this.tex.GetNativeTexturePtr());
  31. SCRtcFactory.Instance.mSCRtcHandle.addTextureID(this.cIdV, TextureID);
  32. }
  33. public virtual void changeVolumn(int v)
  34. {
  35. volumn = v;
  36. }
  37. public virtual void setName(string n)
  38. {
  39. name = n;
  40. }
  41. public virtual void changeTexture(JsonData data)
  42. {
  43. setTexture(data);
  44. }
  45. public virtual void updateTexture()
  46. {
  47. if (TextureID != 0)
  48. {
  49. GL.IssuePluginEvent(GetRenderEventFunc(), TextureID);
  50. }
  51. }
  52. public virtual void setInfo(string type, string id,bool isOpen)
  53. {
  54. if (type == "video")
  55. {
  56. Debug.Log("huan......");
  57. this.cIdV = id;
  58. isVideo = isOpen;
  59. }
  60. else
  61. {
  62. this.cIdA = id;
  63. isAudio = isOpen;
  64. }
  65. }
  66. }