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));
55 TEST_F(DtmfTest, ManualCanDisableDtmfPlayoutExceptOnIphone) {
56 TEST_LOG("Disabling DTMF playout (no tone should be heard) \n");
57 EXPECT_EQ(0, voe_dtmf_->SetDtmfPlayoutStatus(channel_, false));
58 EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 0, true));
61 TEST_LOG("Enabling DTMF playout (tone should be heard) \n");
62 EXPECT_EQ(0, voe_dtmf_->SetDtmfPlayoutStatus(channel_, true));
63 EXPECT_EQ(0, voe_dtmf_->SendTelephoneEvent(channel_, 0, true));
67 // This test modifies the DTMF payload type from the default 106 to 88
68 // and then runs through 16 DTMF out.of-band events.
69 TEST_F(DtmfTest, ManualCanChangeDtmfPayloadType) {
70 webrtc::CodecInst codec_instance;
72 TEST_LOG("Changing DTMF payload type.\n");
74 // Start by modifying the receiving side.
75 for (int i = 0; i < voe_codec_->NumOfCodecs(); i++) {
76 EXPECT_EQ(0, voe_codec_->GetCodec(i, codec_instance));
77 if (!_stricmp("telephone-event", codec_instance.plname)) {
78 codec_instance.pltype = 88; // Use 88 instead of default 106.
79 EXPECT_EQ(0, voe_base_->StopSend(channel_));
80 EXPECT_EQ(0, voe_base_->StopPlayout(channel_));
81 EXPECT_EQ(0, voe_base_->StopReceive(channel_));
82 EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance));
83 EXPECT_EQ(0, voe_base_->StartReceive(channel_));
84 EXPECT_EQ(0, voe_base_->StartPlayout(channel_));
85 EXPECT_EQ(0, voe_base_->StartSend(channel_));
92 // Next, we must modify the sending side as well.
93 EXPECT_EQ(0, voe_dtmf_->SetSendTelephoneEventPayloadType(
94 channel_, codec_instance.pltype));
96 RunSixteenDtmfEvents(true);
98 EXPECT_EQ(0, voe_dtmf_->SetDtmfFeedbackStatus(true, false));