aboutsummaryrefslogtreecommitdiff
path: root/webrtc/voice_engine/include/voe_dtmf.h
blob: 4db8cbc5968d81886eb48c12a4b15156ec72513e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
 *  Copyright (c) 2011 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.
 */

// This sub-API supports the following functionalities:
//
//  - Telephone event transmission.
//  - DTMF tone generation.
//
// Usage example, omitting error checking:
//
//  using namespace webrtc;
//  VoiceEngine* voe = VoiceEngine::Create();
//  VoEBase* base = VoEBase::GetInterface(voe);
//  VoEDtmf* dtmf  = VoEDtmf::GetInterface(voe);
//  base->Init();
//  int ch = base->CreateChannel();
//  ...
//  dtmf->SendTelephoneEvent(ch, 7);
//  ...
//  base->DeleteChannel(ch);
//  base->Terminate();
//  base->Release();
//  dtmf->Release();
//  VoiceEngine::Delete(voe);
//
#ifndef WEBRTC_VOICE_ENGINE_VOE_DTMF_H
#define WEBRTC_VOICE_ENGINE_VOE_DTMF_H

#include "webrtc/common_types.h"

namespace webrtc {

class VoiceEngine;

// VoEDtmf
class WEBRTC_DLLEXPORT VoEDtmf
{
public:

    // Factory for the VoEDtmf sub-API. Increases an internal
    // reference counter if successful. Returns NULL if the API is not
    // supported or if construction fails.
    static VoEDtmf* GetInterface(VoiceEngine* voiceEngine);

    // Releases the VoEDtmf sub-API and decreases an internal
    // reference counter. Returns the new reference count. This value should
    // be zero for all sub-API:s before the VoiceEngine object can be safely
    // deleted.
    virtual int Release() = 0;

    // Sends telephone events either in-band or out-of-band.
    virtual int SendTelephoneEvent(int channel, int eventCode,
                                   bool outOfBand = true, int lengthMs = 160,
                                   int attenuationDb = 10) = 0;


    // Sets the dynamic payload |type| that should be used for telephone
    // events.
    virtual int SetSendTelephoneEventPayloadType(int channel,
                                                 unsigned char type) = 0;


    // Gets the currently set dynamic payload |type| for telephone events.
    virtual int GetSendTelephoneEventPayloadType(int channel,
                                                 unsigned char& type) = 0;

    // Enables or disables local tone playout for received DTMF events
    // out-of-band.
    virtual int SetDtmfPlayoutStatus(int channel, bool enable) = 0;

    // Gets the DTMF playout status.
    virtual int GetDtmfPlayoutStatus(int channel, bool& enabled) = 0;

    // Toogles DTMF feedback state: when a DTMF tone is sent, the same tone
    // is played out on the speaker.
    virtual int SetDtmfFeedbackStatus(bool enable,
                                      bool directFeedback = false) = 0;

    // Gets the DTMF feedback status.
    virtual int GetDtmfFeedbackStatus(bool& enabled, bool& directFeedback) = 0;

    // Plays a DTMF feedback tone (only locally).
    virtual int PlayDtmfTone(int eventCode, int lengthMs = 200,
                             int attenuationDb = 10) = 0;

    // To be removed. Don't use.
    virtual int StartPlayingDtmfTone(int eventCode,
        int attenuationDb = 10) { return -1; }
    virtual int StopPlayingDtmfTone() { return -1; }

protected:
    VoEDtmf() {}
    virtual ~VoEDtmf() {}
};

}  // namespace webrtc

#endif  // WEBRTC_VOICE_ENGINE_VOE_DTMF_H