blob: 21d67426822c1e85bebb73bee84f3ea324d7616b [file] [log] [blame]
Jason Longa5347292020-08-18 17:22:391/*
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
11#ifndef API_VOIP_VOIP_DTMF_H_
12#define API_VOIP_VOIP_DTMF_H_
13
Dor Hen52e46242024-08-19 09:44:5614#include <cstdint>
15
Jason Longa5347292020-08-18 17:22:3916#include "api/voip/voip_base.h"
17
18namespace webrtc {
19
20// DTMF events and their event codes as defined in
21// https://tools.ietf.org/html/rfc4733#section-7
22enum class DtmfEvent : uint8_t {
23 kDigitZero = 0,
24 kDigitOne,
25 kDigitTwo,
26 kDigitThree,
27 kDigitFour,
28 kDigitFive,
29 kDigitSix,
30 kDigitSeven,
31 kDigitEight,
32 kDigitNine,
33 kAsterisk,
34 kHash,
35 kLetterA,
36 kLetterB,
37 kLetterC,
38 kLetterD
39};
40
41// VoipDtmf interface provides DTMF related interfaces such
42// as sending DTMF events to the remote endpoint.
43class VoipDtmf {
44 public:
45 // Register the payload type and sample rate for DTMF (RFC 4733) payload.
46 // Must be called exactly once prior to calling SendDtmfEvent after payload
47 // type has been negotiated with remote.
Tim Nab223cb62020-11-20 17:34:4748 // Returns following VoipResult;
49 // kOk - telephone event type is registered as provided.
Artem Titov0e61fdd2021-07-25 19:50:1450 // kInvalidArgument - `channel_id` is invalid.
Tim Nab223cb62020-11-20 17:34:4751 virtual VoipResult RegisterTelephoneEventType(ChannelId channel_id,
52 int rtp_payload_type,
53 int sample_rate_hz) = 0;
Jason Longa5347292020-08-18 17:22:3954
55 // Send DTMF named event as specified by
56 // https://tools.ietf.org/html/rfc4733#section-3.2
Artem Titov0e61fdd2021-07-25 19:50:1457 // `duration_ms` specifies the duration of DTMF packets that will be emitted
Jason Longa5347292020-08-18 17:22:3958 // in place of real RTP packets instead.
59 // Must be called after RegisterTelephoneEventType and VoipBase::StartSend
60 // have been called.
Tim Nab223cb62020-11-20 17:34:4761 // Returns following VoipResult;
62 // kOk - requested DTMF event is successfully scheduled.
Artem Titov0e61fdd2021-07-25 19:50:1463 // kInvalidArgument - `channel_id` is invalid.
Tim Nab223cb62020-11-20 17:34:4764 // kFailedPrecondition - Missing prerequisite on RegisterTelephoneEventType
65 // or sending state.
66 virtual VoipResult SendDtmfEvent(ChannelId channel_id,
67 DtmfEvent dtmf_event,
68 int duration_ms) = 0;
Jason Longa5347292020-08-18 17:22:3969
70 protected:
71 virtual ~VoipDtmf() = default;
72};
73
74} // namespace webrtc
75
76#endif // API_VOIP_VOIP_DTMF_H_