CandidatePairGraphView.cs 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using UnityEngine.UIElements;
  2. namespace Unity.WebRTC.Editor
  3. {
  4. internal class CandidatePairGraphView
  5. {
  6. private GraphView bytesSentGraph = new GraphView("bytesSent");
  7. private GraphView bytesReceivedGraph = new GraphView("bytesReceived");
  8. private GraphView totalRoundTripTimeGraph = new GraphView("totalRoundTripTime");
  9. private GraphView currentRoundTripTimeGraph = new GraphView("currentRoundTripTime");
  10. private GraphView availableOutgoingBitrateGraph = new GraphView("availableOutgoingBitrate");
  11. private GraphView availableIncomingBitrateGraph = new GraphView("availableIncomingBitrate");
  12. private GraphView requestsReceivedGraph = new GraphView("requestsReceived");
  13. private GraphView requestsSentGraph = new GraphView("requestsSent");
  14. private GraphView responsesReceivedGraph = new GraphView("responsesReceived");
  15. private GraphView responsesSentGraph = new GraphView("responsesSent");
  16. private GraphView retransmissionsReceivedGraph = new GraphView("retransmissionsReceived");
  17. private GraphView retransmissionsSentGraph = new GraphView("retransmissionsSent");
  18. private GraphView consentRequestsReceivedGraph = new GraphView("consentRequestsReceived");
  19. private GraphView consentRequestsSentGraph = new GraphView("consentRequestsSent");
  20. private GraphView consentResponsesReceivedGraph = new GraphView("consentResponsesReceived");
  21. private GraphView consentResponsesSentGraph = new GraphView("consentResponsesSent");
  22. public void AddInput(RTCIceCandidatePairStats input)
  23. {
  24. var timestamp = input.UtcTimeStamp;
  25. bytesSentGraph.AddInput(timestamp, input.bytesSent);
  26. bytesReceivedGraph.AddInput(timestamp, input.bytesReceived);
  27. totalRoundTripTimeGraph.AddInput(timestamp, (float)input.totalRoundTripTime);
  28. currentRoundTripTimeGraph.AddInput(timestamp, (float)input.currentRoundTripTime);
  29. availableOutgoingBitrateGraph.AddInput(timestamp, (float)input.availableOutgoingBitrate);
  30. availableIncomingBitrateGraph.AddInput(timestamp, (float)input.availableIncomingBitrate);
  31. requestsReceivedGraph.AddInput(timestamp, input.requestsReceived);
  32. requestsSentGraph.AddInput(timestamp, input.requestsSent);
  33. responsesReceivedGraph.AddInput(timestamp, input.responsesReceived);
  34. responsesSentGraph.AddInput(timestamp, input.responsesSent);
  35. retransmissionsReceivedGraph.AddInput(timestamp, input.retransmissionsReceived);
  36. retransmissionsSentGraph.AddInput(timestamp, input.retransmissionsSent);
  37. consentRequestsReceivedGraph.AddInput(timestamp, input.consentRequestsReceived);
  38. consentRequestsSentGraph.AddInput(timestamp, input.consentRequestsSent);
  39. consentResponsesReceivedGraph.AddInput(timestamp, input.consentResponsesReceived);
  40. consentResponsesSentGraph.AddInput(timestamp, input.consentResponsesSent);
  41. }
  42. public VisualElement Create()
  43. {
  44. var container = new VisualElement {style = {flexDirection = FlexDirection.Row, flexWrap = Wrap.Wrap}};
  45. container.Add(bytesSentGraph.Create());
  46. container.Add(bytesReceivedGraph.Create());
  47. container.Add(totalRoundTripTimeGraph.Create());
  48. container.Add(currentRoundTripTimeGraph.Create());
  49. container.Add(availableOutgoingBitrateGraph.Create());
  50. container.Add(availableIncomingBitrateGraph.Create());
  51. container.Add(requestsReceivedGraph.Create());
  52. container.Add(requestsSentGraph.Create());
  53. container.Add(responsesReceivedGraph.Create());
  54. container.Add(responsesSentGraph.Create());
  55. container.Add(retransmissionsReceivedGraph.Create());
  56. container.Add(retransmissionsSentGraph.Create());
  57. container.Add(consentRequestsReceivedGraph.Create());
  58. container.Add(consentRequestsSentGraph.Create());
  59. container.Add(consentResponsesReceivedGraph.Create());
  60. container.Add(consentResponsesSentGraph.Create());
  61. return container;
  62. }
  63. }
  64. }