diff --git a/talk/media/base/videoengine_unittest.h b/talk/media/base/videoengine_unittest.h index 8fc3729d87..5f00a0eca3 100644 --- a/talk/media/base/videoengine_unittest.h +++ b/talk/media/base/videoengine_unittest.h @@ -40,10 +40,6 @@ #include "webrtc/base/gunit.h" #include "webrtc/base/timeutils.h" -#ifdef WIN32 -#include // NOLINT -#endif - #define EXPECT_FRAME_WAIT(c, w, h, t) \ EXPECT_EQ_WAIT((c), renderer_.num_rendered_frames(), (t)); \ EXPECT_EQ((w), renderer_.width()); \ @@ -139,28 +135,6 @@ class VideoEngineTest : public testing::Test { engine_.Terminate(); } -#ifdef WIN32 - // Tests that the COM reference count is not munged by the engine. - // Test to make sure LMI does not munge the CoInitialize reference count. - void CheckCoInitialize() { - // Initial refcount should be 0. - EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED)); - - // Engine should start even with COM already inited. - EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); - engine_.Terminate(); - // Refcount after terminate should be 1; this tests if it is nonzero. - EXPECT_EQ(S_FALSE, CoInitializeEx(NULL, COINIT_MULTITHREADED)); - // Decrement refcount to (hopefully) 0. - CoUninitialize(); - CoUninitialize(); - - // Ensure refcount is 0. - EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED)); - CoUninitialize(); - } -#endif - void ConstrainNewCodecBody() { cricket::VideoCodec empty, in, out; cricket::VideoCodec max_settings(engine_.codecs()[0].id, diff --git a/talk/media/webrtc/webrtcvideoengine2_unittest.cc b/talk/media/webrtc/webrtcvideoengine2_unittest.cc index 545520f891..257c5484ea 100644 --- a/talk/media/webrtc/webrtcvideoengine2_unittest.cc +++ b/talk/media/webrtc/webrtcvideoengine2_unittest.cc @@ -753,16 +753,6 @@ class WebRtcVideoChannel2BaseTest #define WEBRTC_DISABLED_BASE_TEST(test) \ TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_##test) { Base::test(); } -// TODO(pbos): Fix WebRtcVideoEngine2BaseTest, where we want CheckCoInitialize. -#if 0 -// TODO(juberti): Figure out why ViE is munging the COM refcount. -#ifdef WIN32 -WEBRTC_DISABLED_BASE_TEST(CheckCoInitialize) { - Base::CheckCoInitialize(); -} -#endif -#endif - WEBRTC_BASE_TEST(SetSend); WEBRTC_BASE_TEST(SetSendWithoutCodecs); WEBRTC_BASE_TEST(SetSendSetsTransportBufferSizes); @@ -2785,6 +2775,151 @@ class WebRtcVideoEngine2SimulcastTest : public testing::Test { WebRtcVideoEngine2 engine_; }; +// Test that if we add a stream with RTX SSRC's, SSRC's get set correctly. +TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestStreamWithRtx) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test that if we get too few ssrcs are given in AddSendStream(), +// only supported sub-streams will be added. +TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TooFewSimulcastSsrcs) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test that even more than enough ssrcs are given in AddSendStream(), +// only supported sub-streams will be added. +TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_MoreThanEnoughSimulcastSscrs) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test that SetSendStreamFormat works well with simulcast. +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_SetSendStreamFormatWithSimulcast) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test that simulcast send codec is reset on new video frame size. +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_ResetSimulcastSendCodecOnNewFrameSize) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test that simulcast send codec is reset on new portait mode video frame. +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_ResetSimulcastSendCodecOnNewPortaitFrame) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_SetBandwidthInConferenceWithSimulcast) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test that sending screencast frames in conference mode changes +// bitrate. +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_SetBandwidthScreencastInConference) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test AddSendStream with simulcast rejects bad StreamParams. +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_AddSendStreamWithBadStreamParams) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test AddSendStream with simulcast sets ssrc and cname correctly. +TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_AddSendStreamWithSimulcast) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test RemoveSendStream with simulcast. +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_RemoveSendStreamWithSimulcast) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test AddSendStream after send codec has already been set will reset +// send codec with simulcast settings. +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_AddSimulcastStreamAfterSetSendCodec) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_GetStatsWithMultipleSsrcs) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test receiving channel(s) local ssrc is set to the same as the first +// simulcast sending ssrc. +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_AddSimulcastStreamAfterCreatingRecvChannels) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test 1:1 call never turn on simulcast. +TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_NoSimulcastWith1on1) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test SetOptions with OPT_CONFERENCE flag. +TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_SetOptionsWithConferenceMode) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test that two different streams can have different formats. +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_MultipleSendStreamsDifferentFormats) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestAdaptToOutputFormat) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_TestAdaptWithCpuOveruseObserver) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +// Test that codec is not reset for every frame sent in non-conference and +// non-screencast mode. +TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_DontResetCodecOnSendFrame) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_UseSimulcastAdapterOnVp8OnlyFactory) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + +TEST_F(WebRtcVideoEngine2SimulcastTest, + DISABLED_DontUseSimulcastAdapterOnNonVp8Factory) { + // TODO(pbos): Implement. + FAIL() << "Not implemented."; +} + class WebRtcVideoChannel2SimulcastTest : public WebRtcVideoEngine2SimulcastTest, public WebRtcCallFactory { public: @@ -2968,151 +3103,6 @@ TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { VerifySimulcastSettings(codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL); } -// Test that if we add a stream with RTX SSRC's, SSRC's get set correctly. -TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestStreamWithRtx) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test that if we get too few ssrcs are given in AddSendStream(), -// only supported sub-streams will be added. -TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TooFewSimulcastSsrcs) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test that even more than enough ssrcs are given in AddSendStream(), -// only supported sub-streams will be added. -TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_MoreThanEnoughSimulcastSscrs) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test that SetSendStreamFormat works well with simulcast. -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_SetSendStreamFormatWithSimulcast) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test that simulcast send codec is reset on new video frame size. -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_ResetSimulcastSendCodecOnNewFrameSize) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test that simulcast send codec is reset on new portait mode video frame. -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_ResetSimulcastSendCodecOnNewPortaitFrame) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_SetBandwidthInConferenceWithSimulcast) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test that sending screencast frames in conference mode changes -// bitrate. -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_SetBandwidthScreencastInConference) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test AddSendStream with simulcast rejects bad StreamParams. -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_AddSendStreamWithBadStreamParams) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test AddSendStream with simulcast sets ssrc and cname correctly. -TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_AddSendStreamWithSimulcast) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test RemoveSendStream with simulcast. -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_RemoveSendStreamWithSimulcast) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test AddSendStream after send codec has already been set will reset -// send codec with simulcast settings. -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_AddSimulcastStreamAfterSetSendCodec) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_GetStatsWithMultipleSsrcs) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test receiving channel(s) local ssrc is set to the same as the first -// simulcast sending ssrc. -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_AddSimulcastStreamAfterCreatingRecvChannels) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test 1:1 call never turn on simulcast. -TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_NoSimulcastWith1on1) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test SetOptions with OPT_CONFERENCE flag. -TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_SetOptionsWithConferenceMode) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test that two different streams can have different formats. -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_MultipleSendStreamsDifferentFormats) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_TestAdaptToOutputFormat) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_TestAdaptWithCpuOveruseObserver) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -// Test that codec is not reset for every frame sent in non-conference and -// non-screencast mode. -TEST_F(WebRtcVideoEngine2SimulcastTest, DISABLED_DontResetCodecOnSendFrame) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_UseSimulcastAdapterOnVp8OnlyFactory) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - -TEST_F(WebRtcVideoEngine2SimulcastTest, - DISABLED_DontUseSimulcastAdapterOnNonVp8Factory) { - // TODO(pbos): Implement. - FAIL() << "Not implemented."; -} - TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_1280x800) { // TODO(pbos): Implement. FAIL() << "Not implemented."; diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc index 391052b8d4..f8c3ac3164 100644 --- a/talk/media/webrtc/webrtcvoiceengine.cc +++ b/talk/media/webrtc/webrtcvoiceengine.cc @@ -54,10 +54,6 @@ #include "webrtc/common.h" #include "webrtc/modules/audio_processing/include/audio_processing.h" -#ifdef WIN32 -#include // NOLINT -#endif - namespace cricket { static const int kMaxNumPacketSize = 6; diff --git a/talk/media/webrtc/webrtcvoiceengine_unittest.cc b/talk/media/webrtc/webrtcvoiceengine_unittest.cc index ef87c74e58..1daf58d377 100644 --- a/talk/media/webrtc/webrtcvoiceengine_unittest.cc +++ b/talk/media/webrtc/webrtcvoiceengine_unittest.cc @@ -25,11 +25,6 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifdef WIN32 -#include "webrtc/base/win32.h" -#include -#endif - #include "webrtc/base/byteorder.h" #include "webrtc/base/gunit.h" #include "talk/media/base/constants.h" @@ -3135,16 +3130,6 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); } -TEST(WebRtcVoiceEngineTest, TestDefaultOptionsBeforeInit) { - cricket::WebRtcVoiceEngine engine; - cricket::AudioOptions options = engine.GetOptions(); - // The default options should have at least a few things set. We purposefully - // don't check the option values here, though. - EXPECT_TRUE(options.echo_cancellation.IsSet()); - EXPECT_TRUE(options.auto_gain_control.IsSet()); - EXPECT_TRUE(options.noise_suppression.IsSet()); -} - // Test that GetReceiveChannelNum returns the default channel for the first // recv stream in 1-1 calls. TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelNumIn1To1Calls) { @@ -3194,165 +3179,6 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOutputScaling) { EXPECT_DOUBLE_EQ(1, right); } -// Tests for the actual WebRtc VoE library. - -// Tests that the library initializes and shuts down properly. -TEST(WebRtcVoiceEngineTest, StartupShutdown) { - cricket::WebRtcVoiceEngine engine; - EXPECT_TRUE(engine.Init(rtc::Thread::Current())); - cricket::VoiceMediaChannel* channel = - engine.CreateChannel(cricket::AudioOptions()); - EXPECT_TRUE(channel != nullptr); - delete channel; - engine.Terminate(); - - // Reinit to catch regression where VoiceEngineObserver reference is lost - EXPECT_TRUE(engine.Init(rtc::Thread::Current())); - engine.Terminate(); -} - -// Tests that the library is configured with the codecs we want. -TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { - cricket::WebRtcVoiceEngine engine; - // Check codecs by name. - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "OPUS", 48000, 0, 2, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "ISAC", 16000, 0, 1, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "ISAC", 32000, 0, 1, 0))); - // Check that name matching is case-insensitive. - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "ILBC", 8000, 0, 1, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "iLBC", 8000, 0, 1, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "PCMU", 8000, 0, 1, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "PCMA", 8000, 0, 1, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "G722", 8000, 0, 1, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "red", 8000, 0, 1, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "CN", 32000, 0, 1, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "CN", 16000, 0, 1, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "CN", 8000, 0, 1, 0))); - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(96, "telephone-event", 8000, 0, 1, 0))); - // Check codecs with an id by id. - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(0, "", 8000, 0, 1, 0))); // PCMU - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(8, "", 8000, 0, 1, 0))); // PCMA - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(9, "", 8000, 0, 1, 0))); // G722 - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(13, "", 8000, 0, 1, 0))); // CN - // Check sample/bitrate matching. - EXPECT_TRUE(engine.FindCodec( - cricket::AudioCodec(0, "PCMU", 8000, 64000, 1, 0))); - // Check that bad codecs fail. - EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(99, "ABCD", 0, 0, 1, 0))); - EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(88, "", 0, 0, 1, 0))); - EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(0, "", 0, 0, 2, 0))); - EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(0, "", 5000, 0, 1, 0))); - EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(0, "", 0, 5000, 1, 0))); - // Verify the payload id of common audio codecs, including CN, ISAC, and G722. - for (std::vector::const_iterator it = - engine.codecs().begin(); it != engine.codecs().end(); ++it) { - if (it->name == "CN" && it->clockrate == 16000) { - EXPECT_EQ(105, it->id); - } else if (it->name == "CN" && it->clockrate == 32000) { - EXPECT_EQ(106, it->id); - } else if (it->name == "ISAC" && it->clockrate == 16000) { - EXPECT_EQ(103, it->id); - } else if (it->name == "ISAC" && it->clockrate == 32000) { - EXPECT_EQ(104, it->id); - } else if (it->name == "G722" && it->clockrate == 8000) { - EXPECT_EQ(9, it->id); - } else if (it->name == "telephone-event") { - EXPECT_EQ(126, it->id); - } else if (it->name == "red") { - EXPECT_EQ(127, it->id); - } else if (it->name == "opus") { - EXPECT_EQ(111, it->id); - ASSERT_TRUE(it->params.find("minptime") != it->params.end()); - EXPECT_EQ("10", it->params.find("minptime")->second); - ASSERT_TRUE(it->params.find("maxptime") != it->params.end()); - EXPECT_EQ("60", it->params.find("maxptime")->second); - ASSERT_TRUE(it->params.find("useinbandfec") != it->params.end()); - EXPECT_EQ("1", it->params.find("useinbandfec")->second); - } - } - - engine.Terminate(); -} - -// Tests that VoE supports at least 32 channels -TEST(WebRtcVoiceEngineTest, Has32Channels) { - cricket::WebRtcVoiceEngine engine; - EXPECT_TRUE(engine.Init(rtc::Thread::Current())); - - cricket::VoiceMediaChannel* channels[32]; - int num_channels = 0; - - while (num_channels < ARRAY_SIZE(channels)) { - cricket::VoiceMediaChannel* channel = - engine.CreateChannel(cricket::AudioOptions()); - if (!channel) - break; - - channels[num_channels++] = channel; - } - - int expected = ARRAY_SIZE(channels); - EXPECT_EQ(expected, num_channels); - - while (num_channels > 0) { - delete channels[--num_channels]; - } - - engine.Terminate(); -} - -// Test that we set our preferred codecs properly. -TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { - cricket::WebRtcVoiceEngine engine; - EXPECT_TRUE(engine.Init(rtc::Thread::Current())); - cricket::WebRtcVoiceMediaChannel channel(&engine); - EXPECT_TRUE(channel.SetRecvCodecs(engine.codecs())); -} - -#ifdef WIN32 -// Test our workarounds to WebRtc VoE' munging of the coinit count -TEST(WebRtcVoiceEngineTest, CoInitialize) { - cricket::WebRtcVoiceEngine* engine = new cricket::WebRtcVoiceEngine(); - - // Initial refcount should be 0. - EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED)); - - // Engine should start even with COM already inited. - EXPECT_TRUE(engine->Init(rtc::Thread::Current())); - engine->Terminate(); - EXPECT_TRUE(engine->Init(rtc::Thread::Current())); - engine->Terminate(); - - // Refcount after terminate should be 1 (in reality 3); test if it is nonzero. - EXPECT_EQ(S_FALSE, CoInitializeEx(NULL, COINIT_MULTITHREADED)); - // Decrement refcount to (hopefully) 0. - CoUninitialize(); - CoUninitialize(); - delete engine; - - // Ensure refcount is 0. - EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED)); - CoUninitialize(); -} -#endif - TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { cricket::FakeCall call((webrtc::Call::Config())); const uint32 kAudioSsrc = 123; @@ -3663,3 +3489,145 @@ TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { EXPECT_TRUE(channel_->RemoveSendStream(2)); EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); } + +// Tests for the actual WebRtc VoE library. + +TEST(WebRtcVoiceEngineTest, TestDefaultOptionsBeforeInit) { + cricket::WebRtcVoiceEngine engine; + cricket::AudioOptions options = engine.GetOptions(); + // The default options should have at least a few things set. We purposefully + // don't check the option values here, though. + EXPECT_TRUE(options.echo_cancellation.IsSet()); + EXPECT_TRUE(options.auto_gain_control.IsSet()); + EXPECT_TRUE(options.noise_suppression.IsSet()); +} + +// Tests that the library initializes and shuts down properly. +TEST(WebRtcVoiceEngineTest, StartupShutdown) { + cricket::WebRtcVoiceEngine engine; + EXPECT_TRUE(engine.Init(rtc::Thread::Current())); + cricket::VoiceMediaChannel* channel = + engine.CreateChannel(cricket::AudioOptions()); + EXPECT_TRUE(channel != nullptr); + delete channel; + engine.Terminate(); + + // Reinit to catch regression where VoiceEngineObserver reference is lost + EXPECT_TRUE(engine.Init(rtc::Thread::Current())); + engine.Terminate(); +} + +// Tests that the library is configured with the codecs we want. +TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { + cricket::WebRtcVoiceEngine engine; + // Check codecs by name. + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "OPUS", 48000, 0, 2, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "ISAC", 16000, 0, 1, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "ISAC", 32000, 0, 1, 0))); + // Check that name matching is case-insensitive. + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "ILBC", 8000, 0, 1, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "iLBC", 8000, 0, 1, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "PCMU", 8000, 0, 1, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "PCMA", 8000, 0, 1, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "G722", 8000, 0, 1, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "red", 8000, 0, 1, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "CN", 32000, 0, 1, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "CN", 16000, 0, 1, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "CN", 8000, 0, 1, 0))); + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(96, "telephone-event", 8000, 0, 1, 0))); + // Check codecs with an id by id. + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(0, "", 8000, 0, 1, 0))); // PCMU + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(8, "", 8000, 0, 1, 0))); // PCMA + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(9, "", 8000, 0, 1, 0))); // G722 + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(13, "", 8000, 0, 1, 0))); // CN + // Check sample/bitrate matching. + EXPECT_TRUE(engine.FindCodec( + cricket::AudioCodec(0, "PCMU", 8000, 64000, 1, 0))); + // Check that bad codecs fail. + EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(99, "ABCD", 0, 0, 1, 0))); + EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(88, "", 0, 0, 1, 0))); + EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(0, "", 0, 0, 2, 0))); + EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(0, "", 5000, 0, 1, 0))); + EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(0, "", 0, 5000, 1, 0))); + // Verify the payload id of common audio codecs, including CN, ISAC, and G722. + for (std::vector::const_iterator it = + engine.codecs().begin(); it != engine.codecs().end(); ++it) { + if (it->name == "CN" && it->clockrate == 16000) { + EXPECT_EQ(105, it->id); + } else if (it->name == "CN" && it->clockrate == 32000) { + EXPECT_EQ(106, it->id); + } else if (it->name == "ISAC" && it->clockrate == 16000) { + EXPECT_EQ(103, it->id); + } else if (it->name == "ISAC" && it->clockrate == 32000) { + EXPECT_EQ(104, it->id); + } else if (it->name == "G722" && it->clockrate == 8000) { + EXPECT_EQ(9, it->id); + } else if (it->name == "telephone-event") { + EXPECT_EQ(126, it->id); + } else if (it->name == "red") { + EXPECT_EQ(127, it->id); + } else if (it->name == "opus") { + EXPECT_EQ(111, it->id); + ASSERT_TRUE(it->params.find("minptime") != it->params.end()); + EXPECT_EQ("10", it->params.find("minptime")->second); + ASSERT_TRUE(it->params.find("maxptime") != it->params.end()); + EXPECT_EQ("60", it->params.find("maxptime")->second); + ASSERT_TRUE(it->params.find("useinbandfec") != it->params.end()); + EXPECT_EQ("1", it->params.find("useinbandfec")->second); + } + } + + engine.Terminate(); +} + +// Tests that VoE supports at least 32 channels +TEST(WebRtcVoiceEngineTest, Has32Channels) { + cricket::WebRtcVoiceEngine engine; + EXPECT_TRUE(engine.Init(rtc::Thread::Current())); + + cricket::VoiceMediaChannel* channels[32]; + int num_channels = 0; + + while (num_channels < ARRAY_SIZE(channels)) { + cricket::VoiceMediaChannel* channel = + engine.CreateChannel(cricket::AudioOptions()); + if (!channel) + break; + + channels[num_channels++] = channel; + } + + int expected = ARRAY_SIZE(channels); + EXPECT_EQ(expected, num_channels); + + while (num_channels > 0) { + delete channels[--num_channels]; + } + + engine.Terminate(); +} + +// Test that we set our preferred codecs properly. +TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { + cricket::WebRtcVoiceEngine engine; + EXPECT_TRUE(engine.Init(rtc::Thread::Current())); + cricket::WebRtcVoiceMediaChannel channel(&engine); + EXPECT_TRUE(channel.SetRecvCodecs(engine.codecs())); +}