DTMF Event Sub-API on VoIP API

Added VoipDtmf in VoipEngine as a sub-API to provide DTMF related interfaces; also added relevant unit tests.

Bug: webrtc:11802
Change-Id: Ie9832aebe075a48ae1207be142361b73646673ca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180225
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Tim Na <natim@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Tim Na <natim@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31974}
This commit is contained in:
Jason Long
2020-08-18 13:22:39 -04:00
committed by Commit Bot
parent e64b3d0159
commit a53472940e
7 changed files with 162 additions and 1 deletions

View File

@ -13,6 +13,7 @@ rtc_source_set("voip_api") {
sources = [
"voip_base.h",
"voip_codec.h",
"voip_dtmf.h",
"voip_engine.h",
"voip_network.h",
]

67
api/voip/voip_dtmf.h Normal file
View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef API_VOIP_VOIP_DTMF_H_
#define API_VOIP_VOIP_DTMF_H_
#include "api/voip/voip_base.h"
namespace webrtc {
// DTMF events and their event codes as defined in
// https://tools.ietf.org/html/rfc4733#section-7
enum class DtmfEvent : uint8_t {
kDigitZero = 0,
kDigitOne,
kDigitTwo,
kDigitThree,
kDigitFour,
kDigitFive,
kDigitSix,
kDigitSeven,
kDigitEight,
kDigitNine,
kAsterisk,
kHash,
kLetterA,
kLetterB,
kLetterC,
kLetterD
};
// VoipDtmf interface provides DTMF related interfaces such
// as sending DTMF events to the remote endpoint.
class VoipDtmf {
public:
// Register the payload type and sample rate for DTMF (RFC 4733) payload.
// Must be called exactly once prior to calling SendDtmfEvent after payload
// type has been negotiated with remote.
virtual void RegisterTelephoneEventType(ChannelId channel_id,
int rtp_payload_type,
int sample_rate_hz) = 0;
// Send DTMF named event as specified by
// https://tools.ietf.org/html/rfc4733#section-3.2
// |duration_ms| specifies the duration of DTMF packets that will be emitted
// in place of real RTP packets instead.
// Must be called after RegisterTelephoneEventType and VoipBase::StartSend
// have been called.
// Returns true if the requested DTMF event is successfully scheduled.
virtual bool SendDtmfEvent(ChannelId channel_id,
DtmfEvent dtmf_event,
int duration_ms) = 0;
protected:
virtual ~VoipDtmf() = default;
};
} // namespace webrtc
#endif // API_VOIP_VOIP_DTMF_H_

View File

@ -16,6 +16,7 @@ namespace webrtc {
class VoipBase;
class VoipCodec;
class VoipNetwork;
class VoipDtmf;
// VoipEngine is the main interface serving as the entry point for all VoIP
// APIs. A single instance of VoipEngine should suffice the most of the need for
@ -80,6 +81,9 @@ class VoipEngine {
// VoipCodec provides codec configuration APIs for encoder and decoders.
virtual VoipCodec& Codec() = 0;
// VoipDtmf provides DTMF event APIs to register and send DTMF events.
virtual VoipDtmf& Dtmf() = 0;
};
} // namespace webrtc