TransmissionClient.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using Scenes.scripts.utils;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Runtime.InteropServices;
  5. using UnityEngine;
  6. //���ͷ����ͻ���
  7. public class TransmissionClient
  8. {
  9. private static string UXR_TEXTURE_Send = "Sender.";
  10. private static AndroidJavaObject transmissionClient;
  11. public const int DefaultFrameRate = 60;
  12. public const int DefaultBitRate = 1024;
  13. //Start
  14. public static void Create()
  15. {
  16. Debug.Log("TransmissionClient Create");
  17. //�������Ͷ�
  18. transmissionClient = new AndroidJavaObject("com.rokid.mrcplugin.glass.codingtransmission.TransmissionClient");
  19. }
  20. public static void Start(int unityTextureId, int width, int height, int frameRate = 60, int bitRate = 1024)
  21. {
  22. Debug.Log($"TransmissionClient.Start TexID - {unityTextureId} Width - {width} Height - {height} FrameRate - {frameRate} BitRate - {bitRate}");
  23. CallBridge.callAndroid(Request.Build()
  24. .Name(UXR_TEXTURE_Send + "start")
  25. .Param("unityTextureId", unityTextureId)
  26. .Param("width", width)
  27. .Param("height", height)
  28. .Param("frameRate", frameRate)
  29. .Param("bitRate", bitRate * 1024));
  30. transmissionClient = CallBridge.callAndroid(Request.Build()
  31. .Name(UXR_TEXTURE_Send + "getInstance"));
  32. }
  33. public static void Release()
  34. {
  35. Debug.Log("TransmissionClient Release");
  36. transmissionClient.Call("release");
  37. }
  38. public static void UpdateTextureData()
  39. {
  40. transmissionClient?.Call("updateTextureData");
  41. }
  42. public static void PushTextureByteData(byte[] data, int length)
  43. {
  44. #if !UNITY_EDITOR
  45. TransmissionClient_PushTextureData(data, length);
  46. #endif
  47. transmissionClient.Call("updateTextureData");
  48. }
  49. [DllImport("transmissionlib")]
  50. private static extern void TransmissionClient_PushTextureData(byte[] data, int length);
  51. }