• 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 //  - Speaker volume controls.
14 //  - Microphone volume control.
15 //  - Non-linear speech level control.
16 //  - Mute functions.
17 //  - Additional stereo scaling methods.
18 //
19 // Usage example, omitting error checking:
20 //
21 //  using namespace webrtc;
22 //  VoiceEngine* voe = VoiceEngine::Create();
23 //  VoEBase* base = VoEBase::GetInterface(voe);
24 //  VoEVolumeControl* volume  = VoEVolumeControl::GetInterface(voe);
25 //  base->Init();
26 //  int ch = base->CreateChannel();
27 //  ...
28 //  volume->SetInputMute(ch, true);
29 //  ...
30 //  base->DeleteChannel(ch);
31 //  base->Terminate();
32 //  base->Release();
33 //  volume->Release();
34 //  VoiceEngine::Delete(voe);
35 //
36 #ifndef WEBRTC_VOICE_ENGINE_VOE_VOLUME_CONTROL_H
37 #define WEBRTC_VOICE_ENGINE_VOE_VOLUME_CONTROL_H
38 
39 #include "webrtc/common_types.h"
40 
41 namespace webrtc {
42 
43 class VoiceEngine;
44 
45 class WEBRTC_DLLEXPORT VoEVolumeControl {
46  public:
47   // Factory for the VoEVolumeControl sub-API. Increases an internal
48   // reference counter if successful. Returns NULL if the API is not
49   // supported or if construction fails.
50   static VoEVolumeControl* GetInterface(VoiceEngine* voiceEngine);
51 
52   // Releases the VoEVolumeControl sub-API and decreases an internal
53   // reference counter. Returns the new reference count. This value should
54   // be zero for all sub-API:s before the VoiceEngine object can be safely
55   // deleted.
56   virtual int Release() = 0;
57 
58   // Sets the speaker |volume| level. Valid range is [0,255].
59   virtual int SetSpeakerVolume(unsigned int volume) = 0;
60 
61   // Gets the speaker |volume| level.
62   virtual int GetSpeakerVolume(unsigned int& volume) = 0;
63 
64   // Sets the microphone volume level. Valid range is [0,255].
65   virtual int SetMicVolume(unsigned int volume) = 0;
66 
67   // Gets the microphone volume level.
68   virtual int GetMicVolume(unsigned int& volume) = 0;
69 
70   // Mutes the microphone input signal completely without affecting
71   // the audio device volume.
72   virtual int SetInputMute(int channel, bool enable) = 0;
73 
74   // Gets the current microphone input mute state.
75   virtual int GetInputMute(int channel, bool& enabled) = 0;
76 
77   // Gets the microphone speech |level|, mapped non-linearly to the range
78   // [0,9].
79   virtual int GetSpeechInputLevel(unsigned int& level) = 0;
80 
81   // Gets the speaker speech |level|, mapped non-linearly to the range
82   // [0,9].
83   virtual int GetSpeechOutputLevel(int channel, unsigned int& level) = 0;
84 
85   // Gets the microphone speech |level|, mapped linearly to the range
86   // [0,32768].
87   virtual int GetSpeechInputLevelFullRange(unsigned int& level) = 0;
88 
89   // Gets the speaker speech |level|, mapped linearly to the range [0,32768].
90   virtual int GetSpeechOutputLevelFullRange(int channel,
91                                             unsigned int& level) = 0;
92 
93   // Sets a volume |scaling| applied to the outgoing signal of a specific
94   // channel. Valid scale range is [0.0, 10.0].
95   virtual int SetChannelOutputVolumeScaling(int channel, float scaling) = 0;
96 
97   // Gets the current volume scaling for a specified |channel|.
98   virtual int GetChannelOutputVolumeScaling(int channel, float& scaling) = 0;
99 
100   // Scales volume of the |left| and |right| channels independently.
101   // Valid scale range is [0.0, 1.0].
102   virtual int SetOutputVolumePan(int channel, float left, float right) = 0;
103 
104   // Gets the current left and right scaling factors.
105   virtual int GetOutputVolumePan(int channel, float& left, float& right) = 0;
106 
107  protected:
VoEVolumeControl()108   VoEVolumeControl(){};
~VoEVolumeControl()109   virtual ~VoEVolumeControl(){};
110 };
111 
112 }  // namespace webrtc
113 
114 #endif  // #ifndef WEBRTC_VOICE_ENGINE_VOE_VOLUME_CONTROL_H
115