From 52e58524b67a27c8bd6cdf6e66954dab996364f7 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Tue, 20 Feb 2018 08:15:36 +0100 Subject: [PATCH] Adjust DTMF min inter-tone gap to 30 ms This brings it in line with the WEBRTC specification: https://w3c.github.io/webrtc-pc/#dom-rtcdtmfsender-insertdtmf Bug: chromium:812587 Change-Id: I705ac35cc94922f405e4951cfec813b74ed5dcab Reviewed-on: https://webrtc-review.googlesource.com/55260 Reviewed-by: Henrik Lundin Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/master@{#22096} --- pc/dtmfsender.cc | 4 +++- pc/dtmfsender_unittest.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pc/dtmfsender.cc b/pc/dtmfsender.cc index 7a98bc32dd..8378eb9a07 100644 --- a/pc/dtmfsender.cc +++ b/pc/dtmfsender.cc @@ -41,11 +41,13 @@ static const char kDtmfValidTones[] = ",0123456789*#ABCDabcd"; static const char kDtmfTonesTable[] = ",0123456789*#ABCD"; // The duration cannot be more than 6000ms or less than 40ms. The gap between // tones must be at least 50 ms. +// Source for values: W3C WEBRTC specification. +// https://w3c.github.io/webrtc-pc/#dom-rtcdtmfsender-insertdtmf static const int kDtmfDefaultDurationMs = 100; static const int kDtmfMinDurationMs = 40; static const int kDtmfMaxDurationMs = 6000; static const int kDtmfDefaultGapMs = 50; -static const int kDtmfMinGapMs = 50; +static const int kDtmfMinGapMs = 30; // Get DTMF code from the DTMF event character. bool GetDtmfCode(char tone, int* code) { diff --git a/pc/dtmfsender_unittest.cc b/pc/dtmfsender_unittest.cc index a5d102b5f2..ddccc448f6 100644 --- a/pc/dtmfsender_unittest.cc +++ b/pc/dtmfsender_unittest.cc @@ -331,7 +331,7 @@ TEST_F(DtmfSenderTest, InsertDtmfWithInvalidDurationOrGap) { EXPECT_FALSE(dtmf_->InsertDtmf(tones, 6001, inter_tone_gap)); EXPECT_FALSE(dtmf_->InsertDtmf(tones, 39, inter_tone_gap)); - EXPECT_FALSE(dtmf_->InsertDtmf(tones, duration, 49)); + EXPECT_FALSE(dtmf_->InsertDtmf(tones, duration, 29)); EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap)); }