blob: 24ed1ff8f81a49491d8fb7f5dabe37c108936495 [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// - Audio device handling.
14// - Device information.
15// - CPU load monitoring.
16//
17// Usage example, omitting error checking:
18//
19// using namespace webrtc;
20// VoiceEngine* voe = VoiceEngine::Create();
21// VoEBase* base = VoEBase::GetInterface(voe);
22// VoEHardware* hardware = VoEHardware::GetInterface(voe);
23// base->Init();
24// ...
25// int n_devices = hardware->GetNumOfPlayoutDevices();
26// ...
27// base->Terminate();
28// base->Release();
29// hardware->Release();
30// VoiceEngine::Delete(voe);
31//
32#ifndef WEBRTC_VOICE_ENGINE_VOE_HARDWARE_H
33#define WEBRTC_VOICE_ENGINE_VOE_HARDWARE_H
34
35#include "common_types.h"
36
37namespace webrtc {
38
39class VoiceEngine;
40
41class WEBRTC_DLLEXPORT VoEHardware
42{
43public:
44 // Factory for the VoEHardware sub-API. Increases an internal
45 // reference counter if successful. Returns NULL if the API is not
46 // supported or if construction fails.
47 static VoEHardware* GetInterface(VoiceEngine* voiceEngine);
48
49 // Releases the VoEHardware sub-API and decreases an internal
50 // reference counter. Returns the new reference count. This value should
51 // be zero for all sub-API:s before the VoiceEngine object can be safely
52 // deleted.
53 virtual int Release() = 0;
54
55 // Gets the number of audio devices available for recording.
56 virtual int GetNumOfRecordingDevices(int& devices) = 0;
57
58 // Gets the number of audio devices available for playout.
59 virtual int GetNumOfPlayoutDevices(int& devices) = 0;
60
61 // Gets the name of a specific recording device given by an |index|.
62 // On Windows Vista/7, it also retrieves an additional unique ID
63 // (GUID) for the recording device.
64 virtual int GetRecordingDeviceName(int index, char strNameUTF8[128],
65 char strGuidUTF8[128]) = 0;
66
67 // Gets the name of a specific playout device given by an |index|.
68 // On Windows Vista/7, it also retrieves an additional unique ID
69 // (GUID) for the playout device.
70 virtual int GetPlayoutDeviceName(int index, char strNameUTF8[128],
71 char strGuidUTF8[128]) = 0;
72
73 // Checks if the sound card is available to be opened for recording.
74 virtual int GetRecordingDeviceStatus(bool& isAvailable) = 0;
75
76 // Checks if the sound card is available to be opened for playout.
77 virtual int GetPlayoutDeviceStatus(bool& isAvailable) = 0;
78
79 // Sets the audio device used for recording.
80 virtual int SetRecordingDevice(
81 int index, StereoChannel recordingChannel = kStereoBoth) = 0;
82
83 // Sets the audio device used for playout.
84 virtual int SetPlayoutDevice(int index) = 0;
85
86 // Sets the type of audio device layer to use.
87 virtual int SetAudioDeviceLayer(AudioLayers audioLayer) = 0;
88
89 // Gets the currently used (active) audio device layer.
90 virtual int GetAudioDeviceLayer(AudioLayers& audioLayer) = 0;
91
phoglund@webrtc.org5badc7e2012-01-18 10:46:07 +000092 // Gets the VoiceEngine's current CPU consumption in terms of the percent
niklase@google.com470e71d2011-07-07 08:21:25 +000093 // of total CPU availability. [Windows only]
94 virtual int GetCPULoad(int& loadPercent) = 0;
95
phoglund@webrtc.org5badc7e2012-01-18 10:46:07 +000096 // Gets the computer's current CPU consumption in terms of the percent
97 // of the total CPU availability. This method may fail a few times on
98 // Windows because it needs a certain warm-up time before reporting the
99 // result. You should check the return value and either try again or
100 // give up when it fails.
niklase@google.com470e71d2011-07-07 08:21:25 +0000101 virtual int GetSystemCPULoad(int& loadPercent) = 0;
102
103 // Not supported
104 virtual int ResetAudioDevice() = 0;
105
106 // Not supported
107 virtual int AudioDeviceControl(
108 unsigned int par1, unsigned int par2, unsigned int par3) = 0;
109
110 // Not supported
111 virtual int SetLoudspeakerStatus(bool enable) = 0;
112
113 // Not supported
114 virtual int GetLoudspeakerStatus(bool& enabled) = 0;
115
andrew@webrtc.orga3c6d612011-09-13 17:17:49 +0000116 // *Experimental - not recommended for use.*
117 // Enables the Windows Core Audio built-in AEC. Fails on other platforms.
118 //
119 // Currently incompatible with the standard VoE AEC and AGC; don't attempt
120 // to enable them while this is active.
121 //
122 // Must be called before VoEBase::StartSend(). When enabled:
123 // 1. VoEBase::StartPlayout() must be called before VoEBase::StartSend().
124 // 2. VoEBase::StopSend() should be called before VoEBase::StopPlayout().
125 // The reverse order may cause garbage audio to be rendered or the
andrew@webrtc.orgb524f442011-09-13 18:04:30 +0000126 // capture side to halt until StopSend() is called.
andrew@webrtc.orga3c6d612011-09-13 17:17:49 +0000127 //
128 // As a consequence, SetPlayoutDevice() should be used with caution
129 // during a call. It will function, but may cause the above issues for
130 // the duration it takes to complete. (In practice, it should complete
131 // fast enough to avoid audible degradation).
132 virtual int EnableBuiltInAEC(bool enable) = 0;
133 virtual bool BuiltInAECIsEnabled() const = 0;
134
niklase@google.com470e71d2011-07-07 08:21:25 +0000135protected:
136 VoEHardware() {}
137 virtual ~VoEHardware() {}
138};
139
140} // namespace webrtc
141
142#endif // WEBRTC_VOICE_ENGINE_VOE_HARDWARE_H