niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 39 | #include "webrtc/common_types.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | |
| 41 | namespace webrtc { |
| 42 | |
| 43 | class VoiceEngine; |
| 44 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 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); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 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; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 58 | // Sets the speaker |volume| level. Valid range is [0,255]. |
| 59 | virtual int SetSpeakerVolume(unsigned int volume) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 61 | // Gets the speaker |volume| level. |
| 62 | virtual int GetSpeakerVolume(unsigned int& volume) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 64 | // Sets the microphone volume level. Valid range is [0,255]. |
| 65 | virtual int SetMicVolume(unsigned int volume) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 67 | // Gets the microphone volume level. |
| 68 | virtual int GetMicVolume(unsigned int& volume) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 70 | // Mutes the microphone input signal completely without affecting |
| 71 | // the audio device volume. |
| 72 | virtual int SetInputMute(int channel, bool enable) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 74 | // Gets the current microphone input mute state. |
| 75 | virtual int GetInputMute(int channel, bool& enabled) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 77 | // Gets the microphone speech |level|, mapped non-linearly to the range |
| 78 | // [0,9]. |
| 79 | virtual int GetSpeechInputLevel(unsigned int& level) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 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; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 85 | // Gets the microphone speech |level|, mapped linearly to the range |
| 86 | // [0,32768]. |
| 87 | virtual int GetSpeechInputLevelFullRange(unsigned int& level) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 89 | // Gets the speaker speech |level|, mapped linearly to the range [0,32768]. |
| 90 | virtual int GetSpeechOutputLevelFullRange(int channel, |
| 91 | unsigned int& level) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 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; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 96 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 97 | // Gets the current volume scaling for a specified |channel|. |
| 98 | virtual int GetChannelOutputVolumeScaling(int channel, float& scaling) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 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; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 103 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 104 | // Gets the current left and right scaling factors. |
| 105 | virtual int GetOutputVolumePan(int channel, float& left, float& right) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 107 | protected: |
| 108 | VoEVolumeControl(){}; |
| 109 | virtual ~VoEVolumeControl(){}; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | } // namespace webrtc |
| 113 | |
| 114 | #endif // #ifndef WEBRTC_VOICE_ENGINE_VOE_VOLUME_CONTROL_H |