1/*
2 *  Copyright (c) 2013 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 utility will portably force the volume of the default microphone to max.
12
13#include <stdio.h>
14
15#include "webrtc/system_wrappers/interface/scoped_ptr.h"
16#include "webrtc/test/channel_transport/include/channel_transport.h"
17#include "webrtc/voice_engine/include/voe_audio_processing.h"
18#include "webrtc/voice_engine/include/voe_base.h"
19#include "webrtc/voice_engine/include/voe_volume_control.h"
20
21int main(int argc, char** argv) {
22  webrtc::VoiceEngine* voe = webrtc::VoiceEngine::Create();
23  if (voe == NULL) {
24    fprintf(stderr, "Failed to initialize voice engine.\n");
25    return 1;
26  }
27
28  webrtc::VoEBase* base = webrtc::VoEBase::GetInterface(voe);
29  webrtc::VoEVolumeControl* volume_control =
30      webrtc::VoEVolumeControl::GetInterface(voe);
31
32  if (base->Init() != 0) {
33    fprintf(stderr, "Failed to initialize voice engine base.\n");
34    return 1;
35  }
36  // Set to 0 first in case the mic is above 100%.
37  if (volume_control->SetMicVolume(0) != 0) {
38    fprintf(stderr, "Failed set volume to 0.\n");
39    return 1;
40  }
41  if (volume_control->SetMicVolume(255) != 0) {
42    fprintf(stderr, "Failed set volume to 255.\n");
43    return 1;
44  }
45
46  return 0;
47}
48