diff options
Diffstat (limited to 'webrtc/voice_engine/test/auto_test')
14 files changed, 230 insertions, 59 deletions
diff --git a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc index 28ab352608..70f68298f5 100644 --- a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc +++ b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc @@ -40,9 +40,7 @@ ConferenceTransport::ConferenceTransport() : pq_crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()), stream_crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()), packet_event_(webrtc::EventWrapper::Create()), - thread_(webrtc::ThreadWrapper::CreateThread(Run, - this, - "ConferenceTransport")), + thread_(Run, this, "ConferenceTransport"), rtt_ms_(0), stream_count_(0), rtp_header_parser_(webrtc::RtpHeaderParser::Create()) { @@ -79,8 +77,8 @@ ConferenceTransport::ConferenceTransport() EXPECT_EQ(0, remote_network_->RegisterExternalTransport(reflector_, *this)); EXPECT_EQ(0, remote_rtp_rtcp_->SetLocalSSRC(reflector_, kReflectorSsrc)); - thread_->Start(); - thread_->SetPriority(webrtc::kHighPriority); + thread_.Start(); + thread_.SetPriority(rtc::kHighPriority); } ConferenceTransport::~ConferenceTransport() { @@ -93,7 +91,7 @@ ConferenceTransport::~ConferenceTransport() { RemoveStream(stream->first); } - EXPECT_TRUE(thread_->Stop()); + thread_.Stop(); remote_file_->Release(); remote_rtp_rtcp_->Release(); diff --git a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h index 7b45e6d3e1..5d105aa39e 100644 --- a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h +++ b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h @@ -17,12 +17,12 @@ #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/basictypes.h" +#include "webrtc/base/platform_thread.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/common_types.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" #include "webrtc/system_wrappers/include/critical_section_wrapper.h" #include "webrtc/system_wrappers/include/event_wrapper.h" -#include "webrtc/system_wrappers/include/thread_wrapper.h" #include "webrtc/voice_engine/include/voe_base.h" #include "webrtc/voice_engine/include/voe_codec.h" #include "webrtc/voice_engine/include/voe_file.h" @@ -131,7 +131,7 @@ class ConferenceTransport: public webrtc::Transport { const rtc::scoped_ptr<webrtc::CriticalSectionWrapper> pq_crit_; const rtc::scoped_ptr<webrtc::CriticalSectionWrapper> stream_crit_; const rtc::scoped_ptr<webrtc::EventWrapper> packet_event_; - const rtc::scoped_ptr<webrtc::ThreadWrapper> thread_; + rtc::PlatformThread thread_; unsigned int rtt_ms_; unsigned int stream_count_; diff --git a/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h b/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h index 1a1075c585..116ff0aec3 100644 --- a/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h +++ b/webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h @@ -13,6 +13,7 @@ #include <deque> +#include "webrtc/base/platform_thread.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/common_types.h" #include "webrtc/modules/rtp_rtcp/source/byte_io.h" @@ -20,7 +21,6 @@ #include "webrtc/system_wrappers/include/critical_section_wrapper.h" #include "webrtc/system_wrappers/include/event_wrapper.h" #include "webrtc/system_wrappers/include/sleep.h" -#include "webrtc/system_wrappers/include/thread_wrapper.h" #include "webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h" class TestErrorObserver; @@ -30,16 +30,14 @@ class LoopBackTransport : public webrtc::Transport { LoopBackTransport(webrtc::VoENetwork* voe_network, int channel) : crit_(webrtc::CriticalSectionWrapper::CreateCriticalSection()), packet_event_(webrtc::EventWrapper::Create()), - thread_(webrtc::ThreadWrapper::CreateThread(NetworkProcess, - this, - "LoopBackTransport")), + thread_(NetworkProcess, this, "LoopBackTransport"), channel_(channel), voe_network_(voe_network), transmitted_packets_(0) { - thread_->Start(); + thread_.Start(); } - ~LoopBackTransport() { thread_->Stop(); } + ~LoopBackTransport() { thread_.Stop(); } bool SendRtp(const uint8_t* data, size_t len, @@ -147,7 +145,7 @@ class LoopBackTransport : public webrtc::Transport { const rtc::scoped_ptr<webrtc::CriticalSectionWrapper> crit_; const rtc::scoped_ptr<webrtc::EventWrapper> packet_event_; - const rtc::scoped_ptr<webrtc::ThreadWrapper> thread_; + rtc::PlatformThread thread_; std::deque<Packet> packet_queue_ GUARDED_BY(crit_.get()); const int channel_; std::map<uint32_t, int> channels_ GUARDED_BY(crit_.get()); diff --git a/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h b/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h index 7a3fad8399..51db985b4a 100644 --- a/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h +++ b/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h @@ -16,7 +16,6 @@ #include "webrtc/common.h" #include "webrtc/common_types.h" #include "webrtc/engine_configurations.h" -#include "webrtc/test/testsupport/gtest_disable.h" #include "webrtc/voice_engine/include/voe_audio_processing.h" #include "webrtc/voice_engine/include/voe_base.h" #include "webrtc/voice_engine/include/voe_codec.h" diff --git a/webrtc/voice_engine/test/auto_test/standard/codec_test.cc b/webrtc/voice_engine/test/auto_test/standard/codec_test.cc index eeb12aba04..3a3d83031d 100644 --- a/webrtc/voice_engine/test/auto_test/standard/codec_test.cc +++ b/webrtc/voice_engine/test/auto_test/standard/codec_test.cc @@ -50,7 +50,7 @@ static bool IsNotViableSendCodec(const char* codec_name) { TEST_F(CodecTest, PcmuIsDefaultCodecAndHasTheRightValues) { EXPECT_EQ(0, voe_codec_->GetSendCodec(channel_, codec_instance_)); - EXPECT_EQ(1, codec_instance_.channels); + EXPECT_EQ(1u, codec_instance_.channels); EXPECT_EQ(160, codec_instance_.pacsize); EXPECT_EQ(8000, codec_instance_.plfreq); EXPECT_EQ(0, codec_instance_.pltype); @@ -153,17 +153,6 @@ TEST_F(CodecTest, OpusMaxPlaybackRateCanBeSet) { } } -TEST_F(CodecTest, OpusMaxPlaybackRateCannotBeSetForNonOpus) { - for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) { - voe_codec_->GetCodec(i, codec_instance_); - if (!_stricmp("opus", codec_instance_.plname)) { - continue; - } - voe_codec_->SetSendCodec(channel_, codec_instance_); - EXPECT_EQ(-1, voe_codec_->SetOpusMaxPlaybackRate(channel_, 16000)); - } -} - TEST_F(CodecTest, OpusDtxCanBeSetForOpus) { for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) { voe_codec_->GetCodec(i, codec_instance_); @@ -183,7 +172,6 @@ TEST_F(CodecTest, OpusDtxCannotBeSetForNonOpus) { continue; } voe_codec_->SetSendCodec(channel_, codec_instance_); - EXPECT_EQ(-1, voe_codec_->SetOpusDtx(channel_, false)); EXPECT_EQ(-1, voe_codec_->SetOpusDtx(channel_, true)); } } diff --git a/webrtc/voice_engine/test/auto_test/standard/external_media_test.cc b/webrtc/voice_engine/test/auto_test/standard/external_media_test.cc index b4daba5afd..4f86010a18 100644 --- a/webrtc/voice_engine/test/auto_test/standard/external_media_test.cc +++ b/webrtc/voice_engine/test/auto_test/standard/external_media_test.cc @@ -9,7 +9,7 @@ */ #include "webrtc/base/arraysize.h" -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/include/module_common_types.h" #include "webrtc/voice_engine/include/voe_external_media.h" #include "webrtc/voice_engine/test/auto_test/fakes/fake_media_process.h" #include "webrtc/voice_engine/test/auto_test/fixtures/after_streaming_fixture.h" diff --git a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc index 780a7f7ba9..1dc15dff49 100644 --- a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc +++ b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/modules/interface/module_common_types.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" +#include "webrtc/modules/include/module_common_types.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" #include "webrtc/system_wrappers/include/atomic32.h" #include "webrtc/system_wrappers/include/sleep.h" #include "webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h" diff --git a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_test.cc b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_test.cc index 14dca27d1c..6efa55d516 100644 --- a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_test.cc +++ b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_test.cc @@ -101,8 +101,7 @@ TEST_F(RtpRtcpTest, RemoteRtcpCnameHasPropagatedToRemoteSide) { EXPECT_STREQ(RTCP_CNAME, char_buffer); } -// Flakily hangs on Linux. code.google.com/p/webrtc/issues/detail?id=2178. -TEST_F(RtpRtcpTest, DISABLED_ON_LINUX(SSRCPropagatesCorrectly)) { +TEST_F(RtpRtcpTest, SSRCPropagatesCorrectly) { unsigned int local_ssrc = 1234; EXPECT_EQ(0, voe_base_->StopSend(channel_)); EXPECT_EQ(0, voe_rtp_rtcp_->SetLocalSSRC(channel_, local_ssrc)); diff --git a/webrtc/voice_engine/test/auto_test/voe_cpu_test.cc b/webrtc/voice_engine/test/auto_test/voe_cpu_test.cc index ad6116dcdd..5666b3f8d1 100644 --- a/webrtc/voice_engine/test/auto_test/voe_cpu_test.cc +++ b/webrtc/voice_engine/test/auto_test/voe_cpu_test.cc @@ -18,7 +18,7 @@ #endif #include "webrtc/base/scoped_ptr.h" -#include "webrtc/test/channel_transport/include/channel_transport.h" +#include "webrtc/test/channel_transport/channel_transport.h" #include "webrtc/voice_engine/test/auto_test/voe_test_defines.h" using namespace webrtc; diff --git a/webrtc/voice_engine/test/auto_test/voe_output_test.cc b/webrtc/voice_engine/test/auto_test/voe_output_test.cc new file mode 100644 index 0000000000..3bedbc3b17 --- /dev/null +++ b/webrtc/voice_engine/test/auto_test/voe_output_test.cc @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/random.h" +#include "webrtc/base/scoped_ptr.h" +#include "webrtc/base/timeutils.h" +#include "webrtc/system_wrappers/include/sleep.h" +#include "webrtc/test/channel_transport/channel_transport.h" +#include "webrtc/test/testsupport/fileutils.h" +#include "webrtc/voice_engine/test/auto_test/voe_standard_test.h" + +namespace { + +const char kIp[] = "127.0.0.1"; +const int kPort = 1234; +const webrtc::CodecInst kCodecInst = {120, "opus", 48000, 960, 2, 64000}; + +} // namespace + +namespace voetest { + +using webrtc::Random; +using webrtc::test::VoiceChannelTransport; + +// This test allows a check on the output signal in an end-to-end call. +class OutputTest { + public: + OutputTest(int16_t lower_bound, int16_t upper_bound); + ~OutputTest(); + + void Start(); + + void EnableOutputCheck(); + void DisableOutputCheck(); + void SetOutputBound(int16_t lower_bound, int16_t upper_bound); + void Mute(); + void Unmute(); + void SetBitRate(int rate); + + private: + // This class checks all output values and count the number of samples that + // go out of a defined range. + class VoEOutputCheckMediaProcess : public VoEMediaProcess { + public: + VoEOutputCheckMediaProcess(int16_t lower_bound, int16_t upper_bound); + + void set_enabled(bool enabled) { enabled_ = enabled; } + void Process(int channel, + ProcessingTypes type, + int16_t audio10ms[], + size_t length, + int samplingFreq, + bool isStereo) override; + + private: + bool enabled_; + int16_t lower_bound_; + int16_t upper_bound_; + }; + + VoETestManager manager_; + VoEOutputCheckMediaProcess output_checker_; + + int channel_; +}; + +OutputTest::OutputTest(int16_t lower_bound, int16_t upper_bound) + : output_checker_(lower_bound, upper_bound) { + EXPECT_TRUE(manager_.Init()); + manager_.GetInterfaces(); + + VoEBase* base = manager_.BasePtr(); + VoECodec* codec = manager_.CodecPtr(); + VoENetwork* network = manager_.NetworkPtr(); + + EXPECT_EQ(0, base->Init()); + + channel_ = base->CreateChannel(); + + // |network| will take care of the life time of |transport|. + VoiceChannelTransport* transport = + new VoiceChannelTransport(network, channel_); + + EXPECT_EQ(0, transport->SetSendDestination(kIp, kPort)); + EXPECT_EQ(0, transport->SetLocalReceiver(kPort)); + + EXPECT_EQ(0, codec->SetSendCodec(channel_, kCodecInst)); + EXPECT_EQ(0, codec->SetOpusDtx(channel_, true)); + + EXPECT_EQ(0, manager_.VolumeControlPtr()->SetSpeakerVolume(255)); + + manager_.ExternalMediaPtr()->RegisterExternalMediaProcessing( + channel_, ProcessingTypes::kPlaybackPerChannel, output_checker_); +} + +OutputTest::~OutputTest() { + EXPECT_EQ(0, manager_.NetworkPtr()->DeRegisterExternalTransport(channel_)); + EXPECT_EQ(0, manager_.ReleaseInterfaces()); +} + +void OutputTest::Start() { + const std::string file_name = + webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); + const webrtc::FileFormats kInputFormat = webrtc::kFileFormatPcm32kHzFile; + + ASSERT_EQ(0, manager_.FilePtr()->StartPlayingFileAsMicrophone( + channel_, file_name.c_str(), true, false, kInputFormat, 1.0)); + + VoEBase* base = manager_.BasePtr(); + ASSERT_EQ(0, base->StartPlayout(channel_)); + ASSERT_EQ(0, base->StartSend(channel_)); +} + +void OutputTest::EnableOutputCheck() { + output_checker_.set_enabled(true); +} + +void OutputTest::DisableOutputCheck() { + output_checker_.set_enabled(false); +} + +void OutputTest::Mute() { + manager_.VolumeControlPtr()->SetInputMute(channel_, true); +} + +void OutputTest::Unmute() { + manager_.VolumeControlPtr()->SetInputMute(channel_, false); +} + +void OutputTest::SetBitRate(int rate) { + manager_.CodecPtr()->SetBitRate(channel_, rate); +} + +OutputTest::VoEOutputCheckMediaProcess::VoEOutputCheckMediaProcess( + int16_t lower_bound, int16_t upper_bound) + : enabled_(false), + lower_bound_(lower_bound), + upper_bound_(upper_bound) {} + +void OutputTest::VoEOutputCheckMediaProcess::Process(int channel, + ProcessingTypes type, + int16_t* audio10ms, + size_t length, + int samplingFreq, + bool isStereo) { + if (!enabled_) + return; + const int num_channels = isStereo ? 2 : 1; + for (size_t i = 0; i < length; ++i) { + for (int c = 0; c < num_channels; ++c) { + ASSERT_GE(audio10ms[i * num_channels + c], lower_bound_); + ASSERT_LE(audio10ms[i * num_channels + c], upper_bound_); + } + } +} + +// This test checks if the Opus does not produce high noise (noise pump) when +// DTX is enabled. The microphone is toggled on and off, and values of the +// output signal during muting should be bounded. +// We do not run this test on bots. Developers that want to see the result +// and/or listen to sound quality can run this test manually. +TEST(OutputTest, DISABLED_OpusDtxHasNoNoisePump) { + const int kRuntimeMs = 20000; + const uint32_t kUnmuteTimeMs = 1000; + const int kCheckAfterMute = 2000; + const uint32_t kCheckTimeMs = 2000; + const int kMinOpusRate = 6000; + const int kMaxOpusRate = 64000; + +#if defined(OPUS_FIXED_POINT) + const int16_t kDtxBoundForSilence = 20; +#else + const int16_t kDtxBoundForSilence = 2; +#endif + + OutputTest test(-kDtxBoundForSilence, kDtxBoundForSilence); + Random random(1234ull); + + uint32_t start_time = rtc::Time(); + test.Start(); + while (rtc::TimeSince(start_time) < kRuntimeMs) { + webrtc::SleepMs(random.Rand(kUnmuteTimeMs - kUnmuteTimeMs / 10, + kUnmuteTimeMs + kUnmuteTimeMs / 10)); + test.Mute(); + webrtc::SleepMs(kCheckAfterMute); + test.EnableOutputCheck(); + webrtc::SleepMs(random.Rand(kCheckTimeMs - kCheckTimeMs / 10, + kCheckTimeMs + kCheckTimeMs / 10)); + test.DisableOutputCheck(); + test.SetBitRate(random.Rand(kMinOpusRate, kMaxOpusRate)); + test.Unmute(); + } +} + +} // namespace voetest diff --git a/webrtc/voice_engine/test/auto_test/voe_standard_test.cc b/webrtc/voice_engine/test/auto_test/voe_standard_test.cc index 22eee15bf0..a187c4bb6c 100644 --- a/webrtc/voice_engine/test/auto_test/voe_standard_test.cc +++ b/webrtc/voice_engine/test/auto_test/voe_standard_test.cc @@ -117,14 +117,6 @@ bool VoETestManager::Init() { if (initialized_) return true; - if (VoiceEngine::SetTraceFile(NULL) != -1) { - // should not be possible to call a Trace method before the VoE is - // created - TEST_LOG("\nError at line: %i (VoiceEngine::SetTraceFile()" - "should fail)!\n", __LINE__); - return false; - } - voice_engine_ = VoiceEngine::Create(); if (!voice_engine_) { TEST_LOG("Failed to create VoiceEngine\n"); @@ -230,11 +222,6 @@ int VoETestManager::ReleaseInterfaces() { releaseOK = false; } - if (VoiceEngine::SetTraceFile(NULL) != -1) { - TEST_LOG("\nError at line: %i (VoiceEngine::SetTraceFile()" - "should fail)!\n", __LINE__); - } - return (releaseOK == true) ? 0 : -1; } diff --git a/webrtc/voice_engine/test/auto_test/voe_standard_test.h b/webrtc/voice_engine/test/auto_test/voe_standard_test.h index 3bf89362d5..b92595982c 100644 --- a/webrtc/voice_engine/test/auto_test/voe_standard_test.h +++ b/webrtc/voice_engine/test/auto_test/voe_standard_test.h @@ -44,7 +44,6 @@ #ifdef WEBRTC_VOICE_ENGINE_NETEQ_STATS_API namespace webrtc { class CriticalSectionWrapper; -class ThreadWrapper; class VoENetEqStats; } #endif diff --git a/webrtc/voice_engine/test/auto_test/voe_stress_test.cc b/webrtc/voice_engine/test/auto_test/voe_stress_test.cc index 960276b699..259eff0ccc 100644 --- a/webrtc/voice_engine/test/auto_test/voe_stress_test.cc +++ b/webrtc/voice_engine/test/auto_test/voe_stress_test.cc @@ -26,7 +26,7 @@ #include "webrtc/base/scoped_ptr.h" #include "webrtc/system_wrappers/include/sleep.h" -#include "webrtc/test/channel_transport/include/channel_transport.h" +#include "webrtc/test/channel_transport/channel_transport.h" #include "webrtc/voice_engine/test/auto_test/voe_standard_test.h" #include "webrtc/voice_engine/test/auto_test/voe_test_defines.h" #include "webrtc/voice_engine/voice_engine_defines.h" // defines build macros @@ -334,9 +334,9 @@ int VoEStressTest::MultipleThreadsTest() { int rnd(0); // Start extra thread - _ptrExtraApiThread = ThreadWrapper::CreateThread(RunExtraApi, this, - "StressTestExtraApiThread"); - VALIDATE_STRESS(!_ptrExtraApiThread->Start()); + _ptrExtraApiThread.reset( + new rtc::PlatformThread(RunExtraApi, this, "StressTestExtraApiThread")); + _ptrExtraApiThread->Start(); // Some possible extensions include: // Add more API calls to randomize @@ -365,7 +365,7 @@ int VoEStressTest::MultipleThreadsTest() { ANL(); // Stop extra thread - VALIDATE_STRESS(!_ptrExtraApiThread->Stop()); + _ptrExtraApiThread->Stop(); ///////////// End test ///////////// diff --git a/webrtc/voice_engine/test/auto_test/voe_stress_test.h b/webrtc/voice_engine/test/auto_test/voe_stress_test.h index 69b3a92bb3..715e8ef724 100644 --- a/webrtc/voice_engine/test/auto_test/voe_stress_test.h +++ b/webrtc/voice_engine/test/auto_test/voe_stress_test.h @@ -11,11 +11,10 @@ #ifndef WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H #define WEBRTC_VOICE_ENGINE_VOE_STRESS_TEST_H -#include "webrtc/system_wrappers/include/thread_wrapper.h" +#include "webrtc/base/platform_thread.h" +#include "webrtc/base/scoped_ptr.h" namespace voetest { -// TODO(andrew): using directives are not permitted. -using namespace webrtc; class VoETestManager; @@ -38,7 +37,8 @@ class VoEStressTest { VoETestManager& _mgr; - rtc::scoped_ptr<ThreadWrapper> _ptrExtraApiThread; + // TODO(pbos): Remove scoped_ptr and use PlatformThread directly. + rtc::scoped_ptr<rtc::PlatformThread> _ptrExtraApiThread; }; } // namespace voetest |