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 GetVersion(char version[1024]);
60 virtual int LastError();
62 virtual AudioTransport* audio_transport() { return this; }
66 RecordedDataIsAvailable(const void* audioSamples,
68 uint8_t nBytesPerSample,
70 uint32_t samplesPerSec,
71 uint32_t totalDelayMS,
75 uint32_t& newMicLevel);
77 virtual int32_t NeedMorePlayData(uint32_t nSamples,
78 uint8_t nBytesPerSample,
80 uint32_t samplesPerSec,
82 uint32_t& nSamplesOut);
84 virtual int OnDataAvailable(const int voe_channels[],
85 int number_of_voe_channels,
86 const int16_t* audio_data,
88 int number_of_channels,
90 int audio_delay_milliseconds,
93 bool need_audio_processing);
95 virtual void OnData(int voe_channel, const void* audio_data,
96 int bits_per_sample, int sample_rate,
97 int number_of_channels, int number_of_frames);
99 virtual void PushCaptureData(int voe_channel, const void* audio_data,
100 int bits_per_sample, int sample_rate,
101 int number_of_channels, int number_of_frames);
103 virtual void PullRenderData(int bits_per_sample, int sample_rate,
104 int number_of_channels, int number_of_frames,
107 // AudioDeviceObserver
108 virtual void OnErrorIsReported(ErrorCode error);
109 virtual void OnWarningIsReported(WarningCode warning);
112 VoEBaseImpl(voe::SharedData* shared);
113 virtual ~VoEBaseImpl();
116 int32_t StartPlayout();
117 int32_t StopPlayout();
120 int32_t TerminateInternal();
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
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,
139 void GetPlayoutData(int sample_rate, int number_of_channels,
140 int number_of_frames, bool feed_data_to_apm,
143 int32_t AddBuildInfo(char* str) const;
144 int32_t AddVoEVersion(char* str) const;
146 // Initialize channel by setting Engine Information then initializing
148 int InitializeChannel(voe::ChannelOwner* channel_owner);
149 #ifdef WEBRTC_EXTERNAL_TRANSPORT
150 int32_t AddExternalTransportBuild(char* str) const;
152 #ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
153 int32_t AddExternalRecAndPlayoutBuild(char* str) const;
155 VoiceEngineObserver* _voiceEngineObserverPtr;
156 CriticalSectionWrapper& _callbackCritSect;
158 bool _voiceEngineObserver;
159 AudioFrame _audioFrame;
160 voe::SharedData* _shared;
163 } // namespace webrtc
165 #endif // WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H