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

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

Issue 1269863005: MediaController/Call instantiation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove redundant reset(nullptr) Created 5 years, 3 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 | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/channelmanager.h » ('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,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products 13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "webrtc/base/byteorder.h" 28 #include "webrtc/base/byteorder.h"
29 #include "webrtc/base/gunit.h" 29 #include "webrtc/base/gunit.h"
30 #include "webrtc/call.h"
30 #include "talk/media/base/constants.h" 31 #include "talk/media/base/constants.h"
31 #include "talk/media/base/fakemediaengine.h" 32 #include "talk/media/base/fakemediaengine.h"
32 #include "talk/media/base/fakemediaprocessor.h" 33 #include "talk/media/base/fakemediaprocessor.h"
33 #include "talk/media/base/fakenetworkinterface.h" 34 #include "talk/media/base/fakenetworkinterface.h"
34 #include "talk/media/base/fakertp.h" 35 #include "talk/media/base/fakertp.h"
35 #include "talk/media/webrtc/fakewebrtccall.h" 36 #include "talk/media/webrtc/fakewebrtccall.h"
36 #include "talk/media/webrtc/fakewebrtcvoiceengine.h" 37 #include "talk/media/webrtc/fakewebrtcvoiceengine.h"
37 #include "talk/media/webrtc/webrtcvoiceengine.h" 38 #include "talk/media/webrtc/webrtcvoiceengine.h"
38 #include "webrtc/p2p/base/fakesession.h" 39 #include "webrtc/p2p/base/fakesession.h"
39 #include "talk/session/media/channel.h" 40 #include "talk/session/media/channel.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 cricket::VoiceMediaChannel::Error error() const { 116 cricket::VoiceMediaChannel::Error error() const {
116 return error_; 117 return error_;
117 } 118 }
118 119
119 private: 120 private:
120 uint32 ssrc_; 121 uint32 ssrc_;
121 cricket::VoiceMediaChannel::Error error_; 122 cricket::VoiceMediaChannel::Error error_;
122 }; 123 };
123 124
124 WebRtcVoiceEngineTestFake() 125 WebRtcVoiceEngineTestFake()
125 : voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)), 126 : call_(webrtc::Call::Config()),
127 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)),
126 trace_wrapper_(new FakeVoETraceWrapper()), 128 trace_wrapper_(new FakeVoETraceWrapper()),
127 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), 129 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_),
128 channel_(nullptr) { 130 channel_(nullptr) {
129 options_conference_.conference_mode.Set(true); 131 options_conference_.conference_mode.Set(true);
130 options_adjust_agc_.adjust_agc_delta.Set(-10); 132 options_adjust_agc_.adjust_agc_delta.Set(-10);
131 } 133 }
132 bool SetupEngineWithoutStream() { 134 bool SetupEngineWithoutStream() {
133 if (!engine_.Init(rtc::Thread::Current())) { 135 if (!engine_.Init(rtc::Thread::Current())) {
134 return false; 136 return false;
135 } 137 }
136 channel_ = engine_.CreateChannel(cricket::AudioOptions()); 138 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
137 return (channel_ != nullptr); 139 return (channel_ != nullptr);
138 } 140 }
139 bool SetupEngine() { 141 bool SetupEngine() {
140 if (!SetupEngineWithoutStream()) { 142 if (!SetupEngineWithoutStream()) {
141 return false; 143 return false;
142 } 144 }
143 return channel_->AddSendStream( 145 return channel_->AddSendStream(
144 cricket::StreamParams::CreateLegacy(kSsrc1)); 146 cricket::StreamParams::CreateLegacy(kSsrc1));
145 } 147 }
146 void SetupForMultiSendStream() { 148 void SetupForMultiSendStream() {
(...skipping 12 matching lines...) Expand all
159 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len); 161 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len);
160 channel_->OnPacketReceived(&packet, rtc::PacketTime()); 162 channel_->OnPacketReceived(&packet, rtc::PacketTime());
161 } 163 }
162 void TearDown() override { 164 void TearDown() override {
163 delete channel_; 165 delete channel_;
164 engine_.Terminate(); 166 engine_.Terminate();
165 } 167 }
166 168
167 void TestInsertDtmf(uint32 ssrc, bool caller) { 169 void TestInsertDtmf(uint32 ssrc, bool caller) {
168 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 170 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
169 channel_ = engine_.CreateChannel(cricket::AudioOptions()); 171 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
170 EXPECT_TRUE(channel_ != nullptr); 172 EXPECT_TRUE(channel_ != nullptr);
171 if (caller) { 173 if (caller) {
172 // if this is a caller, local description will be applied and add the 174 // if this is a caller, local description will be applied and add the
173 // send stream. 175 // send stream.
174 EXPECT_TRUE(channel_->AddSendStream( 176 EXPECT_TRUE(channel_->AddSendStream(
175 cricket::StreamParams::CreateLegacy(kSsrc1))); 177 cricket::StreamParams::CreateLegacy(kSsrc1)));
176 } 178 }
177 int channel_id = voe_.GetLastChannel(); 179 int channel_id = voe_.GetLastChannel();
178 180
179 // Test we can only InsertDtmf when the other side supports telephone-event. 181 // Test we can only InsertDtmf when the other side supports telephone-event.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); 320 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext));
319 321
320 // Ensure all extensions go back off with an empty list. 322 // Ensure all extensions go back off with an empty list.
321 extensions.clear(); 323 extensions.clear();
322 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 324 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
323 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 325 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext));
324 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); 326 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext));
325 } 327 }
326 328
327 protected: 329 protected:
330 cricket::FakeCall call_;
328 cricket::FakeWebRtcVoiceEngine voe_; 331 cricket::FakeWebRtcVoiceEngine voe_;
329 FakeVoETraceWrapper* trace_wrapper_; 332 FakeVoETraceWrapper* trace_wrapper_;
330 cricket::WebRtcVoiceEngine engine_; 333 cricket::WebRtcVoiceEngine engine_;
331 cricket::VoiceMediaChannel* channel_; 334 cricket::VoiceMediaChannel* channel_;
332 335
333 cricket::AudioOptions options_conference_; 336 cricket::AudioOptions options_conference_;
334 cricket::AudioOptions options_adjust_agc_; 337 cricket::AudioOptions options_adjust_agc_;
335 }; 338 };
336 339
337 // Tests that our stub library "works". 340 // Tests that our stub library "works".
338 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) { 341 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) {
339 EXPECT_FALSE(voe_.IsInited()); 342 EXPECT_FALSE(voe_.IsInited());
340 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 343 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
341 EXPECT_TRUE(voe_.IsInited()); 344 EXPECT_TRUE(voe_.IsInited());
342 engine_.Terminate(); 345 engine_.Terminate();
343 EXPECT_FALSE(voe_.IsInited()); 346 EXPECT_FALSE(voe_.IsInited());
344 } 347 }
345 348
346 // Tests that we can create and destroy a channel. 349 // Tests that we can create and destroy a channel.
347 TEST_F(WebRtcVoiceEngineTestFake, CreateChannel) { 350 TEST_F(WebRtcVoiceEngineTestFake, CreateChannel) {
348 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 351 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
349 channel_ = engine_.CreateChannel(cricket::AudioOptions()); 352 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
350 EXPECT_TRUE(channel_ != nullptr); 353 EXPECT_TRUE(channel_ != nullptr);
351 } 354 }
352 355
353 // Tests that we properly handle failures in CreateChannel. 356 // Tests that we properly handle failures in CreateChannel.
354 TEST_F(WebRtcVoiceEngineTestFake, CreateChannelFail) { 357 TEST_F(WebRtcVoiceEngineTestFake, CreateChannelFail) {
355 voe_.set_fail_create_channel(true); 358 voe_.set_fail_create_channel(true);
356 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 359 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
357 channel_ = engine_.CreateChannel(cricket::AudioOptions()); 360 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
358 EXPECT_TRUE(channel_ == nullptr); 361 EXPECT_TRUE(channel_ == nullptr);
359 } 362 }
360 363
361 // Tests that the list of supported codecs is created properly and ordered 364 // Tests that the list of supported codecs is created properly and ordered
362 // correctly 365 // correctly
363 TEST_F(WebRtcVoiceEngineTestFake, CodecPreference) { 366 TEST_F(WebRtcVoiceEngineTestFake, CodecPreference) {
364 const std::vector<cricket::AudioCodec>& codecs = engine_.codecs(); 367 const std::vector<cricket::AudioCodec>& codecs = engine_.codecs();
365 ASSERT_FALSE(codecs.empty()); 368 ASSERT_FALSE(codecs.empty());
366 EXPECT_STRCASEEQ("opus", codecs[0].name.c_str()); 369 EXPECT_STRCASEEQ("opus", codecs[0].name.c_str());
367 EXPECT_EQ(48000, codecs[0].clockrate); 370 EXPECT_EQ(48000, codecs[0].clockrate);
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 TestSendBandwidth(kPcmuCodec, 1, false, 64000); 659 TestSendBandwidth(kPcmuCodec, 1, false, 64000);
657 TestSendBandwidth(kPcmuCodec, 128000, true, 64000); 660 TestSendBandwidth(kPcmuCodec, 128000, true, 64000);
658 TestSendBandwidth(kPcmuCodec, 32000, false, 64000); 661 TestSendBandwidth(kPcmuCodec, 32000, false, 64000);
659 TestSendBandwidth(kPcmuCodec, 64000, true, 64000); 662 TestSendBandwidth(kPcmuCodec, 64000, true, 64000);
660 TestSendBandwidth(kPcmuCodec, 63999, false, 64000); 663 TestSendBandwidth(kPcmuCodec, 63999, false, 64000);
661 TestSendBandwidth(kPcmuCodec, 64001, true, 64000); 664 TestSendBandwidth(kPcmuCodec, 64001, true, 64000);
662 } 665 }
663 666
664 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { 667 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) {
665 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 668 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
666 channel_ = engine_.CreateChannel(cricket::AudioOptions()); 669 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
667 EXPECT_TRUE(channel_ != nullptr); 670 EXPECT_TRUE(channel_ != nullptr);
668 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); 671 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
669 672
670 int desired_bitrate = 128000; 673 int desired_bitrate = 128000;
671 EXPECT_TRUE(channel_->SetMaxSendBandwidth(desired_bitrate)); 674 EXPECT_TRUE(channel_->SetMaxSendBandwidth(desired_bitrate));
672 675
673 EXPECT_TRUE(channel_->AddSendStream( 676 EXPECT_TRUE(channel_->AddSendStream(
674 cricket::StreamParams::CreateLegacy(kSsrc1))); 677 cricket::StreamParams::CreateLegacy(kSsrc1)));
675 678
676 int channel_num = voe_.GetLastChannel(); 679 int channel_num = voe_.GetLastChannel();
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, 1033 codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1031 cricket::kParamValueEmpty)); 1034 cricket::kParamValueEmpty));
1032 EXPECT_FALSE(voe_.GetNACK(channel_num)); 1035 EXPECT_FALSE(voe_.GetNACK(channel_num));
1033 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1036 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1034 EXPECT_TRUE(voe_.GetNACK(channel_num)); 1037 EXPECT_TRUE(voe_.GetNACK(channel_num));
1035 } 1038 }
1036 1039
1037 // Test that we can enable NACK with opus as callee. 1040 // Test that we can enable NACK with opus as callee.
1038 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { 1041 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) {
1039 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 1042 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
1040 channel_ = engine_.CreateChannel(cricket::AudioOptions()); 1043 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
1041 EXPECT_TRUE(channel_ != nullptr); 1044 EXPECT_TRUE(channel_ != nullptr);
1042 1045
1043 int channel_num = voe_.GetLastChannel(); 1046 int channel_num = voe_.GetLastChannel();
1044 std::vector<cricket::AudioCodec> codecs; 1047 std::vector<cricket::AudioCodec> codecs;
1045 codecs.push_back(kOpusCodec); 1048 codecs.push_back(kOpusCodec);
1046 codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, 1049 codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1047 cricket::kParamValueEmpty)); 1050 cricket::kParamValueEmpty));
1048 EXPECT_FALSE(voe_.GetNACK(channel_num)); 1051 EXPECT_FALSE(voe_.GetNACK(channel_num));
1049 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1052 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1050 EXPECT_FALSE(voe_.GetNACK(channel_num)); 1053 EXPECT_FALSE(voe_.GetNACK(channel_num));
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 EXPECT_TRUE(voe_.GetVAD(channel_num)); 1613 EXPECT_TRUE(voe_.GetVAD(channel_num));
1611 EXPECT_FALSE(voe_.GetRED(channel_num)); 1614 EXPECT_FALSE(voe_.GetRED(channel_num));
1612 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 1615 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
1613 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 1616 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
1614 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); 1617 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num));
1615 } 1618 }
1616 1619
1617 // Test that we set VAD and DTMF types correctly as callee. 1620 // Test that we set VAD and DTMF types correctly as callee.
1618 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { 1621 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) {
1619 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 1622 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
1620 channel_ = engine_.CreateChannel(cricket::AudioOptions()); 1623 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
1621 EXPECT_TRUE(channel_ != nullptr); 1624 EXPECT_TRUE(channel_ != nullptr);
1622 1625
1623 int channel_num = voe_.GetLastChannel(); 1626 int channel_num = voe_.GetLastChannel();
1624 std::vector<cricket::AudioCodec> codecs; 1627 std::vector<cricket::AudioCodec> codecs;
1625 codecs.push_back(kIsacCodec); 1628 codecs.push_back(kIsacCodec);
1626 codecs.push_back(kPcmuCodec); 1629 codecs.push_back(kPcmuCodec);
1627 // TODO(juberti): cn 32000 1630 // TODO(juberti): cn 32000
1628 codecs.push_back(kCn16000Codec); 1631 codecs.push_back(kCn16000Codec);
1629 codecs.push_back(kCn8000Codec); 1632 codecs.push_back(kCn8000Codec);
1630 codecs.push_back(kTelephoneEventCodec); 1633 codecs.push_back(kTelephoneEventCodec);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1730 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1728 EXPECT_EQ(96, gcodec.pltype); 1731 EXPECT_EQ(96, gcodec.pltype);
1729 EXPECT_STREQ("ISAC", gcodec.plname); 1732 EXPECT_STREQ("ISAC", gcodec.plname);
1730 EXPECT_TRUE(voe_.GetRED(channel_num)); 1733 EXPECT_TRUE(voe_.GetRED(channel_num));
1731 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); 1734 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
1732 } 1735 }
1733 1736
1734 // Test that we set up RED correctly as callee. 1737 // Test that we set up RED correctly as callee.
1735 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) { 1738 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) {
1736 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 1739 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
1737 channel_ = engine_.CreateChannel(cricket::AudioOptions()); 1740 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
1738 EXPECT_TRUE(channel_ != nullptr); 1741 EXPECT_TRUE(channel_ != nullptr);
1739 1742
1740 int channel_num = voe_.GetLastChannel(); 1743 int channel_num = voe_.GetLastChannel();
1741 std::vector<cricket::AudioCodec> codecs; 1744 std::vector<cricket::AudioCodec> codecs;
1742 codecs.push_back(kRedCodec); 1745 codecs.push_back(kRedCodec);
1743 codecs.push_back(kIsacCodec); 1746 codecs.push_back(kIsacCodec);
1744 codecs.push_back(kPcmuCodec); 1747 codecs.push_back(kPcmuCodec);
1745 codecs[0].id = 127; 1748 codecs[0].id = 127;
1746 codecs[0].params[""] = "96/96"; 1749 codecs[0].params[""] = "96/96";
1747 codecs[1].id = 96; 1750 codecs[1].id = 96;
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2419 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2417 int channel_num2 = voe_.GetLastChannel(); 2420 int channel_num2 = voe_.GetLastChannel();
2418 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num2, send_ssrc)); 2421 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num2, send_ssrc));
2419 EXPECT_EQ(kSsrc1, send_ssrc); 2422 EXPECT_EQ(kSsrc1, send_ssrc);
2420 } 2423 }
2421 2424
2422 // Test that the local SSRC is the same on sending and receiving channels if the 2425 // Test that the local SSRC is the same on sending and receiving channels if the
2423 // receive channel is created before the send channel. 2426 // receive channel is created before the send channel.
2424 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { 2427 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) {
2425 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 2428 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
2426 channel_ = engine_.CreateChannel(cricket::AudioOptions()); 2429 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
2427 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 2430 EXPECT_TRUE(channel_->SetOptions(options_conference_));
2428 2431
2429 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 2432 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2430 int receive_channel_num = voe_.GetLastChannel(); 2433 int receive_channel_num = voe_.GetLastChannel();
2431 EXPECT_TRUE(channel_->AddSendStream( 2434 EXPECT_TRUE(channel_->AddSendStream(
2432 cricket::StreamParams::CreateLegacy(1234))); 2435 cricket::StreamParams::CreateLegacy(1234)));
2433 int send_channel_num = voe_.GetLastChannel(); 2436 int send_channel_num = voe_.GetLastChannel();
2434 2437
2435 unsigned int ssrc = 0; 2438 unsigned int ssrc = 0;
2436 EXPECT_EQ(0, voe_.GetLocalSSRC(send_channel_num, ssrc)); 2439 EXPECT_EQ(0, voe_.GetLocalSSRC(send_channel_num, ssrc));
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2987 EXPECT_EQ(set_config.targetLeveldBOv, config.targetLeveldBOv); 2990 EXPECT_EQ(set_config.targetLeveldBOv, config.targetLeveldBOv);
2988 EXPECT_EQ(set_config.digitalCompressionGaindB, 2991 EXPECT_EQ(set_config.digitalCompressionGaindB,
2989 config.digitalCompressionGaindB); 2992 config.digitalCompressionGaindB);
2990 EXPECT_EQ(set_config.limiterEnable, config.limiterEnable); 2993 EXPECT_EQ(set_config.limiterEnable, config.limiterEnable);
2991 } 2994 }
2992 2995
2993 TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { 2996 TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) {
2994 EXPECT_TRUE(SetupEngine()); 2997 EXPECT_TRUE(SetupEngine());
2995 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel1( 2998 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel1(
2996 static_cast<cricket::WebRtcVoiceMediaChannel*>( 2999 static_cast<cricket::WebRtcVoiceMediaChannel*>(
2997 engine_.CreateChannel(cricket::AudioOptions()))); 3000 engine_.CreateChannel(&call_, cricket::AudioOptions())));
2998 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel2( 3001 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel2(
2999 static_cast<cricket::WebRtcVoiceMediaChannel*>( 3002 static_cast<cricket::WebRtcVoiceMediaChannel*>(
3000 engine_.CreateChannel(cricket::AudioOptions()))); 3003 engine_.CreateChannel(&call_, cricket::AudioOptions())));
3001 3004
3002 // Have to add a stream to make SetSend work. 3005 // Have to add a stream to make SetSend work.
3003 cricket::StreamParams stream1; 3006 cricket::StreamParams stream1;
3004 stream1.ssrcs.push_back(1); 3007 stream1.ssrcs.push_back(1);
3005 channel1->AddSendStream(stream1); 3008 channel1->AddSendStream(stream1);
3006 cricket::StreamParams stream2; 3009 cricket::StreamParams stream2;
3007 stream2.ssrcs.push_back(2); 3010 stream2.ssrcs.push_back(2);
3008 channel2->AddSendStream(stream2); 3011 channel2->AddSendStream(stream2);
3009 3012
3010 // AEC and AGC and NS 3013 // AEC and AGC and NS
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3102 voe_.GetNsStatus(ns_enabled, ns_mode); 3105 voe_.GetNsStatus(ns_enabled, ns_mode);
3103 EXPECT_TRUE(ec_enabled); 3106 EXPECT_TRUE(ec_enabled);
3104 EXPECT_FALSE(agc_enabled); 3107 EXPECT_FALSE(agc_enabled);
3105 EXPECT_FALSE(ns_enabled); 3108 EXPECT_FALSE(ns_enabled);
3106 } 3109 }
3107 3110
3108 // This test verifies DSCP settings are properly applied on voice media channel. 3111 // This test verifies DSCP settings are properly applied on voice media channel.
3109 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { 3112 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
3110 EXPECT_TRUE(SetupEngine()); 3113 EXPECT_TRUE(SetupEngine());
3111 rtc::scoped_ptr<cricket::VoiceMediaChannel> channel( 3114 rtc::scoped_ptr<cricket::VoiceMediaChannel> channel(
3112 engine_.CreateChannel(cricket::AudioOptions())); 3115 engine_.CreateChannel(&call_, cricket::AudioOptions()));
3113 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( 3116 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface(
3114 new cricket::FakeNetworkInterface); 3117 new cricket::FakeNetworkInterface);
3115 channel->SetInterface(network_interface.get()); 3118 channel->SetInterface(network_interface.get());
3116 cricket::AudioOptions options; 3119 cricket::AudioOptions options;
3117 options.dscp.Set(true); 3120 options.dscp.Set(true);
3118 EXPECT_TRUE(channel->SetOptions(options)); 3121 EXPECT_TRUE(channel->SetOptions(options));
3119 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); 3122 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp());
3120 // Verify previous value is not modified if dscp option is not set. 3123 // Verify previous value is not modified if dscp option is not set.
3121 cricket::AudioOptions options1; 3124 cricket::AudioOptions options1;
3122 EXPECT_TRUE(channel->SetOptions(options1)); 3125 EXPECT_TRUE(channel->SetOptions(options1));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3173 3176
3174 EXPECT_TRUE(channel_->SetOutputScaling(kSsrc2, 2, 1)); 3177 EXPECT_TRUE(channel_->SetOutputScaling(kSsrc2, 2, 1));
3175 channel_id = voe_.GetLastChannel(); 3178 channel_id = voe_.GetLastChannel();
3176 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale)); 3179 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale));
3177 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right)); 3180 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right));
3178 EXPECT_DOUBLE_EQ(2, left * scale); 3181 EXPECT_DOUBLE_EQ(2, left * scale);
3179 EXPECT_DOUBLE_EQ(1, right * scale); 3182 EXPECT_DOUBLE_EQ(1, right * scale);
3180 } 3183 }
3181 3184
3182 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { 3185 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) {
3183 cricket::FakeCall call((webrtc::Call::Config()));
3184 const uint32 kAudioSsrc = 123; 3186 const uint32 kAudioSsrc = 123;
3185 const std::string kSyncLabel = "AvSyncLabel"; 3187 const std::string kSyncLabel = "AvSyncLabel";
3186 3188
3187 EXPECT_TRUE(SetupEngine()); 3189 EXPECT_TRUE(SetupEngine());
3188 cricket::WebRtcVoiceMediaChannel* media_channel =
3189 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3190 media_channel->SetCall(&call);
3191 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc); 3190 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc);
3192 sp.sync_label = kSyncLabel; 3191 sp.sync_label = kSyncLabel;
3193 // Creating two channels to make sure that sync label is set properly for both 3192 // Creating two channels to make sure that sync label is set properly for both
3194 // the default voice channel and following ones. 3193 // the default voice channel and following ones.
3195 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3194 EXPECT_TRUE(channel_->AddRecvStream(sp));
3196 sp.ssrcs[0] += 1; 3195 sp.ssrcs[0] += 1;
3197 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3196 EXPECT_TRUE(channel_->AddRecvStream(sp));
3198 3197
3199 ASSERT_EQ(2, call.GetAudioReceiveStreams().size()); 3198 ASSERT_EQ(2, call_.GetAudioReceiveStreams().size());
3200 EXPECT_EQ(kSyncLabel, 3199 EXPECT_EQ(kSyncLabel,
3201 call.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group) 3200 call_.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group)
3202 << "SyncGroup should be set based on sync_label"; 3201 << "SyncGroup should be set based on sync_label";
3203 EXPECT_EQ(kSyncLabel, 3202 EXPECT_EQ(kSyncLabel,
3204 call.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group) 3203 call_.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group)
3205 << "SyncGroup should be set based on sync_label"; 3204 << "SyncGroup should be set based on sync_label";
3206
3207 media_channel->SetCall(nullptr);
3208 } 3205 }
3209 3206
3210 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { 3207 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) {
3211 // Test that changing the combined_audio_video_bwe option results in the 3208 // Test that changing the combined_audio_video_bwe option results in the
3212 // expected state changes on an associated Call. 3209 // expected state changes on an associated Call.
3213 cricket::FakeCall call((webrtc::Call::Config())); 3210 std::vector<uint32> ssrcs;
3214 const uint32 kAudioSsrc1 = 223; 3211 ssrcs.push_back(223);
3215 const uint32 kAudioSsrc2 = 224; 3212 ssrcs.push_back(224);
3216 3213
3217 EXPECT_TRUE(SetupEngine()); 3214 EXPECT_TRUE(SetupEngine());
3218 cricket::WebRtcVoiceMediaChannel* media_channel = 3215 cricket::WebRtcVoiceMediaChannel* media_channel =
3219 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3216 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3220 const auto& rtp_extensions = engine_.rtp_header_extensions(); 3217 for (uint32 ssrc : ssrcs) {
3221 media_channel->SetRecvRtpHeaderExtensions(rtp_extensions); 3218 EXPECT_TRUE(media_channel->AddRecvStream(
3222 media_channel->SetCall(&call); 3219 cricket::StreamParams::CreateLegacy(ssrc)));
3223 EXPECT_TRUE(media_channel->AddRecvStream( 3220 }
3224 cricket::StreamParams::CreateLegacy(kAudioSsrc1))); 3221 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3225 EXPECT_TRUE(media_channel->AddRecvStream(
3226 cricket::StreamParams::CreateLegacy(kAudioSsrc2)));
3227 3222
3228 // Combined BWE should not be set up yet. 3223 // Combined BWE should be disabled.
3229 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); 3224 for (uint32 ssrc : ssrcs) {
3230 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc1) 3225 const auto* s = call_.GetAudioReceiveStream(ssrc);
3231 ->GetConfig() 3226 EXPECT_NE(nullptr, s);
3232 .combined_audio_video_bwe); 3227 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe);
3233 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2) 3228 }
3234 ->GetConfig()
3235 .combined_audio_video_bwe);
3236 3229
3237 // Enable combined BWE option - now it should be set up. 3230 // Enable combined BWE option - now it should be set up.
3238 cricket::AudioOptions options; 3231 cricket::AudioOptions options;
3239 options.combined_audio_video_bwe.Set(true); 3232 options.combined_audio_video_bwe.Set(true);
3240 EXPECT_TRUE(media_channel->SetOptions(options)); 3233 EXPECT_TRUE(media_channel->SetOptions(options));
3241 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); 3234 for (uint32 ssrc : ssrcs) {
3242 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc1) 3235 const auto* s = call_.GetAudioReceiveStream(ssrc);
3243 ->GetConfig() 3236 EXPECT_NE(nullptr, s);
3244 .combined_audio_video_bwe); 3237 EXPECT_EQ(true, s->GetConfig().combined_audio_video_bwe);
3245 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc2) 3238 }
3246 ->GetConfig()
3247 .combined_audio_video_bwe);
3248 3239
3249 // Disable combined BWE option - should be disabled again. 3240 // Disable combined BWE option - should be disabled again.
3250 options.combined_audio_video_bwe.Set(false); 3241 options.combined_audio_video_bwe.Set(false);
3251 EXPECT_TRUE(media_channel->SetOptions(options)); 3242 EXPECT_TRUE(media_channel->SetOptions(options));
3252 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); 3243 for (uint32 ssrc : ssrcs) {
3253 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc1) 3244 const auto* s = call_.GetAudioReceiveStream(ssrc);
3254 ->GetConfig() 3245 EXPECT_NE(nullptr, s);
3255 .combined_audio_video_bwe); 3246 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe);
3256 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2) 3247 }
3257 ->GetConfig()
3258 .combined_audio_video_bwe);
3259 3248
3260 media_channel->SetCall(nullptr); 3249 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3261 }
3262
3263 TEST_F(WebRtcVoiceEngineTestFake, SetCallConfiguresAudioReceiveChannels) {
3264 // Test that calling SetCall() on the voice media channel results in the
3265 // expected state changes in Call.
3266 cricket::FakeCall call((webrtc::Call::Config()));
3267 cricket::FakeCall call2((webrtc::Call::Config()));
3268 const uint32 kAudioSsrc1 = 223;
3269 const uint32 kAudioSsrc2 = 224;
3270
3271 EXPECT_TRUE(SetupEngine());
3272 cricket::WebRtcVoiceMediaChannel* media_channel =
3273 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3274 EXPECT_TRUE(media_channel->AddRecvStream(
3275 cricket::StreamParams::CreateLegacy(kAudioSsrc1)));
3276 EXPECT_TRUE(media_channel->AddRecvStream(
3277 cricket::StreamParams::CreateLegacy(kAudioSsrc2)));
3278
3279 // Combined BWE should not be set up yet.
3280 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3281
3282 // Register - should be enabled.
3283 media_channel->SetCall(&call);
3284 EXPECT_EQ(2, call.GetAudioReceiveStreams().size());
3285 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kAudioSsrc1));
3286 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kAudioSsrc2));
3287
3288 // Re-register - should now be enabled on new call.
3289 media_channel->SetCall(&call2);
3290 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3291 EXPECT_EQ(2, call2.GetAudioReceiveStreams().size());
3292 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc1));
3293 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc2));
3294
3295 // Unregister - should be disabled again.
3296 media_channel->SetCall(nullptr);
3297 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3298 } 3250 }
3299 3251
3300 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { 3252 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) {
3301 // Test that adding receive streams after enabling combined bandwidth 3253 // Test that adding receive streams after enabling combined bandwidth
3302 // estimation will correctly configure each channel. 3254 // estimation will correctly configure each channel.
3303 cricket::FakeCall call((webrtc::Call::Config()));
3304
3305 EXPECT_TRUE(SetupEngine()); 3255 EXPECT_TRUE(SetupEngine());
3306 cricket::WebRtcVoiceMediaChannel* media_channel = 3256 cricket::WebRtcVoiceMediaChannel* media_channel =
3307 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3257 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3308 media_channel->SetCall(&call);
3309 cricket::AudioOptions options; 3258 cricket::AudioOptions options;
3310 options.combined_audio_video_bwe.Set(true); 3259 options.combined_audio_video_bwe.Set(true);
3311 EXPECT_TRUE(media_channel->SetOptions(options)); 3260 EXPECT_TRUE(media_channel->SetOptions(options));
3312 3261
3313 static const uint32 kSsrcs[] = {1, 2, 3, 4}; 3262 static const uint32 kSsrcs[] = {1, 2, 3, 4};
3314 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { 3263 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) {
3315 EXPECT_TRUE(media_channel->AddRecvStream( 3264 EXPECT_TRUE(media_channel->AddRecvStream(
3316 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); 3265 cricket::StreamParams::CreateLegacy(kSsrcs[i])));
3317 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kSsrcs[i])); 3266 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i]));
3318 EXPECT_TRUE(call.GetAudioReceiveStream(kSsrcs[i])
3319 ->GetConfig()
3320 .combined_audio_video_bwe);
3321 } 3267 }
3322 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call.GetAudioReceiveStreams().size()); 3268 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size());
3323
3324 media_channel->SetCall(nullptr);
3325 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3326 } 3269 }
3327 3270
3328 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { 3271 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) {
3329 // Test that setting the header extensions results in the expected state 3272 // Test that setting the header extensions results in the expected state
3330 // changes on an associated Call. 3273 // changes on an associated Call.
3331 cricket::FakeCall call((webrtc::Call::Config()));
3332 std::vector<uint32> ssrcs; 3274 std::vector<uint32> ssrcs;
3333 ssrcs.push_back(223); 3275 ssrcs.push_back(223);
3334 ssrcs.push_back(224); 3276 ssrcs.push_back(224);
3335 3277
3336 EXPECT_TRUE(SetupEngine()); 3278 EXPECT_TRUE(SetupEngine());
3337 cricket::WebRtcVoiceMediaChannel* media_channel = 3279 cricket::WebRtcVoiceMediaChannel* media_channel =
3338 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3280 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3339 media_channel->SetCall(&call); 3281 cricket::AudioOptions options;
3282 options.combined_audio_video_bwe.Set(true);
3283 EXPECT_TRUE(media_channel->SetOptions(options));
3340 for (uint32 ssrc : ssrcs) { 3284 for (uint32 ssrc : ssrcs) {
3341 EXPECT_TRUE(media_channel->AddRecvStream( 3285 EXPECT_TRUE(media_channel->AddRecvStream(
3342 cricket::StreamParams::CreateLegacy(ssrc))); 3286 cricket::StreamParams::CreateLegacy(ssrc)));
3343 } 3287 }
3344 3288
3345 // Combined BWE should be set up, but with no configured extensions. 3289 // Combined BWE should be set up, but with no configured extensions.
3346 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); 3290 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3347 for (uint32 ssrc : ssrcs) { 3291 for (uint32 ssrc : ssrcs) {
3348 const auto* s = call.GetAudioReceiveStream(ssrc); 3292 const auto* s = call_.GetAudioReceiveStream(ssrc);
3349 EXPECT_NE(nullptr, s); 3293 EXPECT_NE(nullptr, s);
3350 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); 3294 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size());
3351 } 3295 }
3352 3296
3353 // Set up receive extensions. 3297 // Set up receive extensions.
3354 const auto& e_exts = engine_.rtp_header_extensions(); 3298 const auto& e_exts = engine_.rtp_header_extensions();
3355 channel_->SetRecvRtpHeaderExtensions(e_exts); 3299 channel_->SetRecvRtpHeaderExtensions(e_exts);
3356 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); 3300 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3357 for (uint32 ssrc : ssrcs) { 3301 for (uint32 ssrc : ssrcs) {
3358 const auto* s = call.GetAudioReceiveStream(ssrc); 3302 const auto* s = call_.GetAudioReceiveStream(ssrc);
3359 EXPECT_NE(nullptr, s); 3303 EXPECT_NE(nullptr, s);
3360 const auto& s_exts = s->GetConfig().rtp.extensions; 3304 const auto& s_exts = s->GetConfig().rtp.extensions;
3361 EXPECT_EQ(e_exts.size(), s_exts.size()); 3305 EXPECT_EQ(e_exts.size(), s_exts.size());
3362 for (const auto& e_ext : e_exts) { 3306 for (const auto& e_ext : e_exts) {
3363 for (const auto& s_ext : s_exts) { 3307 for (const auto& s_ext : s_exts) {
3364 if (e_ext.id == s_ext.id) { 3308 if (e_ext.id == s_ext.id) {
3365 EXPECT_EQ(e_ext.uri, s_ext.name); 3309 EXPECT_EQ(e_ext.uri, s_ext.name);
3366 } 3310 }
3367 } 3311 }
3368 } 3312 }
3369 } 3313 }
3370 3314
3371 // Disable receive extensions. 3315 // Disable receive extensions.
3372 std::vector<cricket::RtpHeaderExtension> extensions; 3316 std::vector<cricket::RtpHeaderExtension> extensions;
3373 channel_->SetRecvRtpHeaderExtensions(extensions); 3317 channel_->SetRecvRtpHeaderExtensions(extensions);
3374 for (uint32 ssrc : ssrcs) { 3318 for (uint32 ssrc : ssrcs) {
3375 const auto* s = call.GetAudioReceiveStream(ssrc); 3319 const auto* s = call_.GetAudioReceiveStream(ssrc);
3376 EXPECT_NE(nullptr, s); 3320 EXPECT_NE(nullptr, s);
3377 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); 3321 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size());
3378 } 3322 }
3379
3380 media_channel->SetCall(nullptr);
3381 } 3323 }
3382 3324
3383 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { 3325 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) {
3384 // Test that packets are forwarded to the Call when configured accordingly. 3326 // Test that packets are forwarded to the Call when configured accordingly.
3385 cricket::FakeCall call((webrtc::Call::Config()));
3386 const uint32 kAudioSsrc = 1; 3327 const uint32 kAudioSsrc = 1;
3387 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); 3328 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame));
3388 static const unsigned char kRtcp[] = { 3329 static const unsigned char kRtcp[] = {
3389 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 3330 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
3390 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 3331 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3391 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3332 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3392 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 3333 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
3393 }; 3334 };
3394 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); 3335 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp));
3395 3336
3396 EXPECT_TRUE(SetupEngine()); 3337 EXPECT_TRUE(SetupEngine());
3397 cricket::WebRtcVoiceMediaChannel* media_channel = 3338 cricket::WebRtcVoiceMediaChannel* media_channel =
3398 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3339 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3399 cricket::AudioOptions options; 3340 cricket::AudioOptions options;
3400 options.combined_audio_video_bwe.Set(true); 3341 options.combined_audio_video_bwe.Set(true);
3401 EXPECT_TRUE(media_channel->SetOptions(options)); 3342 EXPECT_TRUE(media_channel->SetOptions(options));
3402 EXPECT_TRUE(media_channel->AddRecvStream( 3343 EXPECT_TRUE(media_channel->AddRecvStream(
3403 cricket::StreamParams::CreateLegacy(kAudioSsrc))); 3344 cricket::StreamParams::CreateLegacy(kAudioSsrc)));
3404 3345
3405 // Call not set on media channel, so no packets can be forwarded. 3346 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size());
3406 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3407 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime());
3408 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime());
3409 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3410
3411 // Set Call, now there should be a receive stream which is forwarded packets.
3412 media_channel->SetCall(&call);
3413 EXPECT_EQ(1, call.GetAudioReceiveStreams().size());
3414 const cricket::FakeAudioReceiveStream* s = 3347 const cricket::FakeAudioReceiveStream* s =
3415 call.GetAudioReceiveStream(kAudioSsrc); 3348 call_.GetAudioReceiveStream(kAudioSsrc);
3416 EXPECT_EQ(0, s->received_packets()); 3349 EXPECT_EQ(0, s->received_packets());
3417 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); 3350 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime());
3418 EXPECT_EQ(1, s->received_packets()); 3351 EXPECT_EQ(1, s->received_packets());
3419 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); 3352 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime());
3420 EXPECT_EQ(2, s->received_packets()); 3353 EXPECT_EQ(2, s->received_packets());
3421
3422 media_channel->SetCall(nullptr);
3423 } 3354 }
3424 3355
3425 // Associate channel should not set on 1:1 call, since the receive channel also 3356 // Associate channel should not set on 1:1 call, since the receive channel also
3426 // sends RTCP SR. 3357 // sends RTCP SR.
3427 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelUnset1On1) { 3358 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelUnset1On1) {
3428 EXPECT_TRUE(SetupEngine()); 3359 EXPECT_TRUE(SetupEngine());
3429 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 3360 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
3430 int recv_ch = voe_.GetLastChannel(); 3361 int recv_ch = voe_.GetLastChannel();
3431 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); 3362 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1);
3432 } 3363 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3499 // don't check the option values here, though. 3430 // don't check the option values here, though.
3500 EXPECT_TRUE(options.echo_cancellation.IsSet()); 3431 EXPECT_TRUE(options.echo_cancellation.IsSet());
3501 EXPECT_TRUE(options.auto_gain_control.IsSet()); 3432 EXPECT_TRUE(options.auto_gain_control.IsSet());
3502 EXPECT_TRUE(options.noise_suppression.IsSet()); 3433 EXPECT_TRUE(options.noise_suppression.IsSet());
3503 } 3434 }
3504 3435
3505 // Tests that the library initializes and shuts down properly. 3436 // Tests that the library initializes and shuts down properly.
3506 TEST(WebRtcVoiceEngineTest, StartupShutdown) { 3437 TEST(WebRtcVoiceEngineTest, StartupShutdown) {
3507 cricket::WebRtcVoiceEngine engine; 3438 cricket::WebRtcVoiceEngine engine;
3508 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3439 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3440 rtc::scoped_ptr<webrtc::Call> call(
3441 webrtc::Call::Create(webrtc::Call::Config()));
3509 cricket::VoiceMediaChannel* channel = 3442 cricket::VoiceMediaChannel* channel =
3510 engine.CreateChannel(cricket::AudioOptions()); 3443 engine.CreateChannel(call.get(), cricket::AudioOptions());
3511 EXPECT_TRUE(channel != nullptr); 3444 EXPECT_TRUE(channel != nullptr);
3512 delete channel; 3445 delete channel;
3513 engine.Terminate(); 3446 engine.Terminate();
3514 3447
3515 // Reinit to catch regression where VoiceEngineObserver reference is lost 3448 // Reinit to catch regression where VoiceEngineObserver reference is lost
3516 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3449 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3517 engine.Terminate(); 3450 engine.Terminate();
3518 } 3451 }
3519 3452
3520 // Tests that the library is configured with the codecs we want. 3453 // Tests that the library is configured with the codecs we want.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3594 } 3527 }
3595 } 3528 }
3596 3529
3597 engine.Terminate(); 3530 engine.Terminate();
3598 } 3531 }
3599 3532
3600 // Tests that VoE supports at least 32 channels 3533 // Tests that VoE supports at least 32 channels
3601 TEST(WebRtcVoiceEngineTest, Has32Channels) { 3534 TEST(WebRtcVoiceEngineTest, Has32Channels) {
3602 cricket::WebRtcVoiceEngine engine; 3535 cricket::WebRtcVoiceEngine engine;
3603 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3536 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3537 rtc::scoped_ptr<webrtc::Call> call(
3538 webrtc::Call::Create(webrtc::Call::Config()));
3604 3539
3605 cricket::VoiceMediaChannel* channels[32]; 3540 cricket::VoiceMediaChannel* channels[32];
3606 int num_channels = 0; 3541 int num_channels = 0;
3607
3608 while (num_channels < ARRAY_SIZE(channels)) { 3542 while (num_channels < ARRAY_SIZE(channels)) {
3609 cricket::VoiceMediaChannel* channel = 3543 cricket::VoiceMediaChannel* channel =
3610 engine.CreateChannel(cricket::AudioOptions()); 3544 engine.CreateChannel(call.get(), cricket::AudioOptions());
3611 if (!channel) 3545 if (!channel)
3612 break; 3546 break;
3613
3614 channels[num_channels++] = channel; 3547 channels[num_channels++] = channel;
3615 } 3548 }
3616 3549
3617 int expected = ARRAY_SIZE(channels); 3550 int expected = ARRAY_SIZE(channels);
3618 EXPECT_EQ(expected, num_channels); 3551 EXPECT_EQ(expected, num_channels);
3619 3552
3620 while (num_channels > 0) { 3553 while (num_channels > 0) {
3621 delete channels[--num_channels]; 3554 delete channels[--num_channels];
3622 } 3555 }
3623 3556
3624 engine.Terminate(); 3557 engine.Terminate();
3625 } 3558 }
3626 3559
3627 // Test that we set our preferred codecs properly. 3560 // Test that we set our preferred codecs properly.
3628 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { 3561 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) {
3629 cricket::WebRtcVoiceEngine engine; 3562 cricket::WebRtcVoiceEngine engine;
3630 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3563 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3631 cricket::WebRtcVoiceMediaChannel channel(&engine); 3564 rtc::scoped_ptr<webrtc::Call> call(
3565 webrtc::Call::Create(webrtc::Call::Config()));
3566 cricket::WebRtcVoiceMediaChannel channel(&engine, call.get());
3632 EXPECT_TRUE(channel.SetRecvCodecs(engine.codecs())); 3567 EXPECT_TRUE(channel.SetRecvCodecs(engine.codecs()));
3633 } 3568 }
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/channelmanager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698