MediaStreamTrackGraphView.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using UnityEngine.UIElements;
  2. namespace Unity.WebRTC.Editor
  3. {
  4. internal class MediaStreamTrackGraphView
  5. {
  6. private GraphView jitterBufferDelayGraph = new GraphView("jitterBufferDelay");
  7. private GraphView jitterBufferEmittedCountGraph = new GraphView("jitterBufferEmittedCount");
  8. private GraphView frameWidthGraph = new GraphView("frameWidth");
  9. private GraphView frameHeightGraph = new GraphView("frameHeight");
  10. private GraphView framesPerSecondGraph = new GraphView("framesPerSecond");
  11. private GraphView framesSentGraph = new GraphView("framesSent");
  12. private GraphView hugeFramesSentGraph = new GraphView("hugeFramesSent");
  13. private GraphView framesReceivedGraph = new GraphView("framesReceived");
  14. private GraphView framesDecodedGraph = new GraphView("framesDecoded");
  15. private GraphView framesDroppedGraph = new GraphView("framesDropped");
  16. private GraphView framesCorruptedGraph = new GraphView("framesCorrupted");
  17. private GraphView partialFramesLostGraph = new GraphView("partialFramesLost");
  18. private GraphView fullFramesLostGraph = new GraphView("fullFramesLost");
  19. private GraphView audioLevelGraph = new GraphView("audioLevel");
  20. private GraphView totalAudioEnergyGraph = new GraphView("totalAudioEnergy");
  21. private GraphView echoReturnLossGraph = new GraphView("echoReturnLoss");
  22. private GraphView echoReturnLossEnhancementGraph = new GraphView("echoReturnLossEnhancement");
  23. private GraphView totalSamplesReceivedGraph = new GraphView("totalSamplesReceived");
  24. private GraphView totalSamplesDurationGraph = new GraphView("totalSamplesDuration");
  25. private GraphView concealedSamplesGraph = new GraphView("concealedSamples");
  26. private GraphView silentConcealedSamplesGraph = new GraphView("silentConcealedSamples");
  27. private GraphView concealmentEventsGraph = new GraphView("concealmentEvents");
  28. private GraphView insertedSamplesForDecelerationGraph = new GraphView("insertedSamplesForDeceleration");
  29. private GraphView removedSamplesForAccelerationGraph = new GraphView("removedSamplesForAcceleration");
  30. private GraphView jitterBufferFlushesGraph = new GraphView("jitterBufferFlushes");
  31. private GraphView delayedPacketOutageSamplesGraph = new GraphView("delayedPacketOutageSamples");
  32. private GraphView relativePacketArrivalDelayGraph = new GraphView("relativePacketArrivalDelay");
  33. private GraphView interruptionCountGraph = new GraphView("interruptionCount");
  34. private GraphView totalInterruptionDurationGraph = new GraphView("totalInterruptionDuration");
  35. private GraphView freezeCountGraph = new GraphView("freezeCount");
  36. private GraphView pauseCountGraph = new GraphView("pauseCount");
  37. private GraphView totalFreezesDurationGraph = new GraphView("totalFreezesDuration");
  38. private GraphView totalPausesDurationGraph = new GraphView("totalPausesDuration");
  39. private GraphView totalFramesDurationGraph = new GraphView("totalFramesDuration");
  40. private GraphView sumOfSquaredFramesDurationGraph = new GraphView("sumOfSquaredFramesDuration");
  41. public void AddInput(RTCMediaStreamTrackStats input)
  42. {
  43. var timestamp = input.UtcTimeStamp;
  44. jitterBufferDelayGraph.AddInput(timestamp, (float)input.jitterBufferDelay);
  45. jitterBufferEmittedCountGraph.AddInput(timestamp, input.jitterBufferEmittedCount);
  46. frameWidthGraph.AddInput(timestamp, input.frameWidth);
  47. frameHeightGraph.AddInput(timestamp, input.frameHeight);
  48. framesPerSecondGraph.AddInput(timestamp, (float)input.framesPerSecond);
  49. framesSentGraph.AddInput(timestamp, input.framesSent);
  50. hugeFramesSentGraph.AddInput(timestamp, input.hugeFramesSent);
  51. framesReceivedGraph.AddInput(timestamp, input.framesReceived);
  52. framesDecodedGraph.AddInput(timestamp, input.framesDecoded);
  53. framesDroppedGraph.AddInput(timestamp, input.framesDropped);
  54. framesCorruptedGraph.AddInput(timestamp, input.framesCorrupted);
  55. partialFramesLostGraph.AddInput(timestamp, input.partialFramesLost);
  56. fullFramesLostGraph.AddInput(timestamp, input.fullFramesLost);
  57. audioLevelGraph.AddInput(timestamp, (float)input.audioLevel);
  58. totalAudioEnergyGraph.AddInput(timestamp, (float)input.totalAudioEnergy);
  59. echoReturnLossGraph.AddInput(timestamp, (float)input.echoReturnLoss);
  60. echoReturnLossEnhancementGraph.AddInput(timestamp, (float)input.echoReturnLossEnhancement);
  61. totalSamplesReceivedGraph.AddInput(timestamp, input.totalSamplesReceived);
  62. totalSamplesDurationGraph.AddInput(timestamp, (float)input.totalSamplesDuration);
  63. concealedSamplesGraph.AddInput(timestamp, input.concealedSamples);
  64. silentConcealedSamplesGraph.AddInput(timestamp, input.silentConcealedSamples);
  65. concealmentEventsGraph.AddInput(timestamp, input.concealmentEvents);
  66. insertedSamplesForDecelerationGraph.AddInput(timestamp, input.insertedSamplesForDeceleration);
  67. removedSamplesForAccelerationGraph.AddInput(timestamp, input.removedSamplesForAcceleration);
  68. jitterBufferFlushesGraph.AddInput(timestamp, input.jitterBufferFlushes);
  69. delayedPacketOutageSamplesGraph.AddInput(timestamp, input.delayedPacketOutageSamples);
  70. relativePacketArrivalDelayGraph.AddInput(timestamp, (float)input.relativePacketArrivalDelay);
  71. interruptionCountGraph.AddInput(timestamp, input.interruptionCount);
  72. totalInterruptionDurationGraph.AddInput(timestamp, (float)input.totalInterruptionDuration);
  73. freezeCountGraph.AddInput(timestamp, input.freezeCount);
  74. pauseCountGraph.AddInput(timestamp, input.pauseCount);
  75. totalFreezesDurationGraph.AddInput(timestamp, (float)input.totalFreezesDuration);
  76. totalPausesDurationGraph.AddInput(timestamp, (float)input.totalPausesDuration);
  77. totalFramesDurationGraph.AddInput(timestamp, (float)input.totalFramesDuration);
  78. sumOfSquaredFramesDurationGraph.AddInput(timestamp, (float)input.sumOfSquaredFramesDuration);
  79. }
  80. public VisualElement Create()
  81. {
  82. var container = new VisualElement {style = {flexDirection = FlexDirection.Row, flexWrap = Wrap.Wrap}};
  83. container.Add(jitterBufferDelayGraph.Create());
  84. container.Add(jitterBufferEmittedCountGraph.Create());
  85. container.Add(frameWidthGraph.Create());
  86. container.Add(frameHeightGraph.Create());
  87. container.Add(framesPerSecondGraph.Create());
  88. container.Add(framesSentGraph.Create());
  89. container.Add(hugeFramesSentGraph.Create());
  90. container.Add(framesReceivedGraph.Create());
  91. container.Add(framesDecodedGraph.Create());
  92. container.Add(framesDroppedGraph.Create());
  93. container.Add(framesCorruptedGraph.Create());
  94. container.Add(partialFramesLostGraph.Create());
  95. container.Add(fullFramesLostGraph.Create());
  96. container.Add(audioLevelGraph.Create());
  97. container.Add(totalAudioEnergyGraph.Create());
  98. container.Add(echoReturnLossGraph.Create());
  99. container.Add(echoReturnLossEnhancementGraph.Create());
  100. container.Add(totalSamplesReceivedGraph.Create());
  101. container.Add(totalSamplesDurationGraph.Create());
  102. container.Add(concealedSamplesGraph.Create());
  103. container.Add(silentConcealedSamplesGraph.Create());
  104. container.Add(concealmentEventsGraph.Create());
  105. container.Add(insertedSamplesForDecelerationGraph.Create());
  106. container.Add(removedSamplesForAccelerationGraph.Create());
  107. container.Add(jitterBufferFlushesGraph.Create());
  108. container.Add(delayedPacketOutageSamplesGraph.Create());
  109. container.Add(relativePacketArrivalDelayGraph.Create());
  110. container.Add(interruptionCountGraph.Create());
  111. container.Add(totalInterruptionDurationGraph.Create());
  112. container.Add(freezeCountGraph.Create());
  113. container.Add(pauseCountGraph.Create());
  114. container.Add(totalFreezesDurationGraph.Create());
  115. container.Add(totalPausesDurationGraph.Create());
  116. container.Add(totalFramesDurationGraph.Create());
  117. container.Add(sumOfSquaredFramesDurationGraph.Create());
  118. return container;
  119. }
  120. }
  121. }