Allow DTMF delay configurability
This commit enables developers to configure the "," delay value from
the WebRTC spec value of 2 seconds. This flexibility allows developers
to comply with existing WebRTC clients.
Bug: webrtc:11273
Change-Id: Ia94b99e041df882e2396d0926a8f4188afe55885
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165700
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30354}
diff --git a/api/dtmf_sender_interface.h b/api/dtmf_sender_interface.h
index 9cdfba1..7c0e2ce 100644
--- a/api/dtmf_sender_interface.h
+++ b/api/dtmf_sender_interface.h
@@ -44,6 +44,9 @@
// See: https://www.w3.org/TR/webrtc/#peer-to-peer-dtmf
class DtmfSenderInterface : public rtc::RefCountInterface {
public:
+ // Provides the spec compliant default 2 second delay for the ',' character.
+ static const int kDtmfDefaultCommaDelayMs = 2000;
+
// Used to receive events from the DTMF sender. Only one observer can be
// registered at a time. UnregisterObserver should be called before the
// observer object is destroyed.
@@ -71,12 +74,29 @@
// |inter_tone_gap| must be at least 50 ms but should be as short as
// possible.
//
+ // The |comma_delay| parameter indicates the delay after the ','
+ // character. InsertDtmf specifies |comma_delay| as an argument
+ // with a default value of 2 seconds as per the WebRTC spec. This parameter
+ // allows users to comply with legacy WebRTC clients. The |comma_delay|
+ // must be at least 50 ms.
+ //
// If InsertDtmf is called on the same object while an existing task for this
// object to generate DTMF is still running, the previous task is canceled.
// Returns true on success and false on failure.
virtual bool InsertDtmf(const std::string& tones,
int duration,
- int inter_tone_gap) = 0;
+ int inter_tone_gap) {
+ return InsertDtmf(tones, duration, inter_tone_gap,
+ kDtmfDefaultCommaDelayMs);
+ }
+ virtual bool InsertDtmf(const std::string& tones,
+ int duration,
+ int inter_tone_gap,
+ int comma_delay) {
+ // TODO(bugs.webrtc.org/165700): Remove once downstream implementations
+ // override this signature rather than the 3-parameter one.
+ return InsertDtmf(tones, duration, inter_tone_gap);
+ }
// Returns the tones remaining to be played out.
virtual std::string tones() const = 0;
@@ -91,6 +111,11 @@
// default value of 50 ms if InsertDtmf() was never called.
virtual int inter_tone_gap() const = 0;
+ // Returns the current value of the "," character delay in ms.
+ // This value will be the value last set via the InsertDtmf() method, or the
+ // default value of 2000 ms if InsertDtmf() was never called.
+ virtual int comma_delay() const { return kDtmfDefaultCommaDelayMs; }
+
protected:
~DtmfSenderInterface() override = default;
};