voip_dtmf.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * 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.
  9. */
  10. #ifndef API_VOIP_VOIP_DTMF_H_
  11. #define API_VOIP_VOIP_DTMF_H_
  12. #include "api/voip/voip_base.h"
  13. namespace webrtc {
  14. // DTMF events and their event codes as defined in
  15. // https://tools.ietf.org/html/rfc4733#section-7
  16. enum class DtmfEvent : uint8_t {
  17. kDigitZero = 0,
  18. kDigitOne,
  19. kDigitTwo,
  20. kDigitThree,
  21. kDigitFour,
  22. kDigitFive,
  23. kDigitSix,
  24. kDigitSeven,
  25. kDigitEight,
  26. kDigitNine,
  27. kAsterisk,
  28. kHash,
  29. kLetterA,
  30. kLetterB,
  31. kLetterC,
  32. kLetterD
  33. };
  34. // VoipDtmf interface provides DTMF related interfaces such
  35. // as sending DTMF events to the remote endpoint.
  36. class VoipDtmf {
  37. public:
  38. // Register the payload type and sample rate for DTMF (RFC 4733) payload.
  39. // Must be called exactly once prior to calling SendDtmfEvent after payload
  40. // type has been negotiated with remote.
  41. virtual void RegisterTelephoneEventType(ChannelId channel_id,
  42. int rtp_payload_type,
  43. int sample_rate_hz) = 0;
  44. // Send DTMF named event as specified by
  45. // https://tools.ietf.org/html/rfc4733#section-3.2
  46. // |duration_ms| specifies the duration of DTMF packets that will be emitted
  47. // in place of real RTP packets instead.
  48. // Must be called after RegisterTelephoneEventType and VoipBase::StartSend
  49. // have been called.
  50. // Returns true if the requested DTMF event is successfully scheduled.
  51. virtual bool SendDtmfEvent(ChannelId channel_id,
  52. DtmfEvent dtmf_event,
  53. int duration_ms) = 0;
  54. protected:
  55. virtual ~VoipDtmf() = default;
  56. };
  57. } // namespace webrtc
  58. #endif // API_VOIP_VOIP_DTMF_H_