Home | History | Annotate | Download | only in include
      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 {
     47 public:
     48     // Factory for the VoEVolumeControl sub-API. Increases an internal
     49     // reference counter if successful. Returns NULL if the API is not
     50     // supported or if construction fails.
     51     static VoEVolumeControl* GetInterface(VoiceEngine* voiceEngine);
     52 
     53     // Releases the VoEVolumeControl sub-API and decreases an internal
     54     // reference counter. Returns the new reference count. This value should
     55     // be zero for all sub-API:s before the VoiceEngine object can be safely
     56     // deleted.
     57     virtual int Release() = 0;
     58 
     59     // Sets the speaker |volume| level. Valid range is [0,255].
     60     virtual int SetSpeakerVolume(unsigned int volume) = 0;
     61 
     62     // Gets the speaker |volume| level.
     63     virtual int GetSpeakerVolume(unsigned int& volume) = 0;
     64 
     65     // Sets the microphone volume level. Valid range is [0,255].
     66     virtual int SetMicVolume(unsigned int volume) = 0;
     67 
     68     // Gets the microphone volume level.
     69     virtual int GetMicVolume(unsigned int& volume) = 0;
     70 
     71     // Mutes the microphone input signal completely without affecting
     72     // the audio device volume.
     73     virtual int SetInputMute(int channel, bool enable) = 0;
     74 
     75     // Gets the current microphone input mute state.
     76     virtual int GetInputMute(int channel, bool& enabled) = 0;
     77 
     78     // Gets the microphone speech |level|, mapped non-linearly to the range
     79     // [0,9].
     80     virtual int GetSpeechInputLevel(unsigned int& level) = 0;
     81 
     82     // Gets the speaker speech |level|, mapped non-linearly to the range
     83     // [0,9].
     84     virtual int GetSpeechOutputLevel(int channel, unsigned int& level) = 0;
     85 
     86     // Gets the microphone speech |level|, mapped linearly to the range
     87     // [0,32768].
     88     virtual int GetSpeechInputLevelFullRange(unsigned int& level) = 0;
     89 
     90     // Gets the speaker speech |level|, mapped linearly to the range [0,32768].
     91     virtual int GetSpeechOutputLevelFullRange(
     92         int channel, unsigned int& level) = 0;
     93 
     94     // Sets a volume |scaling| applied to the outgoing signal of a specific
     95     // channel. Valid scale range is [0.0, 10.0].
     96     virtual int SetChannelOutputVolumeScaling(int channel, float scaling) = 0;
     97 
     98     // Gets the current volume scaling for a specified |channel|.
     99     virtual int GetChannelOutputVolumeScaling(int channel, float& scaling) = 0;
    100 
    101     // Scales volume of the |left| and |right| channels independently.
    102     // Valid scale range is [0.0, 1.0].
    103     virtual int SetOutputVolumePan(int channel, float left, float right) = 0;
    104 
    105     // Gets the current left and right scaling factors.
    106     virtual int GetOutputVolumePan(int channel, float& left, float& right) = 0;
    107 
    108     // Don't use. Will be removed.
    109     virtual int SetSystemOutputMute(bool enable) { return -1; }
    110     virtual int GetSystemOutputMute(bool &enabled) { return -1; }
    111     virtual int SetSystemInputMute(bool enable) { return -1; }
    112     virtual int GetSystemInputMute(bool& enabled) { return -1; }
    113 
    114 protected:
    115     VoEVolumeControl() {};
    116     virtual ~VoEVolumeControl() {};
    117 };
    118 
    119 }  // namespace webrtc
    120 
    121 #endif  // #ifndef WEBRTC_VOICE_ENGINE_VOE_VOLUME_CONTROL_H
    122