InboundRTPStreamGraphView.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using UnityEngine.UIElements;
  2. namespace Unity.WebRTC.Editor
  3. {
  4. internal class InboundRTPStreamGraphView
  5. {
  6. private GraphView firCountGraph = new GraphView("firCount");
  7. private GraphView pliCountGraph = new GraphView("pliCount");
  8. private GraphView nackCountGraph = new GraphView("nackCount");
  9. private GraphView sliCountGraph = new GraphView("sliCount");
  10. private GraphView qpSumGraph = new GraphView("qpSum");
  11. private GraphView packetsReceivedGraph = new GraphView("packetsReceived");
  12. private GraphView bytesReceivedGraph = new GraphView("bytesReceived");
  13. private GraphView headerBytesReceivedGraph = new GraphView("headerBytesReceived");
  14. private GraphView packetsLostGraph = new GraphView("packetsLost");
  15. private GraphView jitterGraph = new GraphView("jitter");
  16. private GraphView packetsDiscardedGraph = new GraphView("packetsDiscarded");
  17. private GraphView packetsRepairedGraph = new GraphView("packetsRepaired");
  18. private GraphView burstPacketsLostGraph = new GraphView("burstPacketsLost");
  19. private GraphView burstPacketsDiscardedGraph = new GraphView("burstPacketsDiscarded");
  20. private GraphView burstLossCountGraph = new GraphView("burstLossCount");
  21. private GraphView burstDiscardCountGraph = new GraphView("burstDiscardCount");
  22. private GraphView burstLossRateGraph = new GraphView("burstLossRate");
  23. private GraphView burstDiscardRateGraph = new GraphView("burstDiscardRate");
  24. private GraphView gapLossRateGraph = new GraphView("gapLossRate");
  25. private GraphView gapDiscardRateGraph = new GraphView("gapDiscardRate");
  26. private GraphView framesDecodedGraph = new GraphView("framesDecoded");
  27. private GraphView keyFramesDecodedGraph = new GraphView("keyFramesDecoded");
  28. public void AddInput(RTCInboundRTPStreamStats input)
  29. {
  30. var timestamp = input.UtcTimeStamp;
  31. firCountGraph.AddInput(timestamp, input.firCount);
  32. pliCountGraph.AddInput(timestamp, input.pliCount);
  33. nackCountGraph.AddInput(timestamp, input.nackCount);
  34. qpSumGraph.AddInput(timestamp, input.qpSum);
  35. packetsReceivedGraph.AddInput(timestamp, input.packetsReceived);
  36. bytesReceivedGraph.AddInput(timestamp, input.bytesReceived);
  37. headerBytesReceivedGraph.AddInput(timestamp, input.headerBytesReceived);
  38. packetsLostGraph.AddInput(timestamp, input.packetsLost);
  39. jitterGraph.AddInput(timestamp, (float)input.jitter);
  40. packetsDiscardedGraph.AddInput(timestamp, input.packetsDiscarded);
  41. packetsRepairedGraph.AddInput(timestamp, input.packetsRepaired);
  42. burstPacketsLostGraph.AddInput(timestamp, input.burstPacketsLost);
  43. burstPacketsDiscardedGraph.AddInput(timestamp, input.burstPacketsDiscarded);
  44. burstLossCountGraph.AddInput(timestamp, input.burstLossCount);
  45. burstDiscardCountGraph.AddInput(timestamp, input.burstDiscardCount);
  46. burstLossRateGraph.AddInput(timestamp, (float)input.burstLossRate);
  47. burstDiscardRateGraph.AddInput(timestamp, (float)input.burstDiscardRate);
  48. gapLossRateGraph.AddInput(timestamp, (float)input.gapLossRate);
  49. gapDiscardRateGraph.AddInput(timestamp, (float)input.gapDiscardRate);
  50. framesDecodedGraph.AddInput(timestamp, input.framesDecoded);
  51. keyFramesDecodedGraph.AddInput(timestamp, input.keyFramesDecoded);
  52. }
  53. public VisualElement Create()
  54. {
  55. var container = new VisualElement {style = {flexDirection = FlexDirection.Row, flexWrap = Wrap.Wrap}};
  56. container.Add(firCountGraph.Create());
  57. container.Add(pliCountGraph.Create());
  58. container.Add(nackCountGraph.Create());
  59. container.Add(sliCountGraph.Create());
  60. container.Add(qpSumGraph.Create());
  61. container.Add(packetsReceivedGraph.Create());
  62. container.Add(bytesReceivedGraph.Create());
  63. container.Add(headerBytesReceivedGraph.Create());
  64. container.Add(packetsLostGraph.Create());
  65. container.Add(jitterGraph.Create());
  66. container.Add(packetsDiscardedGraph.Create());
  67. container.Add(packetsRepairedGraph.Create());
  68. container.Add(burstPacketsLostGraph.Create());
  69. container.Add(burstPacketsDiscardedGraph.Create());
  70. container.Add(burstLossCountGraph.Create());
  71. container.Add(burstDiscardCountGraph.Create());
  72. container.Add(burstLossRateGraph.Create());
  73. container.Add(burstDiscardRateGraph.Create());
  74. container.Add(gapLossRateGraph.Create());
  75. container.Add(gapDiscardRateGraph.Create());
  76. container.Add(framesDecodedGraph.Create());
  77. container.Add(keyFramesDecodedGraph.Create());
  78. return container;
  79. }
  80. }
  81. }