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

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

Issue 1844843003: Add mock AudioDeviceModule. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@wvoe_adm_in_ctor
Patch Set: rebase Created 4 years, 8 months 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 | « webrtc/media/engine/fakewebrtcvoiceengine.h ('k') | webrtc/media/media.gyp » ('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 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2008 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 <memory> 11 #include <memory>
12 12
13 #include "webrtc/pc/channel.h" 13 #include "webrtc/pc/channel.h"
14 #include "webrtc/base/arraysize.h" 14 #include "webrtc/base/arraysize.h"
15 #include "webrtc/base/byteorder.h" 15 #include "webrtc/base/byteorder.h"
16 #include "webrtc/base/gunit.h" 16 #include "webrtc/base/gunit.h"
17 #include "webrtc/call.h" 17 #include "webrtc/call.h"
18 #include "webrtc/p2p/base/faketransportcontroller.h" 18 #include "webrtc/p2p/base/faketransportcontroller.h"
19 #include "webrtc/test/field_trial.h" 19 #include "webrtc/test/field_trial.h"
20 #include "webrtc/media/base/fakemediaengine.h" 20 #include "webrtc/media/base/fakemediaengine.h"
21 #include "webrtc/media/base/fakenetworkinterface.h" 21 #include "webrtc/media/base/fakenetworkinterface.h"
22 #include "webrtc/media/base/fakertp.h" 22 #include "webrtc/media/base/fakertp.h"
23 #include "webrtc/media/base/mediaconstants.h" 23 #include "webrtc/media/base/mediaconstants.h"
24 #include "webrtc/media/engine/fakewebrtccall.h" 24 #include "webrtc/media/engine/fakewebrtccall.h"
25 #include "webrtc/media/engine/fakewebrtcvoiceengine.h" 25 #include "webrtc/media/engine/fakewebrtcvoiceengine.h"
26 #include "webrtc/media/engine/webrtcvoiceengine.h" 26 #include "webrtc/media/engine/webrtcvoiceengine.h"
27 #include "webrtc/modules/audio_device/include/mock_audio_device.h"
27 28
28 using cricket::kRtpAudioLevelHeaderExtension; 29 using cricket::kRtpAudioLevelHeaderExtension;
29 using cricket::kRtpAbsoluteSenderTimeHeaderExtension; 30 using cricket::kRtpAbsoluteSenderTimeHeaderExtension;
31 using testing::Return;
32 using testing::StrictMock;
30 33
31 namespace { 34 namespace {
32 35
33 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1, 0); 36 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1, 0);
34 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1, 0); 37 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1, 0);
35 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2, 0); 38 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2, 0);
36 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1, 0); 39 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1, 0);
37 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0); 40 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0);
38 const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0); 41 const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0);
39 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0); 42 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0);
(...skipping 14 matching lines...) Expand all
54 engine, // hw 57 engine, // hw
55 engine, // network 58 engine, // network
56 engine, // rtp 59 engine, // rtp
57 engine) { // volume 60 engine) { // volume
58 } 61 }
59 }; 62 };
60 } // namespace 63 } // namespace
61 64
62 // Tests that our stub library "works". 65 // Tests that our stub library "works".
63 TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) { 66 TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) {
67 StrictMock<webrtc::test::MockAudioDeviceModule> adm;
68 EXPECT_CALL(adm, AddRef()).WillOnce(Return(0));
69 EXPECT_CALL(adm, Release()).WillOnce(Return(0));
64 cricket::FakeWebRtcVoiceEngine voe; 70 cricket::FakeWebRtcVoiceEngine voe;
65 EXPECT_FALSE(voe.IsInited()); 71 EXPECT_FALSE(voe.IsInited());
66 { 72 {
67 cricket::WebRtcVoiceEngine engine(nullptr, new FakeVoEWrapper(&voe)); 73 cricket::WebRtcVoiceEngine engine(&adm, new FakeVoEWrapper(&voe));
68 EXPECT_TRUE(voe.IsInited()); 74 EXPECT_TRUE(voe.IsInited());
69 } 75 }
70 EXPECT_FALSE(voe.IsInited()); 76 EXPECT_FALSE(voe.IsInited());
71 } 77 }
72 78
73 class FakeAudioSink : public webrtc::AudioSinkInterface { 79 class FakeAudioSink : public webrtc::AudioSinkInterface {
74 public: 80 public:
75 void OnData(const Data& audio) override {} 81 void OnData(const Data& audio) override {}
76 }; 82 };
77 83
78 class FakeAudioSource : public cricket::AudioSource { 84 class FakeAudioSource : public cricket::AudioSource {
79 void SetSink(Sink* sink) override {} 85 void SetSink(Sink* sink) override {}
80 }; 86 };
81 87
82 class WebRtcVoiceEngineTestFake : public testing::Test { 88 class WebRtcVoiceEngineTestFake : public testing::Test {
83 public: 89 public:
84 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} 90 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {}
85 91
86 explicit WebRtcVoiceEngineTestFake(const char* field_trials) 92 explicit WebRtcVoiceEngineTestFake(const char* field_trials)
87 : call_(webrtc::Call::Config()), 93 : call_(webrtc::Call::Config()), override_field_trials_(field_trials) {
88 engine_(nullptr, new FakeVoEWrapper(&voe_)), 94 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0));
89 override_field_trials_(field_trials) { 95 EXPECT_CALL(adm_, Release()).WillOnce(Return(0));
96 engine_.reset(new cricket::WebRtcVoiceEngine(&adm_,
97 new FakeVoEWrapper(&voe_)));
90 send_parameters_.codecs.push_back(kPcmuCodec); 98 send_parameters_.codecs.push_back(kPcmuCodec);
91 recv_parameters_.codecs.push_back(kPcmuCodec); 99 recv_parameters_.codecs.push_back(kPcmuCodec);
92 } 100 }
93 bool SetupChannel() { 101 bool SetupChannel() {
94 channel_ = engine_.CreateChannel(&call_, cricket::MediaConfig(), 102 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(),
95 cricket::AudioOptions()); 103 cricket::AudioOptions());
96 return (channel_ != nullptr); 104 return (channel_ != nullptr);
97 } 105 }
98 bool SetupRecvStream() { 106 bool SetupRecvStream() {
99 if (!SetupChannel()) { 107 if (!SetupChannel()) {
100 return false; 108 return false;
101 } 109 }
102 return channel_->AddRecvStream( 110 return channel_->AddRecvStream(
103 cricket::StreamParams::CreateLegacy(kSsrc1)); 111 cricket::StreamParams::CreateLegacy(kSsrc1));
104 } 112 }
105 bool SetupSendStream() { 113 bool SetupSendStream() {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 stats.decoding_calls_to_silence_generator); 402 stats.decoding_calls_to_silence_generator);
395 EXPECT_EQ(info.decoding_calls_to_neteq, stats.decoding_calls_to_neteq); 403 EXPECT_EQ(info.decoding_calls_to_neteq, stats.decoding_calls_to_neteq);
396 EXPECT_EQ(info.decoding_normal, stats.decoding_normal); 404 EXPECT_EQ(info.decoding_normal, stats.decoding_normal);
397 EXPECT_EQ(info.decoding_plc, stats.decoding_plc); 405 EXPECT_EQ(info.decoding_plc, stats.decoding_plc);
398 EXPECT_EQ(info.decoding_cng, stats.decoding_cng); 406 EXPECT_EQ(info.decoding_cng, stats.decoding_cng);
399 EXPECT_EQ(info.decoding_plc_cng, stats.decoding_plc_cng); 407 EXPECT_EQ(info.decoding_plc_cng, stats.decoding_plc_cng);
400 EXPECT_EQ(info.capture_start_ntp_time_ms, stats.capture_start_ntp_time_ms); 408 EXPECT_EQ(info.capture_start_ntp_time_ms, stats.capture_start_ntp_time_ms);
401 } 409 }
402 410
403 protected: 411 protected:
412 StrictMock<webrtc::test::MockAudioDeviceModule> adm_;
404 cricket::FakeCall call_; 413 cricket::FakeCall call_;
405 cricket::FakeWebRtcVoiceEngine voe_; 414 cricket::FakeWebRtcVoiceEngine voe_;
406 cricket::WebRtcVoiceEngine engine_; 415 std::unique_ptr<cricket::WebRtcVoiceEngine> engine_;
407 cricket::VoiceMediaChannel* channel_ = nullptr; 416 cricket::VoiceMediaChannel* channel_ = nullptr;
408 cricket::AudioSendParameters send_parameters_; 417 cricket::AudioSendParameters send_parameters_;
409 cricket::AudioRecvParameters recv_parameters_; 418 cricket::AudioRecvParameters recv_parameters_;
410 FakeAudioSource fake_source_; 419 FakeAudioSource fake_source_;
411
412 private: 420 private:
413 webrtc::test::ScopedFieldTrials override_field_trials_; 421 webrtc::test::ScopedFieldTrials override_field_trials_;
414 }; 422 };
415 423
416 // Tests that we can create and destroy a channel. 424 // Tests that we can create and destroy a channel.
417 TEST_F(WebRtcVoiceEngineTestFake, CreateChannel) { 425 TEST_F(WebRtcVoiceEngineTestFake, CreateChannel) {
418 EXPECT_TRUE(SetupChannel()); 426 EXPECT_TRUE(SetupChannel());
419 } 427 }
420 428
421 // Tests that the list of supported codecs is created properly and ordered 429 // Tests that the list of supported codecs is created properly and ordered
422 // correctly 430 // correctly
423 TEST_F(WebRtcVoiceEngineTestFake, CodecPreference) { 431 TEST_F(WebRtcVoiceEngineTestFake, CodecPreference) {
424 const std::vector<cricket::AudioCodec>& codecs = engine_.codecs(); 432 const std::vector<cricket::AudioCodec>& codecs = engine_->codecs();
425 ASSERT_FALSE(codecs.empty()); 433 ASSERT_FALSE(codecs.empty());
426 EXPECT_STRCASEEQ("opus", codecs[0].name.c_str()); 434 EXPECT_STRCASEEQ("opus", codecs[0].name.c_str());
427 EXPECT_EQ(48000, codecs[0].clockrate); 435 EXPECT_EQ(48000, codecs[0].clockrate);
428 EXPECT_EQ(2, codecs[0].channels); 436 EXPECT_EQ(2, codecs[0].channels);
429 EXPECT_EQ(64000, codecs[0].bitrate); 437 EXPECT_EQ(64000, codecs[0].bitrate);
430 int pref = codecs[0].preference; 438 int pref = codecs[0].preference;
431 for (size_t i = 1; i < codecs.size(); ++i) { 439 for (size_t i = 1; i < codecs.size(); ++i) {
432 EXPECT_GT(pref, codecs[i].preference); 440 EXPECT_GT(pref, codecs[i].preference);
433 pref = codecs[i].preference; 441 pref = codecs[i].preference;
434 } 442 }
435 } 443 }
436 444
437 TEST_F(WebRtcVoiceEngineTestFake, OpusSupportsTransportCc) { 445 TEST_F(WebRtcVoiceEngineTestFake, OpusSupportsTransportCc) {
438 const std::vector<cricket::AudioCodec>& codecs = engine_.codecs(); 446 const std::vector<cricket::AudioCodec>& codecs = engine_->codecs();
439 bool opus_found = false; 447 bool opus_found = false;
440 for (cricket::AudioCodec codec : codecs) { 448 for (cricket::AudioCodec codec : codecs) {
441 if (codec.name == "opus") { 449 if (codec.name == "opus") {
442 EXPECT_TRUE(HasTransportCc(codec)); 450 EXPECT_TRUE(HasTransportCc(codec));
443 opus_found = true; 451 opus_found = true;
444 } 452 }
445 } 453 }
446 EXPECT_TRUE(opus_found); 454 EXPECT_TRUE(opus_found);
447 } 455 }
448 456
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 TestSendBandwidth(kPcmuCodec, 32000, false, 64000); 728 TestSendBandwidth(kPcmuCodec, 32000, false, 64000);
721 TestSendBandwidth(kPcmuCodec, 64000, true, 64000); 729 TestSendBandwidth(kPcmuCodec, 64000, true, 64000);
722 TestSendBandwidth(kPcmuCodec, 63999, false, 64000); 730 TestSendBandwidth(kPcmuCodec, 63999, false, 64000);
723 TestSendBandwidth(kPcmuCodec, 64001, true, 64000); 731 TestSendBandwidth(kPcmuCodec, 64001, true, 64000);
724 } 732 }
725 733
726 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { 734 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) {
727 EXPECT_TRUE(SetupChannel()); 735 EXPECT_TRUE(SetupChannel());
728 const int kDesiredBitrate = 128000; 736 const int kDesiredBitrate = 128000;
729 cricket::AudioSendParameters parameters; 737 cricket::AudioSendParameters parameters;
730 parameters.codecs = engine_.codecs(); 738 parameters.codecs = engine_->codecs();
731 parameters.max_bandwidth_bps = kDesiredBitrate; 739 parameters.max_bandwidth_bps = kDesiredBitrate;
732 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 740 EXPECT_TRUE(channel_->SetSendParameters(parameters));
733 741
734 EXPECT_TRUE(channel_->AddSendStream( 742 EXPECT_TRUE(channel_->AddSendStream(
735 cricket::StreamParams::CreateLegacy(kSsrc1))); 743 cricket::StreamParams::CreateLegacy(kSsrc1)));
736 744
737 int channel_num = voe_.GetLastChannel(); 745 int channel_num = voe_.GetLastChannel();
738 webrtc::CodecInst codec; 746 webrtc::CodecInst codec;
739 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); 747 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec));
740 EXPECT_EQ(kDesiredBitrate, codec.rate); 748 EXPECT_EQ(kDesiredBitrate, codec.rate);
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 1306
1299 cricket::AudioRecvParameters recv_parameters; 1307 cricket::AudioRecvParameters recv_parameters;
1300 recv_parameters.codecs.push_back(kIsacCodec); 1308 recv_parameters.codecs.push_back(kIsacCodec);
1301 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters)); 1309 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters));
1302 EXPECT_TRUE( 1310 EXPECT_TRUE(
1303 channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc1))); 1311 channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc1)));
1304 ASSERT_TRUE(call_.GetAudioReceiveStream(kSsrc1) != nullptr); 1312 ASSERT_TRUE(call_.GetAudioReceiveStream(kSsrc1) != nullptr);
1305 EXPECT_FALSE( 1313 EXPECT_FALSE(
1306 call_.GetAudioReceiveStream(kSsrc1)->GetConfig().rtp.transport_cc); 1314 call_.GetAudioReceiveStream(kSsrc1)->GetConfig().rtp.transport_cc);
1307 1315
1308 send_parameters.codecs = engine_.codecs(); 1316 send_parameters.codecs = engine_->codecs();
1309 EXPECT_TRUE(channel_->SetSendParameters(send_parameters)); 1317 EXPECT_TRUE(channel_->SetSendParameters(send_parameters));
1310 ASSERT_TRUE(call_.GetAudioReceiveStream(kSsrc1) != nullptr); 1318 ASSERT_TRUE(call_.GetAudioReceiveStream(kSsrc1) != nullptr);
1311 EXPECT_TRUE( 1319 EXPECT_TRUE(
1312 call_.GetAudioReceiveStream(kSsrc1)->GetConfig().rtp.transport_cc); 1320 call_.GetAudioReceiveStream(kSsrc1)->GetConfig().rtp.transport_cc);
1313 } 1321 }
1314 1322
1315 // Test maxplaybackrate <= 8000 triggers Opus narrow band mode. 1323 // Test maxplaybackrate <= 8000 triggers Opus narrow band mode.
1316 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { 1324 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) {
1317 EXPECT_TRUE(SetupSendStream()); 1325 EXPECT_TRUE(SetupSendStream());
1318 int channel_num = voe_.GetLastChannel(); 1326 int channel_num = voe_.GetLastChannel();
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 } 1978 }
1971 1979
1972 class WebRtcVoiceEngineWithSendSideBweTest : public WebRtcVoiceEngineTestFake { 1980 class WebRtcVoiceEngineWithSendSideBweTest : public WebRtcVoiceEngineTestFake {
1973 public: 1981 public:
1974 WebRtcVoiceEngineWithSendSideBweTest() 1982 WebRtcVoiceEngineWithSendSideBweTest()
1975 : WebRtcVoiceEngineTestFake("WebRTC-Audio-SendSideBwe/Enabled/") {} 1983 : WebRtcVoiceEngineTestFake("WebRTC-Audio-SendSideBwe/Enabled/") {}
1976 }; 1984 };
1977 1985
1978 TEST_F(WebRtcVoiceEngineWithSendSideBweTest, 1986 TEST_F(WebRtcVoiceEngineWithSendSideBweTest,
1979 SupportsTransportSequenceNumberHeaderExtension) { 1987 SupportsTransportSequenceNumberHeaderExtension) {
1980 cricket::RtpCapabilities capabilities = engine_.GetCapabilities(); 1988 cricket::RtpCapabilities capabilities = engine_->GetCapabilities();
1981 ASSERT_FALSE(capabilities.header_extensions.empty()); 1989 ASSERT_FALSE(capabilities.header_extensions.empty());
1982 for (const cricket::RtpHeaderExtension& extension : 1990 for (const cricket::RtpHeaderExtension& extension :
1983 capabilities.header_extensions) { 1991 capabilities.header_extensions) {
1984 if (extension.uri == cricket::kRtpTransportSequenceNumberHeaderExtension) { 1992 if (extension.uri == cricket::kRtpTransportSequenceNumberHeaderExtension) {
1985 EXPECT_EQ(cricket::kRtpTransportSequenceNumberHeaderExtensionDefaultId, 1993 EXPECT_EQ(cricket::kRtpTransportSequenceNumberHeaderExtensionDefaultId,
1986 extension.id); 1994 extension.id);
1987 return; 1995 return;
1988 } 1996 }
1989 } 1997 }
1990 FAIL() << "Transport sequence number extension not in header-extension list."; 1998 FAIL() << "Transport sequence number extension not in header-extension list.";
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 EXPECT_EQ(0, voe_.GetAgcConfig(config)); 2799 EXPECT_EQ(0, voe_.GetAgcConfig(config));
2792 EXPECT_EQ(set_config.targetLeveldBOv, config.targetLeveldBOv); 2800 EXPECT_EQ(set_config.targetLeveldBOv, config.targetLeveldBOv);
2793 EXPECT_EQ(set_config.digitalCompressionGaindB, 2801 EXPECT_EQ(set_config.digitalCompressionGaindB,
2794 config.digitalCompressionGaindB); 2802 config.digitalCompressionGaindB);
2795 EXPECT_EQ(set_config.limiterEnable, config.limiterEnable); 2803 EXPECT_EQ(set_config.limiterEnable, config.limiterEnable);
2796 } 2804 }
2797 2805
2798 TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { 2806 TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) {
2799 EXPECT_TRUE(SetupSendStream()); 2807 EXPECT_TRUE(SetupSendStream());
2800 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel1( 2808 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel1(
2801 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_.CreateChannel( 2809 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel(
2802 &call_, cricket::MediaConfig(), cricket::AudioOptions()))); 2810 &call_, cricket::MediaConfig(), cricket::AudioOptions())));
2803 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel2( 2811 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel2(
2804 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_.CreateChannel( 2812 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel(
2805 &call_, cricket::MediaConfig(), cricket::AudioOptions()))); 2813 &call_, cricket::MediaConfig(), cricket::AudioOptions())));
2806 2814
2807 // Have to add a stream to make SetSend work. 2815 // Have to add a stream to make SetSend work.
2808 cricket::StreamParams stream1; 2816 cricket::StreamParams stream1;
2809 stream1.ssrcs.push_back(1); 2817 stream1.ssrcs.push_back(1);
2810 channel1->AddSendStream(stream1); 2818 channel1->AddSendStream(stream1);
2811 cricket::StreamParams stream2; 2819 cricket::StreamParams stream2;
2812 stream2.ssrcs.push_back(2); 2820 stream2.ssrcs.push_back(2);
2813 channel2->AddSendStream(stream2); 2821 channel2->AddSendStream(stream2);
2814 2822
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2895 EXPECT_FALSE(ns_enabled); 2903 EXPECT_FALSE(ns_enabled);
2896 } 2904 }
2897 2905
2898 // This test verifies DSCP settings are properly applied on voice media channel. 2906 // This test verifies DSCP settings are properly applied on voice media channel.
2899 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { 2907 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
2900 EXPECT_TRUE(SetupSendStream()); 2908 EXPECT_TRUE(SetupSendStream());
2901 cricket::FakeNetworkInterface network_interface; 2909 cricket::FakeNetworkInterface network_interface;
2902 cricket::MediaConfig config; 2910 cricket::MediaConfig config;
2903 std::unique_ptr<cricket::VoiceMediaChannel> channel; 2911 std::unique_ptr<cricket::VoiceMediaChannel> channel;
2904 2912
2905 channel.reset(engine_.CreateChannel(&call_, config, cricket::AudioOptions())); 2913 channel.reset(
2914 engine_->CreateChannel(&call_, config, cricket::AudioOptions()));
2906 channel->SetInterface(&network_interface); 2915 channel->SetInterface(&network_interface);
2907 // Default value when DSCP is disabled should be DSCP_DEFAULT. 2916 // Default value when DSCP is disabled should be DSCP_DEFAULT.
2908 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp()); 2917 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp());
2909 2918
2910 config.enable_dscp = true; 2919 config.enable_dscp = true;
2911 channel.reset(engine_.CreateChannel(&call_, config, cricket::AudioOptions())); 2920 channel.reset(
2921 engine_->CreateChannel(&call_, config, cricket::AudioOptions()));
2912 channel->SetInterface(&network_interface); 2922 channel->SetInterface(&network_interface);
2913 EXPECT_EQ(rtc::DSCP_EF, network_interface.dscp()); 2923 EXPECT_EQ(rtc::DSCP_EF, network_interface.dscp());
2914 2924
2915 // Verify that setting the option to false resets the 2925 // Verify that setting the option to false resets the
2916 // DiffServCodePoint. 2926 // DiffServCodePoint.
2917 config.enable_dscp = false; 2927 config.enable_dscp = false;
2918 channel.reset(engine_.CreateChannel(&call_, config, cricket::AudioOptions())); 2928 channel.reset(
2929 engine_->CreateChannel(&call_, config, cricket::AudioOptions()));
2919 channel->SetInterface(&network_interface); 2930 channel->SetInterface(&network_interface);
2920 // Default value when DSCP is disabled should be DSCP_DEFAULT. 2931 // Default value when DSCP is disabled should be DSCP_DEFAULT.
2921 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp()); 2932 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp());
2922 2933
2923 channel->SetInterface(nullptr); 2934 channel->SetInterface(nullptr);
2924 } 2935 }
2925 2936
2926 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelId) { 2937 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelId) {
2927 EXPECT_TRUE(SetupChannel()); 2938 EXPECT_TRUE(SetupChannel());
2928 cricket::WebRtcVoiceMediaChannel* media_channel = 2939 cricket::WebRtcVoiceMediaChannel* media_channel =
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3022 } 3033 }
3023 3034
3024 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 3035 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3025 for (uint32_t ssrc : ssrcs) { 3036 for (uint32_t ssrc : ssrcs) {
3026 const auto* s = call_.GetAudioReceiveStream(ssrc); 3037 const auto* s = call_.GetAudioReceiveStream(ssrc);
3027 EXPECT_NE(nullptr, s); 3038 EXPECT_NE(nullptr, s);
3028 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); 3039 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size());
3029 } 3040 }
3030 3041
3031 // Set up receive extensions. 3042 // Set up receive extensions.
3032 cricket::RtpCapabilities capabilities = engine_.GetCapabilities(); 3043 cricket::RtpCapabilities capabilities = engine_->GetCapabilities();
3033 cricket::AudioRecvParameters recv_parameters; 3044 cricket::AudioRecvParameters recv_parameters;
3034 recv_parameters.extensions = capabilities.header_extensions; 3045 recv_parameters.extensions = capabilities.header_extensions;
3035 channel_->SetRecvParameters(recv_parameters); 3046 channel_->SetRecvParameters(recv_parameters);
3036 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 3047 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3037 for (uint32_t ssrc : ssrcs) { 3048 for (uint32_t ssrc : ssrcs) {
3038 const auto* s = call_.GetAudioReceiveStream(ssrc); 3049 const auto* s = call_.GetAudioReceiveStream(ssrc);
3039 EXPECT_NE(nullptr, s); 3050 EXPECT_NE(nullptr, s);
3040 const auto& s_exts = s->GetConfig().rtp.extensions; 3051 const auto& s_exts = s->GetConfig().rtp.extensions;
3041 EXPECT_EQ(capabilities.header_extensions.size(), s_exts.size()); 3052 EXPECT_EQ(capabilities.header_extensions.size(), s_exts.size());
3042 for (const auto& e_ext : capabilities.header_extensions) { 3053 for (const auto& e_ext : capabilities.header_extensions) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 cricket::WebRtcVoiceEngine engine(nullptr); 3211 cricket::WebRtcVoiceEngine engine(nullptr);
3201 std::unique_ptr<webrtc::Call> call( 3212 std::unique_ptr<webrtc::Call> call(
3202 webrtc::Call::Create(webrtc::Call::Config())); 3213 webrtc::Call::Create(webrtc::Call::Config()));
3203 cricket::VoiceMediaChannel* channel = engine.CreateChannel( 3214 cricket::VoiceMediaChannel* channel = engine.CreateChannel(
3204 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); 3215 call.get(), cricket::MediaConfig(), cricket::AudioOptions());
3205 EXPECT_TRUE(channel != nullptr); 3216 EXPECT_TRUE(channel != nullptr);
3206 delete channel; 3217 delete channel;
3207 } 3218 }
3208 3219
3209 // Tests that reference counting on the external ADM is correct. 3220 // Tests that reference counting on the external ADM is correct.
3210 TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternADM) { 3221 TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) {
3211 cricket::FakeAudioDeviceModule adm; 3222 testing::NiceMock<webrtc::test::MockAudioDeviceModule> adm;
3223 EXPECT_CALL(adm, AddRef()).Times(3).WillRepeatedly(Return(0));
3224 EXPECT_CALL(adm, Release()).Times(3).WillRepeatedly(Return(0));
3212 { 3225 {
3213 cricket::WebRtcVoiceEngine engine(&adm); 3226 cricket::WebRtcVoiceEngine engine(&adm);
3214 std::unique_ptr<webrtc::Call> call( 3227 std::unique_ptr<webrtc::Call> call(
3215 webrtc::Call::Create(webrtc::Call::Config())); 3228 webrtc::Call::Create(webrtc::Call::Config()));
3216 cricket::VoiceMediaChannel* channel = engine.CreateChannel( 3229 cricket::VoiceMediaChannel* channel = engine.CreateChannel(
3217 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); 3230 call.get(), cricket::MediaConfig(), cricket::AudioOptions());
3218 EXPECT_TRUE(channel != nullptr); 3231 EXPECT_TRUE(channel != nullptr);
3219 delete channel; 3232 delete channel;
3220 } 3233 }
3221 } 3234 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3332 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { 3345 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) {
3333 cricket::WebRtcVoiceEngine engine(nullptr); 3346 cricket::WebRtcVoiceEngine engine(nullptr);
3334 std::unique_ptr<webrtc::Call> call( 3347 std::unique_ptr<webrtc::Call> call(
3335 webrtc::Call::Create(webrtc::Call::Config())); 3348 webrtc::Call::Create(webrtc::Call::Config()));
3336 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), 3349 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
3337 cricket::AudioOptions(), call.get()); 3350 cricket::AudioOptions(), call.get());
3338 cricket::AudioRecvParameters parameters; 3351 cricket::AudioRecvParameters parameters;
3339 parameters.codecs = engine.codecs(); 3352 parameters.codecs = engine.codecs();
3340 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3353 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3341 } 3354 }
OLDNEW
« no previous file with comments | « webrtc/media/engine/fakewebrtcvoiceengine.h ('k') | webrtc/media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698