blob: 1c6b7fc830611aacfb503f510aee3a0e9ce6fde3 [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
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000035#include "webrtc/common_types.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000036
37namespace webrtc {
38
39class VoiceEngine;
40
Jelena Marusic0d266052015-05-04 14:15:32 +020041class WEBRTC_DLLEXPORT VoEHardware {
42 public:
43 // Factory for the VoEHardware sub-API. Increases an internal
44 // reference counter if successful. Returns NULL if the API is not
45 // supported or if construction fails.
46 static VoEHardware* GetInterface(VoiceEngine* voiceEngine);
niklase@google.com470e71d2011-07-07 08:21:25 +000047
Jelena Marusic0d266052015-05-04 14:15:32 +020048 // Releases the VoEHardware sub-API and decreases an internal
49 // reference counter. Returns the new reference count. This value should
50 // be zero for all sub-API:s before the VoiceEngine object can be safely
51 // deleted.
52 virtual int Release() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000053
Jelena Marusic0d266052015-05-04 14:15:32 +020054 // Gets the number of audio devices available for recording.
55 virtual int GetNumOfRecordingDevices(int& devices) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000056
Jelena Marusic0d266052015-05-04 14:15:32 +020057 // Gets the number of audio devices available for playout.
58 virtual int GetNumOfPlayoutDevices(int& devices) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000059
Jelena Marusic0d266052015-05-04 14:15:32 +020060 // Gets the name of a specific recording device given by an |index|.
61 // On Windows Vista/7, it also retrieves an additional unique ID
62 // (GUID) for the recording device.
63 virtual int GetRecordingDeviceName(int index,
64 char strNameUTF8[128],
niklase@google.com470e71d2011-07-07 08:21:25 +000065 char strGuidUTF8[128]) = 0;
66
Jelena Marusic0d266052015-05-04 14:15:32 +020067 // 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,
71 char strNameUTF8[128],
72 char strGuidUTF8[128]) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000073
Jelena Marusic0d266052015-05-04 14:15:32 +020074 // Sets the audio device used for recording.
75 virtual int SetRecordingDevice(
76 int index,
77 StereoChannel recordingChannel = kStereoBoth) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000078
Jelena Marusic0d266052015-05-04 14:15:32 +020079 // Sets the audio device used for playout.
80 virtual int SetPlayoutDevice(int index) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000081
Jelena Marusic0d266052015-05-04 14:15:32 +020082 // Sets the type of audio device layer to use.
83 virtual int SetAudioDeviceLayer(AudioLayers audioLayer) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000084
Jelena Marusic0d266052015-05-04 14:15:32 +020085 // Gets the currently used (active) audio device layer.
86 virtual int GetAudioDeviceLayer(AudioLayers& audioLayer) = 0;
leozwang@webrtc.org96bcac82012-12-04 19:11:55 +000087
Jelena Marusic0d266052015-05-04 14:15:32 +020088 // Native sample rate controls (samples/sec)
89 virtual int SetRecordingSampleRate(unsigned int samples_per_sec) = 0;
90 virtual int RecordingSampleRate(unsigned int* samples_per_sec) const = 0;
91 virtual int SetPlayoutSampleRate(unsigned int samples_per_sec) = 0;
92 virtual int PlayoutSampleRate(unsigned int* samples_per_sec) const = 0;
henrika@webrtc.orga954c072014-12-09 16:22:09 +000093
Jelena Marusic0d266052015-05-04 14:15:32 +020094 virtual bool BuiltInAECIsAvailable() const = 0;
95 virtual int EnableBuiltInAEC(bool enable) = 0;
henrika@webrtc.org3b766272014-05-09 11:43:00 +000096
Jelena Marusic0d266052015-05-04 14:15:32 +020097 // To be removed. Don't use.
98 virtual bool BuiltInAECIsEnabled() const { return false; }
99 virtual int GetRecordingDeviceStatus(bool& isAvailable) { return -1; }
100 virtual int GetPlayoutDeviceStatus(bool& isAvailable) { return -1; }
101 virtual int ResetAudioDevice() { return -1; }
102 virtual int AudioDeviceControl(unsigned int par1,
103 unsigned int par2,
104 unsigned int par3) {
105 return -1;
106 }
107 virtual int SetLoudspeakerStatus(bool enable) { return -1; }
108 virtual int GetLoudspeakerStatus(bool& enabled) { return -1; }
109 virtual int GetCPULoad(int& loadPercent) { return -1; }
andrew@webrtc.orga3c6d612011-09-13 17:17:49 +0000110
Jelena Marusic0d266052015-05-04 14:15:32 +0200111 protected:
112 VoEHardware() {}
113 virtual ~VoEHardware() {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000114};
115
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000116} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000117
118#endif // WEBRTC_VOICE_ENGINE_VOE_HARDWARE_H