Plot bitrate allocation per layer based on RTCP XR target bitrate.

Bug: webrtc:10312
Change-Id: Ic0221e71d27d1fdc35c50a93e7e2303953c4fbf5
Reviewed-on: https://webrtc-review.googlesource.com/c/123222
Reviewed-by: Mirta Dvornicic <mirtad@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26717}
diff --git a/rtc_tools/event_log_visualizer/analyzer.h b/rtc_tools/event_log_visualizer/analyzer.h
index f8dd3de..e0ef0c3 100644
--- a/rtc_tools/event_log_visualizer/analyzer.h
+++ b/rtc_tools/event_log_visualizer/analyzer.h
@@ -81,6 +81,7 @@
                                        bool show_alr_state = false);
 
   void CreateStreamBitrateGraph(PacketDirection direction, Plot* plot);
+  void CreateBitrateAllocationGraph(PacketDirection direction, Plot* plot);
 
   void CreateSendSideBweSimulationGraph(Plot* plot);
   void CreateReceiveSideBweSimulationGraph(Plot* plot);
@@ -132,6 +133,25 @@
   void PrintNotifications(FILE* file);
 
  private:
+  struct LayerDescription {
+    LayerDescription(uint32_t ssrc,
+                     uint8_t spatial_layer,
+                     uint8_t temporal_layer)
+        : ssrc(ssrc),
+          spatial_layer(spatial_layer),
+          temporal_layer(temporal_layer) {}
+    bool operator<(const LayerDescription& other) const {
+      if (ssrc != other.ssrc)
+        return ssrc < other.ssrc;
+      if (spatial_layer != other.spatial_layer)
+        return spatial_layer < other.spatial_layer;
+      return temporal_layer < other.temporal_layer;
+    }
+    uint32_t ssrc;
+    uint8_t spatial_layer;
+    uint8_t temporal_layer;
+  };
+
   bool IsRtxSsrc(PacketDirection direction, uint32_t ssrc) const {
     if (direction == kIncomingPacket) {
       return parsed_log_.incoming_rtx_ssrcs().find(ssrc) !=
@@ -200,6 +220,14 @@
     return name.str();
   }
 
+  std::string GetLayerName(LayerDescription layer) const {
+    char buffer[100];
+    rtc::SimpleStringBuilder name(buffer);
+    name << "SSRC " << layer.ssrc << " sl " << layer.spatial_layer << ", tl "
+         << layer.temporal_layer;
+    return name.str();
+  }
+
   void Alert_RtpLogTimeGap(PacketDirection direction,
                            float time_seconds,
                            int64_t duration) {