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

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

Issue 1405023016: Convert usage of ARRAY_SIZE to arraysize. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: static_cast<int> 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_unittest.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,
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/arraysize.h"
28 #include "webrtc/base/byteorder.h" 29 #include "webrtc/base/byteorder.h"
29 #include "webrtc/base/gunit.h" 30 #include "webrtc/base/gunit.h"
30 #include "webrtc/call.h" 31 #include "webrtc/call.h"
31 #include "talk/media/base/constants.h" 32 #include "talk/media/base/constants.h"
32 #include "talk/media/base/fakemediaengine.h" 33 #include "talk/media/base/fakemediaengine.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"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 int SetTraceFile(const char* fileNameUTF8) override { return 0; } 85 int SetTraceFile(const char* fileNameUTF8) override { return 0; }
85 int SetTraceCallback(webrtc::TraceCallback* callback) override { return 0; } 86 int SetTraceCallback(webrtc::TraceCallback* callback) override { return 0; }
86 unsigned int filter_; 87 unsigned int filter_;
87 }; 88 };
88 } // namespace 89 } // namespace
89 90
90 class WebRtcVoiceEngineTestFake : public testing::Test { 91 class WebRtcVoiceEngineTestFake : public testing::Test {
91 public: 92 public:
92 WebRtcVoiceEngineTestFake() 93 WebRtcVoiceEngineTestFake()
93 : call_(webrtc::Call::Config()), 94 : call_(webrtc::Call::Config()),
94 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)), 95 voe_(kAudioCodecs, arraysize(kAudioCodecs)),
95 trace_wrapper_(new FakeVoETraceWrapper()), 96 trace_wrapper_(new FakeVoETraceWrapper()),
96 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), 97 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_),
97 channel_(nullptr) { 98 channel_(nullptr) {
98 send_parameters_.codecs.push_back(kPcmuCodec); 99 send_parameters_.codecs.push_back(kPcmuCodec);
99 recv_parameters_.codecs.push_back(kPcmuCodec); 100 recv_parameters_.codecs.push_back(kPcmuCodec);
100 options_adjust_agc_.adjust_agc_delta = rtc::Optional<int>(-10); 101 options_adjust_agc_.adjust_agc_delta = rtc::Optional<int>(-10);
101 } 102 }
102 bool SetupEngine() { 103 bool SetupEngine() {
103 if (!engine_.Init(rtc::Thread::Current())) { 104 if (!engine_.Init(rtc::Thread::Current())) {
104 return false; 105 return false;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 parameters.codecs.push_back(kIsacCodec); 487 parameters.codecs.push_back(kIsacCodec);
487 parameters.codecs.push_back(kPcmuCodec); 488 parameters.codecs.push_back(kPcmuCodec);
488 parameters.codecs.push_back(kTelephoneEventCodec); 489 parameters.codecs.push_back(kTelephoneEventCodec);
489 parameters.codecs[0].id = 106; // collide with existing telephone-event 490 parameters.codecs[0].id = 106; // collide with existing telephone-event
490 parameters.codecs[2].id = 126; 491 parameters.codecs[2].id = 126;
491 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 492 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
492 EXPECT_TRUE(channel_->AddRecvStream( 493 EXPECT_TRUE(channel_->AddRecvStream(
493 cricket::StreamParams::CreateLegacy(kSsrc1))); 494 cricket::StreamParams::CreateLegacy(kSsrc1)));
494 int channel_num = voe_.GetLastChannel(); 495 int channel_num = voe_.GetLastChannel();
495 webrtc::CodecInst gcodec; 496 webrtc::CodecInst gcodec;
496 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); 497 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
497 gcodec.plfreq = 16000; 498 gcodec.plfreq = 16000;
498 gcodec.channels = 1; 499 gcodec.channels = 1;
499 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); 500 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
500 EXPECT_EQ(106, gcodec.pltype); 501 EXPECT_EQ(106, gcodec.pltype);
501 EXPECT_STREQ("ISAC", gcodec.plname); 502 EXPECT_STREQ("ISAC", gcodec.plname);
502 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), 503 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event");
503 "telephone-event");
504 gcodec.plfreq = 8000; 504 gcodec.plfreq = 8000;
505 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); 505 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
506 EXPECT_EQ(126, gcodec.pltype); 506 EXPECT_EQ(126, gcodec.pltype);
507 EXPECT_STREQ("telephone-event", gcodec.plname); 507 EXPECT_STREQ("telephone-event", gcodec.plname);
508 } 508 }
509 509
510 // Test that we fail to set an unknown inbound codec. 510 // Test that we fail to set an unknown inbound codec.
511 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) { 511 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) {
512 EXPECT_TRUE(SetupEngine()); 512 EXPECT_TRUE(SetupEngine());
513 cricket::AudioRecvParameters parameters; 513 cricket::AudioRecvParameters parameters;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 parameters.codecs.push_back(kIsacCodec); 600 parameters.codecs.push_back(kIsacCodec);
601 parameters.codecs.push_back(kPcmuCodec); 601 parameters.codecs.push_back(kPcmuCodec);
602 parameters.codecs.push_back(kTelephoneEventCodec); 602 parameters.codecs.push_back(kTelephoneEventCodec);
603 parameters.codecs[0].id = 106; // collide with existing telephone-event 603 parameters.codecs[0].id = 106; // collide with existing telephone-event
604 parameters.codecs[2].id = 126; 604 parameters.codecs[2].id = 126;
605 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 605 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
606 EXPECT_TRUE(channel_->AddRecvStream( 606 EXPECT_TRUE(channel_->AddRecvStream(
607 cricket::StreamParams::CreateLegacy(kSsrc1))); 607 cricket::StreamParams::CreateLegacy(kSsrc1)));
608 int channel_num2 = voe_.GetLastChannel(); 608 int channel_num2 = voe_.GetLastChannel();
609 webrtc::CodecInst gcodec; 609 webrtc::CodecInst gcodec;
610 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); 610 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
611 gcodec.plfreq = 16000; 611 gcodec.plfreq = 16000;
612 gcodec.channels = 1; 612 gcodec.channels = 1;
613 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); 613 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
614 EXPECT_EQ(106, gcodec.pltype); 614 EXPECT_EQ(106, gcodec.pltype);
615 EXPECT_STREQ("ISAC", gcodec.plname); 615 EXPECT_STREQ("ISAC", gcodec.plname);
616 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), 616 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event");
617 "telephone-event");
618 gcodec.plfreq = 8000; 617 gcodec.plfreq = 8000;
619 gcodec.channels = 1; 618 gcodec.channels = 1;
620 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); 619 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
621 EXPECT_EQ(126, gcodec.pltype); 620 EXPECT_EQ(126, gcodec.pltype);
622 EXPECT_STREQ("telephone-event", gcodec.plname); 621 EXPECT_STREQ("telephone-event", gcodec.plname);
623 } 622 }
624 623
625 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { 624 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) {
626 EXPECT_TRUE(SetupEngineWithRecvStream()); 625 EXPECT_TRUE(SetupEngineWithRecvStream());
627 cricket::AudioRecvParameters parameters; 626 cricket::AudioRecvParameters parameters;
628 parameters.codecs.push_back(kIsacCodec); 627 parameters.codecs.push_back(kIsacCodec);
629 parameters.codecs[0].id = 106; // collide with existing telephone-event 628 parameters.codecs[0].id = 106; // collide with existing telephone-event
630 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 629 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
631 630
632 int channel_num2 = voe_.GetLastChannel(); 631 int channel_num2 = voe_.GetLastChannel();
633 webrtc::CodecInst gcodec; 632 webrtc::CodecInst gcodec;
634 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); 633 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
635 gcodec.plfreq = 16000; 634 gcodec.plfreq = 16000;
636 gcodec.channels = 1; 635 gcodec.channels = 1;
637 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); 636 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
638 EXPECT_EQ(106, gcodec.pltype); 637 EXPECT_EQ(106, gcodec.pltype);
639 EXPECT_STREQ("ISAC", gcodec.plname); 638 EXPECT_STREQ("ISAC", gcodec.plname);
640 } 639 }
641 640
642 // Test that we can apply the same set of codecs again while playing. 641 // Test that we can apply the same set of codecs again while playing.
643 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { 642 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) {
644 EXPECT_TRUE(SetupEngineWithRecvStream()); 643 EXPECT_TRUE(SetupEngineWithRecvStream());
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 1975
1977 for (uint32_t ssrc : kSsrcs4) { 1976 for (uint32_t ssrc : kSsrcs4) {
1978 EXPECT_TRUE(channel_->AddSendStream( 1977 EXPECT_TRUE(channel_->AddSendStream(
1979 cricket::StreamParams::CreateLegacy(ssrc))); 1978 cricket::StreamParams::CreateLegacy(ssrc)));
1980 EXPECT_NE(nullptr, call_.GetAudioSendStream(ssrc)); 1979 EXPECT_NE(nullptr, call_.GetAudioSendStream(ssrc));
1981 1980
1982 // Verify that we are in a sending state for all the created streams. 1981 // Verify that we are in a sending state for all the created streams.
1983 int channel_num = voe_.GetChannelFromLocalSsrc(ssrc); 1982 int channel_num = voe_.GetChannelFromLocalSsrc(ssrc);
1984 EXPECT_TRUE(voe_.GetSend(channel_num)); 1983 EXPECT_TRUE(voe_.GetSend(channel_num));
1985 } 1984 }
1986 EXPECT_EQ(ARRAY_SIZE(kSsrcs4), call_.GetAudioSendStreams().size()); 1985 EXPECT_EQ(arraysize(kSsrcs4), call_.GetAudioSendStreams().size());
1987 1986
1988 // Delete the send streams. 1987 // Delete the send streams.
1989 for (uint32_t ssrc : kSsrcs4) { 1988 for (uint32_t ssrc : kSsrcs4) {
1990 EXPECT_TRUE(channel_->RemoveSendStream(ssrc)); 1989 EXPECT_TRUE(channel_->RemoveSendStream(ssrc));
1991 EXPECT_EQ(nullptr, call_.GetAudioSendStream(ssrc)); 1990 EXPECT_EQ(nullptr, call_.GetAudioSendStream(ssrc));
1992 // Stream should already be deleted. 1991 // Stream should already be deleted.
1993 EXPECT_FALSE(channel_->RemoveSendStream(ssrc)); 1992 EXPECT_FALSE(channel_->RemoveSendStream(ssrc));
1994 EXPECT_EQ(-1, voe_.GetChannelFromLocalSsrc(ssrc)); 1993 EXPECT_EQ(-1, voe_.GetChannelFromLocalSsrc(ssrc));
1995 } 1994 }
1996 EXPECT_EQ(0u, call_.GetAudioSendStreams().size()); 1995 EXPECT_EQ(0u, call_.GetAudioSendStreams().size());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 // We need send codec to be set to get all stats. 2080 // We need send codec to be set to get all stats.
2082 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2081 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2083 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); 2082 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
2084 2083
2085 // Check stats for the added streams. 2084 // Check stats for the added streams.
2086 { 2085 {
2087 cricket::VoiceMediaInfo info; 2086 cricket::VoiceMediaInfo info;
2088 EXPECT_EQ(true, channel_->GetStats(&info)); 2087 EXPECT_EQ(true, channel_->GetStats(&info));
2089 2088
2090 // We have added 4 send streams. We should see empty stats for all. 2089 // We have added 4 send streams. We should see empty stats for all.
2091 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); 2090 EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size());
2092 for (const auto& sender : info.senders) { 2091 for (const auto& sender : info.senders) {
2093 VerifyVoiceSenderInfo(sender, false); 2092 VerifyVoiceSenderInfo(sender, false);
2094 } 2093 }
2095 2094
2096 // We have added one receive stream. We should see empty stats. 2095 // We have added one receive stream. We should see empty stats.
2097 EXPECT_EQ(info.receivers.size(), 1u); 2096 EXPECT_EQ(info.receivers.size(), 1u);
2098 EXPECT_EQ(info.receivers[0].ssrc(), 0); 2097 EXPECT_EQ(info.receivers[0].ssrc(), 0);
2099 } 2098 }
2100 2099
2101 // Remove the kSsrc2 stream. No receiver stats. 2100 // Remove the kSsrc2 stream. No receiver stats.
2102 { 2101 {
2103 cricket::VoiceMediaInfo info; 2102 cricket::VoiceMediaInfo info;
2104 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); 2103 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2));
2105 EXPECT_EQ(true, channel_->GetStats(&info)); 2104 EXPECT_EQ(true, channel_->GetStats(&info));
2106 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); 2105 EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size());
2107 EXPECT_EQ(0u, info.receivers.size()); 2106 EXPECT_EQ(0u, info.receivers.size());
2108 } 2107 }
2109 2108
2110 // Deliver a new packet - a default receive stream should be created and we 2109 // Deliver a new packet - a default receive stream should be created and we
2111 // should see stats again. 2110 // should see stats again.
2112 { 2111 {
2113 cricket::VoiceMediaInfo info; 2112 cricket::VoiceMediaInfo info;
2114 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); 2113 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
2115 SetAudioReceiveStreamStats(); 2114 SetAudioReceiveStreamStats();
2116 EXPECT_EQ(true, channel_->GetStats(&info)); 2115 EXPECT_EQ(true, channel_->GetStats(&info));
2117 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); 2116 EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size());
2118 EXPECT_EQ(1u, info.receivers.size()); 2117 EXPECT_EQ(1u, info.receivers.size());
2119 VerifyVoiceReceiverInfo(info.receivers[0]); 2118 VerifyVoiceReceiverInfo(info.receivers[0]);
2120 } 2119 }
2121 } 2120 }
2122 2121
2123 // Test that we can add and remove receive streams, and do proper send/playout. 2122 // Test that we can add and remove receive streams, and do proper send/playout.
2124 // We can receive on multiple streams while sending one stream. 2123 // We can receive on multiple streams while sending one stream.
2125 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { 2124 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) {
2126 EXPECT_TRUE(SetupEngineWithSendStream()); 2125 EXPECT_TRUE(SetupEngineWithSendStream());
2127 int channel_num1 = voe_.GetLastChannel(); 2126 int channel_num1 = voe_.GetLastChannel();
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2435 EXPECT_TRUE(SetupEngineWithSendStream()); 2434 EXPECT_TRUE(SetupEngineWithSendStream());
2436 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2435 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2437 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 2436 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2438 int channel_num1 = voe_.GetLastChannel(); 2437 int channel_num1 = voe_.GetLastChannel();
2439 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2438 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2440 int channel_num2 = voe_.GetLastChannel(); 2439 int channel_num2 = voe_.GetLastChannel();
2441 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); 2440 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3)));
2442 int channel_num3 = voe_.GetLastChannel(); 2441 int channel_num3 = voe_.GetLastChannel();
2443 // Create packets with the right SSRCs. 2442 // Create packets with the right SSRCs.
2444 char packets[4][sizeof(kPcmuFrame)]; 2443 char packets[4][sizeof(kPcmuFrame)];
2445 for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) { 2444 for (size_t i = 0; i < arraysize(packets); ++i) {
2446 memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame)); 2445 memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame));
2447 rtc::SetBE32(packets[i] + 8, static_cast<uint32_t>(i)); 2446 rtc::SetBE32(packets[i] + 8, static_cast<uint32_t>(i));
2448 } 2447 }
2449 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1)); 2448 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1));
2450 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); 2449 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2));
2451 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3)); 2450 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3));
2452 DeliverPacket(packets[0], sizeof(packets[0])); 2451 DeliverPacket(packets[0], sizeof(packets[0]));
2453 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1)); 2452 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1));
2454 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); 2453 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2));
2455 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3)); 2454 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { 2499 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) {
2501 EXPECT_TRUE(SetupEngineWithSendStream()); 2500 EXPECT_TRUE(SetupEngineWithSendStream());
2502 cricket::AudioRecvParameters parameters; 2501 cricket::AudioRecvParameters parameters;
2503 parameters.codecs.push_back(kIsacCodec); 2502 parameters.codecs.push_back(kIsacCodec);
2504 parameters.codecs.push_back(kPcmuCodec); 2503 parameters.codecs.push_back(kPcmuCodec);
2505 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 2504 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
2506 EXPECT_TRUE(channel_->AddRecvStream( 2505 EXPECT_TRUE(channel_->AddRecvStream(
2507 cricket::StreamParams::CreateLegacy(kSsrc1))); 2506 cricket::StreamParams::CreateLegacy(kSsrc1)));
2508 int channel_num2 = voe_.GetLastChannel(); 2507 int channel_num2 = voe_.GetLastChannel();
2509 webrtc::CodecInst gcodec; 2508 webrtc::CodecInst gcodec;
2510 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "opus"); 2509 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "opus");
2511 gcodec.plfreq = 48000; 2510 gcodec.plfreq = 48000;
2512 gcodec.channels = 2; 2511 gcodec.channels = 2;
2513 EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec)); 2512 EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec));
2514 } 2513 }
2515 2514
2516 // Test that we properly clean up any streams that were added, even if 2515 // Test that we properly clean up any streams that were added, even if
2517 // not explicitly removed. 2516 // not explicitly removed.
2518 TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { 2517 TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) {
2519 EXPECT_TRUE(SetupEngineWithSendStream()); 2518 EXPECT_TRUE(SetupEngineWithSendStream());
2520 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 2519 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
3039 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { 3038 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) {
3040 // Test that adding receive streams after enabling combined bandwidth 3039 // Test that adding receive streams after enabling combined bandwidth
3041 // estimation will correctly configure each channel. 3040 // estimation will correctly configure each channel.
3042 EXPECT_TRUE(SetupEngineWithSendStream()); 3041 EXPECT_TRUE(SetupEngineWithSendStream());
3043 cricket::WebRtcVoiceMediaChannel* media_channel = 3042 cricket::WebRtcVoiceMediaChannel* media_channel =
3044 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3043 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3045 send_parameters_.options.combined_audio_video_bwe = rtc::Optional<bool>(true); 3044 send_parameters_.options.combined_audio_video_bwe = rtc::Optional<bool>(true);
3046 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); 3045 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
3047 3046
3048 static const uint32_t kSsrcs[] = {1, 2, 3, 4}; 3047 static const uint32_t kSsrcs[] = {1, 2, 3, 4};
3049 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { 3048 for (unsigned int i = 0; i < arraysize(kSsrcs); ++i) {
3050 EXPECT_TRUE(media_channel->AddRecvStream( 3049 EXPECT_TRUE(media_channel->AddRecvStream(
3051 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); 3050 cricket::StreamParams::CreateLegacy(kSsrcs[i])));
3052 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i])); 3051 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i]));
3053 } 3052 }
3054 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size()); 3053 EXPECT_EQ(arraysize(kSsrcs), call_.GetAudioReceiveStreams().size());
3055 } 3054 }
3056 3055
3057 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { 3056 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) {
3058 // Test that setting the header extensions results in the expected state 3057 // Test that setting the header extensions results in the expected state
3059 // changes on an associated Call. 3058 // changes on an associated Call.
3060 std::vector<uint32_t> ssrcs; 3059 std::vector<uint32_t> ssrcs;
3061 ssrcs.push_back(223); 3060 ssrcs.push_back(223);
3062 ssrcs.push_back(224); 3061 ssrcs.push_back(224);
3063 3062
3064 EXPECT_TRUE(SetupEngineWithSendStream()); 3063 EXPECT_TRUE(SetupEngineWithSendStream());
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3289 3288
3290 // Tests that VoE supports at least 32 channels 3289 // Tests that VoE supports at least 32 channels
3291 TEST(WebRtcVoiceEngineTest, Has32Channels) { 3290 TEST(WebRtcVoiceEngineTest, Has32Channels) {
3292 cricket::WebRtcVoiceEngine engine; 3291 cricket::WebRtcVoiceEngine engine;
3293 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3292 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3294 rtc::scoped_ptr<webrtc::Call> call( 3293 rtc::scoped_ptr<webrtc::Call> call(
3295 webrtc::Call::Create(webrtc::Call::Config())); 3294 webrtc::Call::Create(webrtc::Call::Config()));
3296 3295
3297 cricket::VoiceMediaChannel* channels[32]; 3296 cricket::VoiceMediaChannel* channels[32];
3298 int num_channels = 0; 3297 int num_channels = 0;
3299 while (num_channels < ARRAY_SIZE(channels)) { 3298 while (num_channels < arraysize(channels)) {
3300 cricket::VoiceMediaChannel* channel = 3299 cricket::VoiceMediaChannel* channel =
3301 engine.CreateChannel(call.get(), cricket::AudioOptions()); 3300 engine.CreateChannel(call.get(), cricket::AudioOptions());
3302 if (!channel) 3301 if (!channel)
3303 break; 3302 break;
3304 channels[num_channels++] = channel; 3303 channels[num_channels++] = channel;
3305 } 3304 }
3306 3305
3307 int expected = ARRAY_SIZE(channels); 3306 int expected = arraysize(channels);
3308 EXPECT_EQ(expected, num_channels); 3307 EXPECT_EQ(expected, num_channels);
3309 3308
3310 while (num_channels > 0) { 3309 while (num_channels > 0) {
3311 delete channels[--num_channels]; 3310 delete channels[--num_channels];
3312 } 3311 }
3313 engine.Terminate(); 3312 engine.Terminate();
3314 } 3313 }
3315 3314
3316 // Test that we set our preferred codecs properly. 3315 // Test that we set our preferred codecs properly.
3317 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { 3316 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) {
3318 cricket::WebRtcVoiceEngine engine; 3317 cricket::WebRtcVoiceEngine engine;
3319 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3318 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3320 rtc::scoped_ptr<webrtc::Call> call( 3319 rtc::scoped_ptr<webrtc::Call> call(
3321 webrtc::Call::Create(webrtc::Call::Config())); 3320 webrtc::Call::Create(webrtc::Call::Config()));
3322 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), 3321 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(),
3323 call.get()); 3322 call.get());
3324 cricket::AudioRecvParameters parameters; 3323 cricket::AudioRecvParameters parameters;
3325 parameters.codecs = engine.codecs(); 3324 parameters.codecs = engine.codecs();
3326 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3325 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3327 } 3326 }
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698