OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 int iat_packets = (arrival_times_ms[next] - arrival_times_ms[next - 1]) / | 115 int iat_packets = (arrival_times_ms[next] - arrival_times_ms[next - 1]) / |
116 kPacketSizeMs; | 116 kPacketSizeMs; |
117 const int kTargetBufferLevel = 2; // Define peaks to be iat > 4. | 117 const int kTargetBufferLevel = 2; // Define peaks to be iat > 4. |
118 EXPECT_FALSE(detector.Update(iat_packets, kTargetBufferLevel)); | 118 EXPECT_FALSE(detector.Update(iat_packets, kTargetBufferLevel)); |
119 ++next; | 119 ++next; |
120 } | 120 } |
121 tick_timer.Increment(); | 121 tick_timer.Increment(); |
122 time += 10; // Increase time 10 ms. | 122 time += 10; // Increase time 10 ms. |
123 } | 123 } |
124 } | 124 } |
| 125 |
| 126 // In situations with reordered packets, the DelayPeakDetector may be updated |
| 127 // back-to-back (i.e., without the tick_timer moving) but still with non-zero |
| 128 // inter-arrival time. This test is to make sure that this does not cause |
| 129 // problems. |
| 130 TEST(DelayPeakDetector, ZeroDistancePeaks) { |
| 131 TickTimer tick_timer; |
| 132 DelayPeakDetector detector(&tick_timer); |
| 133 const int kPacketSizeMs = 30; |
| 134 detector.SetPacketAudioLength(kPacketSizeMs); |
| 135 |
| 136 const int kTargetBufferLevel = 2; // Define peaks to be iat > 4. |
| 137 const int kInterArrivalTime = 3 * kTargetBufferLevel; // Will trigger a peak. |
| 138 EXPECT_FALSE(detector.Update(kInterArrivalTime, kTargetBufferLevel)); |
| 139 EXPECT_FALSE(detector.Update(kInterArrivalTime, kTargetBufferLevel)); |
| 140 EXPECT_FALSE(detector.Update(kInterArrivalTime, kTargetBufferLevel)); |
| 141 } |
| 142 |
125 } // namespace webrtc | 143 } // namespace webrtc |
OLD | NEW |