2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #include "webrtc/voice_engine/test/auto_test/fixtures/after_streaming_fixture.h"
12 #include "webrtc/voice_engine/voice_engine_defines.h"
14 class DtmfTest : public AfterStreamingFixture {
16 void RunSixteenDtmfEvents(bool out_of_band) {
17 TEST_LOG("Sending telephone events:\n");
18 EXPECT_EQ(0, voe_dtmf_->SetDtmfFeedbackStatus(false));
20 for (int i = 0; i < 16; i++) {
23 EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(
24 channel_, i, out_of_band, 160, 10));
31 TEST_F(DtmfTest, DtmfFeedbackIsEnabledByDefaultButNotDirectFeedback) {
32 bool dtmf_feedback = false;
33 bool dtmf_direct_feedback = false;
35 EXPECT_EQ(0, voe_dtmf_->GetDtmfFeedbackStatus(dtmf_feedback,
36 dtmf_direct_feedback));
38 EXPECT_TRUE(dtmf_feedback);
39 EXPECT_FALSE(dtmf_direct_feedback);
42 TEST_F(DtmfTest, ManualSuccessfullySendsInBandTelephoneEvents) {
43 RunSixteenDtmfEvents(false);
46 TEST_F(DtmfTest, ManualSuccessfullySendsOutOfBandTelephoneEvents) {
47 RunSixteenDtmfEvents(true);
50 TEST_F(DtmfTest, TestTwoNonDtmfEvents) {
51 EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 32, true));
52 EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 110, true));
56 TEST_F(DtmfTest, ManualCanDisableDtmfPlayoutExceptOnIphone) {
57 TEST_LOG("Disabling DTMF playout (no tone should be heard) \n");
58 EXPECT_EQ(0, voe_dtmf_->SetDtmfPlayoutStatus(channel_, false));
59 EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 0, true));
62 TEST_LOG("Enabling DTMF playout (tone should be heard) \n");
63 EXPECT_EQ(0, voe_dtmf_->SetDtmfPlayoutStatus(channel_, true));
64 EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 0, true));
69 // This test modifies the DTMF payload type from the default 106 to 88
70 // and then runs through 16 DTMF out.of-band events.
71 TEST_F(DtmfTest, ManualCanChangeDtmfPayloadType) {
72 webrtc::CodecInst codec_instance;
74 TEST_LOG("Changing DTMF payload type.\n");
76 // Start by modifying the receiving side.
77 for (int i = 0; i < voe_codec_->NumOfCodecs(); i++) {
78 EXPECT_EQ(0, voe_codec_->GetCodec(i, codec_instance));
79 if (!_stricmp("telephone-event", codec_instance.plname)) {
80 codec_instance.pltype = 88; // Use 88 instead of default 106.
81 EXPECT_EQ(0, voe_base_->StopSend(channel_));
82 EXPECT_EQ(0, voe_base_->StopPlayout(channel_));
83 EXPECT_EQ(0, voe_base_->StopReceive(channel_));
84 EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance));
85 EXPECT_EQ(0, voe_base_->StartReceive(channel_));
86 EXPECT_EQ(0, voe_base_->StartPlayout(channel_));
87 EXPECT_EQ(0, voe_base_->StartSend(channel_));
94 // Next, we must modify the sending side as well.
95 EXPECT_EQ(0, voe_dtmf_->SetSendTelephoneEventPayloadType(
96 channel_, codec_instance.pltype));
98 RunSixteenDtmfEvents(true);
100 EXPECT_EQ(0, voe_dtmf_->SetDtmfFeedbackStatus(true, false));