niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | // - 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.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 35 | #include "webrtc/common_types.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
| 37 | namespace webrtc { |
| 38 | |
| 39 | class VoiceEngine; |
| 40 | |
| 41 | class WEBRTC_DLLEXPORT VoEHardware |
| 42 | { |
| 43 | public: |
| 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 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | // Sets the audio device used for recording. |
| 74 | virtual int SetRecordingDevice( |
| 75 | int index, StereoChannel recordingChannel = kStereoBoth) = 0; |
| 76 | |
| 77 | // Sets the audio device used for playout. |
| 78 | virtual int SetPlayoutDevice(int index) = 0; |
| 79 | |
| 80 | // Sets the type of audio device layer to use. |
| 81 | virtual int SetAudioDeviceLayer(AudioLayers audioLayer) = 0; |
| 82 | |
| 83 | // Gets the currently used (active) audio device layer. |
| 84 | virtual int GetAudioDeviceLayer(AudioLayers& audioLayer) = 0; |
| 85 | |
leozwang@webrtc.org | 96bcac8 | 2012-12-04 19:11:55 +0000 | [diff] [blame] | 86 | // Native sample rate controls (samples/sec) |
| 87 | virtual int SetRecordingSampleRate(unsigned int samples_per_sec) = 0; |
| 88 | virtual int RecordingSampleRate(unsigned int* samples_per_sec) const = 0; |
| 89 | virtual int SetPlayoutSampleRate(unsigned int samples_per_sec) = 0; |
| 90 | virtual int PlayoutSampleRate(unsigned int* samples_per_sec) const = 0; |
| 91 | |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame^] | 92 | virtual bool BuiltInAECIsAvailable() const = 0; |
| 93 | virtual int EnableBuiltInAEC(bool enable) = 0; |
| 94 | |
henrika@webrtc.org | 3b76627 | 2014-05-09 11:43:00 +0000 | [diff] [blame] | 95 | // To be removed. Don't use. |
henrika@webrtc.org | 3b76627 | 2014-05-09 11:43:00 +0000 | [diff] [blame] | 96 | virtual bool BuiltInAECIsEnabled() const { return false; } |
| 97 | virtual int GetRecordingDeviceStatus(bool& isAvailable) { return -1; } |
| 98 | virtual int GetPlayoutDeviceStatus(bool& isAvailable) { return -1; } |
| 99 | virtual int ResetAudioDevice() { return -1; } |
| 100 | virtual int AudioDeviceControl(unsigned int par1, unsigned int par2, |
| 101 | unsigned int par3) { return -1; } |
| 102 | virtual int SetLoudspeakerStatus(bool enable) { return -1; } |
| 103 | virtual int GetLoudspeakerStatus(bool& enabled) { return -1; } |
| 104 | virtual int GetCPULoad(int& loadPercent) { return -1; } |
| 105 | |
andrew@webrtc.org | a3c6d61 | 2011-09-13 17:17:49 +0000 | [diff] [blame] | 106 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 107 | protected: |
| 108 | VoEHardware() {} |
| 109 | virtual ~VoEHardware() {} |
| 110 | }; |
| 111 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 112 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | |
| 114 | #endif // WEBRTC_VOICE_ENGINE_VOE_HARDWARE_H |