Packet waiting-time statistics

Adding new statistics API to NetEQ, reporting the waiting time
for each frame. The output is raw waiting time for the frames
that have been decoded since the last statistics report (or
maximum 100 frames). The statistics are reset on each query.

Implemented functionality in ACM to query NetEQ for the raw
waiting times, and process it to produce max, average and
median.

Updating common_types.h and VoiceEngine tests to include the
new metrics.

Unit tests are also added for NetEQ and AcmNetEq.

Review URL: http://webrtc-codereview.appspot.com/328011

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1251 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/src/modules/audio_coding/neteq/mcu_reset.c b/src/modules/audio_coding/neteq/mcu_reset.c
index 5fe23ec..3aae4ce 100644
--- a/src/modules/audio_coding/neteq/mcu_reset.c
+++ b/src/modules/audio_coding/neteq/mcu_reset.c
@@ -14,6 +14,7 @@
 
 #include "mcu.h"
 
+#include <assert.h>
 #include <string.h>
 
 #include "automode.h"
@@ -61,6 +62,8 @@
 
     WebRtcNetEQ_ResetMcuInCallStats(inst);
 
+    WebRtcNetEQ_ResetWaitingTimeStats(inst);
+
     WebRtcNetEQ_ResetMcuJitterStat(inst);
 
     WebRtcNetEQ_ResetAutomode(&(inst->BufferStat_inst.Automode_inst),
@@ -83,6 +86,33 @@
 }
 
 /*
+ * Reset waiting-time statistics.
+ */
+
+void WebRtcNetEQ_ResetWaitingTimeStats(MCUInst_t *inst) {
+  memset(inst->waiting_times, 0,
+         kLenWaitingTimes * sizeof(inst->waiting_times[0]));
+  inst->len_waiting_times = 0;
+  inst->next_waiting_time_index = 0;
+}
+
+/*
+ * Store waiting-time in the statistics.
+ */
+
+void WebRtcNetEQ_StoreWaitingTime(MCUInst_t *inst, int waiting_time) {
+  assert(inst->next_waiting_time_index < kLenWaitingTimes);
+  inst->waiting_times[inst->next_waiting_time_index] = waiting_time;
+  inst->next_waiting_time_index++;
+  if (inst->next_waiting_time_index >= kLenWaitingTimes) {
+    inst->next_waiting_time_index = 0;
+  }
+  if (inst->len_waiting_times < kLenWaitingTimes) {
+    inst->len_waiting_times++;
+  }
+}
+
+/*
  * Reset all MCU-side statistics variables for the post-call statistics.
  */