• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 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 // This sub-API supports the following functionalities:
12 //
13 //  - Telephone event transmission.
14 //  - DTMF tone generation.
15 //
16 // Usage example, omitting error checking:
17 //
18 //  using namespace webrtc;
19 //  VoiceEngine* voe = VoiceEngine::Create();
20 //  VoEBase* base = VoEBase::GetInterface(voe);
21 //  VoEDtmf* dtmf  = VoEDtmf::GetInterface(voe);
22 //  base->Init();
23 //  int ch = base->CreateChannel();
24 //  ...
25 //  dtmf->SendTelephoneEvent(ch, 7);
26 //  ...
27 //  base->DeleteChannel(ch);
28 //  base->Terminate();
29 //  base->Release();
30 //  dtmf->Release();
31 //  VoiceEngine::Delete(voe);
32 //
33 #ifndef WEBRTC_VOICE_ENGINE_VOE_DTMF_H
34 #define WEBRTC_VOICE_ENGINE_VOE_DTMF_H
35 
36 #include "webrtc/common_types.h"
37 
38 namespace webrtc {
39 
40 class VoiceEngine;
41 
42 // VoEDtmf
43 class WEBRTC_DLLEXPORT VoEDtmf {
44  public:
45   // Factory for the VoEDtmf sub-API. Increases an internal
46   // reference counter if successful. Returns NULL if the API is not
47   // supported or if construction fails.
48   static VoEDtmf* GetInterface(VoiceEngine* voiceEngine);
49 
50   // Releases the VoEDtmf sub-API and decreases an internal
51   // reference counter. Returns the new reference count. This value should
52   // be zero for all sub-API:s before the VoiceEngine object can be safely
53   // deleted.
54   virtual int Release() = 0;
55 
56   // Sends telephone events either in-band or out-of-band.
57   virtual int SendTelephoneEvent(int channel,
58                                  int eventCode,
59                                  bool outOfBand = true,
60                                  int lengthMs = 160,
61                                  int attenuationDb = 10) = 0;
62 
63   // Sets the dynamic payload |type| that should be used for telephone
64   // events.
65   virtual int SetSendTelephoneEventPayloadType(int channel,
66                                                unsigned char type) = 0;
67 
68   // Gets the currently set dynamic payload |type| for telephone events.
69   virtual int GetSendTelephoneEventPayloadType(int channel,
70                                                unsigned char& type) = 0;
71 
72   // Toogles DTMF feedback state: when a DTMF tone is sent, the same tone
73   // is played out on the speaker.
74   virtual int SetDtmfFeedbackStatus(bool enable,
75                                     bool directFeedback = false) = 0;
76 
77   // Gets the DTMF feedback status.
78   virtual int GetDtmfFeedbackStatus(bool& enabled, bool& directFeedback) = 0;
79 
80   // Plays a DTMF feedback tone (only locally).
81   virtual int PlayDtmfTone(int eventCode,
82                            int lengthMs = 200,
83                            int attenuationDb = 10) = 0;
84 
85  protected:
VoEDtmf()86   VoEDtmf() {}
~VoEDtmf()87   virtual ~VoEDtmf() {}
88 };
89 
90 }  // namespace webrtc
91 
92 #endif  // WEBRTC_VOICE_ENGINE_VOE_DTMF_H
93