ImageSenderBaseV2.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Drawing;
  3. namespace Vinno.vCloud.FIS.CrossPlatform.Android.LiveVideo
  4. {
  5. internal abstract class ImageSenderBaseV2
  6. {
  7. protected int SendImageWidth;
  8. protected int SendImageHeight;
  9. protected byte[] PushFrameBuffer;
  10. protected byte[] YuvPushFrameBuffer;
  11. protected readonly int ChannelNumer = 4;
  12. protected Rectangle ImageRectangle;
  13. protected ImageSenderBaseV2()
  14. {
  15. }
  16. protected void ResizeBuffer(ref byte[] buffer, int size)
  17. {
  18. if (buffer == null)
  19. {
  20. buffer = new byte[size];
  21. }
  22. else if (buffer.Length != size)
  23. {
  24. Array.Resize(ref buffer, size);
  25. }
  26. }
  27. protected void ArgbToYuvI420(byte[] rgbData, int width, int height)
  28. {
  29. ResizeBuffer(ref YuvPushFrameBuffer, width * height * 3 / 2);
  30. YuvHelper.ConvertABGRToI420(rgbData, width, height, YuvPushFrameBuffer);
  31. }
  32. }
  33. }