Rewrote DTMF test.
BUG= TEST= Review URL: https://webrtc-codereview.appspot.com/368001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1502 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
31627fe82c
commit
3b57ee0238
101
src/voice_engine/main/test/auto_test/standard/dtmf_test.cc
Normal file
101
src/voice_engine/main/test/auto_test/standard/dtmf_test.cc
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2011 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 "after_streaming_fixture.h"
|
||||
#include "voice_engine_defines.h"
|
||||
|
||||
class DtmfTest : public AfterStreamingFixture {
|
||||
protected:
|
||||
void RunSixteenDtmfEvents(bool out_of_band) {
|
||||
TEST_LOG("Sending telephone events:\n");
|
||||
EXPECT_EQ(0, voe_dtmf_->SetDtmfFeedbackStatus(false));
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
TEST_LOG("%d ", i);
|
||||
TEST_LOG_FLUSH;
|
||||
EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(
|
||||
channel_, i, out_of_band, 160, 10));
|
||||
Sleep(500);
|
||||
}
|
||||
TEST_LOG("\n");
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(DtmfTest, DtmfFeedbackIsEnabledByDefaultButNotDirectFeedback) {
|
||||
bool dtmf_feedback = false;
|
||||
bool dtmf_direct_feedback = false;
|
||||
|
||||
EXPECT_EQ(0, voe_dtmf_->GetDtmfFeedbackStatus(dtmf_feedback,
|
||||
dtmf_direct_feedback));
|
||||
|
||||
EXPECT_TRUE(dtmf_feedback);
|
||||
EXPECT_FALSE(dtmf_direct_feedback);
|
||||
}
|
||||
|
||||
TEST_F(DtmfTest, ManualSuccessfullySendsInBandTelephoneEvents) {
|
||||
RunSixteenDtmfEvents(false);
|
||||
}
|
||||
|
||||
TEST_F(DtmfTest, ManualSuccessfullySendsOutOfBandTelephoneEvents) {
|
||||
RunSixteenDtmfEvents(true);
|
||||
}
|
||||
|
||||
TEST_F(DtmfTest, TestTwoNonDtmfEvents) {
|
||||
EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 32, true));
|
||||
EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 110, true));
|
||||
}
|
||||
|
||||
#ifndef MAC_IPHONE
|
||||
TEST_F(DtmfTest, ManualCanDisableDtmfPlayoutExceptOnIphone) {
|
||||
TEST_LOG("Disabling DTMF playout (no tone should be heard) \n");
|
||||
EXPECT_EQ(0, voe_dtmf_->SetDtmfPlayoutStatus(channel_, false));
|
||||
EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 0, true));
|
||||
Sleep(500);
|
||||
|
||||
TEST_LOG("Enabling DTMF playout (tone should be heard) \n");
|
||||
EXPECT_EQ(0, voe_dtmf_->SetDtmfPlayoutStatus(channel_, true));
|
||||
EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 0, true));
|
||||
Sleep(500);
|
||||
}
|
||||
#endif
|
||||
|
||||
// This test modifies the DTMF payload type from the default 106 to 88
|
||||
// and then runs through 16 DTMF out.of-band events.
|
||||
TEST_F(DtmfTest, ManualCanChangeDtmfPayloadType) {
|
||||
webrtc::CodecInst codec_instance;
|
||||
|
||||
TEST_LOG("Changing DTMF payload type.\n");
|
||||
|
||||
// Start by modifying the receiving side.
|
||||
for (int i = 0; i < voe_codec_->NumOfCodecs(); i++) {
|
||||
EXPECT_EQ(0, voe_codec_->GetCodec(i, codec_instance));
|
||||
if (!_stricmp("telephone-event", codec_instance.plname)) {
|
||||
codec_instance.pltype = 88; // Use 88 instead of default 106.
|
||||
EXPECT_EQ(0, voe_base_->StopSend(channel_));
|
||||
EXPECT_EQ(0, voe_base_->StopPlayout(channel_));
|
||||
EXPECT_EQ(0, voe_base_->StopReceive(channel_));
|
||||
EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance));
|
||||
EXPECT_EQ(0, voe_base_->StartReceive(channel_));
|
||||
EXPECT_EQ(0, voe_base_->StartPlayout(channel_));
|
||||
EXPECT_EQ(0, voe_base_->StartSend(channel_));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(500);
|
||||
|
||||
// Next, we must modify the sending side as well.
|
||||
EXPECT_EQ(0, voe_dtmf_->SetSendTelephoneEventPayloadType(
|
||||
channel_, codec_instance.pltype));
|
||||
|
||||
RunSixteenDtmfEvents(true);
|
||||
|
||||
EXPECT_EQ(0, voe_dtmf_->SetDtmfFeedbackStatus(true, false));
|
||||
}
|
||||
@ -999,192 +999,6 @@ int VoETestManager::DoStandardTest() {
|
||||
TEST_LOG("Skipping FEC tests - WEBRTC_CODEC_RED not defined \n");
|
||||
#endif // #ifdef WEBRTC_CODEC_RED
|
||||
|
||||
////////
|
||||
// Dtmf
|
||||
|
||||
#ifdef _TEST_DTMF_
|
||||
TEST_LOG("\n\n+++ Dtmf tests +++\n\n");
|
||||
|
||||
TEST_LOG("Making sure Dtmf Feedback is enabled by default \n");
|
||||
bool dtmfFeedback = false, dtmfDirectFeedback = true;
|
||||
TEST_MUSTPASS(voe_dtmf_->GetDtmfFeedbackStatus(dtmfFeedback,
|
||||
dtmfDirectFeedback));
|
||||
TEST_MUSTPASS(!dtmfFeedback);
|
||||
TEST_MUSTPASS(dtmfDirectFeedback);
|
||||
|
||||
// Add support when new 4.0 API is complete
|
||||
#if (defined(WEBRTC_DTMF_DETECTION) && !defined(_INSTRUMENTATION_TESTING_))
|
||||
DtmfCallback *d = new DtmfCallback();
|
||||
|
||||
// Set codec to PCMU to make sure tones are not distorted
|
||||
TEST_LOG("Setting codec to PCMU\n");
|
||||
CodecInst ci;
|
||||
ci.channels = 1;
|
||||
ci.pacsize = 160;
|
||||
ci.plfreq = 8000;
|
||||
ci.pltype = 0;
|
||||
ci.rate = 64000;
|
||||
strcpy(ci.plname, "PCMU");
|
||||
TEST_MUSTPASS(voe_codec_->SetSendCodec(0, ci));
|
||||
|
||||
// Loop the different detections methods
|
||||
TelephoneEventDetectionMethods detMethod = kInBand;
|
||||
for (int h=0; h<3; ++h)
|
||||
{
|
||||
if (0 == h)
|
||||
{
|
||||
TEST_LOG("Testing telephone-event (Dtmf) detection"
|
||||
" using in-band method \n");
|
||||
TEST_LOG(" In-band events should be detected \n");
|
||||
TEST_LOG(" Out-of-band Dtmf events (0-15) should be"
|
||||
" detected \n");
|
||||
TEST_LOG(" Out-of-band non-Dtmf events (>15) should NOT be"
|
||||
" detected \n");
|
||||
detMethod = kInBand;
|
||||
}
|
||||
if (1 == h)
|
||||
{
|
||||
TEST_LOG("Testing telephone-event (Dtmf) detection using"
|
||||
" out-of-band method\n");
|
||||
TEST_LOG(" In-band events should NOT be detected \n");
|
||||
TEST_LOG(" Out-of-band events should be detected \n");
|
||||
detMethod = kOutOfBand;
|
||||
}
|
||||
if (2 == h)
|
||||
{
|
||||
TEST_LOG("Testing telephone-event (Dtmf) detection using both"
|
||||
" in-band and out-of-band methods\n");
|
||||
TEST_LOG(" In-band events should be detected \n");
|
||||
TEST_LOG(" Out-of-band Dtmf events (0-15) should be detected"
|
||||
" TWICE \n");
|
||||
TEST_LOG(" Out-of-band non-Dtmf events (>15) should be detected"
|
||||
" ONCE \n");
|
||||
detMethod = kInAndOutOfBand;
|
||||
}
|
||||
TEST_MUSTPASS(voe_dtmf_->RegisterTelephoneEventDetection(0, detMethod, *d));
|
||||
#else
|
||||
TEST_LOG("Skipping Dtmf detection tests - WEBRTC_DTMF_DETECTION not"
|
||||
" defined or _INSTRUMENTATION_TESTING_ defined \n");
|
||||
#endif
|
||||
|
||||
TEST_MUSTPASS(voe_dtmf_->SetDtmfFeedbackStatus(false));
|
||||
TEST_LOG("Sending in-band telephone events:");
|
||||
for (int i = 0; i < 16; i++) {
|
||||
TEST_LOG("\n %d ", i);
|
||||
fflush(NULL);
|
||||
TEST_MUSTPASS(voe_dtmf_->SendTelephoneEvent(0, i, false, 160, 10));
|
||||
SLEEP(500);
|
||||
}
|
||||
#ifdef WEBRTC_CODEC_AVT
|
||||
TEST_LOG("\nSending out-of-band telephone events:");
|
||||
for (int i = 0; i < 16; i++) {
|
||||
TEST_LOG("\n %d ", i);
|
||||
fflush(NULL);
|
||||
TEST_MUSTPASS(voe_dtmf_->SendTelephoneEvent(0, i, true));
|
||||
SLEEP(500);
|
||||
}
|
||||
// Testing 2 non-Dtmf events
|
||||
int num = 32;
|
||||
TEST_LOG("\n %d ", num);
|
||||
fflush(NULL);
|
||||
TEST_MUSTPASS(voe_dtmf_->SendTelephoneEvent(0, num, true));
|
||||
SLEEP(500);
|
||||
num = 110;
|
||||
TEST_LOG("\n %d ", num);
|
||||
fflush(NULL);
|
||||
TEST_MUSTPASS(voe_dtmf_->SendTelephoneEvent(0, num, true));
|
||||
SLEEP(500);
|
||||
ANL();
|
||||
#endif
|
||||
#if (defined(WEBRTC_DTMF_DETECTION) && !defined(_INSTRUMENTATION_TESTING_))
|
||||
TEST_MUSTPASS(voe_dtmf_->DeRegisterTelephoneEventDetection(0));
|
||||
TEST_LOG("Detected %d events \n", d->counter);
|
||||
int expectedCount = 32; // For 0 == h
|
||||
if (1 == h) expectedCount = 18;
|
||||
if (2 == h) expectedCount = 50;
|
||||
TEST_MUSTPASS(d->counter != expectedCount);
|
||||
d->counter = 0;
|
||||
} // for loop
|
||||
|
||||
TEST_LOG("Testing no detection after disabling:");
|
||||
TEST_MUSTPASS(voe_dtmf_->DeRegisterTelephoneEventDetection(0));
|
||||
TEST_LOG(" 0");
|
||||
TEST_MUSTPASS(voe_dtmf_->SendTelephoneEvent(0, 0, false));
|
||||
SLEEP(500);
|
||||
TEST_LOG(" 1");
|
||||
TEST_MUSTPASS(voe_dtmf_->SendTelephoneEvent(0, 1, true));
|
||||
SLEEP(500);
|
||||
TEST_LOG("\nDtmf tones sent: 2, detected: %d \n", d->counter);
|
||||
TEST_MUSTPASS(0 != d->counter);
|
||||
delete d;
|
||||
|
||||
TEST_MUSTPASS(voe_codec_->GetCodec(0, ci));
|
||||
TEST_LOG("Back to first codec in list: %s\n", ci.plname);
|
||||
TEST_MUSTPASS(voe_codec_->SetSendCodec(0, ci));
|
||||
#endif
|
||||
|
||||
#ifndef MAC_IPHONE
|
||||
#ifdef WEBRTC_CODEC_AVT
|
||||
TEST_LOG("Disabling Dtmf playout (no tone should be heard) \n");
|
||||
TEST_MUSTPASS(voe_dtmf_->SetDtmfPlayoutStatus(0, false));
|
||||
TEST_MUSTPASS(voe_dtmf_->SendTelephoneEvent(0, 0, true));
|
||||
SLEEP(500);
|
||||
|
||||
TEST_LOG("Enabling Dtmf playout (tone should be heard) \n");
|
||||
TEST_MUSTPASS(voe_dtmf_->SetDtmfPlayoutStatus(0, true));
|
||||
TEST_MUSTPASS(voe_dtmf_->SendTelephoneEvent(0, 0, true));
|
||||
SLEEP(500);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TEST_LOG("Playing Dtmf tone locally \n");
|
||||
/// TEST_MUSTPASS(dtmf->PlayDtmfTone(0, 300, 15));
|
||||
SLEEP(500);
|
||||
#ifdef WEBRTC_CODEC_AVT
|
||||
CodecInst c2;
|
||||
|
||||
TEST_LOG("Changing Dtmf payload type \n");
|
||||
|
||||
// Start by modifying the receiving side
|
||||
if (voe_codec_) {
|
||||
int nc = voe_codec_->NumOfCodecs();
|
||||
for (int i = 0; i < nc; i++) {
|
||||
TEST_MUSTPASS(voe_codec_->GetCodec(i, c2));
|
||||
if (!_stricmp("telephone-event", c2.plname)) {
|
||||
c2.pltype = 88; // use 88 instead of default 106
|
||||
TEST_MUSTPASS(voe_base_->StopSend(0));
|
||||
TEST_MUSTPASS(voe_base_->StopPlayout(0));
|
||||
TEST_MUSTPASS(voe_base_->StopReceive(0));
|
||||
TEST_MUSTPASS(voe_codec_->SetRecPayloadType(0, c2));
|
||||
TEST_MUSTPASS(voe_base_->StartReceive(0));
|
||||
TEST_MUSTPASS(voe_base_->StartPlayout(0));
|
||||
TEST_MUSTPASS(voe_base_->StartSend(0));
|
||||
TEST_LOG("Start playing a file as microphone again \n");
|
||||
TEST_MUSTPASS(voe_file_->StartPlayingFileAsMicrophone(
|
||||
0, AudioFilename(), true, true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SLEEP(500);
|
||||
|
||||
// Next, we must modify the sending side as well
|
||||
TEST_MUSTPASS(voe_dtmf_->SetSendTelephoneEventPayloadType(0, c2.pltype));
|
||||
|
||||
TEST_LOG("Outband Dtmf test with modified Dtmf payload:");
|
||||
for (int i = 0; i < 16; i++) {
|
||||
TEST_LOG(" %d", i);
|
||||
fflush(NULL);
|
||||
TEST_MUSTPASS(voe_dtmf_->SendTelephoneEvent(0, i, true));
|
||||
SLEEP(500);
|
||||
}
|
||||
ANL();
|
||||
#endif
|
||||
TEST_MUSTPASS(voe_dtmf_->SetDtmfFeedbackStatus(true, false));
|
||||
#else
|
||||
TEST_LOG("\n\n+++ Dtmf tests NOT ENABLED +++\n");
|
||||
#endif // #ifdef _TEST_DTMF_
|
||||
//////////
|
||||
// Volume
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
'auto_test/fixtures/before_initialization_fixture.h',
|
||||
'auto_test/standard/codec_before_streaming_test.cc',
|
||||
'auto_test/standard/codec_test.cc',
|
||||
'auto_test/standard/dtmf_test.cc',
|
||||
'auto_test/standard/hardware_before_initializing_test.cc',
|
||||
'auto_test/standard/hardware_before_streaming_test.cc',
|
||||
'auto_test/standard/hardware_test.cc',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user