tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

audio_device_generic.h (5386B)


      1 /*
      2 *  Copyright (c) 2012 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 #ifndef AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H_
     12 #define AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H_
     13 
     14 #include <cstdint>
     15 
     16 #include "api/audio/audio_device.h"
     17 #include "api/audio/audio_device_defines.h"
     18 #include "modules/audio_device/audio_device_buffer.h"
     19 
     20 namespace webrtc {
     21 
     22 class AudioDeviceGeneric {
     23 public:
     24  // For use with UMA logging. Must be kept in sync with histograms.xml in
     25  // Chrome, located at
     26  // https://cs.chromium.org/chromium/src/tools/metrics/histograms/histograms.xml
     27  enum class InitStatus {
     28    OK = 0,
     29    PLAYOUT_ERROR = 1,
     30    RECORDING_ERROR = 2,
     31    OTHER_ERROR = 3,
     32    NUM_STATUSES = 4
     33  };
     34  // Retrieve the currently utilized audio layer
     35  virtual int32_t ActiveAudioLayer(
     36      AudioDeviceModule::AudioLayer& audioLayer) const = 0;
     37 
     38  // Main initializaton and termination
     39  virtual InitStatus Init() = 0;
     40  virtual int32_t Terminate() = 0;
     41  virtual bool Initialized() const = 0;
     42 
     43  // Device enumeration
     44  virtual int16_t PlayoutDevices() = 0;
     45  virtual int16_t RecordingDevices() = 0;
     46  virtual int32_t PlayoutDeviceName(uint16_t index,
     47                                    char name[kAdmMaxDeviceNameSize],
     48                                    char guid[kAdmMaxGuidSize]) = 0;
     49  virtual int32_t RecordingDeviceName(uint16_t index,
     50                                      char name[kAdmMaxDeviceNameSize],
     51                                      char guid[kAdmMaxGuidSize]) = 0;
     52 
     53  // Device selection
     54  virtual int32_t SetPlayoutDevice(uint16_t index) = 0;
     55  virtual int32_t SetPlayoutDevice(
     56      AudioDeviceModule::WindowsDeviceType device) = 0;
     57  virtual int32_t SetRecordingDevice(uint16_t index) = 0;
     58  virtual int32_t SetRecordingDevice(
     59      AudioDeviceModule::WindowsDeviceType device) = 0;
     60 
     61  // Audio transport initialization
     62  virtual int32_t PlayoutIsAvailable(bool& available) = 0;
     63  virtual int32_t InitPlayout() = 0;
     64  virtual bool PlayoutIsInitialized() const = 0;
     65  virtual int32_t RecordingIsAvailable(bool& available) = 0;
     66  virtual int32_t InitRecording() = 0;
     67  virtual bool RecordingIsInitialized() const = 0;
     68 
     69  // Audio transport control
     70  virtual int32_t StartPlayout() = 0;
     71  virtual int32_t StopPlayout() = 0;
     72  virtual bool Playing() const = 0;
     73  virtual int32_t StartRecording() = 0;
     74  virtual int32_t StopRecording() = 0;
     75  virtual bool Recording() const = 0;
     76 
     77  // Audio mixer initialization
     78  virtual int32_t InitSpeaker() = 0;
     79  virtual bool SpeakerIsInitialized() const = 0;
     80  virtual int32_t InitMicrophone() = 0;
     81  virtual bool MicrophoneIsInitialized() const = 0;
     82 
     83  // Speaker volume controls
     84  virtual int32_t SpeakerVolumeIsAvailable(bool& available) = 0;
     85  virtual int32_t SetSpeakerVolume(uint32_t volume) = 0;
     86  virtual int32_t SpeakerVolume(uint32_t& volume) const = 0;
     87  virtual int32_t MaxSpeakerVolume(uint32_t& maxVolume) const = 0;
     88  virtual int32_t MinSpeakerVolume(uint32_t& minVolume) const = 0;
     89 
     90  // Microphone volume controls
     91  virtual int32_t MicrophoneVolumeIsAvailable(bool& available) = 0;
     92  virtual int32_t SetMicrophoneVolume(uint32_t volume) = 0;
     93  virtual int32_t MicrophoneVolume(uint32_t& volume) const = 0;
     94  virtual int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const = 0;
     95  virtual int32_t MinMicrophoneVolume(uint32_t& minVolume) const = 0;
     96 
     97  // Speaker mute control
     98  virtual int32_t SpeakerMuteIsAvailable(bool& available) = 0;
     99  virtual int32_t SetSpeakerMute(bool enable) = 0;
    100  virtual int32_t SpeakerMute(bool& enabled) const = 0;
    101 
    102  // Microphone mute control
    103  virtual int32_t MicrophoneMuteIsAvailable(bool& available) = 0;
    104  virtual int32_t SetMicrophoneMute(bool enable) = 0;
    105  virtual int32_t MicrophoneMute(bool& enabled) const = 0;
    106 
    107  // Stereo support
    108  virtual int32_t StereoPlayoutIsAvailable(bool& available) = 0;
    109  virtual int32_t SetStereoPlayout(bool enable) = 0;
    110  virtual int32_t StereoPlayout(bool& enabled) const = 0;
    111  virtual int32_t StereoRecordingIsAvailable(bool& available) = 0;
    112  virtual int32_t SetStereoRecording(bool enable) = 0;
    113  virtual int32_t StereoRecording(bool& enabled) const = 0;
    114 
    115  // Delay information and control
    116  virtual int32_t PlayoutDelay(uint16_t& delayMS) const = 0;
    117 
    118  // Android only
    119  virtual bool BuiltInAECIsAvailable() const;
    120  virtual bool BuiltInAGCIsAvailable() const;
    121  virtual bool BuiltInNSIsAvailable() const;
    122 
    123  // Windows Core Audio and Android only.
    124  virtual int32_t EnableBuiltInAEC(bool enable);
    125  virtual int32_t EnableBuiltInAGC(bool enable);
    126  virtual int32_t EnableBuiltInNS(bool enable);
    127 
    128  // Play underrun count.
    129  virtual int32_t GetPlayoutUnderrunCount() const;
    130 
    131 // iOS only.
    132 // TODO(henrika): add Android support.
    133 #if defined(WEBRTC_IOS)
    134  virtual int GetPlayoutAudioParameters(AudioParameters* params) const;
    135  virtual int GetRecordAudioParameters(AudioParameters* params) const;
    136 #endif  // WEBRTC_IOS
    137 
    138  virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) = 0;
    139 
    140  virtual ~AudioDeviceGeneric() {}
    141 };
    142 
    143 }  // namespace webrtc
    144 
    145 #endif  // AUDIO_DEVICE_AUDIO_DEVICE_GENERIC_H_