andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 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 WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H |
| 12 | #define WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H |
| 13 | |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 14 | #include "webrtc/voice_engine/include/voe_base.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 15 | |
pbos@webrtc.org | 471ae72 | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 16 | #include "webrtc/modules/interface/module_common_types.h" |
| 17 | #include "webrtc/voice_engine/shared_data.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc |
| 20 | { |
| 21 | |
| 22 | class ProcessThread; |
| 23 | |
| 24 | class VoEBaseImpl: public VoEBase, |
| 25 | public AudioTransport, |
| 26 | public AudioDeviceObserver |
| 27 | { |
| 28 | public: |
| 29 | virtual int RegisterVoiceEngineObserver(VoiceEngineObserver& observer); |
| 30 | |
| 31 | virtual int DeRegisterVoiceEngineObserver(); |
| 32 | |
andrew@webrtc.org | b79627b | 2013-03-05 01:12:49 +0000 | [diff] [blame] | 33 | virtual int Init(AudioDeviceModule* external_adm = NULL, |
| 34 | AudioProcessing* audioproc = NULL); |
| 35 | virtual AudioProcessing* audio_processing() { |
| 36 | return _shared->audio_processing(); |
| 37 | } |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 38 | |
| 39 | virtual int Terminate(); |
| 40 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 41 | virtual int CreateChannel(); |
turaj@webrtc.org | b43ac9f | 2013-11-13 00:02:48 +0000 | [diff] [blame] | 42 | virtual int CreateChannel(const Config& config); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 43 | |
| 44 | virtual int DeleteChannel(int channel); |
| 45 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 46 | virtual int StartReceive(int channel); |
| 47 | |
| 48 | virtual int StartPlayout(int channel); |
| 49 | |
| 50 | virtual int StartSend(int channel); |
| 51 | |
| 52 | virtual int StopReceive(int channel); |
| 53 | |
| 54 | virtual int StopPlayout(int channel); |
| 55 | |
| 56 | virtual int StopSend(int channel); |
| 57 | |
| 58 | virtual int SetNetEQPlayoutMode(int channel, NetEqModes mode); |
| 59 | |
| 60 | virtual int GetNetEQPlayoutMode(int channel, NetEqModes& mode); |
| 61 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 62 | virtual int SetOnHoldStatus(int channel, |
| 63 | bool enable, |
| 64 | OnHoldModes mode = kHoldSendAndPlay); |
| 65 | |
| 66 | virtual int GetOnHoldStatus(int channel, bool& enabled, OnHoldModes& mode); |
| 67 | |
| 68 | virtual int GetVersion(char version[1024]); |
| 69 | |
| 70 | virtual int LastError(); |
| 71 | |
xians@webrtc.org | 942ba53 | 2014-01-29 13:54:02 +0000 | [diff] [blame^] | 72 | virtual void CaptureCallback(int voe_channel, const void* audio_data, |
| 73 | int bits_per_sample, int sample_rate, |
| 74 | int number_of_channels, int number_of_frames); |
| 75 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 76 | // AudioTransport |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 77 | virtual int32_t |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 78 | RecordedDataIsAvailable(const void* audioSamples, |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 79 | uint32_t nSamples, |
| 80 | uint8_t nBytesPerSample, |
| 81 | uint8_t nChannels, |
| 82 | uint32_t samplesPerSec, |
| 83 | uint32_t totalDelayMS, |
| 84 | int32_t clockDrift, |
| 85 | uint32_t currentMicLevel, |
| 86 | bool keyPressed, |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 87 | uint32_t& newMicLevel); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 88 | |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 89 | virtual int32_t NeedMorePlayData(uint32_t nSamples, |
| 90 | uint8_t nBytesPerSample, |
| 91 | uint8_t nChannels, |
| 92 | uint32_t samplesPerSec, |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 93 | void* audioSamples, |
| 94 | uint32_t& nSamplesOut); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 95 | |
xians@webrtc.org | 0e6fa8c | 2013-07-31 16:27:42 +0000 | [diff] [blame] | 96 | virtual int OnDataAvailable(const int voe_channels[], |
xians@webrtc.org | 44f1239 | 2013-07-31 16:23:37 +0000 | [diff] [blame] | 97 | int number_of_voe_channels, |
| 98 | const int16_t* audio_data, |
| 99 | int sample_rate, |
| 100 | int number_of_channels, |
| 101 | int number_of_frames, |
| 102 | int audio_delay_milliseconds, |
| 103 | int current_volume, |
| 104 | bool key_pressed, |
| 105 | bool need_audio_processing); |
| 106 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 107 | // AudioDeviceObserver |
pbos@webrtc.org | ca7a9a2 | 2013-05-14 08:31:39 +0000 | [diff] [blame] | 108 | virtual void OnErrorIsReported(ErrorCode error); |
| 109 | virtual void OnWarningIsReported(WarningCode warning); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 110 | |
| 111 | protected: |
| 112 | VoEBaseImpl(voe::SharedData* shared); |
| 113 | virtual ~VoEBaseImpl(); |
| 114 | |
| 115 | private: |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 116 | int32_t StartPlayout(); |
| 117 | int32_t StopPlayout(); |
| 118 | int32_t StartSend(); |
| 119 | int32_t StopSend(); |
| 120 | int32_t TerminateInternal(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 121 | |
xians@webrtc.org | 0e6fa8c | 2013-07-31 16:27:42 +0000 | [diff] [blame] | 122 | // Helper function to process the recorded data with AudioProcessing Module, |
| 123 | // demultiplex the data to specific voe channels, encode and send to the |
| 124 | // network. When |number_of_VoE_channels| is 0, it will demultiplex the |
| 125 | // data to all the existing VoE channels. |
| 126 | // It returns new AGC microphone volume or 0 if no volume changes |
| 127 | // should be done. |
| 128 | int ProcessRecordedDataWithAPM(const int voe_channels[], |
| 129 | int number_of_voe_channels, |
| 130 | const void* audio_data, |
| 131 | uint32_t sample_rate, |
| 132 | uint8_t number_of_channels, |
| 133 | uint32_t number_of_frames, |
| 134 | uint32_t audio_delay_milliseconds, |
| 135 | int32_t clock_drift, |
| 136 | uint32_t current_volume, |
| 137 | bool key_pressed); |
| 138 | |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 139 | int32_t AddBuildInfo(char* str) const; |
| 140 | int32_t AddVoEVersion(char* str) const; |
turaj@webrtc.org | b43ac9f | 2013-11-13 00:02:48 +0000 | [diff] [blame] | 141 | |
| 142 | // Initialize channel by setting Engine Information then initializing |
| 143 | // channel. |
| 144 | int InitializeChannel(voe::ChannelOwner* channel_owner); |
pwestin@webrtc.org | 912b7f7 | 2013-03-13 23:20:57 +0000 | [diff] [blame] | 145 | #ifdef WEBRTC_EXTERNAL_TRANSPORT |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 146 | int32_t AddExternalTransportBuild(char* str) const; |
pwestin@webrtc.org | 912b7f7 | 2013-03-13 23:20:57 +0000 | [diff] [blame] | 147 | #endif |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 148 | #ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 149 | int32_t AddExternalRecAndPlayoutBuild(char* str) const; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 150 | #endif |
| 151 | VoiceEngineObserver* _voiceEngineObserverPtr; |
| 152 | CriticalSectionWrapper& _callbackCritSect; |
| 153 | |
| 154 | bool _voiceEngineObserver; |
pbos@webrtc.org | 54f03bc | 2013-04-09 10:09:10 +0000 | [diff] [blame] | 155 | uint32_t _oldVoEMicLevel; |
| 156 | uint32_t _oldMicLevel; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 157 | AudioFrame _audioFrame; |
| 158 | voe::SharedData* _shared; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
pbos@webrtc.org | 3b89e10 | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 161 | } // namespace webrtc |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 162 | |
| 163 | #endif // WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H |