Fixig issues in BWE dynamics plot scripts.

BUG=None

Review-Url: https://codereview.webrtc.org/2360053003
Cr-Commit-Position: refs/heads/master@{#14459}
diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
index b336367..a1f1fd3 100644
--- a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
+++ b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
@@ -180,7 +180,7 @@
     rtc::CritScope cs(&critsect_);
     bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(),
                                                  bitrate);
-    BWE_TEST_LOGGING_PLOT(1, "REMB[kbps]", clock_->TimeInMilliseconds(),
+    BWE_TEST_LOGGING_PLOT(1, "REMB_kbps", clock_->TimeInMilliseconds(),
                           bitrate / 1000);
   }
   MaybeTriggerOnNetworkChanged();
@@ -269,11 +269,11 @@
     new_bitrate = true;
   }
 
-  BWE_TEST_LOGGING_PLOT(1, "fraction_loss_[%%]", clock_->TimeInMilliseconds(),
+  BWE_TEST_LOGGING_PLOT(1, "fraction_loss_%", clock_->TimeInMilliseconds(),
                         (last_fraction_loss_ * 100) / 256);
-  BWE_TEST_LOGGING_PLOT(1, "rtt[ms]", clock_->TimeInMilliseconds(),
+  BWE_TEST_LOGGING_PLOT(1, "rtt_ms", clock_->TimeInMilliseconds(),
                         last_rtt_ms_);
-  BWE_TEST_LOGGING_PLOT(1, "Target_bitrate[kbps]", clock_->TimeInMilliseconds(),
+  BWE_TEST_LOGGING_PLOT(1, "Target_bitrate_kbps", clock_->TimeInMilliseconds(),
                         last_bitrate_bps_ / 1000);
 
   return new_bitrate;
diff --git a/webrtc/modules/remote_bitrate_estimator/BUILD.gn b/webrtc/modules/remote_bitrate_estimator/BUILD.gn
index 2a7c68f..515376b 100644
--- a/webrtc/modules/remote_bitrate_estimator/BUILD.gn
+++ b/webrtc/modules/remote_bitrate_estimator/BUILD.gn
@@ -32,13 +32,11 @@
     "test/bwe_test_logging.h",
   ]
 
-  if (!rtc_include_tests) {
-    if (rtc_enable_bwe_test_logging) {
-      defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1" ]
-      sources += [ "test/bwe_test_logging.cc" ]
-    } else {
-      defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0" ]
-    }
+  if (rtc_enable_bwe_test_logging) {
+    defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1" ]
+    sources += [ "test/bwe_test_logging.cc" ]
+  } else {
+    defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0" ]
   }
 
   if (is_clang) {
@@ -88,7 +86,6 @@
 
     if (rtc_enable_bwe_test_logging) {
       defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1" ]
-      sources += [ "test/bwe_test_logging.cc" ]
     } else {
       defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0" ]
     }
diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc b/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc
index 05f44ac..a57ea16 100644
--- a/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc
+++ b/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc
@@ -94,8 +94,8 @@
   const double prev_offset = prev_offset_;
   prev_offset_ = offset;
   const double T = std::min(num_of_deltas, kMinNumDeltas) * offset;
-  BWE_TEST_LOGGING_PLOT(1, "offset[ms]", now_ms, offset);
-  BWE_TEST_LOGGING_PLOT(1, "gamma[ms]", now_ms, threshold_ / kMinNumDeltas);
+  BWE_TEST_LOGGING_PLOT(1, "offset_ms#1", now_ms, offset);
+  BWE_TEST_LOGGING_PLOT(1, "gamma_ms#1", now_ms, threshold_ / kMinNumDeltas);
   if (T > threshold_) {
     if (time_over_using_ == -1) {
       // Initialize the timer. Assume that we've been
diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc b/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc
index 5535fe3..54e73d9 100644
--- a/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc
+++ b/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc
@@ -53,7 +53,7 @@
                               int64_t now_ms) {
   const double min_frame_period = UpdateMinFramePeriod(ts_delta);
   const double t_ts_delta = t_delta - ts_delta;
-  BWE_TEST_LOGGING_PLOT(1, "dm[ms]", now_ms, t_ts_delta);
+  BWE_TEST_LOGGING_PLOT(1, "dm_ms", now_ms, t_ts_delta);
   double fs_delta = size_delta;
 
   ++num_of_deltas_;
@@ -74,7 +74,7 @@
   const double Eh[2] = {E_[0][0]*h[0] + E_[0][1]*h[1],
                         E_[1][0]*h[0] + E_[1][1]*h[1]};
 
-  BWE_TEST_LOGGING_PLOT(1, "d[ms]", now_ms, slope_ * h[0] - offset_);
+  BWE_TEST_LOGGING_PLOT(1, "d_ms", now_ms, slope_ * h[0] - offset_);
 
   const double residual = t_ts_delta - slope_*h[0] - offset_;
 
@@ -120,7 +120,7 @@
 
   BWE_TEST_LOGGING_PLOT(1, "kc", now_ms, K[0]);
   BWE_TEST_LOGGING_PLOT(1, "km", now_ms, K[1]);
-  BWE_TEST_LOGGING_PLOT(1, "slope[1/bps]", now_ms, slope_);
+  BWE_TEST_LOGGING_PLOT(1, "slope_1/bps", now_ms, slope_);
   BWE_TEST_LOGGING_PLOT(1, "var_noise", now_ms, var_noise_);
 }
 
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi
index e719f2f..a5b0ab8 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi
@@ -41,17 +41,13 @@
         'test/bwe_test_logging.h',
       ], # source
       'conditions': [
-        ['include_tests==0', {
-          'conditions': [
-            ['enable_bwe_test_logging==1', {
-              'defines': [ 'BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1' ],
-              'sources': [
-                'test/bwe_test_logging.cc'
-              ],
-            }, {
-              'defines': [ 'BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0' ],
-            }],
+        ['enable_bwe_test_logging==1', {
+          'defines': [ 'BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1' ],
+          'sources': [
+            'test/bwe_test_logging.cc'
           ],
+        }, {
+          'defines': [ 'BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0' ],
         }],
       ],
     },
diff --git a/webrtc/modules/remote_bitrate_estimator/test/plot_dynamics.py b/webrtc/modules/remote_bitrate_estimator/test/plot_dynamics.py
old mode 100644
new mode 100755
index 1bae1e8..1643001
--- a/webrtc/modules/remote_bitrate_estimator/test/plot_dynamics.py
+++ b/webrtc/modules/remote_bitrate_estimator/test/plot_dynamics.py
@@ -49,11 +49,11 @@
 
 
   def addSample(self, line):
-    groups = re.search(r'_(((\d)+((,(\d)+)*))_(\D+))#\d@(\S+)', line)
+    groups = re.search(r'_(((\d)+((,(\d)+)*))_(\D+))#\d:(\d)@(\S+)', line)
 
     # Each variable will be plotted in a separated box.
     var_name = groups.group(1)
-    alg_name = groups.group(8)
+    alg_name = groups.group(9)
 
     alg_name = alg_name.replace('_', ' ')
 
@@ -126,8 +126,6 @@
           ('Throughput_kbps', "Time (s)", "Throughput (kbps)", 1, 4000),
           ('Delay_ms', "Time (s)", "One-way Delay (ms)", 2, 500),
           ('Packet_Loss', "Time (s)", "Packet Loss Ratio", 3, 1.0),
-          # ('Sending_Estimate_kbps', "Time (s)", "Sending Estimate (kbps)",
-          #                                                        4, 4000),
           ]
 
   var = []
diff --git a/webrtc/modules/remote_bitrate_estimator/test/plot_dynamics.sh b/webrtc/modules/remote_bitrate_estimator/test/plot_dynamics.sh
index fd104a1..cb65e13 100755
--- a/webrtc/modules/remote_bitrate_estimator/test/plot_dynamics.sh
+++ b/webrtc/modules/remote_bitrate_estimator/test/plot_dynamics.sh
@@ -28,7 +28,7 @@
 # Plot dynamics.
 function gen_gnuplot_input {
   colors=(a7001f 0a60c2 b2582b 21a66c d6604d 4393c3 f4a582 92c5de edcbb7 b1c5d0)
-  plots=$(echo "$log" | grep "^PLOT")
+  plots=$(echo "$log" | grep "^PLOT" | grep "#")
   # Each figure corresponds to a separate plot window.
   figures=($(echo "$plots" | cut -f 2 | sort | uniq))
 
diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc
index 0a6c2f9..b3e88fc 100644
--- a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc
@@ -277,11 +277,11 @@
       receive_counters_.retransmitted.packets;
   last_report_old_packets_ = receive_counters_.retransmitted.packets;
   last_report_seq_max_ = received_seq_max_;
-  BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "cumulative_loss[pkts]",
+  BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "cumulative_loss_pkts",
                                   clock_->TimeInMilliseconds(),
                                   cumulative_loss_, ssrc_);
   BWE_TEST_LOGGING_PLOT_WITH_SSRC(
-      1, "received_seq_max[pkts]", clock_->TimeInMilliseconds(),
+      1, "received_seq_max_pkts", clock_->TimeInMilliseconds(),
       (received_seq_max_ - received_seq_first_), ssrc_);
 
   return stats;
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
index 3806968..5514666 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
@@ -902,16 +902,16 @@
   packet->SetExtension<AbsoluteSendTime>(now_ms);
 
   if (video_) {
-    BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "VideoTotBitrate[kbps]", now_ms,
+    BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "VideoTotBitrate_kbps", now_ms,
                                     ActualSendBitrateKbit(), packet->Ssrc());
-    BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "VideoFecBitrate[Kbps]", now_ms,
+    BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "VideoFecBitrate_kbps", now_ms,
                                     FecOverheadRate() / 1000, packet->Ssrc());
-    BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "VideoNackBitrate[Kbps]", now_ms,
+    BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "VideoNackBitrate_kbps", now_ms,
                                     NackOverheadRate() / 1000, packet->Ssrc());
   } else {
-    BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "AudioTotBitrate[kbps]", now_ms,
+    BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "AudioTotBitrate_kbps", now_ms,
                                     ActualSendBitrateKbit(), packet->Ssrc());
-    BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "AudioNackBitrate[Kbps]", now_ms,
+    BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "AudioNackBitrate_kbps", now_ms,
                                     NackOverheadRate() / 1000, packet->Ssrc());
   }