henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 3 | * Copyright 2012 Google Inc. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 28 | #ifndef WEBRTC_API_DTMFSENDERINTERFACE_H_ |
| 29 | #define WEBRTC_API_DTMFSENDERINTERFACE_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 30 | |
| 31 | #include <string> |
| 32 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 33 | #include "webrtc/api/mediastreaminterface.h" |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 34 | #include "webrtc/base/common.h" |
| 35 | #include "webrtc/base/refcount.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 36 | |
| 37 | // This file contains interfaces for DtmfSender. |
| 38 | |
| 39 | namespace webrtc { |
| 40 | |
| 41 | // DtmfSender callback interface. Application should implement this interface |
| 42 | // to get notifications from the DtmfSender. |
| 43 | class DtmfSenderObserverInterface { |
| 44 | public: |
| 45 | // Triggered when DTMF |tone| is sent. |
| 46 | // If |tone| is empty that means the DtmfSender has sent out all the given |
| 47 | // tones. |
| 48 | virtual void OnToneChange(const std::string& tone) = 0; |
| 49 | |
| 50 | protected: |
| 51 | virtual ~DtmfSenderObserverInterface() {} |
| 52 | }; |
| 53 | |
| 54 | // The interface of native implementation of the RTCDTMFSender defined by the |
| 55 | // WebRTC W3C Editor's Draft. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 56 | class DtmfSenderInterface : public rtc::RefCountInterface { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 57 | public: |
| 58 | virtual void RegisterObserver(DtmfSenderObserverInterface* observer) = 0; |
| 59 | virtual void UnregisterObserver() = 0; |
| 60 | |
| 61 | // Returns true if this DtmfSender is capable of sending DTMF. |
| 62 | // Otherwise returns false. |
| 63 | virtual bool CanInsertDtmf() = 0; |
| 64 | |
| 65 | // Queues a task that sends the DTMF |tones|. The |tones| parameter is treated |
| 66 | // as a series of characters. The characters 0 through 9, A through D, #, and |
| 67 | // * generate the associated DTMF tones. The characters a to d are equivalent |
| 68 | // to A to D. The character ',' indicates a delay of 2 seconds before |
| 69 | // processing the next character in the tones parameter. |
| 70 | // Unrecognized characters are ignored. |
| 71 | // The |duration| parameter indicates the duration in ms to use for each |
| 72 | // character passed in the |tones| parameter. |
| 73 | // The duration cannot be more than 6000 or less than 70. |
| 74 | // The |inter_tone_gap| parameter indicates the gap between tones in ms. |
| 75 | // The |inter_tone_gap| must be at least 50 ms but should be as short as |
| 76 | // possible. |
| 77 | // If InsertDtmf is called on the same object while an existing task for this |
| 78 | // object to generate DTMF is still running, the previous task is canceled. |
| 79 | // Returns true on success and false on failure. |
| 80 | virtual bool InsertDtmf(const std::string& tones, int duration, |
| 81 | int inter_tone_gap) = 0; |
| 82 | |
| 83 | // Returns the track given as argument to the constructor. |
| 84 | virtual const AudioTrackInterface* track() const = 0; |
| 85 | |
| 86 | // Returns the tones remaining to be played out. |
| 87 | virtual std::string tones() const = 0; |
| 88 | |
| 89 | // Returns the current tone duration value in ms. |
| 90 | // This value will be the value last set via the InsertDtmf() method, or the |
| 91 | // default value of 100 ms if InsertDtmf() was never called. |
| 92 | virtual int duration() const = 0; |
| 93 | |
| 94 | // Returns the current value of the between-tone gap in ms. |
| 95 | // This value will be the value last set via the InsertDtmf() method, or the |
| 96 | // default value of 50 ms if InsertDtmf() was never called. |
| 97 | virtual int inter_tone_gap() const = 0; |
| 98 | |
| 99 | protected: |
| 100 | virtual ~DtmfSenderInterface() {} |
| 101 | }; |
| 102 | |
| 103 | } // namespace webrtc |
| 104 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 105 | #endif // WEBRTC_API_DTMFSENDERINTERFACE_H_ |