OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" | 14 #include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" |
15 #include "webrtc/modules/audio_coding/audio_network_adaptor/audio_network_adapto
r_impl.h" | 15 #include "webrtc/modules/audio_coding/audio_network_adaptor/audio_network_adapto
r_impl.h" |
16 #include "webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_controller
.h" | 16 #include "webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_controller
.h" |
17 #include "webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_controller
_manager.h" | 17 #include "webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_controller
_manager.h" |
18 #include "webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_debug_dump
_writer.h" | 18 #include "webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_debug_dump
_writer.h" |
19 #include "webrtc/rtc_base/fakeclock.h" | 19 #include "webrtc/rtc_base/fakeclock.h" |
| 20 #include "webrtc/test/field_trial.h" |
20 #include "webrtc/test/gtest.h" | 21 #include "webrtc/test/gtest.h" |
21 | 22 |
22 namespace webrtc { | 23 namespace webrtc { |
23 | 24 |
24 using ::testing::_; | 25 using ::testing::_; |
25 using ::testing::NiceMock; | 26 using ::testing::NiceMock; |
26 using ::testing::Return; | 27 using ::testing::Return; |
27 using ::testing::SetArgPointee; | 28 using ::testing::SetArgPointee; |
28 | 29 |
29 namespace { | 30 namespace { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 TEST(AudioNetworkAdaptorImplTest, | 172 TEST(AudioNetworkAdaptorImplTest, |
172 MakeDecisionIsCalledOnGetEncoderRuntimeConfig) { | 173 MakeDecisionIsCalledOnGetEncoderRuntimeConfig) { |
173 auto states = CreateAudioNetworkAdaptor(); | 174 auto states = CreateAudioNetworkAdaptor(); |
174 for (auto& mock_controller : states.mock_controllers) | 175 for (auto& mock_controller : states.mock_controllers) |
175 EXPECT_CALL(*mock_controller, MakeDecision(_)); | 176 EXPECT_CALL(*mock_controller, MakeDecision(_)); |
176 states.audio_network_adaptor->GetEncoderRuntimeConfig(); | 177 states.audio_network_adaptor->GetEncoderRuntimeConfig(); |
177 } | 178 } |
178 | 179 |
179 TEST(AudioNetworkAdaptorImplTest, | 180 TEST(AudioNetworkAdaptorImplTest, |
180 DumpEncoderRuntimeConfigIsCalledOnGetEncoderRuntimeConfig) { | 181 DumpEncoderRuntimeConfigIsCalledOnGetEncoderRuntimeConfig) { |
| 182 test::ScopedFieldTrials override_field_trials( |
| 183 "WebRTC-Audio-BitrateAdaptation/Enabled/WebRTC-Audio-FecAdaptation/" |
| 184 "Enabled/"); |
181 rtc::ScopedFakeClock fake_clock; | 185 rtc::ScopedFakeClock fake_clock; |
182 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(kClockInitialTimeMs)); | 186 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(kClockInitialTimeMs)); |
183 auto states = CreateAudioNetworkAdaptor(); | 187 auto states = CreateAudioNetworkAdaptor(); |
184 AudioEncoderRuntimeConfig config; | 188 AudioEncoderRuntimeConfig config; |
185 config.bitrate_bps = rtc::Optional<int>(32000); | 189 config.bitrate_bps = rtc::Optional<int>(32000); |
186 config.enable_fec = rtc::Optional<bool>(true); | 190 config.enable_fec = rtc::Optional<bool>(true); |
187 | 191 |
188 EXPECT_CALL(*states.mock_controllers[0], MakeDecision(_)) | 192 EXPECT_CALL(*states.mock_controllers[0], MakeDecision(_)) |
189 .WillOnce(SetArgPointee<0>(config)); | 193 .WillOnce(SetArgPointee<0>(config)); |
190 | 194 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 252 |
249 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(50)); | 253 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(50)); |
250 timestamp_check += 50; | 254 timestamp_check += 50; |
251 check.overhead_bytes_per_packet = rtc::Optional<size_t>(kOverhead); | 255 check.overhead_bytes_per_packet = rtc::Optional<size_t>(kOverhead); |
252 EXPECT_CALL(*states.mock_debug_dump_writer, | 256 EXPECT_CALL(*states.mock_debug_dump_writer, |
253 DumpNetworkMetrics(NetworkMetricsIs(check), timestamp_check)); | 257 DumpNetworkMetrics(NetworkMetricsIs(check), timestamp_check)); |
254 states.audio_network_adaptor->SetOverhead(kOverhead); | 258 states.audio_network_adaptor->SetOverhead(kOverhead); |
255 } | 259 } |
256 | 260 |
257 TEST(AudioNetworkAdaptorImplTest, LogRuntimeConfigOnGetEncoderRuntimeConfig) { | 261 TEST(AudioNetworkAdaptorImplTest, LogRuntimeConfigOnGetEncoderRuntimeConfig) { |
| 262 test::ScopedFieldTrials override_field_trials( |
| 263 "WebRTC-Audio-BitrateAdaptation/Enabled/WebRTC-Audio-FecAdaptation/" |
| 264 "Enabled/"); |
258 auto states = CreateAudioNetworkAdaptor(); | 265 auto states = CreateAudioNetworkAdaptor(); |
259 | 266 |
260 AudioEncoderRuntimeConfig config; | 267 AudioEncoderRuntimeConfig config; |
261 config.bitrate_bps = rtc::Optional<int>(32000); | 268 config.bitrate_bps = rtc::Optional<int>(32000); |
262 config.enable_fec = rtc::Optional<bool>(true); | 269 config.enable_fec = rtc::Optional<bool>(true); |
263 | 270 |
264 EXPECT_CALL(*states.mock_controllers[0], MakeDecision(_)) | 271 EXPECT_CALL(*states.mock_controllers[0], MakeDecision(_)) |
265 .WillOnce(SetArgPointee<0>(config)); | 272 .WillOnce(SetArgPointee<0>(config)); |
266 | 273 |
267 EXPECT_CALL(*states.event_log, | 274 EXPECT_CALL(*states.event_log, |
268 LogAudioNetworkAdaptation(EncoderRuntimeConfigIs(config))) | 275 LogAudioNetworkAdaptation(EncoderRuntimeConfigIs(config))) |
269 .Times(1); | 276 .Times(1); |
270 states.audio_network_adaptor->GetEncoderRuntimeConfig(); | 277 states.audio_network_adaptor->GetEncoderRuntimeConfig(); |
271 } | 278 } |
272 | 279 |
273 TEST(AudioNetworkAdaptorImplTest, TestANAStats) { | 280 TEST(AudioNetworkAdaptorImplTest, TestANAStats) { |
274 auto states = CreateAudioNetworkAdaptor(); | 281 auto states = CreateAudioNetworkAdaptor(); |
275 | 282 |
276 // Simulate some adaptation, otherwise the stats will not show anything. | 283 // Simulate some adaptation, otherwise the stats will not show anything. |
277 AudioEncoderRuntimeConfig config1, config2; | 284 AudioEncoderRuntimeConfig config1, config2; |
278 config1.bitrate_bps = rtc::Optional<int>(32000); | 285 config1.bitrate_bps = rtc::Optional<int>(32000); |
| 286 config1.num_channels = rtc::Optional<size_t>(2); |
279 config1.enable_fec = rtc::Optional<bool>(true); | 287 config1.enable_fec = rtc::Optional<bool>(true); |
| 288 config1.enable_dtx = rtc::Optional<bool>(true); |
| 289 config1.frame_length_ms = rtc::Optional<int>(120); |
| 290 config1.uplink_packet_loss_fraction = rtc::Optional<float>(0.1f); |
280 config2.bitrate_bps = rtc::Optional<int>(16000); | 291 config2.bitrate_bps = rtc::Optional<int>(16000); |
| 292 config2.num_channels = rtc::Optional<size_t>(1); |
281 config2.enable_fec = rtc::Optional<bool>(false); | 293 config2.enable_fec = rtc::Optional<bool>(false); |
| 294 config2.enable_dtx = rtc::Optional<bool>(false); |
| 295 config2.frame_length_ms = rtc::Optional<int>(60); |
| 296 config1.uplink_packet_loss_fraction = rtc::Optional<float>(0.1f); |
282 | 297 |
283 EXPECT_CALL(*states.mock_controllers[0], MakeDecision(_)) | 298 EXPECT_CALL(*states.mock_controllers[0], MakeDecision(_)) |
284 .WillOnce(SetArgPointee<0>(config1)); | 299 .WillOnce(SetArgPointee<0>(config1)); |
285 states.audio_network_adaptor->GetEncoderRuntimeConfig(); | 300 states.audio_network_adaptor->GetEncoderRuntimeConfig(); |
286 EXPECT_CALL(*states.mock_controllers[0], MakeDecision(_)) | 301 EXPECT_CALL(*states.mock_controllers[0], MakeDecision(_)) |
287 .WillOnce(SetArgPointee<0>(config2)); | 302 .WillOnce(SetArgPointee<0>(config2)); |
288 states.audio_network_adaptor->GetEncoderRuntimeConfig(); | 303 states.audio_network_adaptor->GetEncoderRuntimeConfig(); |
| 304 EXPECT_CALL(*states.mock_controllers[0], MakeDecision(_)) |
| 305 .WillOnce(SetArgPointee<0>(config1)); |
| 306 states.audio_network_adaptor->GetEncoderRuntimeConfig(); |
289 | 307 |
290 auto ana_stats = states.audio_network_adaptor->GetStats(); | 308 auto ana_stats = states.audio_network_adaptor->GetStats(); |
291 | 309 |
292 // Check that the default stats are returned, as these have not been | 310 EXPECT_EQ(ana_stats.bitrate_action_counter, 2); |
293 // implemented yet). Tracking bug: https://crbug.com/8127 | 311 EXPECT_EQ(ana_stats.channel_action_counter, 2); |
294 auto default_stats = ANAStats(); | 312 EXPECT_EQ(ana_stats.dtx_action_counter, 2); |
295 EXPECT_EQ(ana_stats.bitrate_action_counter, | 313 EXPECT_EQ(ana_stats.fec_action_counter, 2); |
296 default_stats.bitrate_action_counter); | 314 EXPECT_EQ(ana_stats.frame_length_increase_counter, 1); |
297 EXPECT_EQ(ana_stats.channel_action_counter, | 315 EXPECT_EQ(ana_stats.frame_length_decrease_counter, 1); |
298 default_stats.channel_action_counter); | 316 EXPECT_EQ(ana_stats.uplink_packet_loss_fraction, 0.1f); |
299 EXPECT_EQ(ana_stats.dtx_action_counter, default_stats.dtx_action_counter); | |
300 EXPECT_EQ(ana_stats.fec_action_counter, default_stats.fec_action_counter); | |
301 EXPECT_EQ(ana_stats.frame_length_increase_counter, | |
302 default_stats.frame_length_increase_counter); | |
303 EXPECT_EQ(ana_stats.frame_length_decrease_counter, | |
304 default_stats.frame_length_decrease_counter); | |
305 EXPECT_EQ(ana_stats.uplink_packet_loss_fraction, | |
306 default_stats.uplink_packet_loss_fraction); | |
307 } | 317 } |
308 | 318 |
309 } // namespace webrtc | 319 } // namespace webrtc |
OLD | NEW |