Make DTMF sender wait before sending the first tone.

This is according to WebRTC spec.

Bug: chromium:819118
Change-Id: I4c0c8e69de812730f9f5c0a1b86d08cf05a472ad
Reviewed-on: https://webrtc-review.googlesource.com/60181
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22309}
This commit is contained in:
Harald Alvestrand 2018-03-06 10:51:27 +01:00 committed by Commit Bot
parent 52f8188f5d
commit 1e0c804f19
2 changed files with 13 additions and 1 deletions

View File

@ -141,7 +141,7 @@ bool DtmfSender::InsertDtmf(const std::string& tones, int duration,
// Clear the previous queue.
signaling_thread_->Clear(this, MSG_DO_INSERT_DTMF);
// Kick off a new DTMF task queue.
signaling_thread_->Post(RTC_FROM_HERE, this, MSG_DO_INSERT_DTMF);
signaling_thread_->PostDelayed(RTC_FROM_HERE, 1, this, MSG_DO_INSERT_DTMF);
return true;
}

View File

@ -335,3 +335,15 @@ TEST_F(DtmfSenderTest, InsertDtmfWithInvalidDurationOrGap) {
EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap));
}
TEST_F(DtmfSenderTest, InsertDtmfSendsAfterWait) {
std::string tones = "ABC";
int duration = 100;
int inter_tone_gap = 50;
EXPECT_TRUE(dtmf_->InsertDtmf(tones, duration, inter_tone_gap));
VerifyExpectedState(track_, "ABC", duration, inter_tone_gap);
// Wait until the first tone got sent.
EXPECT_TRUE_SIMULATED_WAIT(observer_->tones().size() == 1, kMaxWaitMs,
fake_clock_);
VerifyExpectedState(track_, "BC", duration, inter_tone_gap);
}