| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2008 Google Inc. | 3 * Copyright 2008 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 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 Loading... |
| 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::Maybe<int>(-10); | 101 options_adjust_agc_.adjust_agc_delta = rtc::Maybe<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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 parameters.codecs.push_back(kIsacCodec); | 486 parameters.codecs.push_back(kIsacCodec); |
| 486 parameters.codecs.push_back(kPcmuCodec); | 487 parameters.codecs.push_back(kPcmuCodec); |
| 487 parameters.codecs.push_back(kTelephoneEventCodec); | 488 parameters.codecs.push_back(kTelephoneEventCodec); |
| 488 parameters.codecs[0].id = 106; // collide with existing telephone-event | 489 parameters.codecs[0].id = 106; // collide with existing telephone-event |
| 489 parameters.codecs[2].id = 126; | 490 parameters.codecs[2].id = 126; |
| 490 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 491 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 491 EXPECT_TRUE(channel_->AddRecvStream( | 492 EXPECT_TRUE(channel_->AddRecvStream( |
| 492 cricket::StreamParams::CreateLegacy(kSsrc1))); | 493 cricket::StreamParams::CreateLegacy(kSsrc1))); |
| 493 int channel_num = voe_.GetLastChannel(); | 494 int channel_num = voe_.GetLastChannel(); |
| 494 webrtc::CodecInst gcodec; | 495 webrtc::CodecInst gcodec; |
| 495 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); | 496 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC"); |
| 496 gcodec.plfreq = 16000; | 497 gcodec.plfreq = 16000; |
| 497 gcodec.channels = 1; | 498 gcodec.channels = 1; |
| 498 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); | 499 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); |
| 499 EXPECT_EQ(106, gcodec.pltype); | 500 EXPECT_EQ(106, gcodec.pltype); |
| 500 EXPECT_STREQ("ISAC", gcodec.plname); | 501 EXPECT_STREQ("ISAC", gcodec.plname); |
| 501 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), | 502 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event"); |
| 502 "telephone-event"); | |
| 503 gcodec.plfreq = 8000; | 503 gcodec.plfreq = 8000; |
| 504 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); | 504 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); |
| 505 EXPECT_EQ(126, gcodec.pltype); | 505 EXPECT_EQ(126, gcodec.pltype); |
| 506 EXPECT_STREQ("telephone-event", gcodec.plname); | 506 EXPECT_STREQ("telephone-event", gcodec.plname); |
| 507 } | 507 } |
| 508 | 508 |
| 509 // Test that we fail to set an unknown inbound codec. | 509 // Test that we fail to set an unknown inbound codec. |
| 510 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) { | 510 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) { |
| 511 EXPECT_TRUE(SetupEngine()); | 511 EXPECT_TRUE(SetupEngine()); |
| 512 cricket::AudioRecvParameters parameters; | 512 cricket::AudioRecvParameters parameters; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 parameters.codecs.push_back(kIsacCodec); | 599 parameters.codecs.push_back(kIsacCodec); |
| 600 parameters.codecs.push_back(kPcmuCodec); | 600 parameters.codecs.push_back(kPcmuCodec); |
| 601 parameters.codecs.push_back(kTelephoneEventCodec); | 601 parameters.codecs.push_back(kTelephoneEventCodec); |
| 602 parameters.codecs[0].id = 106; // collide with existing telephone-event | 602 parameters.codecs[0].id = 106; // collide with existing telephone-event |
| 603 parameters.codecs[2].id = 126; | 603 parameters.codecs[2].id = 126; |
| 604 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 604 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 605 EXPECT_TRUE(channel_->AddRecvStream( | 605 EXPECT_TRUE(channel_->AddRecvStream( |
| 606 cricket::StreamParams::CreateLegacy(kSsrc1))); | 606 cricket::StreamParams::CreateLegacy(kSsrc1))); |
| 607 int channel_num2 = voe_.GetLastChannel(); | 607 int channel_num2 = voe_.GetLastChannel(); |
| 608 webrtc::CodecInst gcodec; | 608 webrtc::CodecInst gcodec; |
| 609 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); | 609 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC"); |
| 610 gcodec.plfreq = 16000; | 610 gcodec.plfreq = 16000; |
| 611 gcodec.channels = 1; | 611 gcodec.channels = 1; |
| 612 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); | 612 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); |
| 613 EXPECT_EQ(106, gcodec.pltype); | 613 EXPECT_EQ(106, gcodec.pltype); |
| 614 EXPECT_STREQ("ISAC", gcodec.plname); | 614 EXPECT_STREQ("ISAC", gcodec.plname); |
| 615 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), | 615 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event"); |
| 616 "telephone-event"); | |
| 617 gcodec.plfreq = 8000; | 616 gcodec.plfreq = 8000; |
| 618 gcodec.channels = 1; | 617 gcodec.channels = 1; |
| 619 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); | 618 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); |
| 620 EXPECT_EQ(126, gcodec.pltype); | 619 EXPECT_EQ(126, gcodec.pltype); |
| 621 EXPECT_STREQ("telephone-event", gcodec.plname); | 620 EXPECT_STREQ("telephone-event", gcodec.plname); |
| 622 } | 621 } |
| 623 | 622 |
| 624 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { | 623 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { |
| 625 EXPECT_TRUE(SetupEngineWithRecvStream()); | 624 EXPECT_TRUE(SetupEngineWithRecvStream()); |
| 626 cricket::AudioRecvParameters parameters; | 625 cricket::AudioRecvParameters parameters; |
| 627 parameters.codecs.push_back(kIsacCodec); | 626 parameters.codecs.push_back(kIsacCodec); |
| 628 parameters.codecs[0].id = 106; // collide with existing telephone-event | 627 parameters.codecs[0].id = 106; // collide with existing telephone-event |
| 629 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 628 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 630 | 629 |
| 631 int channel_num2 = voe_.GetLastChannel(); | 630 int channel_num2 = voe_.GetLastChannel(); |
| 632 webrtc::CodecInst gcodec; | 631 webrtc::CodecInst gcodec; |
| 633 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); | 632 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC"); |
| 634 gcodec.plfreq = 16000; | 633 gcodec.plfreq = 16000; |
| 635 gcodec.channels = 1; | 634 gcodec.channels = 1; |
| 636 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); | 635 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); |
| 637 EXPECT_EQ(106, gcodec.pltype); | 636 EXPECT_EQ(106, gcodec.pltype); |
| 638 EXPECT_STREQ("ISAC", gcodec.plname); | 637 EXPECT_STREQ("ISAC", gcodec.plname); |
| 639 } | 638 } |
| 640 | 639 |
| 641 // Test that we can apply the same set of codecs again while playing. | 640 // Test that we can apply the same set of codecs again while playing. |
| 642 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { | 641 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { |
| 643 EXPECT_TRUE(SetupEngineWithRecvStream()); | 642 EXPECT_TRUE(SetupEngineWithRecvStream()); |
| (...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 | 1974 |
| 1976 for (uint32_t ssrc : kSsrcs4) { | 1975 for (uint32_t ssrc : kSsrcs4) { |
| 1977 EXPECT_TRUE(channel_->AddSendStream( | 1976 EXPECT_TRUE(channel_->AddSendStream( |
| 1978 cricket::StreamParams::CreateLegacy(ssrc))); | 1977 cricket::StreamParams::CreateLegacy(ssrc))); |
| 1979 EXPECT_NE(nullptr, call_.GetAudioSendStream(ssrc)); | 1978 EXPECT_NE(nullptr, call_.GetAudioSendStream(ssrc)); |
| 1980 | 1979 |
| 1981 // Verify that we are in a sending state for all the created streams. | 1980 // Verify that we are in a sending state for all the created streams. |
| 1982 int channel_num = voe_.GetChannelFromLocalSsrc(ssrc); | 1981 int channel_num = voe_.GetChannelFromLocalSsrc(ssrc); |
| 1983 EXPECT_TRUE(voe_.GetSend(channel_num)); | 1982 EXPECT_TRUE(voe_.GetSend(channel_num)); |
| 1984 } | 1983 } |
| 1985 EXPECT_EQ(ARRAY_SIZE(kSsrcs4), call_.GetAudioSendStreams().size()); | 1984 EXPECT_EQ(arraysize(kSsrcs4), call_.GetAudioSendStreams().size()); |
| 1986 | 1985 |
| 1987 // Delete the send streams. | 1986 // Delete the send streams. |
| 1988 for (uint32_t ssrc : kSsrcs4) { | 1987 for (uint32_t ssrc : kSsrcs4) { |
| 1989 EXPECT_TRUE(channel_->RemoveSendStream(ssrc)); | 1988 EXPECT_TRUE(channel_->RemoveSendStream(ssrc)); |
| 1990 EXPECT_EQ(nullptr, call_.GetAudioSendStream(ssrc)); | 1989 EXPECT_EQ(nullptr, call_.GetAudioSendStream(ssrc)); |
| 1991 // Stream should already be deleted. | 1990 // Stream should already be deleted. |
| 1992 EXPECT_FALSE(channel_->RemoveSendStream(ssrc)); | 1991 EXPECT_FALSE(channel_->RemoveSendStream(ssrc)); |
| 1993 EXPECT_EQ(-1, voe_.GetChannelFromLocalSsrc(ssrc)); | 1992 EXPECT_EQ(-1, voe_.GetChannelFromLocalSsrc(ssrc)); |
| 1994 } | 1993 } |
| 1995 EXPECT_EQ(0u, call_.GetAudioSendStreams().size()); | 1994 EXPECT_EQ(0u, call_.GetAudioSendStreams().size()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 // We need send codec to be set to get all stats. | 2079 // We need send codec to be set to get all stats. |
| 2081 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2080 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2082 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); | 2081 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
| 2083 | 2082 |
| 2084 // Check stats for the added streams. | 2083 // Check stats for the added streams. |
| 2085 { | 2084 { |
| 2086 cricket::VoiceMediaInfo info; | 2085 cricket::VoiceMediaInfo info; |
| 2087 EXPECT_EQ(true, channel_->GetStats(&info)); | 2086 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2088 | 2087 |
| 2089 // We have added 4 send streams. We should see empty stats for all. | 2088 // We have added 4 send streams. We should see empty stats for all. |
| 2090 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); | 2089 EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size()); |
| 2091 for (const auto& sender : info.senders) { | 2090 for (const auto& sender : info.senders) { |
| 2092 VerifyVoiceSenderInfo(sender); | 2091 VerifyVoiceSenderInfo(sender); |
| 2093 } | 2092 } |
| 2094 | 2093 |
| 2095 // We have added one receive stream. We should see empty stats. | 2094 // We have added one receive stream. We should see empty stats. |
| 2096 EXPECT_EQ(info.receivers.size(), 1u); | 2095 EXPECT_EQ(info.receivers.size(), 1u); |
| 2097 EXPECT_EQ(info.receivers[0].ssrc(), 0); | 2096 EXPECT_EQ(info.receivers[0].ssrc(), 0); |
| 2098 } | 2097 } |
| 2099 | 2098 |
| 2100 // Remove the kSsrc2 stream. No receiver stats. | 2099 // Remove the kSsrc2 stream. No receiver stats. |
| 2101 { | 2100 { |
| 2102 cricket::VoiceMediaInfo info; | 2101 cricket::VoiceMediaInfo info; |
| 2103 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); | 2102 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); |
| 2104 EXPECT_EQ(true, channel_->GetStats(&info)); | 2103 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2105 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); | 2104 EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size()); |
| 2106 EXPECT_EQ(0u, info.receivers.size()); | 2105 EXPECT_EQ(0u, info.receivers.size()); |
| 2107 } | 2106 } |
| 2108 | 2107 |
| 2109 // Deliver a new packet - a default receive stream should be created and we | 2108 // Deliver a new packet - a default receive stream should be created and we |
| 2110 // should see stats again. | 2109 // should see stats again. |
| 2111 { | 2110 { |
| 2112 cricket::VoiceMediaInfo info; | 2111 cricket::VoiceMediaInfo info; |
| 2113 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2112 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2114 SetAudioReceiveStreamStats(); | 2113 SetAudioReceiveStreamStats(); |
| 2115 EXPECT_EQ(true, channel_->GetStats(&info)); | 2114 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2116 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); | 2115 EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size()); |
| 2117 EXPECT_EQ(1u, info.receivers.size()); | 2116 EXPECT_EQ(1u, info.receivers.size()); |
| 2118 VerifyVoiceReceiverInfo(info.receivers[0]); | 2117 VerifyVoiceReceiverInfo(info.receivers[0]); |
| 2119 } | 2118 } |
| 2120 } | 2119 } |
| 2121 | 2120 |
| 2122 // Test that we can add and remove receive streams, and do proper send/playout. | 2121 // Test that we can add and remove receive streams, and do proper send/playout. |
| 2123 // We can receive on multiple streams while sending one stream. | 2122 // We can receive on multiple streams while sending one stream. |
| 2124 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { | 2123 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { |
| 2125 EXPECT_TRUE(SetupEngineWithSendStream()); | 2124 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2126 int channel_num1 = voe_.GetLastChannel(); | 2125 int channel_num1 = voe_.GetLastChannel(); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2426 EXPECT_TRUE(SetupEngineWithSendStream()); | 2425 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2427 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2426 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2428 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 2427 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 2429 int channel_num1 = voe_.GetLastChannel(); | 2428 int channel_num1 = voe_.GetLastChannel(); |
| 2430 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2429 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 2431 int channel_num2 = voe_.GetLastChannel(); | 2430 int channel_num2 = voe_.GetLastChannel(); |
| 2432 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); | 2431 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
| 2433 int channel_num3 = voe_.GetLastChannel(); | 2432 int channel_num3 = voe_.GetLastChannel(); |
| 2434 // Create packets with the right SSRCs. | 2433 // Create packets with the right SSRCs. |
| 2435 char packets[4][sizeof(kPcmuFrame)]; | 2434 char packets[4][sizeof(kPcmuFrame)]; |
| 2436 for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) { | 2435 for (size_t i = 0; i < arraysize(packets); ++i) { |
| 2437 memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame)); | 2436 memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame)); |
| 2438 rtc::SetBE32(packets[i] + 8, static_cast<uint32_t>(i)); | 2437 rtc::SetBE32(packets[i] + 8, static_cast<uint32_t>(i)); |
| 2439 } | 2438 } |
| 2440 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1)); | 2439 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1)); |
| 2441 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); | 2440 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); |
| 2442 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3)); | 2441 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3)); |
| 2443 DeliverPacket(packets[0], sizeof(packets[0])); | 2442 DeliverPacket(packets[0], sizeof(packets[0])); |
| 2444 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1)); | 2443 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1)); |
| 2445 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); | 2444 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); |
| 2446 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3)); | 2445 EXPECT_TRUE(voe_.CheckNoPacket(channel_num3)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2491 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { | 2490 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { |
| 2492 EXPECT_TRUE(SetupEngineWithSendStream()); | 2491 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2493 cricket::AudioRecvParameters parameters; | 2492 cricket::AudioRecvParameters parameters; |
| 2494 parameters.codecs.push_back(kIsacCodec); | 2493 parameters.codecs.push_back(kIsacCodec); |
| 2495 parameters.codecs.push_back(kPcmuCodec); | 2494 parameters.codecs.push_back(kPcmuCodec); |
| 2496 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 2495 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 2497 EXPECT_TRUE(channel_->AddRecvStream( | 2496 EXPECT_TRUE(channel_->AddRecvStream( |
| 2498 cricket::StreamParams::CreateLegacy(kSsrc1))); | 2497 cricket::StreamParams::CreateLegacy(kSsrc1))); |
| 2499 int channel_num2 = voe_.GetLastChannel(); | 2498 int channel_num2 = voe_.GetLastChannel(); |
| 2500 webrtc::CodecInst gcodec; | 2499 webrtc::CodecInst gcodec; |
| 2501 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "opus"); | 2500 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "opus"); |
| 2502 gcodec.plfreq = 48000; | 2501 gcodec.plfreq = 48000; |
| 2503 gcodec.channels = 2; | 2502 gcodec.channels = 2; |
| 2504 EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec)); | 2503 EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec)); |
| 2505 } | 2504 } |
| 2506 | 2505 |
| 2507 // Test that we properly clean up any streams that were added, even if | 2506 // Test that we properly clean up any streams that were added, even if |
| 2508 // not explicitly removed. | 2507 // not explicitly removed. |
| 2509 TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { | 2508 TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { |
| 2510 EXPECT_TRUE(SetupEngineWithSendStream()); | 2509 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2511 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2510 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3027 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { | 3026 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { |
| 3028 // Test that adding receive streams after enabling combined bandwidth | 3027 // Test that adding receive streams after enabling combined bandwidth |
| 3029 // estimation will correctly configure each channel. | 3028 // estimation will correctly configure each channel. |
| 3030 EXPECT_TRUE(SetupEngineWithSendStream()); | 3029 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 3031 cricket::WebRtcVoiceMediaChannel* media_channel = | 3030 cricket::WebRtcVoiceMediaChannel* media_channel = |
| 3032 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 3031 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
| 3033 send_parameters_.options.combined_audio_video_bwe = rtc::Maybe<bool>(true); | 3032 send_parameters_.options.combined_audio_video_bwe = rtc::Maybe<bool>(true); |
| 3034 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); | 3033 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); |
| 3035 | 3034 |
| 3036 static const uint32_t kSsrcs[] = {1, 2, 3, 4}; | 3035 static const uint32_t kSsrcs[] = {1, 2, 3, 4}; |
| 3037 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { | 3036 for (unsigned int i = 0; i < arraysize(kSsrcs); ++i) { |
| 3038 EXPECT_TRUE(media_channel->AddRecvStream( | 3037 EXPECT_TRUE(media_channel->AddRecvStream( |
| 3039 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); | 3038 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); |
| 3040 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i])); | 3039 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i])); |
| 3041 } | 3040 } |
| 3042 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size()); | 3041 EXPECT_EQ(arraysize(kSsrcs), call_.GetAudioReceiveStreams().size()); |
| 3043 } | 3042 } |
| 3044 | 3043 |
| 3045 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { | 3044 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { |
| 3046 // Test that setting the header extensions results in the expected state | 3045 // Test that setting the header extensions results in the expected state |
| 3047 // changes on an associated Call. | 3046 // changes on an associated Call. |
| 3048 std::vector<uint32_t> ssrcs; | 3047 std::vector<uint32_t> ssrcs; |
| 3049 ssrcs.push_back(223); | 3048 ssrcs.push_back(223); |
| 3050 ssrcs.push_back(224); | 3049 ssrcs.push_back(224); |
| 3051 | 3050 |
| 3052 EXPECT_TRUE(SetupEngineWithSendStream()); | 3051 EXPECT_TRUE(SetupEngineWithSendStream()); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3277 | 3276 |
| 3278 // Tests that VoE supports at least 32 channels | 3277 // Tests that VoE supports at least 32 channels |
| 3279 TEST(WebRtcVoiceEngineTest, Has32Channels) { | 3278 TEST(WebRtcVoiceEngineTest, Has32Channels) { |
| 3280 cricket::WebRtcVoiceEngine engine; | 3279 cricket::WebRtcVoiceEngine engine; |
| 3281 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3280 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
| 3282 rtc::scoped_ptr<webrtc::Call> call( | 3281 rtc::scoped_ptr<webrtc::Call> call( |
| 3283 webrtc::Call::Create(webrtc::Call::Config())); | 3282 webrtc::Call::Create(webrtc::Call::Config())); |
| 3284 | 3283 |
| 3285 cricket::VoiceMediaChannel* channels[32]; | 3284 cricket::VoiceMediaChannel* channels[32]; |
| 3286 int num_channels = 0; | 3285 int num_channels = 0; |
| 3287 while (num_channels < ARRAY_SIZE(channels)) { | 3286 while (num_channels < arraysize(channels)) { |
| 3288 cricket::VoiceMediaChannel* channel = | 3287 cricket::VoiceMediaChannel* channel = |
| 3289 engine.CreateChannel(call.get(), cricket::AudioOptions()); | 3288 engine.CreateChannel(call.get(), cricket::AudioOptions()); |
| 3290 if (!channel) | 3289 if (!channel) |
| 3291 break; | 3290 break; |
| 3292 channels[num_channels++] = channel; | 3291 channels[num_channels++] = channel; |
| 3293 } | 3292 } |
| 3294 | 3293 |
| 3295 int expected = ARRAY_SIZE(channels); | 3294 int expected = arraysize(channels); |
| 3296 EXPECT_EQ(expected, num_channels); | 3295 EXPECT_EQ(expected, num_channels); |
| 3297 | 3296 |
| 3298 while (num_channels > 0) { | 3297 while (num_channels > 0) { |
| 3299 delete channels[--num_channels]; | 3298 delete channels[--num_channels]; |
| 3300 } | 3299 } |
| 3301 engine.Terminate(); | 3300 engine.Terminate(); |
| 3302 } | 3301 } |
| 3303 | 3302 |
| 3304 // Test that we set our preferred codecs properly. | 3303 // Test that we set our preferred codecs properly. |
| 3305 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { | 3304 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { |
| 3306 cricket::WebRtcVoiceEngine engine; | 3305 cricket::WebRtcVoiceEngine engine; |
| 3307 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3306 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
| 3308 rtc::scoped_ptr<webrtc::Call> call( | 3307 rtc::scoped_ptr<webrtc::Call> call( |
| 3309 webrtc::Call::Create(webrtc::Call::Config())); | 3308 webrtc::Call::Create(webrtc::Call::Config())); |
| 3310 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), | 3309 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), |
| 3311 call.get()); | 3310 call.get()); |
| 3312 cricket::AudioRecvParameters parameters; | 3311 cricket::AudioRecvParameters parameters; |
| 3313 parameters.codecs = engine.codecs(); | 3312 parameters.codecs = engine.codecs(); |
| 3314 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3313 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
| 3315 } | 3314 } |
| OLD | NEW |