| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2008 Google Inc. | 3 * Copyright 2008 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0); | 50 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0); |
| 51 const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0); | 51 const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0); |
| 52 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0); | 52 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0); |
| 53 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0); | 53 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0); |
| 54 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, 0, | 54 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, 0, |
| 55 1, 0); | 55 1, 0); |
| 56 const cricket::AudioCodec* const kAudioCodecs[] = { | 56 const cricket::AudioCodec* const kAudioCodecs[] = { |
| 57 &kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec, | 57 &kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec, |
| 58 &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec, | 58 &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec, |
| 59 }; | 59 }; |
| 60 static uint32_t kSsrc1 = 0x99; | 60 const uint32_t kSsrc1 = 0x99; |
| 61 static uint32_t kSsrc2 = 0x98; | 61 const uint32_t kSsrc2 = 0x98; |
| 62 static const uint32_t kSsrcs4[] = {1, 2, 3, 4}; | 62 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 }; |
| 63 | 63 |
| 64 class FakeVoEWrapper : public cricket::VoEWrapper { | 64 class FakeVoEWrapper : public cricket::VoEWrapper { |
| 65 public: | 65 public: |
| 66 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) | 66 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) |
| 67 : cricket::VoEWrapper(engine, // processing | 67 : cricket::VoEWrapper(engine, // processing |
| 68 engine, // base | 68 engine, // base |
| 69 engine, // codec | 69 engine, // codec |
| 70 engine, // dtmf | 70 engine, // dtmf |
| 71 engine, // hw | 71 engine, // hw |
| 72 engine, // network | 72 engine, // network |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 if (!SetupEngine()) { | 117 if (!SetupEngine()) { |
| 118 return false; | 118 return false; |
| 119 } | 119 } |
| 120 return channel_->AddSendStream( | 120 return channel_->AddSendStream( |
| 121 cricket::StreamParams::CreateLegacy(kSsrc1)); | 121 cricket::StreamParams::CreateLegacy(kSsrc1)); |
| 122 } | 122 } |
| 123 void SetupForMultiSendStream() { | 123 void SetupForMultiSendStream() { |
| 124 EXPECT_TRUE(SetupEngineWithSendStream()); | 124 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 125 // Remove stream added in Setup. | 125 // Remove stream added in Setup. |
| 126 int default_channel_num = voe_.GetLastChannel(); | 126 int default_channel_num = voe_.GetLastChannel(); |
| 127 uint32_t default_send_ssrc = 0u; | 127 EXPECT_EQ(kSsrc1, voe_.GetLocalSSRC(default_channel_num)); |
| 128 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); | 128 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc1)); |
| 129 EXPECT_EQ(kSsrc1, default_send_ssrc); | |
| 130 EXPECT_TRUE(channel_->RemoveSendStream(default_send_ssrc)); | |
| 131 | 129 |
| 132 // Verify the channel does not exist. | 130 // Verify the channel does not exist. |
| 133 EXPECT_EQ(-1, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); | 131 EXPECT_EQ(-1, voe_.GetChannelFromLocalSsrc(kSsrc1)); |
| 134 } | 132 } |
| 135 void DeliverPacket(const void* data, int len) { | 133 void DeliverPacket(const void* data, int len) { |
| 136 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len); | 134 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len); |
| 137 channel_->OnPacketReceived(&packet, rtc::PacketTime()); | 135 channel_->OnPacketReceived(&packet, rtc::PacketTime()); |
| 138 } | 136 } |
| 139 void TearDown() override { | 137 void TearDown() override { |
| 140 delete channel_; | 138 delete channel_; |
| 141 engine_.Terminate(); | 139 engine_.Terminate(); |
| 142 } | 140 } |
| 143 | 141 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 EXPECT_NE(channel_num, new_channel_num); | 281 EXPECT_NE(channel_num, new_channel_num); |
| 284 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); | 282 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); |
| 285 | 283 |
| 286 // Ensure all extensions go back off with an empty list. | 284 // Ensure all extensions go back off with an empty list. |
| 287 parameters.extensions.clear(); | 285 parameters.extensions.clear(); |
| 288 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 286 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 289 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 287 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
| 290 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); | 288 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); |
| 291 } | 289 } |
| 292 | 290 |
| 293 const webrtc::AudioReceiveStream::Stats& GetAudioReceiveStreamStats() const { | 291 webrtc::AudioSendStream::Stats GetAudioSendStreamStats() const { |
| 294 static webrtc::AudioReceiveStream::Stats stats; | 292 webrtc::AudioSendStream::Stats stats; |
| 295 if (stats.remote_ssrc == 0) { | 293 stats.local_ssrc = 12; |
| 296 stats.remote_ssrc = 123; | 294 stats.bytes_sent = 345; |
| 297 stats.bytes_rcvd = 456; | 295 stats.packets_sent = 678; |
| 298 stats.packets_rcvd = 768; | 296 stats.packets_lost = 9012; |
| 299 stats.packets_lost = 101; | 297 stats.fraction_lost = 34.56f; |
| 300 stats.fraction_lost = 23.45f; | 298 stats.codec_name = "codec_name_send"; |
| 301 stats.codec_name = "codec_name"; | 299 stats.ext_seqnum = 789; |
| 302 stats.ext_seqnum = 678; | 300 stats.jitter_ms = 12; |
| 303 stats.jitter_ms = 901; | 301 stats.rtt_ms = 345; |
| 304 stats.jitter_buffer_ms = 234; | 302 stats.audio_level = 678; |
| 305 stats.jitter_buffer_preferred_ms = 567; | 303 stats.aec_quality_min = 9.01f; |
| 306 stats.delay_estimate_ms = 890; | 304 stats.echo_delay_median_ms = 234; |
| 307 stats.audio_level = 1234; | 305 stats.echo_delay_std_ms = 567; |
| 308 stats.expand_rate = 5.67f; | 306 stats.echo_return_loss = 890; |
| 309 stats.speech_expand_rate = 8.90f; | 307 stats.echo_return_loss_enhancement = 1234; |
| 310 stats.secondary_decoded_rate = 1.23f; | 308 stats.typing_noise_detected = true; |
| 311 stats.accelerate_rate = 4.56f; | 309 return stats; |
| 312 stats.preemptive_expand_rate = 7.89f; | 310 } |
| 313 stats.decoding_calls_to_silence_generator = 012; | 311 void SetAudioSendStreamStats() { |
| 314 stats.decoding_calls_to_neteq = 345; | 312 for (auto* s : call_.GetAudioSendStreams()) { |
| 315 stats.decoding_normal = 67890; | 313 s->SetStats(GetAudioSendStreamStats()); |
| 316 stats.decoding_plc = 1234; | |
| 317 stats.decoding_cng = 5678; | |
| 318 stats.decoding_plc_cng = 9012; | |
| 319 stats.capture_start_ntp_time_ms = 3456; | |
| 320 } | 314 } |
| 315 } |
| 316 void VerifyVoiceSenderInfo(const cricket::VoiceSenderInfo& info) { |
| 317 const auto stats = GetAudioSendStreamStats(); |
| 318 EXPECT_EQ(info.ssrc(), stats.local_ssrc); |
| 319 EXPECT_EQ(info.bytes_sent, stats.bytes_sent); |
| 320 EXPECT_EQ(info.packets_sent, stats.packets_sent); |
| 321 EXPECT_EQ(info.packets_lost, stats.packets_lost); |
| 322 EXPECT_EQ(info.fraction_lost, stats.fraction_lost); |
| 323 EXPECT_EQ(info.codec_name, stats.codec_name); |
| 324 EXPECT_EQ(info.ext_seqnum, stats.ext_seqnum); |
| 325 EXPECT_EQ(info.jitter_ms, stats.jitter_ms); |
| 326 EXPECT_EQ(info.rtt_ms, stats.rtt_ms); |
| 327 EXPECT_EQ(info.audio_level, stats.audio_level); |
| 328 EXPECT_EQ(info.aec_quality_min, stats.aec_quality_min); |
| 329 EXPECT_EQ(info.echo_delay_median_ms, stats.echo_delay_median_ms); |
| 330 EXPECT_EQ(info.echo_delay_std_ms, stats.echo_delay_std_ms); |
| 331 EXPECT_EQ(info.echo_return_loss, stats.echo_return_loss); |
| 332 EXPECT_EQ(info.echo_return_loss_enhancement, |
| 333 stats.echo_return_loss_enhancement); |
| 334 // TODO(solenberg): Move typing noise detection into AudioSendStream. |
| 335 // EXPECT_EQ(info.typing_noise_detected, stats.typing_noise_detected); |
| 336 } |
| 337 |
| 338 webrtc::AudioReceiveStream::Stats GetAudioReceiveStreamStats() const { |
| 339 webrtc::AudioReceiveStream::Stats stats; |
| 340 stats.remote_ssrc = 123; |
| 341 stats.bytes_rcvd = 456; |
| 342 stats.packets_rcvd = 768; |
| 343 stats.packets_lost = 101; |
| 344 stats.fraction_lost = 23.45f; |
| 345 stats.codec_name = "codec_name_recv"; |
| 346 stats.ext_seqnum = 678; |
| 347 stats.jitter_ms = 901; |
| 348 stats.jitter_buffer_ms = 234; |
| 349 stats.jitter_buffer_preferred_ms = 567; |
| 350 stats.delay_estimate_ms = 890; |
| 351 stats.audio_level = 1234; |
| 352 stats.expand_rate = 5.67f; |
| 353 stats.speech_expand_rate = 8.90f; |
| 354 stats.secondary_decoded_rate = 1.23f; |
| 355 stats.accelerate_rate = 4.56f; |
| 356 stats.preemptive_expand_rate = 7.89f; |
| 357 stats.decoding_calls_to_silence_generator = 12; |
| 358 stats.decoding_calls_to_neteq = 345; |
| 359 stats.decoding_normal = 67890; |
| 360 stats.decoding_plc = 1234; |
| 361 stats.decoding_cng = 5678; |
| 362 stats.decoding_plc_cng = 9012; |
| 363 stats.capture_start_ntp_time_ms = 3456; |
| 321 return stats; | 364 return stats; |
| 322 } | 365 } |
| 323 void SetAudioReceiveStreamStats() { | 366 void SetAudioReceiveStreamStats() { |
| 324 for (auto* s : call_.GetAudioReceiveStreams()) { | 367 for (auto* s : call_.GetAudioReceiveStreams()) { |
| 325 s->SetStats(GetAudioReceiveStreamStats()); | 368 s->SetStats(GetAudioReceiveStreamStats()); |
| 326 } | 369 } |
| 327 } | 370 } |
| 328 void VerifyVoiceReceiverInfo(const cricket::VoiceReceiverInfo& info) { | 371 void VerifyVoiceReceiverInfo(const cricket::VoiceReceiverInfo& info) { |
| 329 const auto& kStats = GetAudioReceiveStreamStats(); | 372 const auto stats = GetAudioReceiveStreamStats(); |
| 330 EXPECT_EQ(info.local_stats.front().ssrc, kStats.remote_ssrc); | 373 EXPECT_EQ(info.ssrc(), stats.remote_ssrc); |
| 331 EXPECT_EQ(info.bytes_rcvd, kStats.bytes_rcvd); | 374 EXPECT_EQ(info.bytes_rcvd, stats.bytes_rcvd); |
| 332 EXPECT_EQ(info.packets_rcvd, kStats.packets_rcvd); | 375 EXPECT_EQ(info.packets_rcvd, stats.packets_rcvd); |
| 333 EXPECT_EQ(info.packets_lost, kStats.packets_lost); | 376 EXPECT_EQ(info.packets_lost, stats.packets_lost); |
| 334 EXPECT_EQ(info.fraction_lost, kStats.fraction_lost); | 377 EXPECT_EQ(info.fraction_lost, stats.fraction_lost); |
| 335 EXPECT_EQ(info.codec_name, kStats.codec_name); | 378 EXPECT_EQ(info.codec_name, stats.codec_name); |
| 336 EXPECT_EQ(info.ext_seqnum, kStats.ext_seqnum); | 379 EXPECT_EQ(info.ext_seqnum, stats.ext_seqnum); |
| 337 EXPECT_EQ(info.jitter_ms, kStats.jitter_ms); | 380 EXPECT_EQ(info.jitter_ms, stats.jitter_ms); |
| 338 EXPECT_EQ(info.jitter_buffer_ms, kStats.jitter_buffer_ms); | 381 EXPECT_EQ(info.jitter_buffer_ms, stats.jitter_buffer_ms); |
| 339 EXPECT_EQ(info.jitter_buffer_preferred_ms, | 382 EXPECT_EQ(info.jitter_buffer_preferred_ms, |
| 340 kStats.jitter_buffer_preferred_ms); | 383 stats.jitter_buffer_preferred_ms); |
| 341 EXPECT_EQ(info.delay_estimate_ms, kStats.delay_estimate_ms); | 384 EXPECT_EQ(info.delay_estimate_ms, stats.delay_estimate_ms); |
| 342 EXPECT_EQ(info.audio_level, kStats.audio_level); | 385 EXPECT_EQ(info.audio_level, stats.audio_level); |
| 343 EXPECT_EQ(info.expand_rate, kStats.expand_rate); | 386 EXPECT_EQ(info.expand_rate, stats.expand_rate); |
| 344 EXPECT_EQ(info.speech_expand_rate, kStats.speech_expand_rate); | 387 EXPECT_EQ(info.speech_expand_rate, stats.speech_expand_rate); |
| 345 EXPECT_EQ(info.secondary_decoded_rate, kStats.secondary_decoded_rate); | 388 EXPECT_EQ(info.secondary_decoded_rate, stats.secondary_decoded_rate); |
| 346 EXPECT_EQ(info.accelerate_rate, kStats.accelerate_rate); | 389 EXPECT_EQ(info.accelerate_rate, stats.accelerate_rate); |
| 347 EXPECT_EQ(info.preemptive_expand_rate, kStats.preemptive_expand_rate); | 390 EXPECT_EQ(info.preemptive_expand_rate, stats.preemptive_expand_rate); |
| 348 EXPECT_EQ(info.decoding_calls_to_silence_generator, | 391 EXPECT_EQ(info.decoding_calls_to_silence_generator, |
| 349 kStats.decoding_calls_to_silence_generator); | 392 stats.decoding_calls_to_silence_generator); |
| 350 EXPECT_EQ(info.decoding_calls_to_neteq, kStats.decoding_calls_to_neteq); | 393 EXPECT_EQ(info.decoding_calls_to_neteq, stats.decoding_calls_to_neteq); |
| 351 EXPECT_EQ(info.decoding_normal, kStats.decoding_normal); | 394 EXPECT_EQ(info.decoding_normal, stats.decoding_normal); |
| 352 EXPECT_EQ(info.decoding_plc, kStats.decoding_plc); | 395 EXPECT_EQ(info.decoding_plc, stats.decoding_plc); |
| 353 EXPECT_EQ(info.decoding_cng, kStats.decoding_cng); | 396 EXPECT_EQ(info.decoding_cng, stats.decoding_cng); |
| 354 EXPECT_EQ(info.decoding_plc_cng, kStats.decoding_plc_cng); | 397 EXPECT_EQ(info.decoding_plc_cng, stats.decoding_plc_cng); |
| 355 EXPECT_EQ(info.capture_start_ntp_time_ms, kStats.capture_start_ntp_time_ms); | 398 EXPECT_EQ(info.capture_start_ntp_time_ms, stats.capture_start_ntp_time_ms); |
| 356 } | 399 } |
| 357 | 400 |
| 358 protected: | 401 protected: |
| 359 cricket::FakeCall call_; | 402 cricket::FakeCall call_; |
| 360 cricket::FakeWebRtcVoiceEngine voe_; | 403 cricket::FakeWebRtcVoiceEngine voe_; |
| 361 FakeVoETraceWrapper* trace_wrapper_; | 404 FakeVoETraceWrapper* trace_wrapper_; |
| 362 cricket::WebRtcVoiceEngine engine_; | 405 cricket::WebRtcVoiceEngine engine_; |
| 363 cricket::VoiceMediaChannel* channel_; | 406 cricket::VoiceMediaChannel* channel_; |
| 364 | 407 |
| 365 cricket::AudioSendParameters send_parameters_; | 408 cricket::AudioSendParameters send_parameters_; |
| (...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 | 2064 |
| 2022 // Test we can set the correct statistics on all send streams. | 2065 // Test we can set the correct statistics on all send streams. |
| 2023 TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { | 2066 TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { |
| 2024 SetupForMultiSendStream(); | 2067 SetupForMultiSendStream(); |
| 2025 | 2068 |
| 2026 // Create send streams. | 2069 // Create send streams. |
| 2027 for (uint32_t ssrc : kSsrcs4) { | 2070 for (uint32_t ssrc : kSsrcs4) { |
| 2028 EXPECT_TRUE(channel_->AddSendStream( | 2071 EXPECT_TRUE(channel_->AddSendStream( |
| 2029 cricket::StreamParams::CreateLegacy(ssrc))); | 2072 cricket::StreamParams::CreateLegacy(ssrc))); |
| 2030 } | 2073 } |
| 2074 SetAudioSendStreamStats(); |
| 2075 |
| 2031 // Create a receive stream to check that none of the send streams end up in | 2076 // Create a receive stream to check that none of the send streams end up in |
| 2032 // the receive stream stats. | 2077 // the receive stream stats. |
| 2033 EXPECT_TRUE(channel_->AddRecvStream( | 2078 EXPECT_TRUE(channel_->AddRecvStream( |
| 2034 cricket::StreamParams::CreateLegacy(kSsrc2))); | 2079 cricket::StreamParams::CreateLegacy(kSsrc2))); |
| 2035 // We need send codec to be set to get all stats. | 2080 // We need send codec to be set to get all stats. |
| 2036 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2081 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2037 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); | 2082 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
| 2038 | 2083 |
| 2039 cricket::VoiceMediaInfo info; | 2084 // Check stats for the added streams. |
| 2040 EXPECT_EQ(true, channel_->GetStats(&info)); | 2085 { |
| 2041 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); | 2086 cricket::VoiceMediaInfo info; |
| 2087 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2042 | 2088 |
| 2043 // Verify the statistic information is correct. | 2089 // We have added 4 send streams. We should see empty stats for all. |
| 2044 // TODO(solenberg): Make this loop ordering independent. | 2090 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); |
| 2045 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { | 2091 for (const auto& sender : info.senders) { |
| 2046 EXPECT_EQ(kSsrcs4[i], info.senders[i].ssrc()); | 2092 VerifyVoiceSenderInfo(sender); |
| 2047 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); | 2093 } |
| 2048 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].bytes_sent); | 2094 |
| 2049 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_sent); | 2095 // We have added one receive stream. We should see empty stats. |
| 2050 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_lost); | 2096 EXPECT_EQ(info.receivers.size(), 1u); |
| 2051 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[i].fraction_lost); | 2097 EXPECT_EQ(info.receivers[0].ssrc(), 0); |
| 2052 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].ext_seqnum); | |
| 2053 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].rtt_ms); | |
| 2054 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].jitter_ms); | |
| 2055 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); | |
| 2056 } | 2098 } |
| 2057 | 2099 |
| 2058 // We have added one receive stream. We should see empty stats. | |
| 2059 EXPECT_EQ(info.receivers.size(), 1u); | |
| 2060 EXPECT_EQ(info.receivers[0].local_stats.front().ssrc, 0); | |
| 2061 | |
| 2062 // Remove the kSsrc2 stream. No receiver stats. | 2100 // Remove the kSsrc2 stream. No receiver stats. |
| 2063 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); | 2101 { |
| 2064 EXPECT_EQ(true, channel_->GetStats(&info)); | 2102 cricket::VoiceMediaInfo info; |
| 2065 EXPECT_EQ(0u, info.receivers.size()); | 2103 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); |
| 2104 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2105 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); |
| 2106 EXPECT_EQ(0u, info.receivers.size()); |
| 2107 } |
| 2066 | 2108 |
| 2067 // Deliver a new packet - a default receive stream should be created and we | 2109 // Deliver a new packet - a default receive stream should be created and we |
| 2068 // should see stats again. | 2110 // should see stats again. |
| 2069 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2111 { |
| 2070 SetAudioReceiveStreamStats(); | 2112 cricket::VoiceMediaInfo info; |
| 2071 EXPECT_EQ(true, channel_->GetStats(&info)); | 2113 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2072 EXPECT_EQ(1u, info.receivers.size()); | 2114 SetAudioReceiveStreamStats(); |
| 2073 VerifyVoiceReceiverInfo(info.receivers[0]); | 2115 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2116 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); |
| 2117 EXPECT_EQ(1u, info.receivers.size()); |
| 2118 VerifyVoiceReceiverInfo(info.receivers[0]); |
| 2119 } |
| 2074 } | 2120 } |
| 2075 | 2121 |
| 2076 // Test that we can add and remove receive streams, and do proper send/playout. | 2122 // Test that we can add and remove receive streams, and do proper send/playout. |
| 2077 // We can receive on multiple streams while sending one stream. | 2123 // We can receive on multiple streams while sending one stream. |
| 2078 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { | 2124 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { |
| 2079 EXPECT_TRUE(SetupEngineWithSendStream()); | 2125 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2080 int channel_num1 = voe_.GetLastChannel(); | 2126 int channel_num1 = voe_.GetLastChannel(); |
| 2081 | 2127 |
| 2082 // Start playout without a receive stream. | 2128 // Start playout without a receive stream. |
| 2083 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2129 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2285 "tracefilter " + rtc::ToString(webrtc::kTraceDefault); | 2331 "tracefilter " + rtc::ToString(webrtc::kTraceDefault); |
| 2286 engine_.SetLogging(rtc::LS_VERBOSE, filter.c_str()); | 2332 engine_.SetLogging(rtc::LS_VERBOSE, filter.c_str()); |
| 2287 EXPECT_EQ(static_cast<unsigned int>(webrtc::kTraceDefault), | 2333 EXPECT_EQ(static_cast<unsigned int>(webrtc::kTraceDefault), |
| 2288 trace_wrapper_->filter_); | 2334 trace_wrapper_->filter_); |
| 2289 } | 2335 } |
| 2290 | 2336 |
| 2291 // Test that we can set the outgoing SSRC properly. | 2337 // Test that we can set the outgoing SSRC properly. |
| 2292 // SSRC is set in SetupEngine by calling AddSendStream. | 2338 // SSRC is set in SetupEngine by calling AddSendStream. |
| 2293 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { | 2339 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { |
| 2294 EXPECT_TRUE(SetupEngineWithSendStream()); | 2340 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2295 int channel_num = voe_.GetLastChannel(); | 2341 EXPECT_EQ(kSsrc1, voe_.GetLocalSSRC(voe_.GetLastChannel())); |
| 2296 unsigned int send_ssrc; | |
| 2297 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc)); | |
| 2298 EXPECT_NE(0U, send_ssrc); | |
| 2299 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc)); | |
| 2300 EXPECT_EQ(kSsrc1, send_ssrc); | |
| 2301 } | 2342 } |
| 2302 | 2343 |
| 2303 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { | 2344 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { |
| 2304 // Setup. We need send codec to be set to get all stats. | 2345 // Setup. We need send codec to be set to get all stats. |
| 2305 EXPECT_TRUE(SetupEngineWithSendStream()); | 2346 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2347 SetAudioSendStreamStats(); |
| 2306 // SetupEngineWithSendStream adds a send stream with kSsrc1, so the receive | 2348 // SetupEngineWithSendStream adds a send stream with kSsrc1, so the receive |
| 2307 // stream has to use a different SSRC. | 2349 // stream has to use a different SSRC. |
| 2308 EXPECT_TRUE(channel_->AddRecvStream( | 2350 EXPECT_TRUE(channel_->AddRecvStream( |
| 2309 cricket::StreamParams::CreateLegacy(kSsrc2))); | 2351 cricket::StreamParams::CreateLegacy(kSsrc2))); |
| 2310 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2352 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2311 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); | 2353 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
| 2312 | 2354 |
| 2313 cricket::VoiceMediaInfo info; | 2355 // Check stats for the added streams. |
| 2314 EXPECT_EQ(true, channel_->GetStats(&info)); | 2356 { |
| 2315 EXPECT_EQ(1u, info.senders.size()); | 2357 cricket::VoiceMediaInfo info; |
| 2316 EXPECT_EQ(kSsrc1, info.senders[0].ssrc()); | 2358 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2317 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); | 2359 |
| 2318 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].bytes_sent); | 2360 // We have added one send stream. We should see the stats we've set. |
| 2319 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_sent); | 2361 EXPECT_EQ(1u, info.senders.size()); |
| 2320 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_lost); | 2362 VerifyVoiceSenderInfo(info.senders[0]); |
| 2321 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[0].fraction_lost); | 2363 // We have added one receive stream. We should see empty stats. |
| 2322 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].ext_seqnum); | 2364 EXPECT_EQ(info.receivers.size(), 1u); |
| 2323 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].rtt_ms); | 2365 EXPECT_EQ(info.receivers[0].ssrc(), 0); |
| 2324 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].jitter_ms); | 2366 } |
| 2325 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); | |
| 2326 // TODO(sriniv): Add testing for more fields. These are not populated | |
| 2327 // in FakeWebrtcVoiceEngine yet. | |
| 2328 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].audio_level); | |
| 2329 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_median_ms); | |
| 2330 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_std_ms); | |
| 2331 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_return_loss); | |
| 2332 // EXPECT_EQ(cricket::kIntStatValue, | |
| 2333 // info.senders[0].echo_return_loss_enhancement); | |
| 2334 // We have added one receive stream. We should see empty stats. | |
| 2335 EXPECT_EQ(info.receivers.size(), 1u); | |
| 2336 EXPECT_EQ(info.receivers[0].local_stats.front().ssrc, 0); | |
| 2337 | 2367 |
| 2338 // Remove the kSsrc2 stream. No receiver stats. | 2368 // Remove the kSsrc2 stream. No receiver stats. |
| 2339 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); | 2369 { |
| 2340 EXPECT_EQ(true, channel_->GetStats(&info)); | 2370 cricket::VoiceMediaInfo info; |
| 2341 EXPECT_EQ(0u, info.receivers.size()); | 2371 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); |
| 2372 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2373 EXPECT_EQ(1u, info.senders.size()); |
| 2374 EXPECT_EQ(0u, info.receivers.size()); |
| 2375 } |
| 2342 | 2376 |
| 2343 // Deliver a new packet - a default receive stream should be created and we | 2377 // Deliver a new packet - a default receive stream should be created and we |
| 2344 // should see stats again. | 2378 // should see stats again. |
| 2345 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2379 { |
| 2346 SetAudioReceiveStreamStats(); | 2380 cricket::VoiceMediaInfo info; |
| 2347 EXPECT_EQ(true, channel_->GetStats(&info)); | 2381 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2348 EXPECT_EQ(1u, info.receivers.size()); | 2382 SetAudioReceiveStreamStats(); |
| 2349 VerifyVoiceReceiverInfo(info.receivers[0]); | 2383 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2384 EXPECT_EQ(1u, info.senders.size()); |
| 2385 EXPECT_EQ(1u, info.receivers.size()); |
| 2386 VerifyVoiceReceiverInfo(info.receivers[0]); |
| 2387 } |
| 2350 } | 2388 } |
| 2351 | 2389 |
| 2352 // Test that we can set the outgoing SSRC properly with multiple streams. | 2390 // Test that we can set the outgoing SSRC properly with multiple streams. |
| 2353 // SSRC is set in SetupEngine by calling AddSendStream. | 2391 // SSRC is set in SetupEngine by calling AddSendStream. |
| 2354 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { | 2392 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { |
| 2355 EXPECT_TRUE(SetupEngineWithSendStream()); | 2393 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2356 int channel_num1 = voe_.GetLastChannel(); | 2394 EXPECT_EQ(kSsrc1, voe_.GetLocalSSRC(voe_.GetLastChannel())); |
| 2357 unsigned int send_ssrc; | |
| 2358 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc)); | |
| 2359 EXPECT_EQ(kSsrc1, send_ssrc); | |
| 2360 | |
| 2361 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2395 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 2362 int channel_num2 = voe_.GetLastChannel(); | 2396 EXPECT_EQ(kSsrc1, voe_.GetLocalSSRC(voe_.GetLastChannel())); |
| 2363 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num2, send_ssrc)); | |
| 2364 EXPECT_EQ(kSsrc1, send_ssrc); | |
| 2365 } | 2397 } |
| 2366 | 2398 |
| 2367 // Test that the local SSRC is the same on sending and receiving channels if the | 2399 // Test that the local SSRC is the same on sending and receiving channels if the |
| 2368 // receive channel is created before the send channel. | 2400 // receive channel is created before the send channel. |
| 2369 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { | 2401 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { |
| 2370 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); | 2402 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); |
| 2371 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); | 2403 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); |
| 2372 | 2404 |
| 2373 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 2405 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 2374 int receive_channel_num = voe_.GetLastChannel(); | 2406 int receive_channel_num = voe_.GetLastChannel(); |
| 2375 EXPECT_TRUE(channel_->AddSendStream( | 2407 EXPECT_TRUE(channel_->AddSendStream( |
| 2376 cricket::StreamParams::CreateLegacy(1234))); | 2408 cricket::StreamParams::CreateLegacy(1234))); |
| 2377 int send_channel_num = voe_.GetLastChannel(); | 2409 int send_channel_num = voe_.GetLastChannel(); |
| 2378 | 2410 |
| 2379 unsigned int ssrc = 0; | 2411 EXPECT_EQ(1234U, voe_.GetLocalSSRC(send_channel_num)); |
| 2380 EXPECT_EQ(0, voe_.GetLocalSSRC(send_channel_num, ssrc)); | 2412 EXPECT_EQ(1234U, voe_.GetLocalSSRC(receive_channel_num)); |
| 2381 EXPECT_EQ(1234U, ssrc); | |
| 2382 ssrc = 0; | |
| 2383 EXPECT_EQ(0, voe_.GetLocalSSRC(receive_channel_num, ssrc)); | |
| 2384 EXPECT_EQ(1234U, ssrc); | |
| 2385 } | 2413 } |
| 2386 | 2414 |
| 2387 // Test that we can properly receive packets. | 2415 // Test that we can properly receive packets. |
| 2388 TEST_F(WebRtcVoiceEngineTestFake, Recv) { | 2416 TEST_F(WebRtcVoiceEngineTestFake, Recv) { |
| 2389 EXPECT_TRUE(SetupEngine()); | 2417 EXPECT_TRUE(SetupEngine()); |
| 2390 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2418 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2391 int channel_num = voe_.GetLastChannel(); | 2419 int channel_num = voe_.GetLastChannel(); |
| 2392 EXPECT_TRUE(voe_.CheckPacket(channel_num, kPcmuFrame, | 2420 EXPECT_TRUE(voe_.CheckPacket(channel_num, kPcmuFrame, |
| 2393 sizeof(kPcmuFrame))); | 2421 sizeof(kPcmuFrame))); |
| 2394 } | 2422 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2538 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); | 2566 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); |
| 2539 EXPECT_TRUE(channel_->SetPlayout(false)); | 2567 EXPECT_TRUE(channel_->SetPlayout(false)); |
| 2540 EXPECT_FALSE(channel_->SetPlayout(true)); | 2568 EXPECT_FALSE(channel_->SetPlayout(true)); |
| 2541 } | 2569 } |
| 2542 | 2570 |
| 2543 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { | 2571 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { |
| 2544 EXPECT_TRUE(SetupEngineWithSendStream()); | 2572 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2545 | 2573 |
| 2546 bool ec_enabled; | 2574 bool ec_enabled; |
| 2547 webrtc::EcModes ec_mode; | 2575 webrtc::EcModes ec_mode; |
| 2548 bool ec_metrics_enabled; | |
| 2549 webrtc::AecmModes aecm_mode; | 2576 webrtc::AecmModes aecm_mode; |
| 2550 bool cng_enabled; | 2577 bool cng_enabled; |
| 2551 bool agc_enabled; | 2578 bool agc_enabled; |
| 2552 webrtc::AgcModes agc_mode; | 2579 webrtc::AgcModes agc_mode; |
| 2553 webrtc::AgcConfig agc_config; | 2580 webrtc::AgcConfig agc_config; |
| 2554 bool ns_enabled; | 2581 bool ns_enabled; |
| 2555 webrtc::NsModes ns_mode; | 2582 webrtc::NsModes ns_mode; |
| 2556 bool highpass_filter_enabled; | 2583 bool highpass_filter_enabled; |
| 2557 bool stereo_swapping_enabled; | 2584 bool stereo_swapping_enabled; |
| 2558 bool typing_detection_enabled; | 2585 bool typing_detection_enabled; |
| 2559 voe_.GetEcStatus(ec_enabled, ec_mode); | 2586 voe_.GetEcStatus(ec_enabled, ec_mode); |
| 2560 voe_.GetEcMetricsStatus(ec_metrics_enabled); | |
| 2561 voe_.GetAecmMode(aecm_mode, cng_enabled); | 2587 voe_.GetAecmMode(aecm_mode, cng_enabled); |
| 2562 voe_.GetAgcStatus(agc_enabled, agc_mode); | 2588 voe_.GetAgcStatus(agc_enabled, agc_mode); |
| 2563 voe_.GetAgcConfig(agc_config); | 2589 voe_.GetAgcConfig(agc_config); |
| 2564 voe_.GetNsStatus(ns_enabled, ns_mode); | 2590 voe_.GetNsStatus(ns_enabled, ns_mode); |
| 2565 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); | 2591 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); |
| 2566 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | 2592 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); |
| 2567 voe_.GetTypingDetectionStatus(typing_detection_enabled); | 2593 voe_.GetTypingDetectionStatus(typing_detection_enabled); |
| 2568 EXPECT_TRUE(ec_enabled); | 2594 EXPECT_TRUE(ec_enabled); |
| 2569 EXPECT_TRUE(ec_metrics_enabled); | 2595 EXPECT_TRUE(voe_.ec_metrics_enabled()); |
| 2570 EXPECT_FALSE(cng_enabled); | 2596 EXPECT_FALSE(cng_enabled); |
| 2571 EXPECT_TRUE(agc_enabled); | 2597 EXPECT_TRUE(agc_enabled); |
| 2572 EXPECT_EQ(0, agc_config.targetLeveldBOv); | 2598 EXPECT_EQ(0, agc_config.targetLeveldBOv); |
| 2573 EXPECT_TRUE(ns_enabled); | 2599 EXPECT_TRUE(ns_enabled); |
| 2574 EXPECT_TRUE(highpass_filter_enabled); | 2600 EXPECT_TRUE(highpass_filter_enabled); |
| 2575 EXPECT_FALSE(stereo_swapping_enabled); | 2601 EXPECT_FALSE(stereo_swapping_enabled); |
| 2576 EXPECT_TRUE(typing_detection_enabled); | 2602 EXPECT_TRUE(typing_detection_enabled); |
| 2577 EXPECT_EQ(ec_mode, webrtc::kEcConference); | 2603 EXPECT_EQ(ec_mode, webrtc::kEcConference); |
| 2578 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); | 2604 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); |
| 2579 | 2605 |
| 2580 // Nothing set, so all ignored. | 2606 // Nothing set, so all ignored. |
| 2581 cricket::AudioOptions options; | 2607 cricket::AudioOptions options; |
| 2582 ASSERT_TRUE(engine_.SetOptions(options)); | 2608 ASSERT_TRUE(engine_.SetOptions(options)); |
| 2583 voe_.GetEcStatus(ec_enabled, ec_mode); | 2609 voe_.GetEcStatus(ec_enabled, ec_mode); |
| 2584 voe_.GetEcMetricsStatus(ec_metrics_enabled); | |
| 2585 voe_.GetAecmMode(aecm_mode, cng_enabled); | 2610 voe_.GetAecmMode(aecm_mode, cng_enabled); |
| 2586 voe_.GetAgcStatus(agc_enabled, agc_mode); | 2611 voe_.GetAgcStatus(agc_enabled, agc_mode); |
| 2587 voe_.GetAgcConfig(agc_config); | 2612 voe_.GetAgcConfig(agc_config); |
| 2588 voe_.GetNsStatus(ns_enabled, ns_mode); | 2613 voe_.GetNsStatus(ns_enabled, ns_mode); |
| 2589 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); | 2614 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); |
| 2590 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | 2615 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); |
| 2591 voe_.GetTypingDetectionStatus(typing_detection_enabled); | 2616 voe_.GetTypingDetectionStatus(typing_detection_enabled); |
| 2592 EXPECT_TRUE(ec_enabled); | 2617 EXPECT_TRUE(ec_enabled); |
| 2593 EXPECT_TRUE(ec_metrics_enabled); | 2618 EXPECT_TRUE(voe_.ec_metrics_enabled()); |
| 2594 EXPECT_FALSE(cng_enabled); | 2619 EXPECT_FALSE(cng_enabled); |
| 2595 EXPECT_TRUE(agc_enabled); | 2620 EXPECT_TRUE(agc_enabled); |
| 2596 EXPECT_EQ(0, agc_config.targetLeveldBOv); | 2621 EXPECT_EQ(0, agc_config.targetLeveldBOv); |
| 2597 EXPECT_TRUE(ns_enabled); | 2622 EXPECT_TRUE(ns_enabled); |
| 2598 EXPECT_TRUE(highpass_filter_enabled); | 2623 EXPECT_TRUE(highpass_filter_enabled); |
| 2599 EXPECT_FALSE(stereo_swapping_enabled); | 2624 EXPECT_FALSE(stereo_swapping_enabled); |
| 2600 EXPECT_TRUE(typing_detection_enabled); | 2625 EXPECT_TRUE(typing_detection_enabled); |
| 2601 EXPECT_EQ(ec_mode, webrtc::kEcConference); | 2626 EXPECT_EQ(ec_mode, webrtc::kEcConference); |
| 2602 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); | 2627 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); |
| 2603 EXPECT_EQ(50, voe_.GetNetEqCapacity()); // From GetDefaultEngineOptions(). | 2628 EXPECT_EQ(50, voe_.GetNetEqCapacity()); // From GetDefaultEngineOptions(). |
| 2604 EXPECT_FALSE( | 2629 EXPECT_FALSE( |
| 2605 voe_.GetNetEqFastAccelerate()); // From GetDefaultEngineOptions(). | 2630 voe_.GetNetEqFastAccelerate()); // From GetDefaultEngineOptions(). |
| 2606 | 2631 |
| 2607 // Turn echo cancellation off | 2632 // Turn echo cancellation off |
| 2608 options.echo_cancellation.Set(false); | 2633 options.echo_cancellation.Set(false); |
| 2609 ASSERT_TRUE(engine_.SetOptions(options)); | 2634 ASSERT_TRUE(engine_.SetOptions(options)); |
| 2610 voe_.GetEcStatus(ec_enabled, ec_mode); | 2635 voe_.GetEcStatus(ec_enabled, ec_mode); |
| 2611 EXPECT_FALSE(ec_enabled); | 2636 EXPECT_FALSE(ec_enabled); |
| 2612 | 2637 |
| 2613 // Turn echo cancellation back on, with settings, and make sure | 2638 // Turn echo cancellation back on, with settings, and make sure |
| 2614 // nothing else changed. | 2639 // nothing else changed. |
| 2615 options.echo_cancellation.Set(true); | 2640 options.echo_cancellation.Set(true); |
| 2616 ASSERT_TRUE(engine_.SetOptions(options)); | 2641 ASSERT_TRUE(engine_.SetOptions(options)); |
| 2617 voe_.GetEcStatus(ec_enabled, ec_mode); | 2642 voe_.GetEcStatus(ec_enabled, ec_mode); |
| 2618 voe_.GetEcMetricsStatus(ec_metrics_enabled); | |
| 2619 voe_.GetAecmMode(aecm_mode, cng_enabled); | 2643 voe_.GetAecmMode(aecm_mode, cng_enabled); |
| 2620 voe_.GetAgcStatus(agc_enabled, agc_mode); | 2644 voe_.GetAgcStatus(agc_enabled, agc_mode); |
| 2621 voe_.GetAgcConfig(agc_config); | 2645 voe_.GetAgcConfig(agc_config); |
| 2622 voe_.GetNsStatus(ns_enabled, ns_mode); | 2646 voe_.GetNsStatus(ns_enabled, ns_mode); |
| 2623 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); | 2647 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); |
| 2624 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | 2648 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); |
| 2625 voe_.GetTypingDetectionStatus(typing_detection_enabled); | 2649 voe_.GetTypingDetectionStatus(typing_detection_enabled); |
| 2626 EXPECT_TRUE(ec_enabled); | 2650 EXPECT_TRUE(ec_enabled); |
| 2627 EXPECT_TRUE(ec_metrics_enabled); | 2651 EXPECT_TRUE(voe_.ec_metrics_enabled()); |
| 2628 EXPECT_TRUE(agc_enabled); | 2652 EXPECT_TRUE(agc_enabled); |
| 2629 EXPECT_EQ(0, agc_config.targetLeveldBOv); | 2653 EXPECT_EQ(0, agc_config.targetLeveldBOv); |
| 2630 EXPECT_TRUE(ns_enabled); | 2654 EXPECT_TRUE(ns_enabled); |
| 2631 EXPECT_TRUE(highpass_filter_enabled); | 2655 EXPECT_TRUE(highpass_filter_enabled); |
| 2632 EXPECT_FALSE(stereo_swapping_enabled); | 2656 EXPECT_FALSE(stereo_swapping_enabled); |
| 2633 EXPECT_TRUE(typing_detection_enabled); | 2657 EXPECT_TRUE(typing_detection_enabled); |
| 2634 EXPECT_EQ(ec_mode, webrtc::kEcConference); | 2658 EXPECT_EQ(ec_mode, webrtc::kEcConference); |
| 2635 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); | 2659 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); |
| 2636 | 2660 |
| 2637 // Turn on delay agnostic aec and make sure nothing change w.r.t. echo | 2661 // Turn on delay agnostic aec and make sure nothing change w.r.t. echo |
| 2638 // control. | 2662 // control. |
| 2639 options.delay_agnostic_aec.Set(true); | 2663 options.delay_agnostic_aec.Set(true); |
| 2640 ASSERT_TRUE(engine_.SetOptions(options)); | 2664 ASSERT_TRUE(engine_.SetOptions(options)); |
| 2641 voe_.GetEcStatus(ec_enabled, ec_mode); | 2665 voe_.GetEcStatus(ec_enabled, ec_mode); |
| 2642 voe_.GetEcMetricsStatus(ec_metrics_enabled); | |
| 2643 voe_.GetAecmMode(aecm_mode, cng_enabled); | 2666 voe_.GetAecmMode(aecm_mode, cng_enabled); |
| 2644 EXPECT_TRUE(ec_enabled); | 2667 EXPECT_TRUE(ec_enabled); |
| 2645 EXPECT_TRUE(ec_metrics_enabled); | 2668 EXPECT_TRUE(voe_.ec_metrics_enabled()); |
| 2646 EXPECT_EQ(ec_mode, webrtc::kEcConference); | 2669 EXPECT_EQ(ec_mode, webrtc::kEcConference); |
| 2647 | 2670 |
| 2648 // Turn off echo cancellation and delay agnostic aec. | 2671 // Turn off echo cancellation and delay agnostic aec. |
| 2649 options.delay_agnostic_aec.Set(false); | 2672 options.delay_agnostic_aec.Set(false); |
| 2650 options.extended_filter_aec.Set(false); | 2673 options.extended_filter_aec.Set(false); |
| 2651 options.echo_cancellation.Set(false); | 2674 options.echo_cancellation.Set(false); |
| 2652 ASSERT_TRUE(engine_.SetOptions(options)); | 2675 ASSERT_TRUE(engine_.SetOptions(options)); |
| 2653 voe_.GetEcStatus(ec_enabled, ec_mode); | 2676 voe_.GetEcStatus(ec_enabled, ec_mode); |
| 2654 EXPECT_FALSE(ec_enabled); | 2677 EXPECT_FALSE(ec_enabled); |
| 2655 // Turning delay agnostic aec back on should also turn on echo cancellation. | 2678 // Turning delay agnostic aec back on should also turn on echo cancellation. |
| 2656 options.delay_agnostic_aec.Set(true); | 2679 options.delay_agnostic_aec.Set(true); |
| 2657 ASSERT_TRUE(engine_.SetOptions(options)); | 2680 ASSERT_TRUE(engine_.SetOptions(options)); |
| 2658 voe_.GetEcStatus(ec_enabled, ec_mode); | 2681 voe_.GetEcStatus(ec_enabled, ec_mode); |
| 2659 voe_.GetEcMetricsStatus(ec_metrics_enabled); | |
| 2660 EXPECT_TRUE(ec_enabled); | 2682 EXPECT_TRUE(ec_enabled); |
| 2661 EXPECT_TRUE(ec_metrics_enabled); | 2683 EXPECT_TRUE(voe_.ec_metrics_enabled()); |
| 2662 EXPECT_EQ(ec_mode, webrtc::kEcConference); | 2684 EXPECT_EQ(ec_mode, webrtc::kEcConference); |
| 2663 | 2685 |
| 2664 // Turn off AGC | 2686 // Turn off AGC |
| 2665 options.auto_gain_control.Set(false); | 2687 options.auto_gain_control.Set(false); |
| 2666 ASSERT_TRUE(engine_.SetOptions(options)); | 2688 ASSERT_TRUE(engine_.SetOptions(options)); |
| 2667 voe_.GetAgcStatus(agc_enabled, agc_mode); | 2689 voe_.GetAgcStatus(agc_enabled, agc_mode); |
| 2668 EXPECT_FALSE(agc_enabled); | 2690 EXPECT_FALSE(agc_enabled); |
| 2669 | 2691 |
| 2670 // Turn AGC back on | 2692 // Turn AGC back on |
| 2671 options.auto_gain_control.Set(true); | 2693 options.auto_gain_control.Set(true); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2699 EXPECT_EQ(webrtc::kEcConference, ec_mode); | 2721 EXPECT_EQ(webrtc::kEcConference, ec_mode); |
| 2700 EXPECT_FALSE(ns_enabled); | 2722 EXPECT_FALSE(ns_enabled); |
| 2701 EXPECT_EQ(webrtc::kNsHighSuppression, ns_mode); | 2723 EXPECT_EQ(webrtc::kNsHighSuppression, ns_mode); |
| 2702 } | 2724 } |
| 2703 | 2725 |
| 2704 TEST_F(WebRtcVoiceEngineTestFake, DefaultOptions) { | 2726 TEST_F(WebRtcVoiceEngineTestFake, DefaultOptions) { |
| 2705 EXPECT_TRUE(SetupEngineWithSendStream()); | 2727 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2706 | 2728 |
| 2707 bool ec_enabled; | 2729 bool ec_enabled; |
| 2708 webrtc::EcModes ec_mode; | 2730 webrtc::EcModes ec_mode; |
| 2709 bool ec_metrics_enabled; | |
| 2710 bool agc_enabled; | 2731 bool agc_enabled; |
| 2711 webrtc::AgcModes agc_mode; | 2732 webrtc::AgcModes agc_mode; |
| 2712 bool ns_enabled; | 2733 bool ns_enabled; |
| 2713 webrtc::NsModes ns_mode; | 2734 webrtc::NsModes ns_mode; |
| 2714 bool highpass_filter_enabled; | 2735 bool highpass_filter_enabled; |
| 2715 bool stereo_swapping_enabled; | 2736 bool stereo_swapping_enabled; |
| 2716 bool typing_detection_enabled; | 2737 bool typing_detection_enabled; |
| 2717 | 2738 |
| 2718 voe_.GetEcStatus(ec_enabled, ec_mode); | 2739 voe_.GetEcStatus(ec_enabled, ec_mode); |
| 2719 voe_.GetEcMetricsStatus(ec_metrics_enabled); | |
| 2720 voe_.GetAgcStatus(agc_enabled, agc_mode); | 2740 voe_.GetAgcStatus(agc_enabled, agc_mode); |
| 2721 voe_.GetNsStatus(ns_enabled, ns_mode); | 2741 voe_.GetNsStatus(ns_enabled, ns_mode); |
| 2722 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); | 2742 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); |
| 2723 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | 2743 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); |
| 2724 voe_.GetTypingDetectionStatus(typing_detection_enabled); | 2744 voe_.GetTypingDetectionStatus(typing_detection_enabled); |
| 2725 EXPECT_TRUE(ec_enabled); | 2745 EXPECT_TRUE(ec_enabled); |
| 2726 EXPECT_TRUE(agc_enabled); | 2746 EXPECT_TRUE(agc_enabled); |
| 2727 EXPECT_TRUE(ns_enabled); | 2747 EXPECT_TRUE(ns_enabled); |
| 2728 EXPECT_TRUE(highpass_filter_enabled); | 2748 EXPECT_TRUE(highpass_filter_enabled); |
| 2729 EXPECT_TRUE(typing_detection_enabled); | 2749 EXPECT_TRUE(typing_detection_enabled); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2971 for (uint32_t ssrc : ssrcs) { | 2991 for (uint32_t ssrc : ssrcs) { |
| 2972 EXPECT_TRUE(media_channel->AddRecvStream( | 2992 EXPECT_TRUE(media_channel->AddRecvStream( |
| 2973 cricket::StreamParams::CreateLegacy(ssrc))); | 2993 cricket::StreamParams::CreateLegacy(ssrc))); |
| 2974 } | 2994 } |
| 2975 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); | 2995 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); |
| 2976 | 2996 |
| 2977 // Combined BWE should be disabled. | 2997 // Combined BWE should be disabled. |
| 2978 for (uint32_t ssrc : ssrcs) { | 2998 for (uint32_t ssrc : ssrcs) { |
| 2979 const auto* s = call_.GetAudioReceiveStream(ssrc); | 2999 const auto* s = call_.GetAudioReceiveStream(ssrc); |
| 2980 EXPECT_NE(nullptr, s); | 3000 EXPECT_NE(nullptr, s); |
| 2981 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); | 3001 EXPECT_FALSE(s->GetConfig().combined_audio_video_bwe); |
| 2982 } | 3002 } |
| 2983 | 3003 |
| 2984 // Enable combined BWE option - now it should be set up. | 3004 // Enable combined BWE option - now it should be set up. |
| 2985 send_parameters_.options.combined_audio_video_bwe.Set(true); | 3005 send_parameters_.options.combined_audio_video_bwe.Set(true); |
| 2986 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); | 3006 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); |
| 2987 for (uint32_t ssrc : ssrcs) { | 3007 for (uint32_t ssrc : ssrcs) { |
| 2988 const auto* s = call_.GetAudioReceiveStream(ssrc); | 3008 const auto* s = call_.GetAudioReceiveStream(ssrc); |
| 2989 EXPECT_NE(nullptr, s); | 3009 EXPECT_NE(nullptr, s); |
| 2990 EXPECT_EQ(true, s->GetConfig().combined_audio_video_bwe); | 3010 EXPECT_EQ(true, s->GetConfig().combined_audio_video_bwe); |
| 2991 } | 3011 } |
| 2992 | 3012 |
| 2993 // Disable combined BWE option - should be disabled again. | 3013 // Disable combined BWE option - should be disabled again. |
| 2994 send_parameters_.options.combined_audio_video_bwe.Set(false); | 3014 send_parameters_.options.combined_audio_video_bwe.Set(false); |
| 2995 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); | 3015 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); |
| 2996 for (uint32_t ssrc : ssrcs) { | 3016 for (uint32_t ssrc : ssrcs) { |
| 2997 const auto* s = call_.GetAudioReceiveStream(ssrc); | 3017 const auto* s = call_.GetAudioReceiveStream(ssrc); |
| 2998 EXPECT_NE(nullptr, s); | 3018 EXPECT_NE(nullptr, s); |
| 2999 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); | 3019 EXPECT_FALSE(s->GetConfig().combined_audio_video_bwe); |
| 3000 } | 3020 } |
| 3001 | 3021 |
| 3002 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); | 3022 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); |
| 3003 } | 3023 } |
| 3004 | 3024 |
| 3005 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { | 3025 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { |
| 3006 // Test that adding receive streams after enabling combined bandwidth | 3026 // Test that adding receive streams after enabling combined bandwidth |
| 3007 // estimation will correctly configure each channel. | 3027 // estimation will correctly configure each channel. |
| 3008 EXPECT_TRUE(SetupEngineWithSendStream()); | 3028 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 3009 cricket::WebRtcVoiceMediaChannel* media_channel = | 3029 cricket::WebRtcVoiceMediaChannel* media_channel = |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3284 cricket::WebRtcVoiceEngine engine; | 3304 cricket::WebRtcVoiceEngine engine; |
| 3285 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3305 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
| 3286 rtc::scoped_ptr<webrtc::Call> call( | 3306 rtc::scoped_ptr<webrtc::Call> call( |
| 3287 webrtc::Call::Create(webrtc::Call::Config())); | 3307 webrtc::Call::Create(webrtc::Call::Config())); |
| 3288 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), | 3308 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), |
| 3289 call.get()); | 3309 call.get()); |
| 3290 cricket::AudioRecvParameters parameters; | 3310 cricket::AudioRecvParameters parameters; |
| 3291 parameters.codecs = engine.codecs(); | 3311 parameters.codecs = engine.codecs(); |
| 3292 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3312 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
| 3293 } | 3313 } |
| OLD | NEW |