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