2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H
12 #define WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H
14 #include "webrtc/voice_engine/include/voe_base.h"
16 #include "webrtc/modules/interface/module_common_types.h"
17 #include "webrtc/voice_engine/shared_data.h"
24 class VoEBaseImpl: public VoEBase,
25 public AudioTransport,
26 public AudioDeviceObserver
29 virtual int RegisterVoiceEngineObserver(VoiceEngineObserver& observer);
31 virtual int DeRegisterVoiceEngineObserver();
33 virtual int Init(AudioDeviceModule* external_adm = NULL,
34 AudioProcessing* audioproc = NULL);
35 virtual AudioProcessing* audio_processing() {
36 return _shared->audio_processing();
39 virtual int Terminate();
41 virtual int CreateChannel();
42 virtual int CreateChannel(const Config& config);
44 virtual int DeleteChannel(int channel);
46 virtual int StartReceive(int channel);
48 virtual int StartPlayout(int channel);
50 virtual int StartSend(int channel);
52 virtual int StopReceive(int channel);
54 virtual int StopPlayout(int channel);
56 virtual int StopSend(int channel);
58 virtual int SetNetEQPlayoutMode(int channel, NetEqModes mode);
60 virtual int GetNetEQPlayoutMode(int channel, NetEqModes& mode);
62 virtual int SetOnHoldStatus(int channel,
64 OnHoldModes mode = kHoldSendAndPlay);
66 virtual int GetOnHoldStatus(int channel, bool& enabled, OnHoldModes& mode);
68 virtual int GetVersion(char version[1024]);
70 virtual int LastError();
72 virtual AudioTransport* audio_transport() { return this; }
76 RecordedDataIsAvailable(const void* audioSamples,
78 uint8_t nBytesPerSample,
80 uint32_t samplesPerSec,
81 uint32_t totalDelayMS,
83 uint32_t currentMicLevel,
85 uint32_t& newMicLevel);
87 virtual int32_t NeedMorePlayData(uint32_t nSamples,
88 uint8_t nBytesPerSample,
90 uint32_t samplesPerSec,
92 uint32_t& nSamplesOut);
94 virtual int OnDataAvailable(const int voe_channels[],
95 int number_of_voe_channels,
96 const int16_t* audio_data,
98 int number_of_channels,
100 int audio_delay_milliseconds,
103 bool need_audio_processing);
105 virtual void OnData(int voe_channel, const void* audio_data,
106 int bits_per_sample, int sample_rate,
107 int number_of_channels, int number_of_frames);
109 // AudioDeviceObserver
110 virtual void OnErrorIsReported(ErrorCode error);
111 virtual void OnWarningIsReported(WarningCode warning);
114 VoEBaseImpl(voe::SharedData* shared);
115 virtual ~VoEBaseImpl();
118 int32_t StartPlayout();
119 int32_t StopPlayout();
122 int32_t TerminateInternal();
124 // Helper function to process the recorded data with AudioProcessing Module,
125 // demultiplex the data to specific voe channels, encode and send to the
126 // network. When |number_of_VoE_channels| is 0, it will demultiplex the
127 // data to all the existing VoE channels.
128 // It returns new AGC microphone volume or 0 if no volume changes
130 int ProcessRecordedDataWithAPM(const int voe_channels[],
131 int number_of_voe_channels,
132 const void* audio_data,
133 uint32_t sample_rate,
134 uint8_t number_of_channels,
135 uint32_t number_of_frames,
136 uint32_t audio_delay_milliseconds,
138 uint32_t current_volume,
141 int32_t AddBuildInfo(char* str) const;
142 int32_t AddVoEVersion(char* str) const;
144 // Initialize channel by setting Engine Information then initializing
146 int InitializeChannel(voe::ChannelOwner* channel_owner);
147 #ifdef WEBRTC_EXTERNAL_TRANSPORT
148 int32_t AddExternalTransportBuild(char* str) const;
150 #ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
151 int32_t AddExternalRecAndPlayoutBuild(char* str) const;
153 VoiceEngineObserver* _voiceEngineObserverPtr;
154 CriticalSectionWrapper& _callbackCritSect;
156 bool _voiceEngineObserver;
157 uint32_t _oldVoEMicLevel;
158 uint32_t _oldMicLevel;
159 AudioFrame _audioFrame;
160 voe::SharedData* _shared;
163 } // namespace webrtc
165 #endif // WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H