ImageClipHelper.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using fis.media.Library.Media.Players;
  2. using fis.media.Library.Media.Publisher;
  3. using fis.media.Library.Players;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace fis.media.Helpers
  10. {
  11. public class ImageClipHelper
  12. {
  13. private static TerminalLiveDataBytes _termialliveDataBytes = new TerminalLiveDataBytes();
  14. public static bool ClippedChannelData(List<PlayerChannel> playerChannels, VideoFrameData videoFrameData)
  15. {
  16. var isClipped = false;
  17. foreach (var c in playerChannels)
  18. {
  19. UpdateChannels(c, videoFrameData, ref isClipped);
  20. }
  21. return true;
  22. }
  23. private static void UpdateChannels(PlayerChannel c, VideoFrameData videoFrameData, ref bool isClipped)
  24. {
  25. var layerType = c.MemberLayerConfig.LayerType;
  26. if (layerType == LayerType.Single)
  27. {
  28. c.UpdateFrame(videoFrameData.Data,videoFrameData.Width, videoFrameData.Height);
  29. return;
  30. }
  31. if (layerType == LayerType.WithOneCamera)
  32. {
  33. var deskTopWidth = c.MemberLayerConfig.RegionInfo.MainRegion.Width;
  34. var deskTopHeight = c.MemberLayerConfig.RegionInfo.MainRegion.Height;
  35. var cameraWidth = c.MemberLayerConfig.RegionInfo.SideRegionOne.Width;
  36. var cameraHeight= c.MemberLayerConfig.RegionInfo.SideRegionOne.Height;
  37. var terminalBytesSize = deskTopWidth * deskTopHeight * 4;
  38. var cameraBytesSize = cameraWidth * cameraHeight * 4;
  39. if (isClipped)
  40. {
  41. if (c.ChannelName == ChannelNameEnum.Main)
  42. {
  43. c.UpdateFrame(_termialliveDataBytes.TerminalData, deskTopWidth, deskTopHeight);
  44. }
  45. if (c.ChannelName == ChannelNameEnum.SideOne)
  46. {
  47. c.UpdateFrame(_termialliveDataBytes.CameraData, cameraWidth,cameraHeight);
  48. }
  49. return;
  50. }
  51. _termialliveDataBytes.Update(videoFrameData.Data, terminalBytesSize, cameraBytesSize,
  52. deskTopWidth, deskTopHeight, c.MemberLayerConfig.RegionInfo.Width);
  53. isClipped = true;
  54. if (c.ChannelName == ChannelNameEnum.Main)
  55. {
  56. c.UpdateFrame(_termialliveDataBytes.TerminalData, deskTopWidth, deskTopHeight);
  57. }
  58. if (c.ChannelName == ChannelNameEnum.SideOne)
  59. {
  60. c.UpdateFrame(_termialliveDataBytes.CameraData, cameraWidth, cameraHeight);
  61. }
  62. }
  63. }
  64. }
  65. }