TRTCVideoFrameData.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. namespace Vinno.FIS.TRTCClient.ImageSender
  3. {
  4. internal class TRTCVideoFrameData : IDisposable
  5. {
  6. private readonly Action<object> _dispose;
  7. private bool _disposed;
  8. /// <summary>
  9. /// Gets the width of image.
  10. /// </summary>
  11. public int Width { get; set; }
  12. /// <summary>
  13. /// Gets the height of the image.
  14. /// </summary>
  15. public int Height { get; set; }
  16. /// <summary>
  17. /// Gets the data of the image, which is in Bgr32 format.
  18. /// </summary>
  19. public byte[] Data { get; set; }
  20. /// <summary>
  21. /// It's a bitmap on android and uiimage on IOS
  22. /// </summary>
  23. public object ImageData { get; set; }
  24. public string Key { get; set; }
  25. public TRTCVideoFrameData(int width, int height, byte[] data, Action<object> dispose = null)
  26. {
  27. Width = width;
  28. Height = height;
  29. Data = data;
  30. _dispose = dispose;
  31. }
  32. ~TRTCVideoFrameData()
  33. {
  34. Dispose();
  35. }
  36. public void Dispose()
  37. {
  38. if (!_disposed)
  39. {
  40. _dispose?.Invoke(ImageData);
  41. _disposed = true;
  42. }
  43. }
  44. }
  45. }