You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
4.4 KiB

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