TextureHelper.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Scenes.scripts.utils;
  2. using UnityEngine;
  3. //½ÓÊÕ·½
  4. public class TextureHelper
  5. {
  6. private static string UXR_TEXTURE_Reviever = "Receiver.";
  7. private static AndroidJavaObject textureHolder;
  8. public static void Create()
  9. {
  10. Debug.Log("TextureHelper Create");
  11. //´´½¨½ÓÊÕ¶Ë
  12. new AndroidJavaObject("com.rokid.mrcplugin.codingtransmission.textureholder.TextureHolder");
  13. }
  14. public static void Start(string ip,int unityTextureId, int width, int height, int frameRate = 60, int bitRate = 1024)
  15. {
  16. Debug.Log($"TextureHelper.Start IP - {ip} TexID - {unityTextureId} Width - {width} Height - {height} FrameRate - {frameRate} BitRate - {bitRate}");
  17. CallBridge.callAndroid(Request.Build()
  18. .Name(UXR_TEXTURE_Reviever + "start")
  19. .Param("ip", ip)
  20. .Param("unityTextureId", unityTextureId)
  21. .Param("width", width)
  22. .Param("height", height)
  23. .Param("frameRate", frameRate)
  24. .Param("bitRate", bitRate * 1024));
  25. textureHolder = CallBridge.callAndroid(Request.Build()
  26. .Name(UXR_TEXTURE_Reviever + "getInstance"));
  27. }
  28. public static void _updateTexture()
  29. {
  30. //Debug.Log("TextureHelper _updateTexture");
  31. textureHolder.Call("updateTexture");
  32. }
  33. public static bool _isFrameUpdated()
  34. {
  35. if(textureHolder == null)
  36. {
  37. return false;
  38. }
  39. return textureHolder.Call<bool>("isUpdateFrame");
  40. }
  41. public static void Release()
  42. {
  43. Debug.Log("TextureHelper.Release");
  44. CallBridge.callAndroid(Request.Build()
  45. .Name(UXR_TEXTURE_Reviever + "release"));
  46. //textureHolder.Call("release");
  47. }
  48. //public static void initTCP()
  49. //{
  50. // Debug.Log("TextureHelper initTCP");
  51. // CallBridge.callAndroid(Request.Build()
  52. // .Name(UXR_TEXTURE_Reviever + "initTCP"));
  53. //}
  54. public static void _setTextureModeListener(string callObj, string method)
  55. {
  56. CallBridge.callAndroid(Request.Build()
  57. .Name(UXR_TEXTURE_Reviever + "setTextureModeListener")
  58. .AndroidCallback(CallBridge.createCallback(callObj, method)));
  59. }
  60. }