Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1267)

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine_unittest.cc

Issue 1430433004: Replace rtc::cricket::Settable with rtc::Maybe (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 class WebRtcVoiceEngineTestFake : public testing::Test { 90 class WebRtcVoiceEngineTestFake : public testing::Test {
91 public: 91 public:
92 WebRtcVoiceEngineTestFake() 92 WebRtcVoiceEngineTestFake()
93 : call_(webrtc::Call::Config()), 93 : call_(webrtc::Call::Config()),
94 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)), 94 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)),
95 trace_wrapper_(new FakeVoETraceWrapper()), 95 trace_wrapper_(new FakeVoETraceWrapper()),
96 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), 96 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_),
97 channel_(nullptr) { 97 channel_(nullptr) {
98 send_parameters_.codecs.push_back(kPcmuCodec); 98 send_parameters_.codecs.push_back(kPcmuCodec);
99 recv_parameters_.codecs.push_back(kPcmuCodec); 99 recv_parameters_.codecs.push_back(kPcmuCodec);
100 options_adjust_agc_.adjust_agc_delta.Set(-10); 100 options_adjust_agc_.adjust_agc_delta = rtc::Maybe<int>(-10);
101 } 101 }
102 bool SetupEngine() { 102 bool SetupEngine() {
103 if (!engine_.Init(rtc::Thread::Current())) { 103 if (!engine_.Init(rtc::Thread::Current())) {
104 return false; 104 return false;
105 } 105 }
106 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 106 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
107 return (channel_ != nullptr); 107 return (channel_ != nullptr);
108 } 108 }
109 bool SetupEngineWithRecvStream() { 109 bool SetupEngineWithRecvStream() {
110 if (!SetupEngine()) { 110 if (!SetupEngine()) {
(...skipping 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 EXPECT_EQ(0, agc_config.targetLeveldBOv); // level was restored 2274 EXPECT_EQ(0, agc_config.targetLeveldBOv); // level was restored
2275 } 2275 }
2276 2276
2277 TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { 2277 TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) {
2278 EXPECT_TRUE(SetupEngineWithSendStream()); 2278 EXPECT_TRUE(SetupEngineWithSendStream());
2279 webrtc::AgcConfig agc_config; 2279 webrtc::AgcConfig agc_config;
2280 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2280 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2281 EXPECT_EQ(0, agc_config.targetLeveldBOv); 2281 EXPECT_EQ(0, agc_config.targetLeveldBOv);
2282 2282
2283 cricket::AudioOptions options; 2283 cricket::AudioOptions options;
2284 options.tx_agc_target_dbov.Set(3); 2284 options.tx_agc_target_dbov = rtc::Maybe<uint16_t>(3);
2285 options.tx_agc_digital_compression_gain.Set(9); 2285 options.tx_agc_digital_compression_gain = rtc::Maybe<uint16_t>(9);
2286 options.tx_agc_limiter.Set(true); 2286 options.tx_agc_limiter = rtc::Maybe<bool>(true);
2287 options.auto_gain_control.Set(true); 2287 options.auto_gain_control = rtc::Maybe<bool>(true);
2288 EXPECT_TRUE(engine_.SetOptions(options)); 2288 EXPECT_TRUE(engine_.SetOptions(options));
2289 2289
2290 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2290 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2291 EXPECT_EQ(3, agc_config.targetLeveldBOv); 2291 EXPECT_EQ(3, agc_config.targetLeveldBOv);
2292 EXPECT_EQ(9, agc_config.digitalCompressionGaindB); 2292 EXPECT_EQ(9, agc_config.digitalCompressionGaindB);
2293 EXPECT_TRUE(agc_config.limiterEnable); 2293 EXPECT_TRUE(agc_config.limiterEnable);
2294 2294
2295 // Check interaction with adjust_agc_delta. Both should be respected, for 2295 // Check interaction with adjust_agc_delta. Both should be respected, for
2296 // backwards compatibility. 2296 // backwards compatibility.
2297 options.adjust_agc_delta.Set(-10); 2297 options.adjust_agc_delta = rtc::Maybe<int>(-10);
2298 EXPECT_TRUE(engine_.SetOptions(options)); 2298 EXPECT_TRUE(engine_.SetOptions(options));
2299 2299
2300 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2300 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2301 EXPECT_EQ(13, agc_config.targetLeveldBOv); 2301 EXPECT_EQ(13, agc_config.targetLeveldBOv);
2302 } 2302 }
2303 2303
2304 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { 2304 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) {
2305 EXPECT_TRUE(SetupEngineWithSendStream()); 2305 EXPECT_TRUE(SetupEngineWithSendStream());
2306 cricket::AudioOptions options; 2306 cricket::AudioOptions options;
2307 options.recording_sample_rate.Set(48000u); 2307 options.recording_sample_rate = rtc::Maybe<uint32_t>(48000);
2308 options.playout_sample_rate.Set(44100u); 2308 options.playout_sample_rate = rtc::Maybe<uint32_t>(44100);
2309 EXPECT_TRUE(engine_.SetOptions(options)); 2309 EXPECT_TRUE(engine_.SetOptions(options));
2310 2310
2311 unsigned int recording_sample_rate, playout_sample_rate; 2311 unsigned int recording_sample_rate, playout_sample_rate;
2312 EXPECT_EQ(0, voe_.RecordingSampleRate(&recording_sample_rate)); 2312 EXPECT_EQ(0, voe_.RecordingSampleRate(&recording_sample_rate));
2313 EXPECT_EQ(0, voe_.PlayoutSampleRate(&playout_sample_rate)); 2313 EXPECT_EQ(0, voe_.PlayoutSampleRate(&playout_sample_rate));
2314 EXPECT_EQ(48000u, recording_sample_rate); 2314 EXPECT_EQ(48000u, recording_sample_rate);
2315 EXPECT_EQ(44100u, playout_sample_rate); 2315 EXPECT_EQ(44100u, playout_sample_rate);
2316 } 2316 }
2317 2317
2318 TEST_F(WebRtcVoiceEngineTestFake, TraceFilterViaTraceOptions) { 2318 TEST_F(WebRtcVoiceEngineTestFake, TraceFilterViaTraceOptions) {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2623 EXPECT_TRUE(highpass_filter_enabled); 2623 EXPECT_TRUE(highpass_filter_enabled);
2624 EXPECT_FALSE(stereo_swapping_enabled); 2624 EXPECT_FALSE(stereo_swapping_enabled);
2625 EXPECT_TRUE(typing_detection_enabled); 2625 EXPECT_TRUE(typing_detection_enabled);
2626 EXPECT_EQ(ec_mode, webrtc::kEcConference); 2626 EXPECT_EQ(ec_mode, webrtc::kEcConference);
2627 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); 2627 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression);
2628 EXPECT_EQ(50, voe_.GetNetEqCapacity()); // From GetDefaultEngineOptions(). 2628 EXPECT_EQ(50, voe_.GetNetEqCapacity()); // From GetDefaultEngineOptions().
2629 EXPECT_FALSE( 2629 EXPECT_FALSE(
2630 voe_.GetNetEqFastAccelerate()); // From GetDefaultEngineOptions(). 2630 voe_.GetNetEqFastAccelerate()); // From GetDefaultEngineOptions().
2631 2631
2632 // Turn echo cancellation off 2632 // Turn echo cancellation off
2633 options.echo_cancellation.Set(false); 2633 options.echo_cancellation = rtc::Maybe<bool>(false);
2634 ASSERT_TRUE(engine_.SetOptions(options)); 2634 ASSERT_TRUE(engine_.SetOptions(options));
2635 voe_.GetEcStatus(ec_enabled, ec_mode); 2635 voe_.GetEcStatus(ec_enabled, ec_mode);
2636 EXPECT_FALSE(ec_enabled); 2636 EXPECT_FALSE(ec_enabled);
2637 2637
2638 // Turn echo cancellation back on, with settings, and make sure 2638 // Turn echo cancellation back on, with settings, and make sure
2639 // nothing else changed. 2639 // nothing else changed.
2640 options.echo_cancellation.Set(true); 2640 options.echo_cancellation = rtc::Maybe<bool>(true);
2641 ASSERT_TRUE(engine_.SetOptions(options)); 2641 ASSERT_TRUE(engine_.SetOptions(options));
2642 voe_.GetEcStatus(ec_enabled, ec_mode); 2642 voe_.GetEcStatus(ec_enabled, ec_mode);
2643 voe_.GetAecmMode(aecm_mode, cng_enabled); 2643 voe_.GetAecmMode(aecm_mode, cng_enabled);
2644 voe_.GetAgcStatus(agc_enabled, agc_mode); 2644 voe_.GetAgcStatus(agc_enabled, agc_mode);
2645 voe_.GetAgcConfig(agc_config); 2645 voe_.GetAgcConfig(agc_config);
2646 voe_.GetNsStatus(ns_enabled, ns_mode); 2646 voe_.GetNsStatus(ns_enabled, ns_mode);
2647 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); 2647 highpass_filter_enabled = voe_.IsHighPassFilterEnabled();
2648 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); 2648 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled();
2649 voe_.GetTypingDetectionStatus(typing_detection_enabled); 2649 voe_.GetTypingDetectionStatus(typing_detection_enabled);
2650 EXPECT_TRUE(ec_enabled); 2650 EXPECT_TRUE(ec_enabled);
2651 EXPECT_TRUE(voe_.ec_metrics_enabled()); 2651 EXPECT_TRUE(voe_.ec_metrics_enabled());
2652 EXPECT_TRUE(agc_enabled); 2652 EXPECT_TRUE(agc_enabled);
2653 EXPECT_EQ(0, agc_config.targetLeveldBOv); 2653 EXPECT_EQ(0, agc_config.targetLeveldBOv);
2654 EXPECT_TRUE(ns_enabled); 2654 EXPECT_TRUE(ns_enabled);
2655 EXPECT_TRUE(highpass_filter_enabled); 2655 EXPECT_TRUE(highpass_filter_enabled);
2656 EXPECT_FALSE(stereo_swapping_enabled); 2656 EXPECT_FALSE(stereo_swapping_enabled);
2657 EXPECT_TRUE(typing_detection_enabled); 2657 EXPECT_TRUE(typing_detection_enabled);
2658 EXPECT_EQ(ec_mode, webrtc::kEcConference); 2658 EXPECT_EQ(ec_mode, webrtc::kEcConference);
2659 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression); 2659 EXPECT_EQ(ns_mode, webrtc::kNsHighSuppression);
2660 2660
2661 // 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
2662 // control. 2662 // control.
2663 options.delay_agnostic_aec.Set(true); 2663 options.delay_agnostic_aec = rtc::Maybe<bool>(true);
2664 ASSERT_TRUE(engine_.SetOptions(options)); 2664 ASSERT_TRUE(engine_.SetOptions(options));
2665 voe_.GetEcStatus(ec_enabled, ec_mode); 2665 voe_.GetEcStatus(ec_enabled, ec_mode);
2666 voe_.GetAecmMode(aecm_mode, cng_enabled); 2666 voe_.GetAecmMode(aecm_mode, cng_enabled);
2667 EXPECT_TRUE(ec_enabled); 2667 EXPECT_TRUE(ec_enabled);
2668 EXPECT_TRUE(voe_.ec_metrics_enabled()); 2668 EXPECT_TRUE(voe_.ec_metrics_enabled());
2669 EXPECT_EQ(ec_mode, webrtc::kEcConference); 2669 EXPECT_EQ(ec_mode, webrtc::kEcConference);
2670 2670
2671 // Turn off echo cancellation and delay agnostic aec. 2671 // Turn off echo cancellation and delay agnostic aec.
2672 options.delay_agnostic_aec.Set(false); 2672 options.delay_agnostic_aec = rtc::Maybe<bool>(false);
2673 options.extended_filter_aec.Set(false); 2673 options.extended_filter_aec = rtc::Maybe<bool>(false);
2674 options.echo_cancellation.Set(false); 2674 options.echo_cancellation = rtc::Maybe<bool>(false);
2675 ASSERT_TRUE(engine_.SetOptions(options)); 2675 ASSERT_TRUE(engine_.SetOptions(options));
2676 voe_.GetEcStatus(ec_enabled, ec_mode); 2676 voe_.GetEcStatus(ec_enabled, ec_mode);
2677 EXPECT_FALSE(ec_enabled); 2677 EXPECT_FALSE(ec_enabled);
2678 // 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.
2679 options.delay_agnostic_aec.Set(true); 2679 options.delay_agnostic_aec = rtc::Maybe<bool>(true);
2680 ASSERT_TRUE(engine_.SetOptions(options)); 2680 ASSERT_TRUE(engine_.SetOptions(options));
2681 voe_.GetEcStatus(ec_enabled, ec_mode); 2681 voe_.GetEcStatus(ec_enabled, ec_mode);
2682 EXPECT_TRUE(ec_enabled); 2682 EXPECT_TRUE(ec_enabled);
2683 EXPECT_TRUE(voe_.ec_metrics_enabled()); 2683 EXPECT_TRUE(voe_.ec_metrics_enabled());
2684 EXPECT_EQ(ec_mode, webrtc::kEcConference); 2684 EXPECT_EQ(ec_mode, webrtc::kEcConference);
2685 2685
2686 // Turn off AGC 2686 // Turn off AGC
2687 options.auto_gain_control.Set(false); 2687 options.auto_gain_control = rtc::Maybe<bool>(false);
2688 ASSERT_TRUE(engine_.SetOptions(options)); 2688 ASSERT_TRUE(engine_.SetOptions(options));
2689 voe_.GetAgcStatus(agc_enabled, agc_mode); 2689 voe_.GetAgcStatus(agc_enabled, agc_mode);
2690 EXPECT_FALSE(agc_enabled); 2690 EXPECT_FALSE(agc_enabled);
2691 2691
2692 // Turn AGC back on 2692 // Turn AGC back on
2693 options.auto_gain_control.Set(true); 2693 options.auto_gain_control = rtc::Maybe<bool>(true);
2694 options.adjust_agc_delta.Clear(); 2694 options.adjust_agc_delta = rtc::Maybe<int>();
2695 ASSERT_TRUE(engine_.SetOptions(options)); 2695 ASSERT_TRUE(engine_.SetOptions(options));
2696 voe_.GetAgcStatus(agc_enabled, agc_mode); 2696 voe_.GetAgcStatus(agc_enabled, agc_mode);
2697 EXPECT_TRUE(agc_enabled); 2697 EXPECT_TRUE(agc_enabled);
2698 voe_.GetAgcConfig(agc_config); 2698 voe_.GetAgcConfig(agc_config);
2699 EXPECT_EQ(0, agc_config.targetLeveldBOv); 2699 EXPECT_EQ(0, agc_config.targetLeveldBOv);
2700 2700
2701 // Turn off other options (and stereo swapping on). 2701 // Turn off other options (and stereo swapping on).
2702 options.noise_suppression.Set(false); 2702 options.noise_suppression = rtc::Maybe<bool>(false);
2703 options.highpass_filter.Set(false); 2703 options.highpass_filter = rtc::Maybe<bool>(false);
2704 options.typing_detection.Set(false); 2704 options.typing_detection = rtc::Maybe<bool>(false);
2705 options.stereo_swapping.Set(true); 2705 options.stereo_swapping = rtc::Maybe<bool>(true);
2706 ASSERT_TRUE(engine_.SetOptions(options)); 2706 ASSERT_TRUE(engine_.SetOptions(options));
2707 voe_.GetNsStatus(ns_enabled, ns_mode); 2707 voe_.GetNsStatus(ns_enabled, ns_mode);
2708 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); 2708 highpass_filter_enabled = voe_.IsHighPassFilterEnabled();
2709 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); 2709 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled();
2710 voe_.GetTypingDetectionStatus(typing_detection_enabled); 2710 voe_.GetTypingDetectionStatus(typing_detection_enabled);
2711 EXPECT_FALSE(ns_enabled); 2711 EXPECT_FALSE(ns_enabled);
2712 EXPECT_FALSE(highpass_filter_enabled); 2712 EXPECT_FALSE(highpass_filter_enabled);
2713 EXPECT_FALSE(typing_detection_enabled); 2713 EXPECT_FALSE(typing_detection_enabled);
2714 EXPECT_TRUE(stereo_swapping_enabled); 2714 EXPECT_TRUE(stereo_swapping_enabled);
2715 2715
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2778 // Have to add a stream to make SetSend work. 2778 // Have to add a stream to make SetSend work.
2779 cricket::StreamParams stream1; 2779 cricket::StreamParams stream1;
2780 stream1.ssrcs.push_back(1); 2780 stream1.ssrcs.push_back(1);
2781 channel1->AddSendStream(stream1); 2781 channel1->AddSendStream(stream1);
2782 cricket::StreamParams stream2; 2782 cricket::StreamParams stream2;
2783 stream2.ssrcs.push_back(2); 2783 stream2.ssrcs.push_back(2);
2784 channel2->AddSendStream(stream2); 2784 channel2->AddSendStream(stream2);
2785 2785
2786 // AEC and AGC and NS 2786 // AEC and AGC and NS
2787 cricket::AudioSendParameters parameters_options_all = send_parameters_; 2787 cricket::AudioSendParameters parameters_options_all = send_parameters_;
2788 parameters_options_all.options.echo_cancellation.Set(true); 2788 parameters_options_all.options.echo_cancellation = rtc::Maybe<bool>(true);
2789 parameters_options_all.options.auto_gain_control.Set(true); 2789 parameters_options_all.options.auto_gain_control = rtc::Maybe<bool>(true);
2790 parameters_options_all.options.noise_suppression.Set(true); 2790 parameters_options_all.options.noise_suppression = rtc::Maybe<bool>(true);
2791 ASSERT_TRUE(channel1->SetSendParameters(parameters_options_all)); 2791 ASSERT_TRUE(channel1->SetSendParameters(parameters_options_all));
2792 EXPECT_EQ(parameters_options_all.options, channel1->options()); 2792 EXPECT_EQ(parameters_options_all.options, channel1->options());
2793 ASSERT_TRUE(channel2->SetSendParameters(parameters_options_all)); 2793 ASSERT_TRUE(channel2->SetSendParameters(parameters_options_all));
2794 EXPECT_EQ(parameters_options_all.options, channel2->options()); 2794 EXPECT_EQ(parameters_options_all.options, channel2->options());
2795 2795
2796 // unset NS 2796 // unset NS
2797 cricket::AudioSendParameters parameters_options_no_ns = send_parameters_; 2797 cricket::AudioSendParameters parameters_options_no_ns = send_parameters_;
2798 parameters_options_no_ns.options.noise_suppression.Set(false); 2798 parameters_options_no_ns.options.noise_suppression = rtc::Maybe<bool>(false);
2799 ASSERT_TRUE(channel1->SetSendParameters(parameters_options_no_ns)); 2799 ASSERT_TRUE(channel1->SetSendParameters(parameters_options_no_ns));
2800 cricket::AudioOptions expected_options = parameters_options_all.options; 2800 cricket::AudioOptions expected_options = parameters_options_all.options;
2801 expected_options.echo_cancellation.Set(true); 2801 expected_options.echo_cancellation = rtc::Maybe<bool>(true);
2802 expected_options.auto_gain_control.Set(true); 2802 expected_options.auto_gain_control = rtc::Maybe<bool>(true);
2803 expected_options.noise_suppression.Set(false); 2803 expected_options.noise_suppression = rtc::Maybe<bool>(false);
2804 EXPECT_EQ(expected_options, channel1->options()); 2804 EXPECT_EQ(expected_options, channel1->options());
2805 2805
2806 // unset AGC 2806 // unset AGC
2807 cricket::AudioSendParameters parameters_options_no_agc = send_parameters_; 2807 cricket::AudioSendParameters parameters_options_no_agc = send_parameters_;
2808 parameters_options_no_agc.options.auto_gain_control.Set(false); 2808 parameters_options_no_agc.options.auto_gain_control = rtc::Maybe<bool>(false);
2809 ASSERT_TRUE(channel2->SetSendParameters(parameters_options_no_agc)); 2809 ASSERT_TRUE(channel2->SetSendParameters(parameters_options_no_agc));
2810 expected_options.echo_cancellation.Set(true); 2810 expected_options.echo_cancellation = rtc::Maybe<bool>(true);
2811 expected_options.auto_gain_control.Set(false); 2811 expected_options.auto_gain_control = rtc::Maybe<bool>(false);
2812 expected_options.noise_suppression.Set(true); 2812 expected_options.noise_suppression = rtc::Maybe<bool>(true);
2813 EXPECT_EQ(expected_options, channel2->options()); 2813 EXPECT_EQ(expected_options, channel2->options());
2814 2814
2815 ASSERT_TRUE(engine_.SetOptions(parameters_options_all.options)); 2815 ASSERT_TRUE(engine_.SetOptions(parameters_options_all.options));
2816 bool ec_enabled; 2816 bool ec_enabled;
2817 webrtc::EcModes ec_mode; 2817 webrtc::EcModes ec_mode;
2818 bool agc_enabled; 2818 bool agc_enabled;
2819 webrtc::AgcModes agc_mode; 2819 webrtc::AgcModes agc_mode;
2820 bool ns_enabled; 2820 bool ns_enabled;
2821 webrtc::NsModes ns_mode; 2821 webrtc::NsModes ns_mode;
2822 voe_.GetEcStatus(ec_enabled, ec_mode); 2822 voe_.GetEcStatus(ec_enabled, ec_mode);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2855 voe_.GetAgcStatus(agc_enabled, agc_mode); 2855 voe_.GetAgcStatus(agc_enabled, agc_mode);
2856 voe_.GetNsStatus(ns_enabled, ns_mode); 2856 voe_.GetNsStatus(ns_enabled, ns_mode);
2857 EXPECT_TRUE(ec_enabled); 2857 EXPECT_TRUE(ec_enabled);
2858 EXPECT_TRUE(agc_enabled); 2858 EXPECT_TRUE(agc_enabled);
2859 EXPECT_TRUE(ns_enabled); 2859 EXPECT_TRUE(ns_enabled);
2860 2860
2861 // Make sure settings take effect while we are sending. 2861 // Make sure settings take effect while we are sending.
2862 ASSERT_TRUE(engine_.SetOptions(parameters_options_all.options)); 2862 ASSERT_TRUE(engine_.SetOptions(parameters_options_all.options));
2863 cricket::AudioSendParameters parameters_options_no_agc_nor_ns = 2863 cricket::AudioSendParameters parameters_options_no_agc_nor_ns =
2864 send_parameters_; 2864 send_parameters_;
2865 parameters_options_no_agc_nor_ns.options.auto_gain_control.Set(false); 2865 parameters_options_no_agc_nor_ns.options.auto_gain_control =
2866 parameters_options_no_agc_nor_ns.options.noise_suppression.Set(false); 2866 rtc::Maybe<bool>(false);
2867 parameters_options_no_agc_nor_ns.options.noise_suppression =
2868 rtc::Maybe<bool>(false);
2867 channel2->SetSend(cricket::SEND_MICROPHONE); 2869 channel2->SetSend(cricket::SEND_MICROPHONE);
2868 channel2->SetSendParameters(parameters_options_no_agc_nor_ns); 2870 channel2->SetSendParameters(parameters_options_no_agc_nor_ns);
2869 expected_options.echo_cancellation.Set(true); 2871 expected_options.echo_cancellation = rtc::Maybe<bool>(true);
2870 expected_options.auto_gain_control.Set(false); 2872 expected_options.auto_gain_control = rtc::Maybe<bool>(false);
2871 expected_options.noise_suppression.Set(false); 2873 expected_options.noise_suppression = rtc::Maybe<bool>(false);
2872 EXPECT_EQ(expected_options, channel2->options()); 2874 EXPECT_EQ(expected_options, channel2->options());
2873 voe_.GetEcStatus(ec_enabled, ec_mode); 2875 voe_.GetEcStatus(ec_enabled, ec_mode);
2874 voe_.GetAgcStatus(agc_enabled, agc_mode); 2876 voe_.GetAgcStatus(agc_enabled, agc_mode);
2875 voe_.GetNsStatus(ns_enabled, ns_mode); 2877 voe_.GetNsStatus(ns_enabled, ns_mode);
2876 EXPECT_TRUE(ec_enabled); 2878 EXPECT_TRUE(ec_enabled);
2877 EXPECT_FALSE(agc_enabled); 2879 EXPECT_FALSE(agc_enabled);
2878 EXPECT_FALSE(ns_enabled); 2880 EXPECT_FALSE(ns_enabled);
2879 } 2881 }
2880 2882
2881 // This test verifies DSCP settings are properly applied on voice media channel. 2883 // This test verifies DSCP settings are properly applied on voice media channel.
2882 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { 2884 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
2883 EXPECT_TRUE(SetupEngineWithSendStream()); 2885 EXPECT_TRUE(SetupEngineWithSendStream());
2884 rtc::scoped_ptr<cricket::VoiceMediaChannel> channel( 2886 rtc::scoped_ptr<cricket::VoiceMediaChannel> channel(
2885 engine_.CreateChannel(&call_, cricket::AudioOptions())); 2887 engine_.CreateChannel(&call_, cricket::AudioOptions()));
2886 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( 2888 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface(
2887 new cricket::FakeNetworkInterface); 2889 new cricket::FakeNetworkInterface);
2888 channel->SetInterface(network_interface.get()); 2890 channel->SetInterface(network_interface.get());
2889 cricket::AudioSendParameters parameters = send_parameters_; 2891 cricket::AudioSendParameters parameters = send_parameters_;
2890 parameters.options.dscp.Set(true); 2892 parameters.options.dscp = rtc::Maybe<bool>(true);
2891 EXPECT_TRUE(channel->SetSendParameters(parameters)); 2893 EXPECT_TRUE(channel->SetSendParameters(parameters));
2892 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); 2894 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp());
2893 // Verify previous value is not modified if dscp option is not set. 2895 // Verify previous value is not modified if dscp option is not set.
2894 EXPECT_TRUE(channel->SetSendParameters(send_parameters_)); 2896 EXPECT_TRUE(channel->SetSendParameters(send_parameters_));
2895 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); 2897 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp());
2896 parameters.options.dscp.Set(false); 2898 parameters.options.dscp = rtc::Maybe<bool>(false);
2897 EXPECT_TRUE(channel->SetSendParameters(parameters)); 2899 EXPECT_TRUE(channel->SetSendParameters(parameters));
2898 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); 2900 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
2899 } 2901 }
2900 2902
2901 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelId) { 2903 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelId) {
2902 EXPECT_TRUE(SetupEngine()); 2904 EXPECT_TRUE(SetupEngine());
2903 cricket::WebRtcVoiceMediaChannel* media_channel = 2905 cricket::WebRtcVoiceMediaChannel* media_channel =
2904 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 2906 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
2905 EXPECT_EQ(-1, media_channel->GetReceiveChannelId(0)); 2907 EXPECT_EQ(-1, media_channel->GetReceiveChannelId(0));
2906 EXPECT_TRUE(channel_->AddRecvStream( 2908 EXPECT_TRUE(channel_->AddRecvStream(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 2997 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
2996 2998
2997 // Combined BWE should be disabled. 2999 // Combined BWE should be disabled.
2998 for (uint32_t ssrc : ssrcs) { 3000 for (uint32_t ssrc : ssrcs) {
2999 const auto* s = call_.GetAudioReceiveStream(ssrc); 3001 const auto* s = call_.GetAudioReceiveStream(ssrc);
3000 EXPECT_NE(nullptr, s); 3002 EXPECT_NE(nullptr, s);
3001 EXPECT_FALSE(s->GetConfig().combined_audio_video_bwe); 3003 EXPECT_FALSE(s->GetConfig().combined_audio_video_bwe);
3002 } 3004 }
3003 3005
3004 // Enable combined BWE option - now it should be set up. 3006 // Enable combined BWE option - now it should be set up.
3005 send_parameters_.options.combined_audio_video_bwe.Set(true); 3007 send_parameters_.options.combined_audio_video_bwe = rtc::Maybe<bool>(true);
3006 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); 3008 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
3007 for (uint32_t ssrc : ssrcs) { 3009 for (uint32_t ssrc : ssrcs) {
3008 const auto* s = call_.GetAudioReceiveStream(ssrc); 3010 const auto* s = call_.GetAudioReceiveStream(ssrc);
3009 EXPECT_NE(nullptr, s); 3011 EXPECT_NE(nullptr, s);
3010 EXPECT_EQ(true, s->GetConfig().combined_audio_video_bwe); 3012 EXPECT_EQ(true, s->GetConfig().combined_audio_video_bwe);
3011 } 3013 }
3012 3014
3013 // Disable combined BWE option - should be disabled again. 3015 // Disable combined BWE option - should be disabled again.
3014 send_parameters_.options.combined_audio_video_bwe.Set(false); 3016 send_parameters_.options.combined_audio_video_bwe = rtc::Maybe<bool>(false);
3015 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); 3017 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
3016 for (uint32_t ssrc : ssrcs) { 3018 for (uint32_t ssrc : ssrcs) {
3017 const auto* s = call_.GetAudioReceiveStream(ssrc); 3019 const auto* s = call_.GetAudioReceiveStream(ssrc);
3018 EXPECT_NE(nullptr, s); 3020 EXPECT_NE(nullptr, s);
3019 EXPECT_FALSE(s->GetConfig().combined_audio_video_bwe); 3021 EXPECT_FALSE(s->GetConfig().combined_audio_video_bwe);
3020 } 3022 }
3021 3023
3022 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 3024 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3023 } 3025 }
3024 3026
3025 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { 3027 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) {
3026 // Test that adding receive streams after enabling combined bandwidth 3028 // Test that adding receive streams after enabling combined bandwidth
3027 // estimation will correctly configure each channel. 3029 // estimation will correctly configure each channel.
3028 EXPECT_TRUE(SetupEngineWithSendStream()); 3030 EXPECT_TRUE(SetupEngineWithSendStream());
3029 cricket::WebRtcVoiceMediaChannel* media_channel = 3031 cricket::WebRtcVoiceMediaChannel* media_channel =
3030 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3032 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3031 send_parameters_.options.combined_audio_video_bwe.Set(true); 3033 send_parameters_.options.combined_audio_video_bwe = rtc::Maybe<bool>(true);
3032 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); 3034 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
3033 3035
3034 static const uint32_t kSsrcs[] = {1, 2, 3, 4}; 3036 static const uint32_t kSsrcs[] = {1, 2, 3, 4};
3035 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { 3037 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) {
3036 EXPECT_TRUE(media_channel->AddRecvStream( 3038 EXPECT_TRUE(media_channel->AddRecvStream(
3037 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); 3039 cricket::StreamParams::CreateLegacy(kSsrcs[i])));
3038 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i])); 3040 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i]));
3039 } 3041 }
3040 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size()); 3042 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size());
3041 } 3043 }
3042 3044
3043 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { 3045 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) {
3044 // Test that setting the header extensions results in the expected state 3046 // Test that setting the header extensions results in the expected state
3045 // changes on an associated Call. 3047 // changes on an associated Call.
3046 std::vector<uint32_t> ssrcs; 3048 std::vector<uint32_t> ssrcs;
3047 ssrcs.push_back(223); 3049 ssrcs.push_back(223);
3048 ssrcs.push_back(224); 3050 ssrcs.push_back(224);
3049 3051
3050 EXPECT_TRUE(SetupEngineWithSendStream()); 3052 EXPECT_TRUE(SetupEngineWithSendStream());
3051 cricket::WebRtcVoiceMediaChannel* media_channel = 3053 cricket::WebRtcVoiceMediaChannel* media_channel =
3052 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3054 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3053 send_parameters_.options.combined_audio_video_bwe.Set(true); 3055 send_parameters_.options.combined_audio_video_bwe = rtc::Maybe<bool>(true);
3054 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); 3056 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
3055 for (uint32_t ssrc : ssrcs) { 3057 for (uint32_t ssrc : ssrcs) {
3056 EXPECT_TRUE(media_channel->AddRecvStream( 3058 EXPECT_TRUE(media_channel->AddRecvStream(
3057 cricket::StreamParams::CreateLegacy(ssrc))); 3059 cricket::StreamParams::CreateLegacy(ssrc)));
3058 } 3060 }
3059 3061
3060 // Combined BWE should be set up, but with no configured extensions. 3062 // Combined BWE should be set up, but with no configured extensions.
3061 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 3063 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3062 for (uint32_t ssrc : ssrcs) { 3064 for (uint32_t ssrc : ssrcs) {
3063 const auto* s = call_.GetAudioReceiveStream(ssrc); 3065 const auto* s = call_.GetAudioReceiveStream(ssrc);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3102 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 3104 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
3103 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 3105 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3104 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 3107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
3106 }; 3108 };
3107 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); 3109 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp));
3108 3110
3109 EXPECT_TRUE(SetupEngineWithSendStream()); 3111 EXPECT_TRUE(SetupEngineWithSendStream());
3110 cricket::WebRtcVoiceMediaChannel* media_channel = 3112 cricket::WebRtcVoiceMediaChannel* media_channel =
3111 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3113 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3112 send_parameters_.options.combined_audio_video_bwe.Set(true); 3114 send_parameters_.options.combined_audio_video_bwe = rtc::Maybe<bool>(true);
3113 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3115 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3114 EXPECT_TRUE(media_channel->AddRecvStream( 3116 EXPECT_TRUE(media_channel->AddRecvStream(
3115 cricket::StreamParams::CreateLegacy(kAudioSsrc))); 3117 cricket::StreamParams::CreateLegacy(kAudioSsrc)));
3116 3118
3117 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size()); 3119 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size());
3118 const cricket::FakeAudioReceiveStream* s = 3120 const cricket::FakeAudioReceiveStream* s =
3119 call_.GetAudioReceiveStream(kAudioSsrc); 3121 call_.GetAudioReceiveStream(kAudioSsrc);
3120 EXPECT_EQ(0, s->received_packets()); 3122 EXPECT_EQ(0, s->received_packets());
3121 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); 3123 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime());
3122 EXPECT_EQ(1, s->received_packets()); 3124 EXPECT_EQ(1, s->received_packets());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); 3166 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1);
3165 } 3167 }
3166 3168
3167 // Tests for the actual WebRtc VoE library. 3169 // Tests for the actual WebRtc VoE library.
3168 3170
3169 TEST(WebRtcVoiceEngineTest, TestDefaultOptionsBeforeInit) { 3171 TEST(WebRtcVoiceEngineTest, TestDefaultOptionsBeforeInit) {
3170 cricket::WebRtcVoiceEngine engine; 3172 cricket::WebRtcVoiceEngine engine;
3171 cricket::AudioOptions options = engine.GetOptions(); 3173 cricket::AudioOptions options = engine.GetOptions();
3172 // The default options should have at least a few things set. We purposefully 3174 // The default options should have at least a few things set. We purposefully
3173 // don't check the option values here, though. 3175 // don't check the option values here, though.
3174 EXPECT_TRUE(options.echo_cancellation.IsSet()); 3176 EXPECT_TRUE(options.echo_cancellation);
3175 EXPECT_TRUE(options.auto_gain_control.IsSet()); 3177 EXPECT_TRUE(options.auto_gain_control);
3176 EXPECT_TRUE(options.noise_suppression.IsSet()); 3178 EXPECT_TRUE(options.noise_suppression);
3177 } 3179 }
3178 3180
3179 // Tests that the library initializes and shuts down properly. 3181 // Tests that the library initializes and shuts down properly.
3180 TEST(WebRtcVoiceEngineTest, StartupShutdown) { 3182 TEST(WebRtcVoiceEngineTest, StartupShutdown) {
3181 cricket::WebRtcVoiceEngine engine; 3183 cricket::WebRtcVoiceEngine engine;
3182 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3184 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3183 rtc::scoped_ptr<webrtc::Call> call( 3185 rtc::scoped_ptr<webrtc::Call> call(
3184 webrtc::Call::Create(webrtc::Call::Config())); 3186 webrtc::Call::Create(webrtc::Call::Config()));
3185 cricket::VoiceMediaChannel* channel = 3187 cricket::VoiceMediaChannel* channel =
3186 engine.CreateChannel(call.get(), cricket::AudioOptions()); 3188 engine.CreateChannel(call.get(), cricket::AudioOptions());
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
3304 cricket::WebRtcVoiceEngine engine; 3306 cricket::WebRtcVoiceEngine engine;
3305 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3307 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3306 rtc::scoped_ptr<webrtc::Call> call( 3308 rtc::scoped_ptr<webrtc::Call> call(
3307 webrtc::Call::Create(webrtc::Call::Config())); 3309 webrtc::Call::Create(webrtc::Call::Config()));
3308 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), 3310 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(),
3309 call.get()); 3311 call.get());
3310 cricket::AudioRecvParameters parameters; 3312 cricket::AudioRecvParameters parameters;
3311 parameters.codecs = engine.codecs(); 3313 parameters.codecs = engine.codecs();
3312 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3314 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3313 } 3315 }
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698