| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 15 matching lines...) Expand all Loading... |
| 26 const int kClusterSize = 5; | 26 const int kClusterSize = 5; |
| 27 const int kProbeSize = 1000; | 27 const int kProbeSize = 1000; |
| 28 const int kMinProbeDurationMs = 15; | 28 const int kMinProbeDurationMs = 15; |
| 29 | 29 |
| 30 prober.CreateProbeCluster(kTestBitrate1, now_ms); | 30 prober.CreateProbeCluster(kTestBitrate1, now_ms); |
| 31 prober.CreateProbeCluster(kTestBitrate2, now_ms); | 31 prober.CreateProbeCluster(kTestBitrate2, now_ms); |
| 32 EXPECT_FALSE(prober.IsProbing()); | 32 EXPECT_FALSE(prober.IsProbing()); |
| 33 | 33 |
| 34 prober.OnIncomingPacket(kProbeSize); | 34 prober.OnIncomingPacket(kProbeSize); |
| 35 EXPECT_TRUE(prober.IsProbing()); | 35 EXPECT_TRUE(prober.IsProbing()); |
| 36 EXPECT_EQ(0, prober.CurrentClusterId()); | 36 EXPECT_EQ(0, prober.CurrentCluster().probe_cluster_id); |
| 37 | 37 |
| 38 // First packet should probe as soon as possible. | 38 // First packet should probe as soon as possible. |
| 39 EXPECT_EQ(0, prober.TimeUntilNextProbe(now_ms)); | 39 EXPECT_EQ(0, prober.TimeUntilNextProbe(now_ms)); |
| 40 | 40 |
| 41 for (int i = 0; i < kClusterSize; ++i) { | 41 for (int i = 0; i < kClusterSize; ++i) { |
| 42 now_ms += prober.TimeUntilNextProbe(now_ms); | 42 now_ms += prober.TimeUntilNextProbe(now_ms); |
| 43 EXPECT_EQ(0, prober.TimeUntilNextProbe(now_ms)); | 43 EXPECT_EQ(0, prober.TimeUntilNextProbe(now_ms)); |
| 44 EXPECT_EQ(0, prober.CurrentClusterId()); | 44 EXPECT_EQ(0, prober.CurrentCluster().probe_cluster_id); |
| 45 prober.ProbeSent(now_ms, kProbeSize); | 45 prober.ProbeSent(now_ms, kProbeSize); |
| 46 } | 46 } |
| 47 | 47 |
| 48 EXPECT_GE(now_ms, kMinProbeDurationMs); | 48 EXPECT_GE(now_ms, kMinProbeDurationMs); |
| 49 // Verify that the actual bitrate is withing 10% of the target. | 49 // Verify that the actual bitrate is withing 10% of the target. |
| 50 double bitrate = kProbeSize * (kClusterSize - 1) * 8 * 1000.0 / now_ms; | 50 double bitrate = kProbeSize * (kClusterSize - 1) * 8 * 1000.0 / now_ms; |
| 51 EXPECT_GT(bitrate, kTestBitrate1 * 0.9); | 51 EXPECT_GT(bitrate, kTestBitrate1 * 0.9); |
| 52 EXPECT_LT(bitrate, kTestBitrate1 * 1.1); | 52 EXPECT_LT(bitrate, kTestBitrate1 * 1.1); |
| 53 | 53 |
| 54 now_ms += prober.TimeUntilNextProbe(now_ms); | 54 now_ms += prober.TimeUntilNextProbe(now_ms); |
| 55 int64_t probe2_started = now_ms; | 55 int64_t probe2_started = now_ms; |
| 56 | 56 |
| 57 for (int i = 0; i < kClusterSize; ++i) { | 57 for (int i = 0; i < kClusterSize; ++i) { |
| 58 now_ms += prober.TimeUntilNextProbe(now_ms); | 58 now_ms += prober.TimeUntilNextProbe(now_ms); |
| 59 EXPECT_EQ(0, prober.TimeUntilNextProbe(now_ms)); | 59 EXPECT_EQ(0, prober.TimeUntilNextProbe(now_ms)); |
| 60 EXPECT_EQ(1, prober.CurrentClusterId()); | 60 EXPECT_EQ(1, prober.CurrentCluster().probe_cluster_id); |
| 61 prober.ProbeSent(now_ms, kProbeSize); | 61 prober.ProbeSent(now_ms, kProbeSize); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Verify that the actual bitrate is withing 10% of the target. | 64 // Verify that the actual bitrate is withing 10% of the target. |
| 65 int duration = now_ms - probe2_started; | 65 int duration = now_ms - probe2_started; |
| 66 EXPECT_GE(duration, kMinProbeDurationMs); | 66 EXPECT_GE(duration, kMinProbeDurationMs); |
| 67 bitrate = kProbeSize * (kClusterSize - 1) * 8 * 1000.0 / duration; | 67 bitrate = kProbeSize * (kClusterSize - 1) * 8 * 1000.0 / duration; |
| 68 EXPECT_GT(bitrate, kTestBitrate2 * 0.9); | 68 EXPECT_GT(bitrate, kTestBitrate2 * 0.9); |
| 69 EXPECT_LT(bitrate, kTestBitrate2 * 1.1); | 69 EXPECT_LT(bitrate, kTestBitrate2 * 1.1); |
| 70 | 70 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 int bytes_sent = 0; | 174 int bytes_sent = 0; |
| 175 while (bytes_sent < kExpectedBytesSent) { | 175 while (bytes_sent < kExpectedBytesSent) { |
| 176 ASSERT_TRUE(prober.IsProbing()); | 176 ASSERT_TRUE(prober.IsProbing()); |
| 177 prober.ProbeSent(0, kSmallPacketSize); | 177 prober.ProbeSent(0, kSmallPacketSize); |
| 178 bytes_sent += kSmallPacketSize; | 178 bytes_sent += kSmallPacketSize; |
| 179 } | 179 } |
| 180 | 180 |
| 181 EXPECT_FALSE(prober.IsProbing()); | 181 EXPECT_FALSE(prober.IsProbing()); |
| 182 } | 182 } |
| 183 } // namespace webrtc | 183 } // namespace webrtc |
| OLD | NEW |