blob: 240ab935af41d4355ee207b1c2a8cd9d2eb2412a [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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.org956aa7e2013-05-21 13:52:32 +000039#include "webrtc/common_types.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000040
41namespace webrtc {
42
43class VoiceEngine;
44
Jelena Marusic0d266052015-05-04 14:15:32 +020045class 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.com470e71d2011-07-07 08:21:25 +000051
Jelena Marusic0d266052015-05-04 14:15:32 +020052 // 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.com470e71d2011-07-07 08:21:25 +000057
Jelena Marusic0d266052015-05-04 14:15:32 +020058 // Sets the speaker |volume| level. Valid range is [0,255].
59 virtual int SetSpeakerVolume(unsigned int volume) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000060
Jelena Marusic0d266052015-05-04 14:15:32 +020061 // Gets the speaker |volume| level.
62 virtual int GetSpeakerVolume(unsigned int& volume) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000063
Jelena Marusic0d266052015-05-04 14:15:32 +020064 // Sets the microphone volume level. Valid range is [0,255].
65 virtual int SetMicVolume(unsigned int volume) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000066
Jelena Marusic0d266052015-05-04 14:15:32 +020067 // Gets the microphone volume level.
68 virtual int GetMicVolume(unsigned int& volume) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000069
Jelena Marusic0d266052015-05-04 14:15:32 +020070 // Mutes the microphone input signal completely without affecting
71 // the audio device volume.
72 virtual int SetInputMute(int channel, bool enable) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000073
Jelena Marusic0d266052015-05-04 14:15:32 +020074 // Gets the current microphone input mute state.
75 virtual int GetInputMute(int channel, bool& enabled) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000076
Jelena Marusic0d266052015-05-04 14:15:32 +020077 // Gets the microphone speech |level|, mapped non-linearly to the range
78 // [0,9].
79 virtual int GetSpeechInputLevel(unsigned int& level) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000080
Jelena Marusic0d266052015-05-04 14:15:32 +020081 // 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.com470e71d2011-07-07 08:21:25 +000084
Jelena Marusic0d266052015-05-04 14:15:32 +020085 // Gets the microphone speech |level|, mapped linearly to the range
86 // [0,32768].
87 virtual int GetSpeechInputLevelFullRange(unsigned int& level) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000088
Jelena Marusic0d266052015-05-04 14:15:32 +020089 // 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.com470e71d2011-07-07 08:21:25 +000092
Jelena Marusic0d266052015-05-04 14:15:32 +020093 // 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.com470e71d2011-07-07 08:21:25 +000096
Jelena Marusic0d266052015-05-04 14:15:32 +020097 // Gets the current volume scaling for a specified |channel|.
98 virtual int GetChannelOutputVolumeScaling(int channel, float& scaling) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000099
Jelena Marusic0d266052015-05-04 14:15:32 +0200100 // 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.com470e71d2011-07-07 08:21:25 +0000103
Jelena Marusic0d266052015-05-04 14:15:32 +0200104 // Gets the current left and right scaling factors.
105 virtual int GetOutputVolumePan(int channel, float& left, float& right) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
Jelena Marusic0d266052015-05-04 14:15:32 +0200107 protected:
108 VoEVolumeControl(){};
109 virtual ~VoEVolumeControl(){};
niklase@google.com470e71d2011-07-07 08:21:25 +0000110};
111
112} // namespace webrtc
113
114#endif // #ifndef WEBRTC_VOICE_ENGINE_VOE_VOLUME_CONTROL_H