blob: 17c6ed3d2138f68417dc4d1ec99072a2fcfb96dd [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
kma@webrtc.orgde66b912012-02-01 18:39:44 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
14#include "voe_base.h"
15
kma@webrtc.orgde66b912012-02-01 18:39:44 +000016#include "module_common_types.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000017#include "shared_data.h"
18
19namespace webrtc
20{
21
22class ProcessThread;
23
tommi@webrtc.org851becd2012-04-04 14:57:19 +000024class VoEBaseImpl: public VoEBase,
niklase@google.com470e71d2011-07-07 08:21:25 +000025 public AudioTransport,
26 public AudioDeviceObserver
27{
28public:
niklase@google.com470e71d2011-07-07 08:21:25 +000029 virtual int RegisterVoiceEngineObserver(VoiceEngineObserver& observer);
30
31 virtual int DeRegisterVoiceEngineObserver();
32
andrew@webrtc.orgf0a90c32013-03-05 01:12:49 +000033 virtual int Init(AudioDeviceModule* external_adm = NULL,
34 AudioProcessing* audioproc = NULL);
35 virtual AudioProcessing* audio_processing() {
36 return _shared->audio_processing();
37 }
niklase@google.com470e71d2011-07-07 08:21:25 +000038
39 virtual int Terminate();
40
41 virtual int MaxNumOfChannels();
42
43 virtual int CreateChannel();
44
45 virtual int DeleteChannel(int channel);
46
pwestin@webrtc.org684f0572013-03-13 23:20:57 +000047 virtual int SetLocalReceiver(int channel, int port,
48 int RTCPport = kVoEDefault,
49 const char ipAddr[64] = NULL,
50 const char multiCastAddr[64] = NULL);
51
52 virtual int GetLocalReceiver(int channel, int& port, int& RTCPport,
53 char ipAddr[64]);
54
55 virtual int SetSendDestination(int channel, int port,
56 const char ipAddr[64],
57 int sourcePort = kVoEDefault,
58 int RTCPport = kVoEDefault);
59
60 virtual int GetSendDestination(int channel,
61 int& port,
62 char ipAddr[64],
63 int& sourcePort,
64 int& RTCPport);
65
niklase@google.com470e71d2011-07-07 08:21:25 +000066 virtual int StartReceive(int channel);
67
68 virtual int StartPlayout(int channel);
69
70 virtual int StartSend(int channel);
71
72 virtual int StopReceive(int channel);
73
74 virtual int StopPlayout(int channel);
75
76 virtual int StopSend(int channel);
77
78 virtual int SetNetEQPlayoutMode(int channel, NetEqModes mode);
79
80 virtual int GetNetEQPlayoutMode(int channel, NetEqModes& mode);
81
niklase@google.com470e71d2011-07-07 08:21:25 +000082 virtual int SetOnHoldStatus(int channel,
83 bool enable,
84 OnHoldModes mode = kHoldSendAndPlay);
85
86 virtual int GetOnHoldStatus(int channel, bool& enabled, OnHoldModes& mode);
87
88 virtual int GetVersion(char version[1024]);
89
90 virtual int LastError();
91
92 // AudioTransport
93 virtual WebRtc_Word32
henrika@webrtc.org907bc552012-03-09 08:59:19 +000094 RecordedDataIsAvailable(const void* audioSamples,
niklase@google.com470e71d2011-07-07 08:21:25 +000095 const WebRtc_UWord32 nSamples,
96 const WebRtc_UWord8 nBytesPerSample,
97 const WebRtc_UWord8 nChannels,
98 const WebRtc_UWord32 samplesPerSec,
99 const WebRtc_UWord32 totalDelayMS,
100 const WebRtc_Word32 clockDrift,
101 const WebRtc_UWord32 currentMicLevel,
102 WebRtc_UWord32& newMicLevel);
103
104 virtual WebRtc_Word32 NeedMorePlayData(const WebRtc_UWord32 nSamples,
105 const WebRtc_UWord8 nBytesPerSample,
106 const WebRtc_UWord8 nChannels,
107 const WebRtc_UWord32 samplesPerSec,
henrika@webrtc.org907bc552012-03-09 08:59:19 +0000108 void* audioSamples,
niklase@google.com470e71d2011-07-07 08:21:25 +0000109 WebRtc_UWord32& nSamplesOut);
110
111 // AudioDeviceObserver
112 virtual void OnErrorIsReported(const ErrorCode error);
113 virtual void OnWarningIsReported(const WarningCode warning);
114
115protected:
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000116 VoEBaseImpl(voe::SharedData* shared);
niklase@google.com470e71d2011-07-07 08:21:25 +0000117 virtual ~VoEBaseImpl();
118
119private:
120 WebRtc_Word32 StartPlayout();
121 WebRtc_Word32 StopPlayout();
122 WebRtc_Word32 StartSend();
123 WebRtc_Word32 StopSend();
124 WebRtc_Word32 TerminateInternal();
125
126 WebRtc_Word32 AddBuildInfo(char* str) const;
127 WebRtc_Word32 AddVoEVersion(char* str) const;
pwestin@webrtc.org684f0572013-03-13 23:20:57 +0000128#ifdef WEBRTC_EXTERNAL_TRANSPORT
129 WebRtc_Word32 AddExternalTransportBuild(char* str) const;
130#endif
niklase@google.com470e71d2011-07-07 08:21:25 +0000131#ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
132 WebRtc_Word32 AddExternalRecAndPlayoutBuild(char* str) const;
133#endif
niklase@google.com470e71d2011-07-07 08:21:25 +0000134 VoiceEngineObserver* _voiceEngineObserverPtr;
135 CriticalSectionWrapper& _callbackCritSect;
136
137 bool _voiceEngineObserver;
138 WebRtc_UWord32 _oldVoEMicLevel;
139 WebRtc_UWord32 _oldMicLevel;
kma@webrtc.orgde66b912012-02-01 18:39:44 +0000140 AudioFrame _audioFrame;
tommi@webrtc.org851becd2012-04-04 14:57:19 +0000141 voe::SharedData* _shared;
pwestin@webrtc.org684f0572013-03-13 23:20:57 +0000142
niklase@google.com470e71d2011-07-07 08:21:25 +0000143};
144
145} // namespace webrtc
146
147#endif // WEBRTC_VOICE_ENGINE_VOE_BASE_IMPL_H