|
1 /* |
|
2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: voip audio service - |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "VoIPAudioServicesTestClass.h" |
|
22 #include "debug.h" |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 /************************************************************************************************************/ |
|
29 |
|
30 // ---------------------------------------------------------------------------- |
|
31 // CVoIPAudioServicesTestClass::FillBuffer |
|
32 // |
|
33 // Callback from MVoIPDownlinkObserver |
|
34 // ---------------------------------------------------------------------------- |
|
35 // |
|
36 void CVoIPAudioServicesTestClass::FillBuffer(const CVoIPAudioDownlinkStream& /*aSrc*/, |
|
37 CVoIPDataBuffer* aBuffer) |
|
38 { |
|
39 |
|
40 iLog->Log(_L("CVoIPAudioServicesTestClass::FillBuffer")); |
|
41 ProcessEvent(EFillBuffer, KErrNone); |
|
42 |
|
43 // In JB mode we will only receive FillBuffer callback once after |
|
44 // ConfigureJB. We will simply reuse same buffer to send data to VAS. |
|
45 aBuffer->GetPayloadPtr(iPlayBufPtr); |
|
46 iPlayBufReady = ETrue; // always ready in JB mode |
|
47 |
|
48 #ifndef __JITTER_BUFFER_TEST__ |
|
49 // In JB mode, DoLoopback is only called when from EmptyBuffer |
|
50 if (iDnLinkStatus == EStreaming) |
|
51 { |
|
52 DoLoopback(); |
|
53 } |
|
54 #endif //__JITTER_BUFFER_TEST__ |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // CVoIPAudioServicesTestClass::Event |
|
59 // |
|
60 // Callback from MVoIPDownlinkObserver |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 void CVoIPAudioServicesTestClass::Event(const CVoIPAudioDownlinkStream& /*aSrc*/, |
|
64 TInt aEventType, |
|
65 TInt aError) |
|
66 { |
|
67 switch (aEventType) |
|
68 { |
|
69 case MVoIPDownlinkObserver::KOpenComplete: |
|
70 { |
|
71 if (aError == KErrNone) |
|
72 { |
|
73 // Now we can configure decoder and audio device |
|
74 iVoIPDnlink->GetMaxVolume(iMaxVolume); |
|
75 iVoIPDnlink->SetVolume(iMaxVolume / 2); |
|
76 // ConfigureDecoder(); |
|
77 |
|
78 #ifdef __JITTER_BUFFER_TEST__ |
|
79 if (iDnLinkCodec != EPCM16) |
|
80 { |
|
81 ConfigureJB(); // will trigger FillBuffer callback |
|
82 } |
|
83 #endif //__JITTER_BUFFER_TEST__ |
|
84 |
|
85 iDnLinkStatus = EReady; |
|
86 iLog->Log(_L("MVoIPDownlinkObserver::KOpenComplete: aError = %d"), aError); |
|
87 ProcessEvent(EOpenDownlinkComplete, aError); |
|
88 } |
|
89 |
|
90 iLog->Log(_L("DNL Initialized: aError = %d"), aError); |
|
91 break; |
|
92 } |
|
93 case MVoIPDownlinkObserver::KDownlinkClosed: |
|
94 { |
|
95 iDnLinkStatus = ENotReady; |
|
96 iLog->Log(_L("MVoIPDownlinkObserver::KDownlinkClosed: aError = %d"), aError); |
|
97 ProcessEvent(EDownlinkClosed, aError); |
|
98 break; |
|
99 } |
|
100 case MVoIPDownlinkObserver::KDownlinkError: |
|
101 { |
|
102 iDnLinkStatus = EReady; |
|
103 iLog->Log(_L("DNL Error: aError = %d"), aError); |
|
104 break; |
|
105 } |
|
106 /* case KVoIPOpenDTMFComplete: |
|
107 { |
|
108 DisplayText(_L("DTMF (DNL) Open"), aError); |
|
109 break; |
|
110 }*/ |
|
111 /* |
|
112 case KVoIP_TEMP1: |
|
113 { |
|
114 DisplayText(_L("DTMF PLR Ready"), aError); |
|
115 break; |
|
116 } |
|
117 case KVoIP_TEMP2: |
|
118 { |
|
119 DisplayText(_L("DTMF PLR Ready"), aError); |
|
120 break; |
|
121 } |
|
122 */ |
|
123 default: |
|
124 break; |
|
125 } |
|
126 } |
|
127 |
|
128 // ---------------------------------------------------------------------------- |
|
129 // CVoIPAudioServicesTestClass::EmptyBuffer |
|
130 // |
|
131 // Callback from MVoIPUplinkObserver |
|
132 // ---------------------------------------------------------------------------- |
|
133 // |
|
134 void CVoIPAudioServicesTestClass::EmptyBuffer(const CVoIPAudioUplinkStream& /*aSrc*/, |
|
135 CVoIPDataBuffer* aBuffer) |
|
136 { |
|
137 iLog->Log(_L("CVoIPAudioServicesTestClass::EmptyBuffer")); |
|
138 ProcessEvent(EEmptyBuffer, KErrNone); |
|
139 |
|
140 aBuffer->GetPayloadPtr(iRecBufPtr); |
|
141 iRecBufReady = ETrue; |
|
142 |
|
143 if (iUpLinkStatus == EStreaming) |
|
144 { |
|
145 DoLoopback(); |
|
146 // iVoIPUplink->BufferEmptied(aBuffer); |
|
147 // iUpLinkStatus = EReady; |
|
148 } |
|
149 } |
|
150 |
|
151 // ---------------------------------------------------------------------------- |
|
152 // CVoIPAudioServicesTestClass::Event |
|
153 // |
|
154 // Callback from MVoIPUplinkObserver |
|
155 // ---------------------------------------------------------------------------- |
|
156 // |
|
157 void CVoIPAudioServicesTestClass::Event(const CVoIPAudioUplinkStream& /*aSrc*/, |
|
158 TInt aEventType, |
|
159 TInt aError) |
|
160 { |
|
161 switch (aEventType) |
|
162 { |
|
163 case MVoIPUplinkObserver::KOpenComplete: |
|
164 { |
|
165 if (aError == KErrNone) |
|
166 { |
|
167 // Now we can configure encoder and audio device |
|
168 iVoIPUplink->GetMaxGain(iMaxGain); |
|
169 iVoIPUplink->SetGain(iMaxGain); |
|
170 |
|
171 iUpLinkStatus = EReady; |
|
172 iLog->Log(_L("MVoIPUplinkObserver::KOpenComplete: aError = %d"), aError); |
|
173 ProcessEvent(EOpenUplinkComplete, aError); |
|
174 } |
|
175 |
|
176 iLog->Log(_L("UPL Initialized: aError = %d"), aError); |
|
177 break; |
|
178 } |
|
179 case MVoIPUplinkObserver::KUplinkClosed: |
|
180 { |
|
181 iUpLinkStatus = ENotReady; |
|
182 iLog->Log(_L("MVoIPUplinkObserver::KUplinkClosed: aError = %d"), aError); |
|
183 ProcessEvent(EUplinkClosed, aError); |
|
184 break; |
|
185 } |
|
186 case MVoIPUplinkObserver::KUplinkError: |
|
187 { |
|
188 iUpLinkStatus = EReady; |
|
189 iLog->Log(_L("UPL Error: aError = %d"), aError); |
|
190 break; |
|
191 } |
|
192 |
|
193 // TODO: Move to MDTMFToneObserver::Event handler |
|
194 /* case KVoIP_TEMP1: |
|
195 { |
|
196 DisplayText(_L("DTMF PLR Ready"), aError); |
|
197 break; |
|
198 } |
|
199 case KVoIP_TEMP2: |
|
200 { |
|
201 DisplayText(_L("DTMF PLR Ready"), aError); |
|
202 break; |
|
203 } |
|
204 */ |
|
205 default: |
|
206 break; |
|
207 } |
|
208 } |
|
209 |
|
210 // ---------------------------------------------------------------------------- |
|
211 // CVoIPAudioServicesTestClass::Event |
|
212 // |
|
213 // Callback from MVoIPFormatObserver |
|
214 // ---------------------------------------------------------------------------- |
|
215 // |
|
216 void CVoIPAudioServicesTestClass::Event(const CVoIPFormatIntfc& /*aSrc*/, TInt aEventType) |
|
217 { |
|
218 switch (aEventType) |
|
219 { |
|
220 case MVoIPFormatObserver::KSilenceBegin: |
|
221 case MVoIPFormatObserver::KSilenceUpdate: |
|
222 case MVoIPFormatObserver::KSilenceEnd: |
|
223 case MVoIPFormatObserver::KObserverEventMax: |
|
224 default: |
|
225 break; |
|
226 } |
|
227 } |
|
228 |
|
229 // ---------------------------------------------------------------------------- |
|
230 // CVoIPAudioServicesTestClass::Event |
|
231 // |
|
232 // Callback from MDTMFToneObserver |
|
233 // ---------------------------------------------------------------------------- |
|
234 // |
|
235 void CVoIPAudioServicesTestClass::Event(const CDTMFTonePlayer& /*aSrc*/, |
|
236 TInt aEventType, |
|
237 TInt aError) |
|
238 { |
|
239 switch (aEventType) |
|
240 { |
|
241 case MDTMFToneObserver::KOpenCompleteDNL: |
|
242 iLog->Log(_L("MDTMFToneObserver:KOpenCompleteDNL:DTMF DNL-PLR Ready: aError = %d"), aError); |
|
243 ProcessEvent(EOpenCompleteDNL, aError); |
|
244 break; |
|
245 case MDTMFToneObserver::KOpenCompleteUPL: |
|
246 iLog->Log(_L("MDTMFToneObserver:KOpenCompleteUPL:DTMF UPL-PLR Ready: aError = %d"), aError); |
|
247 ProcessEvent(EOpenCompleteUPL, aError); |
|
248 break; |
|
249 default: |
|
250 break; |
|
251 } |
|
252 } |
|
253 |
|
254 // ---------------------------------------------------------------------------- |
|
255 // CVoIPAudioServicesTestClass::Event |
|
256 // |
|
257 // Callback from MRingToneObserver |
|
258 // ---------------------------------------------------------------------------- |
|
259 // |
|
260 void CVoIPAudioServicesTestClass::Event(const CRingTonePlayer& /*aSrc*/, |
|
261 TInt aEventType, |
|
262 TInt aError) |
|
263 { |
|
264 switch (aEventType) |
|
265 { |
|
266 case MRingToneObserver::KOpenComplete: |
|
267 ProcessEvent(EOpenComplete, aError); |
|
268 iLog->Log(_L("RT PLR Ready: error = %d"), aError); |
|
269 break; |
|
270 case MRingToneObserver::KPlaybackComplete: |
|
271 ProcessEvent(EPlaybackComplete, aError); |
|
272 iLog->Log(_L("RT Play Complete: error = %d"), aError); |
|
273 break; |
|
274 default: |
|
275 break; |
|
276 } |
|
277 } |
|
278 |
|
279 #ifdef __JITTER_BUFFER_TEST__ |
|
280 // ---------------------------------------------------------------------------- |
|
281 // CVoIPAudioServicesTestClass::Event |
|
282 // |
|
283 // Callback from MVoIPJitterBufferObserver |
|
284 // ---------------------------------------------------------------------------- |
|
285 // |
|
286 void CVoIPAudioServicesTestClass::Event(const CVoIPJitterBufferIntfc& /*aSrc*/, |
|
287 TInt aEventType) |
|
288 { |
|
289 switch (aEventType) |
|
290 { |
|
291 // Reserved for future use |
|
292 case MVoIPJitterBufferObserver::KJBReserved1: |
|
293 case MVoIPJitterBufferObserver::KJBReserved2: |
|
294 default: |
|
295 break; |
|
296 } |
|
297 } |
|
298 |
|
299 #endif //__JITTER_BUFFER_TEST__ |
|
300 |