blob: a4d270d905599de790ed52ed6aa4b621bc0b92f0 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00009 */
10
Henrik Kjellander15583c12016-02-10 10:53:12 +010011#ifndef WEBRTC_API_DTMFSENDERINTERFACE_H_
12#define WEBRTC_API_DTMFSENDERINTERFACE_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000013
14#include <string>
15
Henrik Kjellander15583c12016-02-10 10:53:12 +010016#include "webrtc/api/mediastreaminterface.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000017#include "webrtc/base/refcount.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000018
19// This file contains interfaces for DtmfSender.
20
21namespace webrtc {
22
23// DtmfSender callback interface. Application should implement this interface
24// to get notifications from the DtmfSender.
25class DtmfSenderObserverInterface {
26 public:
27 // Triggered when DTMF |tone| is sent.
28 // If |tone| is empty that means the DtmfSender has sent out all the given
29 // tones.
30 virtual void OnToneChange(const std::string& tone) = 0;
31
32 protected:
33 virtual ~DtmfSenderObserverInterface() {}
34};
35
36// The interface of native implementation of the RTCDTMFSender defined by the
37// WebRTC W3C Editor's Draft.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000038class DtmfSenderInterface : public rtc::RefCountInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000039 public:
40 virtual void RegisterObserver(DtmfSenderObserverInterface* observer) = 0;
41 virtual void UnregisterObserver() = 0;
42
43 // Returns true if this DtmfSender is capable of sending DTMF.
44 // Otherwise returns false.
45 virtual bool CanInsertDtmf() = 0;
46
47 // Queues a task that sends the DTMF |tones|. The |tones| parameter is treated
48 // as a series of characters. The characters 0 through 9, A through D, #, and
49 // * generate the associated DTMF tones. The characters a to d are equivalent
50 // to A to D. The character ',' indicates a delay of 2 seconds before
51 // processing the next character in the tones parameter.
52 // Unrecognized characters are ignored.
53 // The |duration| parameter indicates the duration in ms to use for each
54 // character passed in the |tones| parameter.
55 // The duration cannot be more than 6000 or less than 70.
56 // The |inter_tone_gap| parameter indicates the gap between tones in ms.
57 // The |inter_tone_gap| must be at least 50 ms but should be as short as
58 // possible.
59 // If InsertDtmf is called on the same object while an existing task for this
60 // object to generate DTMF is still running, the previous task is canceled.
61 // Returns true on success and false on failure.
62 virtual bool InsertDtmf(const std::string& tones, int duration,
63 int inter_tone_gap) = 0;
64
65 // Returns the track given as argument to the constructor.
66 virtual const AudioTrackInterface* track() const = 0;
67
68 // Returns the tones remaining to be played out.
69 virtual std::string tones() const = 0;
70
71 // Returns the current tone duration value in ms.
72 // This value will be the value last set via the InsertDtmf() method, or the
73 // default value of 100 ms if InsertDtmf() was never called.
74 virtual int duration() const = 0;
75
76 // Returns the current value of the between-tone gap in ms.
77 // This value will be the value last set via the InsertDtmf() method, or the
78 // default value of 50 ms if InsertDtmf() was never called.
79 virtual int inter_tone_gap() const = 0;
80
81 protected:
82 virtual ~DtmfSenderInterface() {}
83};
84
85} // namespace webrtc
86
Henrik Kjellander15583c12016-02-10 10:53:12 +010087#endif // WEBRTC_API_DTMFSENDERINTERFACE_H_