aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/audio_coding/main/test/TestVADDTX.cc
diff options
context:
space:
mode:
authorChih-hung Hsieh <chh@google.com>2016-01-20 17:50:13 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-01-20 17:50:13 +0000
commitb3cb8ab4ede8bb77f0bdef2715efc2c1e6267072 (patch)
tree28c4cf735dd5bd9cc8f1ccd06fff8a173b20d1cb /webrtc/modules/audio_coding/main/test/TestVADDTX.cc
parenta4acd9d6bc9b3b033d7d274316e75ee067df8d20 (diff)
parent9a337512d97e37afc142dee4fd50a41b741a87d2 (diff)
downloadwebrtc-nougat-mr2.2-release.tar.gz
Merge "Merge upstream SHA 04cb763"android-cts_7.1_r1android-cts-7.1_r9android-cts-7.1_r8android-cts-7.1_r7android-cts-7.1_r6android-cts-7.1_r5android-cts-7.1_r4android-cts-7.1_r3android-cts-7.1_r29android-cts-7.1_r28android-cts-7.1_r27android-cts-7.1_r26android-cts-7.1_r25android-cts-7.1_r24android-cts-7.1_r23android-cts-7.1_r22android-cts-7.1_r21android-cts-7.1_r20android-cts-7.1_r2android-cts-7.1_r19android-cts-7.1_r18android-cts-7.1_r17android-cts-7.1_r16android-cts-7.1_r15android-cts-7.1_r14android-cts-7.1_r13android-cts-7.1_r12android-cts-7.1_r11android-cts-7.1_r10android-cts-7.1_r1android-cts-7.0_r9android-cts-7.0_r8android-cts-7.0_r7android-cts-7.0_r6android-cts-7.0_r5android-cts-7.0_r4android-cts-7.0_r33android-cts-7.0_r32android-cts-7.0_r31android-cts-7.0_r30android-cts-7.0_r3android-cts-7.0_r29android-cts-7.0_r28android-cts-7.0_r27android-cts-7.0_r26android-cts-7.0_r25android-cts-7.0_r24android-cts-7.0_r23android-cts-7.0_r22android-cts-7.0_r21android-cts-7.0_r20android-cts-7.0_r2android-cts-7.0_r19android-cts-7.0_r18android-cts-7.0_r17android-cts-7.0_r16android-cts-7.0_r15android-cts-7.0_r14android-cts-7.0_r13android-cts-7.0_r12android-cts-7.0_r11android-cts-7.0_r10android-cts-7.0_r1android-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r39android-7.1.2_r38android-7.1.2_r37android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1android-7.1.1_r9android-7.1.1_r8android-7.1.1_r7android-7.1.1_r61android-7.1.1_r60android-7.1.1_r6android-7.1.1_r59android-7.1.1_r58android-7.1.1_r57android-7.1.1_r56android-7.1.1_r55android-7.1.1_r54android-7.1.1_r53android-7.1.1_r52android-7.1.1_r51android-7.1.1_r50android-7.1.1_r49android-7.1.1_r48android-7.1.1_r47android-7.1.1_r46android-7.1.1_r45android-7.1.1_r44android-7.1.1_r43android-7.1.1_r42android-7.1.1_r41android-7.1.1_r40android-7.1.1_r4android-7.1.1_r39android-7.1.1_r38android-7.1.1_r35android-7.1.1_r33android-7.1.1_r32android-7.1.1_r31android-7.1.1_r3android-7.1.1_r28android-7.1.1_r27android-7.1.1_r26android-7.1.1_r25android-7.1.1_r24android-7.1.1_r23android-7.1.1_r22android-7.1.1_r21android-7.1.1_r20android-7.1.1_r2android-7.1.1_r17android-7.1.1_r16android-7.1.1_r15android-7.1.1_r14android-7.1.1_r13android-7.1.1_r12android-7.1.1_r11android-7.1.1_r10android-7.1.1_r1android-7.1.0_r7android-7.1.0_r6android-7.1.0_r5android-7.1.0_r4android-7.1.0_r3android-7.1.0_r2android-7.1.0_r1android-7.0.0_r9android-7.0.0_r8android-7.0.0_r7android-7.0.0_r6android-7.0.0_r5android-7.0.0_r4android-7.0.0_r36android-7.0.0_r35android-7.0.0_r34android-7.0.0_r33android-7.0.0_r32android-7.0.0_r31android-7.0.0_r30android-7.0.0_r3android-7.0.0_r29android-7.0.0_r28android-7.0.0_r27android-7.0.0_r24android-7.0.0_r21android-7.0.0_r19android-7.0.0_r17android-7.0.0_r15android-7.0.0_r14android-7.0.0_r13android-7.0.0_r12android-7.0.0_r11android-7.0.0_r10android-7.0.0_r1nougat-releasenougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-security-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-devnougat-mr1.8-releasenougat-mr1.7-releasenougat-mr1.6-releasenougat-mr1.5-releasenougat-mr1.4-releasenougat-mr1.3-releasenougat-mr1.2-releasenougat-mr1.1-releasenougat-mr1-volantis-releasenougat-mr1-security-releasenougat-mr1-releasenougat-mr1-flounder-releasenougat-mr1-devnougat-mr1-cts-releasenougat-mr0.5-releasenougat-dr1-releasenougat-devnougat-cts-releasenougat-bugfix-release
am: 9a337512d9 * commit '9a337512d97e37afc142dee4fd50a41b741a87d2': (797 commits) Add tests for verifying transport feedback for audio and video. Eliminate defines in talk/ Revert of Update with new default boringssl no-aes cipher suites. Re-enable tests. (patchset #3 id:40001 of https://codereview.webrtc.org/1550773002/ ) Remove assert which was incorrectly added to TcpPort::OnSentPacket. Reland Connect TurnPort and TCPPort to AsyncPacketSocket::SignalSentPacket. Update with new default boringssl no-aes cipher suites. Re-enable tests. Revert of Connect TurnPort and TCPPort to AsyncPacketSocket::SignalSentPacket. (patchset #3 id:40001 of https://codereview.webrtc.org/1577873003/ ) Re-land: "Use an explicit identifier in Config" Connect TurnPort and TCPPort to AsyncPacketSocket::SignalSentPacket. Revert of Delete remnants of non-square pixel support from cricket::VideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/1586613002/ ) Remove libfuzzer trybot from default trybot set. Add ramp-up tests for transport sequence number with and w/o audio. Delete remnants of non-square pixel support from cricket::VideoFrame. Fix IPAddress::ToSensitiveString() to avoid dependency on inet_ntop(). Revert of Storing raw audio sink for default audio track. (patchset #7 id:120001 of https://codereview.chromium.org/1551813002/ ) Re-enable tests that failed under Linux_Msan. Revert of Use an explicit identifier in Config (patchset #4 id:60001 of https://codereview.webrtc.org/1538643004/ ) Roll chromium_revision 346fea9..099be58 (369082:369139) Disable WebRtcVideoChannel2BaseTest.SendManyResizeOnce for TSan Add build_protobuf variable. ...
Diffstat (limited to 'webrtc/modules/audio_coding/main/test/TestVADDTX.cc')
-rw-r--r--webrtc/modules/audio_coding/main/test/TestVADDTX.cc271
1 files changed, 0 insertions, 271 deletions
diff --git a/webrtc/modules/audio_coding/main/test/TestVADDTX.cc b/webrtc/modules/audio_coding/main/test/TestVADDTX.cc
deleted file mode 100644
index bd0335a5f3..0000000000
--- a/webrtc/modules/audio_coding/main/test/TestVADDTX.cc
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (c) 2012 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 "webrtc/modules/audio_coding/main/test/TestVADDTX.h"
-
-#include <string>
-
-#include "webrtc/engine_configurations.h"
-#include "webrtc/modules/audio_coding/main/test/PCMFile.h"
-#include "webrtc/modules/audio_coding/main/test/utility.h"
-#include "webrtc/test/testsupport/fileutils.h"
-
-namespace webrtc {
-
-#ifdef WEBRTC_CODEC_ISAC
-const CodecInst kIsacWb = {103, "ISAC", 16000, 480, 1, 32000};
-const CodecInst kIsacSwb = {104, "ISAC", 32000, 960, 1, 56000};
-#endif
-
-#ifdef WEBRTC_CODEC_ILBC
-const CodecInst kIlbc = {102, "ILBC", 8000, 240, 1, 13300};
-#endif
-
-#ifdef WEBRTC_CODEC_OPUS
-const CodecInst kOpus = {120, "opus", 48000, 960, 1, 64000};
-const CodecInst kOpusStereo = {120, "opus", 48000, 960, 2, 64000};
-#endif
-
-ActivityMonitor::ActivityMonitor() {
- ResetStatistics();
-}
-
-int32_t ActivityMonitor::InFrameType(FrameType frame_type) {
- counter_[frame_type]++;
- return 0;
-}
-
-void ActivityMonitor::PrintStatistics() {
- printf("\n");
- printf("kEmptyFrame %u\n", counter_[kEmptyFrame]);
- printf("kAudioFrameSpeech %u\n", counter_[kAudioFrameSpeech]);
- printf("kAudioFrameCN %u\n", counter_[kAudioFrameCN]);
- printf("kVideoFrameKey %u\n", counter_[kVideoFrameKey]);
- printf("kVideoFrameDelta %u\n", counter_[kVideoFrameDelta]);
- printf("\n\n");
-}
-
-void ActivityMonitor::ResetStatistics() {
- memset(counter_, 0, sizeof(counter_));
-}
-
-void ActivityMonitor::GetStatistics(uint32_t* counter) {
- memcpy(counter, counter_, sizeof(counter_));
-}
-
-TestVadDtx::TestVadDtx()
- : acm_send_(AudioCodingModule::Create(0)),
- acm_receive_(AudioCodingModule::Create(1)),
- channel_(new Channel),
- monitor_(new ActivityMonitor) {
- EXPECT_EQ(0, acm_send_->RegisterTransportCallback(channel_.get()));
- channel_->RegisterReceiverACM(acm_receive_.get());
- EXPECT_EQ(0, acm_send_->RegisterVADCallback(monitor_.get()));
-}
-
-void TestVadDtx::RegisterCodec(CodecInst codec_param) {
- // Set the codec for sending and receiving.
- EXPECT_EQ(0, acm_send_->RegisterSendCodec(codec_param));
- EXPECT_EQ(0, acm_receive_->RegisterReceiveCodec(codec_param));
- channel_->SetIsStereo(codec_param.channels > 1);
-}
-
-// Encoding a file and see if the numbers that various packets occur follow
-// the expectation.
-void TestVadDtx::Run(std::string in_filename, int frequency, int channels,
- std::string out_filename, bool append,
- const int* expects) {
- monitor_->ResetStatistics();
-
- PCMFile in_file;
- in_file.Open(in_filename, frequency, "rb");
- in_file.ReadStereo(channels > 1);
-
- PCMFile out_file;
- if (append) {
- out_file.Open(out_filename, kOutputFreqHz, "ab");
- } else {
- out_file.Open(out_filename, kOutputFreqHz, "wb");
- }
-
- uint16_t frame_size_samples = in_file.PayloadLength10Ms();
- uint32_t time_stamp = 0x12345678;
- AudioFrame audio_frame;
- while (!in_file.EndOfFile()) {
- in_file.Read10MsData(audio_frame);
- audio_frame.timestamp_ = time_stamp;
- time_stamp += frame_size_samples;
- EXPECT_GE(acm_send_->Add10MsData(audio_frame), 0);
- acm_receive_->PlayoutData10Ms(kOutputFreqHz, &audio_frame);
- out_file.Write10MsData(audio_frame);
- }
-
- in_file.Close();
- out_file.Close();
-
-#ifdef PRINT_STAT
- monitor_->PrintStatistics();
-#endif
-
- uint32_t stats[5];
- monitor_->GetStatistics(stats);
- monitor_->ResetStatistics();
-
- for (const auto& st : stats) {
- int i = &st - stats; // Calculate the current position in stats.
- switch (expects[i]) {
- case 0: {
- EXPECT_EQ(0u, st) << "stats[" << i << "] error.";
- break;
- }
- case 1: {
- EXPECT_GT(st, 0u) << "stats[" << i << "] error.";
- break;
- }
- }
- }
-}
-
-// Following is the implementation of TestWebRtcVadDtx.
-TestWebRtcVadDtx::TestWebRtcVadDtx()
- : vad_enabled_(false),
- dtx_enabled_(false),
- output_file_num_(0) {
-}
-
-void TestWebRtcVadDtx::Perform() {
- // Go through various test cases.
-#ifdef WEBRTC_CODEC_ISAC
- // Register iSAC WB as send codec
- RegisterCodec(kIsacWb);
- RunTestCases();
-
- // Register iSAC SWB as send codec
- RegisterCodec(kIsacSwb);
- RunTestCases();
-#endif
-
-#ifdef WEBRTC_CODEC_ILBC
- // Register iLBC as send codec
- RegisterCodec(kIlbc);
- RunTestCases();
-#endif
-
-#ifdef WEBRTC_CODEC_OPUS
- // Register Opus as send codec
- RegisterCodec(kOpus);
- RunTestCases();
-#endif
-}
-
-// Test various configurations on VAD/DTX.
-void TestWebRtcVadDtx::RunTestCases() {
- // #1 DTX = OFF, VAD = OFF, VADNormal
- SetVAD(false, false, VADNormal);
- Test(true);
-
- // #2 DTX = ON, VAD = ON, VADAggr
- SetVAD(true, true, VADAggr);
- Test(false);
-
- // #3 DTX = ON, VAD = ON, VADLowBitrate
- SetVAD(true, true, VADLowBitrate);
- Test(false);
-
- // #4 DTX = ON, VAD = ON, VADVeryAggr
- SetVAD(true, true, VADVeryAggr);
- Test(false);
-
- // #5 DTX = ON, VAD = ON, VADNormal
- SetVAD(true, true, VADNormal);
- Test(false);
-}
-
-// Set the expectation and run the test.
-void TestWebRtcVadDtx::Test(bool new_outfile) {
- int expects[] = {-1, 1, dtx_enabled_, 0, 0};
- if (new_outfile) {
- output_file_num_++;
- }
- std::stringstream out_filename;
- out_filename << webrtc::test::OutputPath()
- << "testWebRtcVadDtx_outFile_"
- << output_file_num_
- << ".pcm";
- Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
- 32000, 1, out_filename.str(), !new_outfile, expects);
-}
-
-void TestWebRtcVadDtx::SetVAD(bool enable_dtx, bool enable_vad,
- ACMVADMode vad_mode) {
- ACMVADMode mode;
- EXPECT_EQ(0, acm_send_->SetVAD(enable_dtx, enable_vad, vad_mode));
- EXPECT_EQ(0, acm_send_->VAD(&dtx_enabled_, &vad_enabled_, &mode));
-
- CodecInst codec_param;
- acm_send_->SendCodec(&codec_param);
- if (STR_CASE_CMP(codec_param.plname, "opus") == 0) {
- // If send codec is Opus, WebRTC VAD/DTX cannot be used.
- enable_dtx = enable_vad = false;
- }
-
- EXPECT_EQ(dtx_enabled_ , enable_dtx); // DTX should be set as expected.
-
- if (dtx_enabled_) {
- EXPECT_TRUE(vad_enabled_); // WebRTC DTX cannot run without WebRTC VAD.
- } else {
- // Using no DTX should not affect setting of VAD.
- EXPECT_EQ(enable_vad, vad_enabled_);
- }
-}
-
-// Following is the implementation of TestOpusDtx.
-void TestOpusDtx::Perform() {
-#ifdef WEBRTC_CODEC_ISAC
- // If we set other codec than Opus, DTX cannot be toggled.
- RegisterCodec(kIsacWb);
- EXPECT_EQ(-1, acm_send_->EnableOpusDtx());
- EXPECT_EQ(-1, acm_send_->DisableOpusDtx());
-#endif
-
-#ifdef WEBRTC_CODEC_OPUS
- int expects[] = {0, 1, 0, 0, 0};
-
- // Register Opus as send codec
- std::string out_filename = webrtc::test::OutputPath() +
- "testOpusDtx_outFile_mono.pcm";
- RegisterCodec(kOpus);
- EXPECT_EQ(0, acm_send_->DisableOpusDtx());
-
- Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
- 32000, 1, out_filename, false, expects);
-
- EXPECT_EQ(0, acm_send_->EnableOpusDtx());
- expects[kEmptyFrame] = 1;
- Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
- 32000, 1, out_filename, true, expects);
-
- // Register stereo Opus as send codec
- out_filename = webrtc::test::OutputPath() + "testOpusDtx_outFile_stereo.pcm";
- RegisterCodec(kOpusStereo);
- EXPECT_EQ(0, acm_send_->DisableOpusDtx());
- expects[kEmptyFrame] = 0;
- Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"),
- 32000, 2, out_filename, false, expects);
-
- EXPECT_EQ(0, acm_send_->EnableOpusDtx());
-
- expects[kEmptyFrame] = 1;
- Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"),
- 32000, 2, out_filename, true, expects);
-#endif
-}
-
-} // namespace webrtc