OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const uint32_t kWindowBps = 10000; | 59 const uint32_t kWindowBps = 10000; |
60 media_opt_.SuspendBelowMinBitrate(kThresholdBps, kWindowBps); | 60 media_opt_.SuspendBelowMinBitrate(kThresholdBps, kWindowBps); |
61 | 61 |
62 // The video should not be suspended from the start. | 62 // The video should not be suspended from the start. |
63 EXPECT_FALSE(media_opt_.IsVideoSuspended()); | 63 EXPECT_FALSE(media_opt_.IsVideoSuspended()); |
64 | 64 |
65 uint32_t target_bitrate_kbps = 100; | 65 uint32_t target_bitrate_kbps = 100; |
66 media_opt_.SetTargetRates(target_bitrate_kbps * 1000, | 66 media_opt_.SetTargetRates(target_bitrate_kbps * 1000, |
67 0, // Lossrate. | 67 0, // Lossrate. |
68 100, // RTT in ms. | 68 100, // RTT in ms. |
69 nullptr, nullptr); | 69 nullptr); |
70 media_opt_.EnableFrameDropper(true); | 70 media_opt_.EnableFrameDropper(true); |
71 for (int time = 0; time < 2000; time += frame_time_ms_) { | 71 for (int time = 0; time < 2000; time += frame_time_ms_) { |
72 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, false)); | 72 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, false)); |
73 } | 73 } |
74 | 74 |
75 // Set the target rate below the limit for muting. | 75 // Set the target rate below the limit for muting. |
76 media_opt_.SetTargetRates(kThresholdBps - 1000, | 76 media_opt_.SetTargetRates(kThresholdBps - 1000, |
77 0, // Lossrate. | 77 0, // Lossrate. |
78 100, // RTT in ms. | 78 100, // RTT in ms. |
79 nullptr, nullptr); | 79 nullptr); |
80 // Expect the muter to engage immediately and stay muted. | 80 // Expect the muter to engage immediately and stay muted. |
81 // Test during 2 seconds. | 81 // Test during 2 seconds. |
82 for (int time = 0; time < 2000; time += frame_time_ms_) { | 82 for (int time = 0; time < 2000; time += frame_time_ms_) { |
83 EXPECT_TRUE(media_opt_.IsVideoSuspended()); | 83 EXPECT_TRUE(media_opt_.IsVideoSuspended()); |
84 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true)); | 84 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true)); |
85 } | 85 } |
86 | 86 |
87 // Set the target above the limit for muting, but not above the | 87 // Set the target above the limit for muting, but not above the |
88 // limit + window. | 88 // limit + window. |
89 media_opt_.SetTargetRates(kThresholdBps + 1000, | 89 media_opt_.SetTargetRates(kThresholdBps + 1000, |
90 0, // Lossrate. | 90 0, // Lossrate. |
91 100, // RTT in ms. | 91 100, // RTT in ms. |
92 nullptr, nullptr); | 92 nullptr); |
93 // Expect the muter to stay muted. | 93 // Expect the muter to stay muted. |
94 // Test during 2 seconds. | 94 // Test during 2 seconds. |
95 for (int time = 0; time < 2000; time += frame_time_ms_) { | 95 for (int time = 0; time < 2000; time += frame_time_ms_) { |
96 EXPECT_TRUE(media_opt_.IsVideoSuspended()); | 96 EXPECT_TRUE(media_opt_.IsVideoSuspended()); |
97 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true)); | 97 ASSERT_NO_FATAL_FAILURE(AddFrameAndAdvanceTime(target_bitrate_kbps, true)); |
98 } | 98 } |
99 | 99 |
100 // Set the target above limit + window. | 100 // Set the target above limit + window. |
101 media_opt_.SetTargetRates(kThresholdBps + kWindowBps + 1000, | 101 media_opt_.SetTargetRates(kThresholdBps + kWindowBps + 1000, |
102 0, // Lossrate. | 102 0, // Lossrate. |
103 100, // RTT in ms. | 103 100, // RTT in ms. |
104 nullptr, nullptr); | 104 nullptr); |
105 // Expect the muter to disengage immediately. | 105 // Expect the muter to disengage immediately. |
106 // Test during 2 seconds. | 106 // Test during 2 seconds. |
107 for (int time = 0; time < 2000; time += frame_time_ms_) { | 107 for (int time = 0; time < 2000; time += frame_time_ms_) { |
108 EXPECT_FALSE(media_opt_.IsVideoSuspended()); | 108 EXPECT_FALSE(media_opt_.IsVideoSuspended()); |
109 ASSERT_NO_FATAL_FAILURE( | 109 ASSERT_NO_FATAL_FAILURE( |
110 AddFrameAndAdvanceTime((kThresholdBps + kWindowBps) / 1000, false)); | 110 AddFrameAndAdvanceTime((kThresholdBps + kWindowBps) / 1000, false)); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 TEST_F(TestMediaOptimization, ProtectsUsingFecBitrateAboveCodecMax) { | 114 TEST_F(TestMediaOptimization, ProtectsUsingFecBitrateAboveCodecMax) { |
(...skipping 16 matching lines...) Expand all Loading... |
131 uint32_t fec_rate_bps_; | 131 uint32_t fec_rate_bps_; |
132 } protection_callback; | 132 } protection_callback; |
133 | 133 |
134 media_opt_.SetProtectionMethod(kFec); | 134 media_opt_.SetProtectionMethod(kFec); |
135 media_opt_.SetEncodingData(kVideoCodecVP8, kCodecBitrateBps, kCodecBitrateBps, | 135 media_opt_.SetEncodingData(kVideoCodecVP8, kCodecBitrateBps, kCodecBitrateBps, |
136 640, 480, 30, 1, 1000); | 136 640, 480, 30, 1, 1000); |
137 | 137 |
138 // Using 10% of codec bitrate for FEC, should still be able to use all of it. | 138 // Using 10% of codec bitrate for FEC, should still be able to use all of it. |
139 protection_callback.fec_rate_bps_ = kCodecBitrateBps / 10; | 139 protection_callback.fec_rate_bps_ = kCodecBitrateBps / 10; |
140 uint32_t target_bitrate = media_opt_.SetTargetRates( | 140 uint32_t target_bitrate = media_opt_.SetTargetRates( |
141 kMaxBitrateBps, 0, 0, &protection_callback, nullptr); | 141 kMaxBitrateBps, 0, 0, &protection_callback); |
142 | 142 |
143 EXPECT_EQ(kCodecBitrateBps, static_cast<int>(target_bitrate)); | 143 EXPECT_EQ(kCodecBitrateBps, static_cast<int>(target_bitrate)); |
144 | 144 |
145 // Using as much for codec bitrate as fec rate, new target rate should share | 145 // Using as much for codec bitrate as fec rate, new target rate should share |
146 // both equally, but only be half of max (since that ceiling should be hit). | 146 // both equally, but only be half of max (since that ceiling should be hit). |
147 protection_callback.fec_rate_bps_ = kCodecBitrateBps; | 147 protection_callback.fec_rate_bps_ = kCodecBitrateBps; |
148 target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 128, 100, | 148 target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 128, 100, |
149 &protection_callback, nullptr); | 149 &protection_callback); |
150 EXPECT_EQ(kMaxBitrateBps / 2, static_cast<int>(target_bitrate)); | 150 EXPECT_EQ(kMaxBitrateBps / 2, static_cast<int>(target_bitrate)); |
151 } | 151 } |
152 | 152 |
153 } // namespace media_optimization | 153 } // namespace media_optimization |
154 } // namespace webrtc | 154 } // namespace webrtc |
OLD | NEW |