|
1 /* |
|
2 * Copyright (c) 2007-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 server session class implementation. |
|
15 * Each session is created either for an uplink, downlink or |
|
16 * ring tone player. Separate thread is created for uplink and |
|
17 * downlink stream. Ring tone player runs in the main thread. |
|
18 * |
|
19 */ |
|
20 |
|
21 #include <AudioPreference.h> |
|
22 #include <MProEngEngine.h> |
|
23 #include <MProEngProfile.h> |
|
24 #include <MProEngTones.h> |
|
25 #include <ProEngFactory.h> |
|
26 #include <voipaudiocommon.h> |
|
27 #include "debugtracemacros.h" |
|
28 #include "VoIPAudioSession.h" |
|
29 #include "VoIPServerThread.h" |
|
30 #include "VoIPSharedData.h" |
|
31 #include "VoIPServerSession.h" |
|
32 |
|
33 // These are the default tone length settings for the US |
|
34 const TUint KDTMFToneLengthOn = 250000; |
|
35 const TUint KDTMFToneLengthOff = 50000; |
|
36 const TUint KDTMFToneLengthPause = 2500000; |
|
37 const TUint KArrayExpandSize = 8; |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CVoIPAudioServerSession::NewL |
|
41 // Symbian constructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CVoIPAudioServerSession* CVoIPAudioServerSession::NewL( |
|
45 CVoIPAudioServer &aServer) |
|
46 { |
|
47 CVoIPAudioServerSession* self = new (ELeave) CVoIPAudioServerSession( |
|
48 aServer); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop(self); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CVoIPAudioServerSession::~CVoIPAudioServerSession |
|
57 // The destructor |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CVoIPAudioServerSession::~CVoIPAudioServerSession() |
|
61 { |
|
62 TRACE_PRN_FN_ENT; |
|
63 |
|
64 if (iAO) |
|
65 { |
|
66 iAO->Cancel(); |
|
67 delete iAO; |
|
68 } |
|
69 |
|
70 delete iDevSound; |
|
71 delete iToneBuf; |
|
72 delete iRingTonePlayer; |
|
73 delete iDTMFTonePlayer; |
|
74 iCodecsUp.Reset(); |
|
75 iCodecsUp.Close(); |
|
76 iCodecsDn.Reset(); |
|
77 iCodecsDn.Close(); |
|
78 |
|
79 if (iThread.Handle() > 0) |
|
80 { |
|
81 iThread.Close(); // close thread handle |
|
82 } |
|
83 |
|
84 if (iMsgComQueueDtmf.Handle() > 0) |
|
85 { |
|
86 iMsgComQueueDtmf.Close(); |
|
87 } |
|
88 |
|
89 if (iMsgComQueue.Handle() > 0) |
|
90 { |
|
91 iMsgComQueue.Close(); |
|
92 } |
|
93 |
|
94 if (iITCMsgComQueue.Handle() > 0) |
|
95 { |
|
96 iITCMsgComQueue.Close(); |
|
97 } |
|
98 |
|
99 iShared.iMutex.Close(); |
|
100 iShared.iCodecSettings.iArrBitrates.Reset(); |
|
101 |
|
102 iVoIPServer.DropSession(); // will start shutdown if no more sessions left |
|
103 |
|
104 // Release memory and close handles to unused plug-ins held by the DevSound |
|
105 REComSession::FinalClose(); |
|
106 |
|
107 TRACE_PRN_FN_EXT; |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CVoIPAudioServerSession::ConstructL |
|
112 // 2-nd phase constructor. |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CVoIPAudioServerSession::ConstructL() |
|
116 { |
|
117 TRACE_PRN_FN_ENT; |
|
118 |
|
119 // Create semaphore for thread signaling when accessing shared data |
|
120 iShared.iMutex.CreateLocal(); |
|
121 |
|
122 // Setup A/O for ITC to receive callbacks from the uplink/downlink threads |
|
123 // Note: Must replace with msg queue if multiple callbacks can be |
|
124 // received at the same time. |
|
125 TThreadId tID = RThread().Id(); |
|
126 iShared.iMutex.Wait(); |
|
127 iShared.iMainThreadID = tID; |
|
128 iAO = new (ELeave) CVoIPServerAO(this, tID); |
|
129 iShared.iMnThreadStatus = &(this->iAO->iStatus); |
|
130 iShared.iMutex.Signal(); |
|
131 iShared.iCodecSettings.iG711FrameRate = TVoIPCodecSettings::E20MS; |
|
132 iAO->Request(); |
|
133 iSessionType = ENone; |
|
134 |
|
135 TRACE_PRN_FN_EXT; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CVoIPAudioServerSession::CVoIPAudioServerSession |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 CVoIPAudioServerSession::CVoIPAudioServerSession(CVoIPAudioServer &aServer) : |
|
143 iVoIPServer(aServer) |
|
144 { |
|
145 TRACE_PRN_FN_ENT; |
|
146 iVoIPServer.AddSession(); //add new session |
|
147 TRACE_PRN_FN_EXT; |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CVoIPAudioServerSession::ServiceL |
|
152 // Service request handler. |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CVoIPAudioServerSession::ServiceL(const RMessage2& aMessage) |
|
156 { |
|
157 TRAPD(err, DispatchMessageL(aMessage)); |
|
158 if (!iMsgQueued) |
|
159 { |
|
160 aMessage.Complete(err); |
|
161 } |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CVoIPAudioServerSession::DispatchMessageL |
|
166 // Service request handler. |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CVoIPAudioServerSession::DispatchMessageL(const RMessage2& aMessage) |
|
170 { |
|
171 switch (aMessage.Function()) |
|
172 { |
|
173 case EVoIPSetEncoderPriority: |
|
174 case EVoIPSetDecoderPriority: |
|
175 SetPriorityL(aMessage); |
|
176 break; |
|
177 case EVoIPGetSupportedEncodersCount: |
|
178 if (iSessionType == ENone) |
|
179 { |
|
180 iSessionType = EQueryEnc; |
|
181 } |
|
182 GetCodecsCountL(aMessage); |
|
183 break; |
|
184 case EVoIPGetSupportedDecodersCount: |
|
185 if (iSessionType == ENone) |
|
186 { |
|
187 iSessionType = EQueryDec; |
|
188 } |
|
189 GetCodecsCountL(aMessage); |
|
190 break; |
|
191 case EVoIPGetSupportedEncoders: |
|
192 if (iSessionType == ENone) |
|
193 { |
|
194 iSessionType = EQueryEnc; |
|
195 } |
|
196 GetSupportedCodecsL(aMessage); |
|
197 break; |
|
198 case EVoIPGetSupportedDecoders: |
|
199 GetSupportedCodecsL(aMessage); |
|
200 break; |
|
201 case EVoIPSetDecoder: |
|
202 if (iSessionType == ENone) |
|
203 { |
|
204 iSessionType = EQueryDec; |
|
205 } |
|
206 SetFormatL(aMessage); |
|
207 break; |
|
208 case EVoIPSetEncoder: |
|
209 if (iSessionType == ENone) |
|
210 { |
|
211 iSessionType = EQueryEnc; |
|
212 } |
|
213 SetFormatL(aMessage); |
|
214 break; |
|
215 case EVoIPOpenDownlink: |
|
216 OpenDownlinkL(aMessage); |
|
217 break; |
|
218 case EVoIPOpenUplink: |
|
219 OpenUplinkL(aMessage); |
|
220 break; |
|
221 case EVoIPStartDownlink: |
|
222 StartDownlink(); |
|
223 break; |
|
224 case EVoIPStartUplink: |
|
225 StartUplink(); |
|
226 break; |
|
227 case EVoIPStopDownlink: |
|
228 StopDownlink(); |
|
229 break; |
|
230 case EVoIPStopUplink: |
|
231 StopUplink(); |
|
232 break; |
|
233 case EVoIPCloseDownlink: |
|
234 CloseDownlink(); |
|
235 break; |
|
236 case EVoIPCloseUplink: |
|
237 CloseUplink(); |
|
238 break; |
|
239 case EVoIPGetMaxVolume: |
|
240 GetMaxVolumeL(aMessage); |
|
241 break; |
|
242 case EVoIPGetVolume: |
|
243 GetVolume(aMessage); |
|
244 break; |
|
245 case EVoIPSetVolume: |
|
246 SetVolume(aMessage); |
|
247 break; |
|
248 case EVoIPGetMaxGain: |
|
249 GetMaxGainL(aMessage); |
|
250 break; |
|
251 case EVoIPGetGain: |
|
252 GetGain(aMessage); |
|
253 break; |
|
254 case EVoIPSetGain: |
|
255 SetGain(aMessage); |
|
256 break; |
|
257 case EVoIPSetAudioDevice: |
|
258 SetAudioDeviceL(aMessage); |
|
259 break; |
|
260 case EVoIPGetAudioDevice: |
|
261 GetAudioDevice(aMessage); |
|
262 break; |
|
263 case EVoIPBufferFilled: |
|
264 BufferFilledL(aMessage); |
|
265 break; |
|
266 case EVoIPBufferEmptied: |
|
267 BufferEmptiedL(aMessage); |
|
268 break; |
|
269 case EVoIPSetIlbcCodecMode: |
|
270 SetIlbcCodecModeL(aMessage); |
|
271 break; |
|
272 case EVoIPGetIlbcCodecMode: |
|
273 GetIlbcCodecMode(aMessage); |
|
274 break; |
|
275 case EVoIPSetG711CodecMode: |
|
276 SetG711CodecModeL(aMessage); |
|
277 break; |
|
278 case EVoIPGetG711CodecMode: |
|
279 GetG711CodecMode(aMessage); |
|
280 break; |
|
281 case EVoIPGetSupportedBitratesCount: |
|
282 GetSupportedBitratesCount(aMessage); |
|
283 break; |
|
284 case EVoIPGetSupportedBitrates: |
|
285 GetSupportedBitratesL(aMessage); |
|
286 break; |
|
287 case EVoIPSetBitrate: |
|
288 SetBitrate(aMessage); |
|
289 break; |
|
290 case EVoIPGetBitrate: |
|
291 GetBitrate(aMessage); |
|
292 break; |
|
293 case EVoIPFrameModeRqrdForEC: |
|
294 FrameModeRqrdForEC(aMessage); |
|
295 break; |
|
296 case EVoIPSetFrameMode: |
|
297 SetFrameMode(aMessage); |
|
298 break; |
|
299 case EVoIPGetFrameMode: |
|
300 GetFrameMode(aMessage); |
|
301 break; |
|
302 case EVoIPConcealErrForNextBuf: |
|
303 ConcealErrorForNextBuffer(); |
|
304 break; |
|
305 case EVoIPSetVad: |
|
306 SetVad(aMessage); |
|
307 break; |
|
308 case EVoIPGetVad: |
|
309 GetVad(aMessage); |
|
310 break; |
|
311 case EVoIPSetCng: |
|
312 SetCng(aMessage); |
|
313 break; |
|
314 case EVoIPGetCng: |
|
315 GetCng(aMessage); |
|
316 break; |
|
317 case EVoIPSetPlc: |
|
318 SetPlc(aMessage); |
|
319 break; |
|
320 case EVoIPGetPlc: |
|
321 GetPlc(aMessage); |
|
322 break; |
|
323 case EVoIPBadLsfNextBuffer: |
|
324 BadLsfNextBuffer(); |
|
325 break; |
|
326 case EVoIPOpenDTMFTonePlayer: |
|
327 OpenDTMFTonePlayerL(); |
|
328 break; |
|
329 case EVoIPPlayDTMFTone: |
|
330 PlayDTMFToneL(aMessage); |
|
331 break; |
|
332 case EVoIPStopDTMFTone: |
|
333 StopDTMFTonePlay(); |
|
334 break; |
|
335 case EVoIPCloseDTMFTonePlayer: |
|
336 CloseDTMFTonePlayer(); |
|
337 break; |
|
338 case EVoIPOpenRingTonePlayerFromFile: |
|
339 OpenRingTonePlayerFromFileL(aMessage); |
|
340 break; |
|
341 case EVoIPOpenRingTonePlayerFromRFile: |
|
342 OpenRingTonePlayerFromRFileL(aMessage); |
|
343 break; |
|
344 case EVoIPOpenRingTonePlayerFromProfile: |
|
345 OpenRingTonePlayerFromProfileL(); |
|
346 break; |
|
347 case EVoIPOpenRingTonePlayerFromDes: |
|
348 OpenRingTonePlayerFromDesL(aMessage); |
|
349 break; |
|
350 case EVoIPPlayRingTone: |
|
351 PlayRingTone(); |
|
352 break; |
|
353 case EVoIPPauseRingTone: |
|
354 PauseRingTone(); |
|
355 break; |
|
356 case EVoIPResumeRingTone: |
|
357 ResumeRingTone(); |
|
358 break; |
|
359 case EVoIPStopRingTone: |
|
360 StopRingTone(); |
|
361 break; |
|
362 case EVoIPCloseRingTonePlayer: |
|
363 CloseRingTonePlayer(); |
|
364 break; |
|
365 case EVoIPConfigJitterBuffer: |
|
366 ConfigureJitterBufferL(aMessage); |
|
367 break; |
|
368 case EVoIPResetJitterBuffer: |
|
369 ResetJitterBuffer(aMessage); |
|
370 break; |
|
371 case EVoIPJBDelayDown: |
|
372 JBDelayDown(); |
|
373 break; |
|
374 case EVoIPJBDelayUp: |
|
375 JBDelayUp(); |
|
376 break; |
|
377 case EVoIPSessionClose: |
|
378 break; |
|
379 default: |
|
380 User::Leave(KErrNotSupported); |
|
381 break; |
|
382 } |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CVoIPAudioServerSession::SetDecoderPriority |
|
387 // |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 void CVoIPAudioServerSession::SetPriorityL(const RMessage2& aMessage) |
|
391 { |
|
392 TMMFPrioritySettingsPckg pckg; |
|
393 aMessage.ReadL(0, pckg); |
|
394 iPriority = pckg(); |
|
395 iShared.iMutex.Wait(); |
|
396 iShared.iPreference = iPriority.iPref; |
|
397 iShared.iPriority = iPriority.iPriority; |
|
398 iShared.iMutex.Signal(); |
|
399 } |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // CVoIPAudioServerSession::GetCodecsCountL |
|
403 // |
|
404 // ----------------------------------------------------------------------------- |
|
405 // |
|
406 void CVoIPAudioServerSession::GetCodecsCountL(const RMessage2& aMessage) |
|
407 { |
|
408 TRACE_PRN_FN_ENT; |
|
409 |
|
410 TVoIPMsgBufPckg p; |
|
411 p().iStatus = KErrNone; |
|
412 p().iInt = 0; |
|
413 |
|
414 // Is codecs info already available? |
|
415 if (iCodecsCountUp > 0 && |
|
416 (iSessionType == EQueryEnc || iSessionType == EUplink)) |
|
417 { |
|
418 p().iInt = iCodecsCountUp; |
|
419 iShared.iMutex.Wait(); |
|
420 p().iUint = iShared.iCodecSettings.iG711FrameRate; //TODO: |
|
421 iShared.iMutex.Signal(); |
|
422 } |
|
423 else if (iCodecsCountDn > 0 && |
|
424 (iSessionType == EQueryDec || iSessionType == EDnlink)) |
|
425 { |
|
426 p().iInt = iCodecsCountDn; |
|
427 iShared.iMutex.Wait(); |
|
428 p().iUint = iShared.iCodecSettings.iG711FrameRate; //TODO: |
|
429 iShared.iMutex.Signal(); |
|
430 } |
|
431 else |
|
432 { |
|
433 delete iDevSound; |
|
434 iDevSound = NULL; |
|
435 iDevSound = CMMFDevSound::NewL(); |
|
436 |
|
437 if (iDevSound) |
|
438 { |
|
439 iCodecsUp.Reset(); |
|
440 iCodecsCountUp = 0; |
|
441 iDevSound->GetSupportedInputDataTypesL(iCodecsUp, iPriority); |
|
442 /* |
|
443 #ifdef __WINSCW__ |
|
444 // Support for adaptation stubs |
|
445 iCodecsUp.Append(KMccFourCCIdG711); |
|
446 iCodecsUp.Append(KMccFourCCIdG729); |
|
447 iCodecsUp.Append(KMccFourCCIdILBC); |
|
448 iCodecsUp.Append(KMccFourCCIdAMRNB); |
|
449 #endif |
|
450 */ |
|
451 iCodecsCountUp = iCodecsUp.Count(); |
|
452 |
|
453 iCodecsDn.Reset(); |
|
454 iCodecsCountDn = 0; |
|
455 iDevSound->GetSupportedOutputDataTypesL(iCodecsDn, iPriority); |
|
456 /* |
|
457 #ifdef __WINSCW__ |
|
458 // Support for adaptation stubs |
|
459 iCodecsDn.Append(KMccFourCCIdG711); |
|
460 iCodecsDn.Append(KMccFourCCIdG729); |
|
461 iCodecsDn.Append(KMccFourCCIdILBC); |
|
462 iCodecsDn.Append(KMccFourCCIdAMRNB); |
|
463 #endif |
|
464 */ |
|
465 iCodecsCountDn = iCodecsDn.Count(); |
|
466 } |
|
467 } |
|
468 |
|
469 delete iDevSound; |
|
470 iDevSound = NULL; |
|
471 |
|
472 if (iSessionType == EQueryEnc || iSessionType == EUplink) |
|
473 { |
|
474 p().iInt = iCodecsCountUp; |
|
475 } |
|
476 else if (iSessionType == EQueryDec || iSessionType == EDnlink) |
|
477 { |
|
478 p().iInt = iCodecsCountDn; |
|
479 } |
|
480 |
|
481 p().iUint = KVoIPG711FrameLen20ms; //good for 10ms and 20ms |
|
482 aMessage.WriteL(0, p); |
|
483 |
|
484 TRACE_PRN_FN_EXT; |
|
485 } |
|
486 |
|
487 // ----------------------------------------------------------------------------- |
|
488 // CVoIPAudioServerSession::GetSupportedEncodersL |
|
489 // |
|
490 // ----------------------------------------------------------------------------- |
|
491 // |
|
492 void CVoIPAudioServerSession::GetSupportedCodecsL(const RMessage2& aMessage) |
|
493 { |
|
494 TRACE_PRN_FN_ENT; |
|
495 |
|
496 CBufFlat* dataCopyBuffer = CBufFlat::NewL(KArrayExpandSize); |
|
497 CleanupStack::PushL(dataCopyBuffer); |
|
498 RBufWriteStream stream; |
|
499 stream.Open(*dataCopyBuffer); |
|
500 CleanupClosePushL(stream); |
|
501 |
|
502 if (iCodecsCountUp > 0 && |
|
503 (iSessionType == EQueryEnc || iSessionType == EUplink)) |
|
504 { |
|
505 for (TInt i = 0; i < iCodecsCountUp; i++) |
|
506 { |
|
507 stream.WriteUint32L(iCodecsUp[i].FourCC()); |
|
508 TRACE_PRN_N2(_L("VoIP->CodecUP[%d]==[0x%x]"), i+1, iCodecsUp[i].FourCC()); |
|
509 } |
|
510 } |
|
511 else if (iCodecsCountDn > 0 && |
|
512 (iSessionType == EQueryDec || iSessionType == EDnlink)) |
|
513 { |
|
514 for (TInt i = 0; i < iCodecsCountDn; i++) |
|
515 { |
|
516 stream.WriteUint32L(iCodecsDn[i].FourCC()); |
|
517 TRACE_PRN_N2(_L("VoIP->CodecDN[%d]==[0x%x]"), i+1, iCodecsDn[i].FourCC()); |
|
518 } |
|
519 } |
|
520 |
|
521 aMessage.WriteL(0, dataCopyBuffer->Ptr(0)); |
|
522 |
|
523 CleanupStack::PopAndDestroy(&stream); |
|
524 CleanupStack::PopAndDestroy(dataCopyBuffer); |
|
525 |
|
526 TRACE_PRN_FN_EXT; |
|
527 } |
|
528 |
|
529 // ----------------------------------------------------------------------------- |
|
530 // CVoIPAudioServerSession::OpenDownlinkL |
|
531 // Method for player initialization. |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 void CVoIPAudioServerSession::OpenDownlinkL(const RMessage2& aMessage) |
|
535 { |
|
536 TRACE_PRN_FN_ENT; |
|
537 |
|
538 TMMFPrioritySettingsPckg pckg; |
|
539 aMessage.ReadL(0, pckg); |
|
540 iShared.iMutex.Wait(); |
|
541 iShared.iPreference = pckg().iPref; |
|
542 iShared.iPriority = pckg().iPriority; |
|
543 iShared.iMutex.Signal(); |
|
544 |
|
545 TInt err = KErrPermissionDenied; |
|
546 |
|
547 if (iVoIPServer.HasDnLinkSession()) |
|
548 { |
|
549 User::Leave(err); |
|
550 } |
|
551 |
|
552 // Create thread only once |
|
553 if (iThread.Handle() <= 0) |
|
554 { |
|
555 err = iThread.Create(_L("VoIPDownlinkThread"), |
|
556 CVoIPDownlinkThread::ThreadFunction, |
|
557 KDefaultStackSize, |
|
558 KMinHeapSize, |
|
559 KMinHeapSize << 12, //1MB |
|
560 &iShared); |
|
561 if (err == KErrNone) |
|
562 { |
|
563 iThread.SetPriority(EPriorityRealTime); |
|
564 iThread.Resume(); |
|
565 |
|
566 // Open message queue for ITC back to the client |
|
567 if (iMsgComQueue.Handle() <= 0) |
|
568 { |
|
569 err = iMsgComQueue.OpenGlobal(KDnLinkComQueue); |
|
570 } |
|
571 |
|
572 // Create message queue for ITC with CVoIPDownlinkThread |
|
573 if (iITCMsgComQueue.Handle() <= 0) |
|
574 { |
|
575 err = iITCMsgComQueue.CreateGlobal(KDnLinkThreadComQueue, |
|
576 KVoIPMsgComQSlots); |
|
577 } |
|
578 |
|
579 iVoIPServer.SetDnLinkSession(this, ETrue); |
|
580 iSessionType = EDnlink; |
|
581 } |
|
582 } |
|
583 |
|
584 TRACE_PRN_IF_ERR(err); |
|
585 TRACE_PRN_FN_EXT; |
|
586 } |
|
587 |
|
588 // ----------------------------------------------------------------------------- |
|
589 // CVoIPAudioServerSession::OpenUplinkL |
|
590 // Method for recorder initialization. |
|
591 // ----------------------------------------------------------------------------- |
|
592 // |
|
593 void CVoIPAudioServerSession::OpenUplinkL(const RMessage2& aMessage) |
|
594 { |
|
595 TRACE_PRN_FN_ENT; |
|
596 |
|
597 TMMFPrioritySettingsPckg pckg; |
|
598 aMessage.ReadL(0, pckg); |
|
599 iShared.iMutex.Wait(); |
|
600 iShared.iPreference = pckg().iPref; |
|
601 iShared.iPriority = pckg().iPriority; |
|
602 iShared.iMutex.Signal(); |
|
603 |
|
604 TInt err = KErrPermissionDenied; |
|
605 |
|
606 if (iVoIPServer.HasUpLinkSession()) |
|
607 { |
|
608 User::Leave(err); |
|
609 } |
|
610 |
|
611 // Create thread only once |
|
612 if (iThread.Handle() <= 0) |
|
613 { |
|
614 err = iThread.Create(_L("VoIPUplinkThread"), |
|
615 CVoIPUplinkThread::ThreadFunction, |
|
616 KDefaultStackSize, |
|
617 KMinHeapSize, |
|
618 KMinHeapSize << 12, //1MB |
|
619 &iShared); |
|
620 if (err == KErrNone) |
|
621 { |
|
622 iThread.SetPriority(EPriorityRealTime); |
|
623 iThread.Resume(); |
|
624 |
|
625 // Create message queues |
|
626 if (iMsgComQueue.Handle() <= 0) |
|
627 { |
|
628 err = iMsgComQueue.OpenGlobal(KUpLinkComQueue); |
|
629 } |
|
630 |
|
631 // Create message queue for ITC with CVoIPDownlinkThread |
|
632 if (iITCMsgComQueue.Handle() <= 0) |
|
633 { |
|
634 err = iITCMsgComQueue.CreateGlobal(KUpLinkThreadComQueue, |
|
635 KVoIPMsgComQSlots); |
|
636 } |
|
637 |
|
638 iVoIPServer.SetUpLinkSession(this, ETrue); |
|
639 iSessionType = EUplink; |
|
640 } |
|
641 } |
|
642 |
|
643 TRACE_PRN_IF_ERR(err); |
|
644 TRACE_PRN_FN_EXT; |
|
645 } |
|
646 |
|
647 // ----------------------------------------------------------------------------- |
|
648 // CVoIPAudioServerSession::SetFormat |
|
649 // |
|
650 // ----------------------------------------------------------------------------- |
|
651 // |
|
652 void CVoIPAudioServerSession::SetFormatL(const RMessage2& aMessage) |
|
653 { |
|
654 TPckgBuf<TUint32> pckg; |
|
655 aMessage.ReadL(0, pckg); |
|
656 iShared.iMutex.Wait(); |
|
657 iShared.iCodecSettings.iFourCC = pckg(); |
|
658 iShared.iMutex.Signal(); |
|
659 } |
|
660 |
|
661 // ----------------------------------------------------------------------------- |
|
662 // CVoIPAudioServerSession::StartDownlink |
|
663 // Call the thread to initialize downlink stream |
|
664 // ----------------------------------------------------------------------------- |
|
665 // |
|
666 void CVoIPAudioServerSession::StartDownlink() |
|
667 { |
|
668 SendCmdToThread(ECmdStartDownlink); |
|
669 } |
|
670 |
|
671 // ----------------------------------------------------------------------------- |
|
672 // CVoIPAudioServerSession::StartUplink |
|
673 // Call the thread to initialize uplink stream |
|
674 // ----------------------------------------------------------------------------- |
|
675 // |
|
676 void CVoIPAudioServerSession::StartUplink() |
|
677 { |
|
678 SendCmdToThread(ECmdStartUplink); |
|
679 } |
|
680 |
|
681 // ----------------------------------------------------------------------------- |
|
682 // CVoIPAudioServerSession::StopDownlink |
|
683 // |
|
684 // ----------------------------------------------------------------------------- |
|
685 // |
|
686 void CVoIPAudioServerSession::StopDownlink() |
|
687 { |
|
688 SendCmdToThread(ECmdStopDownlink); |
|
689 } |
|
690 |
|
691 // ----------------------------------------------------------------------------- |
|
692 // CVoIPAudioServerSession::StopUplink |
|
693 // |
|
694 // ----------------------------------------------------------------------------- |
|
695 // |
|
696 void CVoIPAudioServerSession::StopUplink() |
|
697 { |
|
698 SendCmdToThread(ECmdStopUplink); |
|
699 } |
|
700 |
|
701 // ----------------------------------------------------------------------------- |
|
702 // CVoIPAudioServerSession::CloseDownlink |
|
703 // Request downlink thread termination |
|
704 // ----------------------------------------------------------------------------- |
|
705 // |
|
706 void CVoIPAudioServerSession::CloseDownlink() |
|
707 { |
|
708 if (iThread.Handle() > 0) |
|
709 { |
|
710 SendCmdToThread(ECmdTerminateThread); |
|
711 iThread.Close(); // close thread handle |
|
712 iVoIPServer.SetDnLinkSession(this, EFalse); |
|
713 NotifyClient(ECmdDownlinkThreadClosed); |
|
714 } |
|
715 } |
|
716 |
|
717 // ----------------------------------------------------------------------------- |
|
718 // CVoIPAudioServerSession::CloseUplink |
|
719 // |
|
720 // ----------------------------------------------------------------------------- |
|
721 // |
|
722 void CVoIPAudioServerSession::CloseUplink() |
|
723 { |
|
724 if (iThread.Handle() > 0) |
|
725 { |
|
726 SendCmdToThread(ECmdTerminateThread); |
|
727 iThread.Close(); // close thread handle |
|
728 iVoIPServer.SetUpLinkSession(this, EFalse); |
|
729 NotifyClient(ECmdUplinkThreadClosed); |
|
730 } |
|
731 } |
|
732 |
|
733 // ----------------------------------------------------------------------------- |
|
734 // CVoIPAudioServerSession::GetMaxVolume |
|
735 // |
|
736 // ----------------------------------------------------------------------------- |
|
737 // |
|
738 void CVoIPAudioServerSession::GetMaxVolumeL(const RMessage2& aMessage) |
|
739 { |
|
740 TPckgBuf<TInt> p(iMaxVolume); |
|
741 aMessage.WriteL(0, p); |
|
742 |
|
743 TRACE_PRN_N1(_L("VoIP->SRV-SESSION: GetMaxVolumeL->MaxVolume [%d]"), |
|
744 iMaxVolume); |
|
745 } |
|
746 |
|
747 // ----------------------------------------------------------------------------- |
|
748 // CVoIPAudioServerSession::GetVolume |
|
749 // |
|
750 // ----------------------------------------------------------------------------- |
|
751 // |
|
752 void CVoIPAudioServerSession::GetVolume(const RMessage2& aMessage) |
|
753 { |
|
754 iMessage = aMessage; |
|
755 iMsgQueued = ETrue; |
|
756 SendCmdToThread(ECmdGetVolume); |
|
757 } |
|
758 |
|
759 // ----------------------------------------------------------------------------- |
|
760 // CVoIPAudioServerSession::SetVolume |
|
761 // |
|
762 // ----------------------------------------------------------------------------- |
|
763 // |
|
764 void CVoIPAudioServerSession::SetVolume(const RMessage2& aMessage) |
|
765 { |
|
766 iShared.iMutex.Wait(); |
|
767 iShared.iInt = aMessage.Int0(); |
|
768 iShared.iMutex.Signal(); |
|
769 SendCmdToThread(ECmdSetVolume); |
|
770 } |
|
771 |
|
772 // ----------------------------------------------------------------------------- |
|
773 // CVoIPAudioServerSession::GetMaxGain |
|
774 // |
|
775 // ----------------------------------------------------------------------------- |
|
776 // |
|
777 void CVoIPAudioServerSession::GetMaxGainL(const RMessage2& aMessage) |
|
778 { |
|
779 TPckgBuf<TInt> p(iMaxGain); |
|
780 aMessage.WriteL(0, p); |
|
781 |
|
782 TRACE_PRN_N1(_L("VoIP->SRV-SESSION: GetMaxGainL->MaxGain [%d]"), iMaxGain); |
|
783 } |
|
784 |
|
785 // ----------------------------------------------------------------------------- |
|
786 // CVoIPAudioServerSession::GetGain |
|
787 // |
|
788 // ----------------------------------------------------------------------------- |
|
789 // |
|
790 void CVoIPAudioServerSession::GetGain(const RMessage2& aMessage) |
|
791 { |
|
792 iMessage = aMessage; |
|
793 iMsgQueued = ETrue; |
|
794 SendCmdToThread(ECmdGetGain); |
|
795 } |
|
796 |
|
797 // ----------------------------------------------------------------------------- |
|
798 // CVoIPAudioServerSession::SetGain |
|
799 // |
|
800 // ----------------------------------------------------------------------------- |
|
801 // |
|
802 void CVoIPAudioServerSession::SetGain(const RMessage2& aMessage) |
|
803 { |
|
804 TInt gain = aMessage.Int0(); |
|
805 if (gain > iMaxGain) |
|
806 { |
|
807 gain = iMaxGain; |
|
808 } |
|
809 |
|
810 iShared.iMutex.Wait(); |
|
811 iShared.iInt = gain; |
|
812 iShared.iMutex.Signal(); |
|
813 SendCmdToThread(ECmdSetGain); |
|
814 } |
|
815 |
|
816 // ----------------------------------------------------------------------------- |
|
817 // CVoIPAudioServerSession::SetAudioDeviceL |
|
818 // |
|
819 // ----------------------------------------------------------------------------- |
|
820 // |
|
821 void CVoIPAudioServerSession::SetAudioDeviceL(const RMessage2& aMessage) |
|
822 { |
|
823 TPckgBuf<TUint> pckg; |
|
824 aMessage.ReadL(0, pckg); |
|
825 iShared.iMutex.Wait(); |
|
826 iShared.iAudioDevice = pckg(); |
|
827 iShared.iMutex.Signal(); |
|
828 SendCmdToThread(ECmdSetAudioDevice); |
|
829 } |
|
830 |
|
831 // ----------------------------------------------------------------------------- |
|
832 // CVoIPAudioServerSession::GetAudioDevice |
|
833 // |
|
834 // ----------------------------------------------------------------------------- |
|
835 // |
|
836 void CVoIPAudioServerSession::GetAudioDevice(const RMessage2& aMessage) |
|
837 { |
|
838 iMessage = aMessage; |
|
839 iMsgQueued = ETrue; |
|
840 SendCmdToThread(ECmdGetAudioDevice); |
|
841 } |
|
842 |
|
843 // ----------------------------------------------------------------------------- |
|
844 // CVoIPAudioServerSession::BufferFilled |
|
845 // |
|
846 // ----------------------------------------------------------------------------- |
|
847 // |
|
848 void CVoIPAudioServerSession::BufferFilledL(const RMessage2& aMessage) |
|
849 { |
|
850 // TRACE_PRN_FN_ENT; |
|
851 |
|
852 TVoIPMsgBufPckg pckg; |
|
853 aMessage.ReadL(0, pckg); |
|
854 iShared.iMutex.Wait(); |
|
855 iShared.iBufferSize = pckg().iInt; |
|
856 iShared.iSequenceNum = pckg().iUint; |
|
857 iShared.iMutex.Signal(); |
|
858 SendCmdToThread(ECmdBufferFilled); |
|
859 |
|
860 // TRACE_PRN_FN_EXT; |
|
861 } |
|
862 |
|
863 // ----------------------------------------------------------------------------- |
|
864 // CVoIPAudioServerSession::BufferEmptied |
|
865 // |
|
866 // ----------------------------------------------------------------------------- |
|
867 // |
|
868 void CVoIPAudioServerSession::BufferEmptiedL(const RMessage2& /*aMessage*/) |
|
869 { |
|
870 // TRACE_PRN_FN_ENT; |
|
871 SendCmdToThread(ECmdBufferEmptied); |
|
872 // TRACE_PRN_FN_EXT; |
|
873 } |
|
874 |
|
875 // ----------------------------------------------------------------------------- |
|
876 // CVoIPAudioServerSession::SetIlbcCodecMode |
|
877 // |
|
878 // ----------------------------------------------------------------------------- |
|
879 // |
|
880 void CVoIPAudioServerSession::SetIlbcCodecModeL(const RMessage2& aMessage) |
|
881 { |
|
882 TPckgBuf<CVoIPFormatIntfc::TILBCCodecMode> pckg; |
|
883 aMessage.ReadL(0, pckg); |
|
884 iShared.iMutex.Wait(); |
|
885 iShared.iCodecSettings.iILBCCodecMode = pckg(); |
|
886 iShared.iMutex.Signal(); |
|
887 SendCmdToThread(ECmdSetIlbcCodecMode); |
|
888 } |
|
889 |
|
890 // ----------------------------------------------------------------------------- |
|
891 // CVoIPAudioServerSession::GetIlbcCodecMode |
|
892 // |
|
893 // ----------------------------------------------------------------------------- |
|
894 // |
|
895 void CVoIPAudioServerSession::GetIlbcCodecMode(const RMessage2& aMessage) |
|
896 { |
|
897 iMessage = aMessage; |
|
898 iMsgQueued = ETrue; |
|
899 SendCmdToThread(ECmdGetIlbcCodecMode); |
|
900 } |
|
901 |
|
902 // ----------------------------------------------------------------------------- |
|
903 // CVoIPAudioServerSession::SetG711CodecMode |
|
904 // |
|
905 // ----------------------------------------------------------------------------- |
|
906 // |
|
907 void CVoIPAudioServerSession::SetG711CodecModeL(const RMessage2& aMessage) |
|
908 { |
|
909 TPckgBuf<CVoIPFormatIntfc::TG711CodecMode> pckg; |
|
910 aMessage.ReadL(0, pckg); |
|
911 iShared.iMutex.Wait(); |
|
912 iShared.iCodecSettings.iG711CodecMode = pckg(); |
|
913 iShared.iMutex.Signal(); |
|
914 SendCmdToThread(ECmdSetG711CodecMode); |
|
915 } |
|
916 |
|
917 // ----------------------------------------------------------------------------- |
|
918 // CVoIPAudioServerSession::GetG711CodecMode |
|
919 // |
|
920 // ----------------------------------------------------------------------------- |
|
921 // |
|
922 void CVoIPAudioServerSession::GetG711CodecMode(const RMessage2& aMessage) |
|
923 { |
|
924 iMessage = aMessage; |
|
925 iMsgQueued = ETrue; |
|
926 SendCmdToThread(ECmdGetG711CodecMode); |
|
927 } |
|
928 |
|
929 // ----------------------------------------------------------------------------- |
|
930 // CVoIPAudioServerSession::GetSupportedBitratesCount |
|
931 // |
|
932 // ----------------------------------------------------------------------------- |
|
933 // |
|
934 void CVoIPAudioServerSession::GetSupportedBitratesCount( |
|
935 const RMessage2& aMessage) |
|
936 { |
|
937 iMessage = aMessage; |
|
938 iMsgQueued = ETrue; |
|
939 SendCmdToThread(ECmdGetSupportedBitrates); |
|
940 } |
|
941 |
|
942 // ----------------------------------------------------------------------------- |
|
943 // CVoIPAudioServerSession::GetSupportedBitratesL |
|
944 // Bitrates are already returned from the codec as a result of call to |
|
945 // GetSupportedBitratesCount(). Just pack them into a descriptor and return |
|
946 // bact to the client. |
|
947 // ----------------------------------------------------------------------------- |
|
948 // |
|
949 void CVoIPAudioServerSession::GetSupportedBitratesL(const RMessage2& aMessage) |
|
950 { |
|
951 TRACE_PRN_FN_ENT; |
|
952 |
|
953 CBufFlat* dataCopyBuffer = CBufFlat::NewL(KArrayExpandSize); |
|
954 CleanupStack::PushL(dataCopyBuffer); |
|
955 RBufWriteStream stream; |
|
956 stream.Open(*dataCopyBuffer); |
|
957 CleanupClosePushL(stream); |
|
958 |
|
959 RArray<TUint> bitrates; |
|
960 iShared.iMutex.Wait(); |
|
961 bitrates = iShared.iCodecSettings.iArrBitrates; |
|
962 iShared.iMutex.Signal(); |
|
963 TInt numOfItems = bitrates.Count(); |
|
964 |
|
965 for (TInt i = 0; i < numOfItems; i++) |
|
966 { |
|
967 stream.WriteUint32L(bitrates[i]); |
|
968 |
|
969 TRACE_PRN_N1(_L("VoIP->SRV-SESSION: BR: [%d]"), bitrates[i]); |
|
970 } |
|
971 |
|
972 aMessage.WriteL(0, dataCopyBuffer->Ptr(0)); |
|
973 |
|
974 CleanupStack::PopAndDestroy(&stream); |
|
975 CleanupStack::PopAndDestroy(dataCopyBuffer); |
|
976 |
|
977 TRACE_PRN_FN_EXT; |
|
978 } |
|
979 |
|
980 // ----------------------------------------------------------------------------- |
|
981 // CVoIPAudioServerSession::SetBitrate |
|
982 // |
|
983 // ----------------------------------------------------------------------------- |
|
984 // |
|
985 void CVoIPAudioServerSession::SetBitrate(const RMessage2& aMessage) |
|
986 { |
|
987 TUint bitrate = aMessage.Int0(); |
|
988 iShared.iMutex.Wait(); |
|
989 iShared.iCodecSettings.iBitrate = bitrate; |
|
990 iShared.iMutex.Signal(); |
|
991 SendCmdToThread(ECmdSetBitrate); |
|
992 } |
|
993 |
|
994 // ----------------------------------------------------------------------------- |
|
995 // CVoIPAudioServerSession::GetBitrate |
|
996 // |
|
997 // ----------------------------------------------------------------------------- |
|
998 // |
|
999 void CVoIPAudioServerSession::GetBitrate(const RMessage2& aMessage) |
|
1000 { |
|
1001 iMessage = aMessage; |
|
1002 iMsgQueued = ETrue; |
|
1003 SendCmdToThread(ECmdGetBitrate); |
|
1004 } |
|
1005 |
|
1006 // ----------------------------------------------------------------------------- |
|
1007 // CVoIPAudioServerSession::FrameModeRequiredForEC |
|
1008 // |
|
1009 // ----------------------------------------------------------------------------- |
|
1010 // |
|
1011 void CVoIPAudioServerSession::FrameModeRqrdForEC(const RMessage2& aMessage) |
|
1012 { |
|
1013 iMessage = aMessage; |
|
1014 iMsgQueued = ETrue; |
|
1015 SendCmdToThread(ECmdFrameModeRqrdForEC); |
|
1016 } |
|
1017 |
|
1018 // ----------------------------------------------------------------------------- |
|
1019 // CVoIPAudioServerSession::SetFrameMode |
|
1020 // |
|
1021 // ----------------------------------------------------------------------------- |
|
1022 // |
|
1023 void CVoIPAudioServerSession::SetFrameMode(const RMessage2& aMessage) |
|
1024 { |
|
1025 iShared.iMutex.Wait(); |
|
1026 iShared.iCodecSettings.iFrameMode = TBool(aMessage.Int0()); |
|
1027 iShared.iMutex.Signal(); |
|
1028 SendCmdToThread(ECmdSetFrameMode); |
|
1029 } |
|
1030 |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // CVoIPAudioServerSession::GetFrameMode |
|
1033 // |
|
1034 // ----------------------------------------------------------------------------- |
|
1035 // |
|
1036 void CVoIPAudioServerSession::GetFrameMode(const RMessage2& aMessage) |
|
1037 { |
|
1038 iMessage = aMessage; |
|
1039 iMsgQueued = ETrue; |
|
1040 SendCmdToThread(ECmdGetFrameMode); |
|
1041 } |
|
1042 |
|
1043 // ----------------------------------------------------------------------------- |
|
1044 // CVoIPAudioServerSession::ConcealErrorForNextBuffer |
|
1045 // ----------------------------------------------------------------------------- |
|
1046 // |
|
1047 void CVoIPAudioServerSession::ConcealErrorForNextBuffer() |
|
1048 { |
|
1049 SendCmdToThread(ECmdConcealErrForNextBuf); |
|
1050 } |
|
1051 |
|
1052 // ----------------------------------------------------------------------------- |
|
1053 // CVoIPAudioServerSession::SetVad |
|
1054 // |
|
1055 // ----------------------------------------------------------------------------- |
|
1056 // |
|
1057 void CVoIPAudioServerSession::SetVad(const RMessage2& aMessage) |
|
1058 { |
|
1059 iShared.iMutex.Wait(); |
|
1060 iShared.iCodecSettings.iVad = TBool(aMessage.Int0()); |
|
1061 iShared.iMutex.Signal(); |
|
1062 SendCmdToThread(ECmdSetVad); |
|
1063 } |
|
1064 |
|
1065 // ----------------------------------------------------------------------------- |
|
1066 // CVoIPAudioServerSession::GetVad |
|
1067 // |
|
1068 // ----------------------------------------------------------------------------- |
|
1069 // |
|
1070 void CVoIPAudioServerSession::GetVad(const RMessage2& aMessage) |
|
1071 { |
|
1072 iMessage = aMessage; |
|
1073 iMsgQueued = ETrue; |
|
1074 SendCmdToThread(ECmdGetVad); |
|
1075 } |
|
1076 |
|
1077 // ----------------------------------------------------------------------------- |
|
1078 // CVoIPAudioServerSession::SetCng |
|
1079 // |
|
1080 // ----------------------------------------------------------------------------- |
|
1081 // |
|
1082 void CVoIPAudioServerSession::SetCng(const RMessage2& aMessage) |
|
1083 { |
|
1084 iShared.iMutex.Wait(); |
|
1085 iShared.iCodecSettings.iCng = TBool(aMessage.Int0()); |
|
1086 iShared.iMutex.Signal(); |
|
1087 SendCmdToThread(ECmdSetCng); |
|
1088 } |
|
1089 |
|
1090 // ----------------------------------------------------------------------------- |
|
1091 // CVoIPAudioServerSession::GetCng |
|
1092 // |
|
1093 // ----------------------------------------------------------------------------- |
|
1094 // |
|
1095 void CVoIPAudioServerSession::GetCng(const RMessage2& aMessage) |
|
1096 { |
|
1097 iMessage = aMessage; |
|
1098 iMsgQueued = ETrue; |
|
1099 SendCmdToThread(ECmdGetCng); |
|
1100 } |
|
1101 |
|
1102 // ----------------------------------------------------------------------------- |
|
1103 // CVoIPAudioServerSession::SetPlc |
|
1104 // |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // |
|
1107 void CVoIPAudioServerSession::SetPlc(const RMessage2& aMessage) |
|
1108 { |
|
1109 iShared.iMutex.Wait(); |
|
1110 iShared.iCodecSettings.iPlc = TBool(aMessage.Int0()); |
|
1111 iShared.iMutex.Signal(); |
|
1112 SendCmdToThread(ECmdSetPlc); |
|
1113 } |
|
1114 |
|
1115 // ----------------------------------------------------------------------------- |
|
1116 // CVoIPAudioServerSession::GetPlc |
|
1117 // |
|
1118 // ----------------------------------------------------------------------------- |
|
1119 // |
|
1120 void CVoIPAudioServerSession::GetPlc(const RMessage2& aMessage) |
|
1121 { |
|
1122 iMessage = aMessage; |
|
1123 iMsgQueued = ETrue; |
|
1124 SendCmdToThread(ECmdGetPlc); |
|
1125 } |
|
1126 |
|
1127 // ----------------------------------------------------------------------------- |
|
1128 // CVoIPAudioServerSession::BadLsfNextBuffer |
|
1129 // |
|
1130 // ----------------------------------------------------------------------------- |
|
1131 // |
|
1132 void CVoIPAudioServerSession::BadLsfNextBuffer() |
|
1133 { |
|
1134 SendCmdToThread(ECmdBadLsfNextBuffer); |
|
1135 } |
|
1136 |
|
1137 // ----------------------------------------------------------------------------- |
|
1138 // CVoIPAudioServerSession::ConfigureJitterBufferL |
|
1139 // ----------------------------------------------------------------------------- |
|
1140 // |
|
1141 void CVoIPAudioServerSession::ConfigureJitterBufferL(const RMessage2& aMessage) |
|
1142 { |
|
1143 TRACE_PRN_FN_ENT; |
|
1144 |
|
1145 TPckgBuf<TVoIPJBConfig> pckg; |
|
1146 aMessage.ReadL(0, pckg); |
|
1147 iShared.iMutex.Wait(); |
|
1148 iShared.iJBConfig.iJBBufferLength = pckg().iJBBufferLength; |
|
1149 iShared.iJBConfig.iJBThreshold = pckg().iJBThreshold; |
|
1150 iShared.iJBConfig.iJitterLatency = pckg().iJitterLatency; |
|
1151 iShared.iJBConfig.iSampleInterval = pckg().iSampleInterval; |
|
1152 iShared.iJBConfig.iJBInactivityTimeOut = pckg().iJBInactivityTimeOut; |
|
1153 iShared.iMutex.Signal(); |
|
1154 SendCmdToThread(ECmdVoIPConfigJB); |
|
1155 |
|
1156 TRACE_PRN_FN_EXT; |
|
1157 } |
|
1158 |
|
1159 // ----------------------------------------------------------------------------- |
|
1160 // CVoIPAudioServerSession::ResetJitterBuffer |
|
1161 // ----------------------------------------------------------------------------- |
|
1162 // |
|
1163 void CVoIPAudioServerSession::ResetJitterBuffer(const RMessage2& aMessage) |
|
1164 { |
|
1165 iShared.iMutex.Wait(); |
|
1166 iShared.iBool = TBool(aMessage.Int0()); |
|
1167 iShared.iMutex.Signal(); |
|
1168 SendCmdToThread(ECmdVoIPResetJB); |
|
1169 } |
|
1170 |
|
1171 // ----------------------------------------------------------------------------- |
|
1172 // CVoIPAudioServerSession::JBDelayDown |
|
1173 // ----------------------------------------------------------------------------- |
|
1174 // |
|
1175 void CVoIPAudioServerSession::JBDelayDown() |
|
1176 { |
|
1177 SendCmdToThread(ECmdVoIPJBDelayDown); |
|
1178 } |
|
1179 |
|
1180 // ----------------------------------------------------------------------------- |
|
1181 // CVoIPAudioServerSession::JBDelayUp |
|
1182 // ----------------------------------------------------------------------------- |
|
1183 // |
|
1184 void CVoIPAudioServerSession::JBDelayUp() |
|
1185 { |
|
1186 SendCmdToThread(ECmdVoIPJBDelayUp); |
|
1187 } |
|
1188 |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // CVoIPAudioServerSession::OpenDTMFTonePlayerL |
|
1191 // ----------------------------------------------------------------------------- |
|
1192 // |
|
1193 void CVoIPAudioServerSession::OpenDTMFTonePlayerL() |
|
1194 { |
|
1195 TRACE_PRN_FN_ENT; |
|
1196 |
|
1197 if (iSessionType == EUplink || iSessionType == EDnlink) |
|
1198 { |
|
1199 CloseDTMFTonePlayer(); |
|
1200 iDTMFTonePlayer = CMMFDevSound::NewL(); |
|
1201 |
|
1202 if (iDTMFTonePlayer) |
|
1203 { |
|
1204 iDTMFTonePlayerInitRequest = ETrue; |
|
1205 TRAPD(err, iDTMFTonePlayer->InitializeL(*this, EMMFStateTonePlaying)); |
|
1206 if (err != KErrNone) |
|
1207 { |
|
1208 delete iDTMFTonePlayer; |
|
1209 iDTMFTonePlayer = NULL; |
|
1210 iDTMFTonePlayerInitRequest = EFalse; |
|
1211 return; |
|
1212 } |
|
1213 |
|
1214 // Open message queue for ITC back to the client |
|
1215 if (iMsgComQueueDtmf.Handle() <= 0) |
|
1216 { |
|
1217 switch (iSessionType) |
|
1218 { |
|
1219 case EDnlink: |
|
1220 { |
|
1221 while (iMsgComQueueDtmf.OpenGlobal( |
|
1222 KDTMFToneComQueueDNL)) |
|
1223 { |
|
1224 // to make sure queue is created |
|
1225 User::After(KQueueCreateWaitTime); |
|
1226 } |
|
1227 break; |
|
1228 } |
|
1229 case EUplink: |
|
1230 { |
|
1231 while (iMsgComQueueDtmf.OpenGlobal( |
|
1232 KDTMFToneComQueueUPL)) |
|
1233 { |
|
1234 // to make sure queue is created |
|
1235 User::After(KQueueCreateWaitTime); |
|
1236 } |
|
1237 break; |
|
1238 } |
|
1239 default: |
|
1240 break; |
|
1241 } |
|
1242 } |
|
1243 } |
|
1244 } |
|
1245 |
|
1246 TRACE_PRN_FN_EXT; |
|
1247 } |
|
1248 |
|
1249 // --------------------------------------------------------------------------- |
|
1250 // CVoIPAudioServerSession::PlayDTMFToneL |
|
1251 // --------------------------------------------------------------------------- |
|
1252 // |
|
1253 void CVoIPAudioServerSession::PlayDTMFToneL(const RMessage2& aMessage) |
|
1254 { |
|
1255 TRACE_PRN_FN_ENT; |
|
1256 |
|
1257 // NOTE: no need to queue message, we can complete the message and let |
|
1258 // DTMF tones play automatically upon MatoPrepareComplete. |
|
1259 |
|
1260 if (iDTMFTonePlayer) |
|
1261 { |
|
1262 TTonesMsgBufPckg pckg; |
|
1263 aMessage.ReadL(0, pckg); |
|
1264 TBuf<KTonesBufferSize> tones; |
|
1265 tones = pckg().iFileName; |
|
1266 iDTMFTonePlayer->SetDTMFLengths(iToneLenOn, iToneLenOff, |
|
1267 iToneLenPause); |
|
1268 iDTMFTonePlayer->PlayDTMFStringL(tones); |
|
1269 } |
|
1270 |
|
1271 TRACE_PRN_FN_EXT; |
|
1272 } |
|
1273 |
|
1274 // --------------------------------------------------------------------------- |
|
1275 // CVoIPAudioServerSession::StopDTMFTonePlay |
|
1276 // --------------------------------------------------------------------------- |
|
1277 // |
|
1278 void CVoIPAudioServerSession::StopDTMFTonePlay() |
|
1279 { |
|
1280 if (iDTMFTonePlayer) |
|
1281 { |
|
1282 iDTMFTonePlayer->Stop(); |
|
1283 } |
|
1284 } |
|
1285 |
|
1286 // --------------------------------------------------------------------------- |
|
1287 // CVoIPAudioServerSession::CloseDTMFTonePlayer |
|
1288 // --------------------------------------------------------------------------- |
|
1289 // |
|
1290 void CVoIPAudioServerSession::CloseDTMFTonePlayer() |
|
1291 { |
|
1292 delete iDTMFTonePlayer; |
|
1293 iDTMFTonePlayer = NULL; |
|
1294 } |
|
1295 |
|
1296 // ----------------------------------------------------------------------------- |
|
1297 // CVoIPAudioServerSession::OpenRingTonePlayerFromFileL |
|
1298 // ----------------------------------------------------------------------------- |
|
1299 // |
|
1300 void CVoIPAudioServerSession::OpenRingTonePlayerFromFileL( |
|
1301 const RMessage2& aMessage) |
|
1302 { |
|
1303 TRACE_PRN_FN_ENT; |
|
1304 |
|
1305 InitRingTonePlayerL(); |
|
1306 TTonesMsgBufPckg pckg; |
|
1307 aMessage.ReadL(0, pckg); |
|
1308 iRingTonePlayer->OpenFileL(pckg().iFileName); |
|
1309 iSessionType = ERingTone; |
|
1310 |
|
1311 TRACE_PRN_FN_EXT; |
|
1312 } |
|
1313 |
|
1314 // ----------------------------------------------------------------------------- |
|
1315 // CVoIPAudioServerSession::OpenRingTonePlayerFromRFileL |
|
1316 // ----------------------------------------------------------------------------- |
|
1317 // |
|
1318 void CVoIPAudioServerSession::OpenRingTonePlayerFromRFileL( |
|
1319 const RMessage2& aMessage) |
|
1320 { |
|
1321 TRACE_PRN_FN_ENT; |
|
1322 |
|
1323 InitRingTonePlayerL(); |
|
1324 RFile file; |
|
1325 // Note: iFs and file handle are already open by the client who |
|
1326 // owns these handles. |
|
1327 TInt err = file.AdoptFromClient(aMessage, 0, 1); // 0==iFs, 1==fileHandle |
|
1328 CleanupClosePushL(file); |
|
1329 |
|
1330 if (err == KErrNone) |
|
1331 { |
|
1332 iRingTonePlayer->OpenFileL(file); |
|
1333 iSessionType = ERingTone; |
|
1334 } |
|
1335 |
|
1336 file.Close(); //will RFs close? |
|
1337 CleanupStack::Pop(&file); |
|
1338 |
|
1339 TRACE_PRN_FN_EXT; |
|
1340 } |
|
1341 |
|
1342 // ----------------------------------------------------------------------------- |
|
1343 // CVoIPAudioServerSession::OpenRingTonePlayerFromProfileL |
|
1344 // ----------------------------------------------------------------------------- |
|
1345 // |
|
1346 void CVoIPAudioServerSession::OpenRingTonePlayerFromProfileL() |
|
1347 { |
|
1348 TRACE_PRN_FN_ENT; |
|
1349 |
|
1350 InitRingTonePlayerL(); |
|
1351 |
|
1352 MProEngEngine* engine = ProEngFactory::NewEngineL(); |
|
1353 CleanupReleasePushL(*engine); |
|
1354 MProEngProfile* profile = engine->ActiveProfileLC(); |
|
1355 MProEngTones& tones = profile->ProfileTones(); |
|
1356 |
|
1357 // NOTE: Here is how to use volume settings from Profiles |
|
1358 // const TProfileToneSettings& ts = tones.ToneSettings(); |
|
1359 // iVolume = ts.iRingingVolume; |
|
1360 |
|
1361 TBuf<KMaxFileName> file; |
|
1362 file = tones.RingingTone1(); |
|
1363 // NOTE: alternate line settings can also be used from RingingTone2 |
|
1364 iRingTonePlayer->OpenFileL(file); |
|
1365 iSessionType = ERingTone; |
|
1366 |
|
1367 CleanupStack::PopAndDestroy(2); //profile, engine |
|
1368 |
|
1369 TRACE_PRN_FN_EXT; |
|
1370 } |
|
1371 |
|
1372 // ----------------------------------------------------------------------------- |
|
1373 // CVoIPAudioServerSession::OpenRingTonePlayerFromDesL |
|
1374 // ----------------------------------------------------------------------------- |
|
1375 // |
|
1376 void CVoIPAudioServerSession::OpenRingTonePlayerFromDesL( |
|
1377 const RMessage2& aMessage) |
|
1378 { |
|
1379 TRACE_PRN_FN_ENT; |
|
1380 |
|
1381 InitRingTonePlayerL(); |
|
1382 TInt size = aMessage.GetDesLength(0); |
|
1383 |
|
1384 if (size > 0) |
|
1385 { |
|
1386 delete iToneBuf; |
|
1387 iToneBuf = NULL; |
|
1388 iToneBuf = HBufC8::NewL(size); |
|
1389 TPtr8 ptr = iToneBuf->Des(); |
|
1390 aMessage.ReadL(0, ptr); |
|
1391 iRingTonePlayer->OpenDesL(*iToneBuf); |
|
1392 iSessionType = ERingTone; |
|
1393 } |
|
1394 else |
|
1395 { |
|
1396 User::Leave(KErrArgument); //-6 |
|
1397 } |
|
1398 |
|
1399 TRACE_PRN_FN_EXT; |
|
1400 } |
|
1401 |
|
1402 // ----------------------------------------------------------------------------- |
|
1403 // CVoIPAudioServerSession::PlayRingTone |
|
1404 // ----------------------------------------------------------------------------- |
|
1405 // |
|
1406 void CVoIPAudioServerSession::PlayRingTone() |
|
1407 { |
|
1408 if (iRingTonePlayer) |
|
1409 { |
|
1410 iRingTonePlayer->Play(); //TODO: function returns status |
|
1411 } |
|
1412 } |
|
1413 |
|
1414 // ----------------------------------------------------------------------------- |
|
1415 // CVoIPAudioServerSession::PauseRingTone |
|
1416 // ----------------------------------------------------------------------------- |
|
1417 // |
|
1418 void CVoIPAudioServerSession::PauseRingTone() |
|
1419 { |
|
1420 if (iRingTonePlayer) |
|
1421 { |
|
1422 iRingTonePlayer->Pause(); //TODO: function returns status |
|
1423 } |
|
1424 } |
|
1425 |
|
1426 // ----------------------------------------------------------------------------- |
|
1427 // CVoIPAudioServerSession::ResumeRingTone |
|
1428 // ----------------------------------------------------------------------------- |
|
1429 // |
|
1430 void CVoIPAudioServerSession::ResumeRingTone() |
|
1431 { |
|
1432 if (iRingTonePlayer) |
|
1433 { |
|
1434 iRingTonePlayer->Play(); |
|
1435 } |
|
1436 } |
|
1437 |
|
1438 // ----------------------------------------------------------------------------- |
|
1439 // CVoIPAudioServerSession::StopRingTone |
|
1440 // ----------------------------------------------------------------------------- |
|
1441 // |
|
1442 void CVoIPAudioServerSession::StopRingTone() |
|
1443 { |
|
1444 if (iRingTonePlayer) |
|
1445 { |
|
1446 iRingTonePlayer->Stop(); |
|
1447 } |
|
1448 } |
|
1449 |
|
1450 // ----------------------------------------------------------------------------- |
|
1451 // CVoIPAudioServerSession::CloseRingTonePlayer |
|
1452 // ----------------------------------------------------------------------------- |
|
1453 // |
|
1454 void CVoIPAudioServerSession::CloseRingTonePlayer() |
|
1455 { |
|
1456 if (iRingTonePlayer) |
|
1457 { |
|
1458 iRingTonePlayer->Close(); |
|
1459 } |
|
1460 } |
|
1461 |
|
1462 // ----------------------------------------------------------------------------- |
|
1463 // CVoIPAudioServerSession::InitRingTonePlayerL |
|
1464 // ----------------------------------------------------------------------------- |
|
1465 // |
|
1466 void CVoIPAudioServerSession::InitRingTonePlayerL() |
|
1467 { |
|
1468 if (!iRingTonePlayer) |
|
1469 { |
|
1470 TMdaPriorityPreference pref = TMdaPriorityPreference( |
|
1471 KAudioPrefIncomingCall); |
|
1472 TInt prio = KAudioPriorityRingingTone; |
|
1473 iRingTonePlayer = CMdaAudioPlayerUtility::NewL(*this, prio, pref); |
|
1474 } |
|
1475 |
|
1476 // Open message queue for ITC back to the client |
|
1477 if (iRingTonePlayer && iMsgComQueue.Handle() <= 0) |
|
1478 { |
|
1479 while (iMsgComQueue.OpenGlobal(KRingToneComQueue)) |
|
1480 { |
|
1481 // just to make sure queue is created |
|
1482 User::After(KQueueCreateWaitTime); |
|
1483 } |
|
1484 } |
|
1485 } |
|
1486 |
|
1487 // ---------------------------------------------------------------------------- |
|
1488 // CVoIPAudioServerSession::DownlinkInitComplete |
|
1489 // |
|
1490 // ---------------------------------------------------------------------------- |
|
1491 // |
|
1492 void CVoIPAudioServerSession::DownlinkInitComplete(TInt aError) |
|
1493 { |
|
1494 TRACE_PRN_FN_ENT; |
|
1495 TRACE_PRN_IF_ERR(aError); |
|
1496 |
|
1497 // state == DNL initialized |
|
1498 // iStatus = EReady; |
|
1499 iShared.iMutex.Wait(); |
|
1500 iMaxVolume = iShared.iMaxVolume; |
|
1501 iShared.iMutex.Signal(); |
|
1502 NotifyClient(ECmdDownlinkInitComplete, aError); |
|
1503 |
|
1504 TRACE_PRN_FN_EXT; |
|
1505 } |
|
1506 |
|
1507 // ---------------------------------------------------------------------------- |
|
1508 // CVoIPAudioServerSession::UplinkInitComplete |
|
1509 // |
|
1510 // ---------------------------------------------------------------------------- |
|
1511 // |
|
1512 void CVoIPAudioServerSession::UplinkInitComplete(TInt aError) |
|
1513 { |
|
1514 TRACE_PRN_FN_ENT; |
|
1515 TRACE_PRN_IF_ERR(aError); |
|
1516 |
|
1517 // state == UPL initialized |
|
1518 // iStatus = EReady; |
|
1519 iShared.iMutex.Wait(); |
|
1520 iMaxGain = iShared.iMaxGain; |
|
1521 iShared.iMutex.Signal(); |
|
1522 NotifyClient(ECmdUplinkInitComplete, aError); |
|
1523 |
|
1524 TRACE_PRN_FN_EXT; |
|
1525 } |
|
1526 |
|
1527 // ---------------------------------------------------------------------------- |
|
1528 // CVoIPAudioServerSession::GetVolumeComplete |
|
1529 // |
|
1530 // ---------------------------------------------------------------------------- |
|
1531 // |
|
1532 void CVoIPAudioServerSession::GetVolumeComplete(TInt aError) |
|
1533 { |
|
1534 TRACE_PRN_FN_ENT; |
|
1535 TRACE_PRN_IF_ERR(aError); |
|
1536 |
|
1537 iShared.iMutex.Wait(); |
|
1538 TInt vol = iShared.iInt; |
|
1539 iShared.iMutex.Signal(); |
|
1540 TVoIPMsgBufPckg p; |
|
1541 p().iInt = vol; |
|
1542 p().iStatus = aError; |
|
1543 TRAPD(err, iMessage.WriteL(0, p)); |
|
1544 iMessage.Complete(err); |
|
1545 iMsgQueued = EFalse; |
|
1546 |
|
1547 TRACE_PRN_FN_EXT; |
|
1548 } |
|
1549 |
|
1550 // ---------------------------------------------------------------------------- |
|
1551 // CVoIPAudioServerSession::GetGainComplete |
|
1552 // |
|
1553 // ---------------------------------------------------------------------------- |
|
1554 // |
|
1555 void CVoIPAudioServerSession::GetGainComplete(TInt aError) |
|
1556 { |
|
1557 TRACE_PRN_FN_ENT; |
|
1558 TRACE_PRN_IF_ERR(aError); |
|
1559 |
|
1560 iShared.iMutex.Wait(); |
|
1561 TInt gain = iShared.iInt; |
|
1562 iShared.iMutex.Signal(); |
|
1563 TVoIPMsgBufPckg p; |
|
1564 p().iInt = gain; |
|
1565 p().iStatus = aError; |
|
1566 TRAPD(err, iMessage.WriteL(0, p)); |
|
1567 iMessage.Complete(err); |
|
1568 iMsgQueued = EFalse; |
|
1569 |
|
1570 TRACE_PRN_FN_EXT; |
|
1571 } |
|
1572 |
|
1573 // ---------------------------------------------------------------------------- |
|
1574 // CVoIPAudioServerSession::GetAudioDeviceComplete |
|
1575 // |
|
1576 // ---------------------------------------------------------------------------- |
|
1577 // |
|
1578 void CVoIPAudioServerSession::GetAudioDeviceComplete(TInt aError) |
|
1579 { |
|
1580 TRACE_PRN_FN_ENT; |
|
1581 TRACE_PRN_IF_ERR(aError); |
|
1582 |
|
1583 TVoIPMsgBufPckg p; |
|
1584 iShared.iMutex.Wait(); |
|
1585 p().iUint = iShared.iAudioDevice; |
|
1586 p().iStatus = aError; |
|
1587 iShared.iMutex.Signal(); |
|
1588 TRAPD(err, iMessage.WriteL(0, p)); |
|
1589 iMessage.Complete(err); |
|
1590 iMsgQueued = EFalse; |
|
1591 |
|
1592 TRACE_PRN_FN_EXT; |
|
1593 } |
|
1594 |
|
1595 // ---------------------------------------------------------------------------- |
|
1596 // CVoIPAudioServerSession::GetSupportedBitratesComplete |
|
1597 // Notifies bitrate count first. |
|
1598 // ---------------------------------------------------------------------------- |
|
1599 // |
|
1600 void CVoIPAudioServerSession::GetSupportedBitratesComplete(TInt aError) |
|
1601 { |
|
1602 TRACE_PRN_FN_ENT; |
|
1603 TRACE_PRN_IF_ERR(aError); |
|
1604 |
|
1605 TVoIPMsgBufPckg p; |
|
1606 iShared.iMutex.Wait(); |
|
1607 p().iInt = iShared.iCodecSettings.iArrBitrates.Count(); |
|
1608 p().iStatus = aError; |
|
1609 iShared.iMutex.Signal(); |
|
1610 TRAPD(err, iMessage.WriteL(0, p)); |
|
1611 iMessage.Complete(err); |
|
1612 iMsgQueued = EFalse; |
|
1613 |
|
1614 TRACE_PRN_FN_EXT; |
|
1615 } |
|
1616 |
|
1617 // ---------------------------------------------------------------------------- |
|
1618 // CVoIPAudioServerSession::GetBitrateComplete |
|
1619 // |
|
1620 // ---------------------------------------------------------------------------- |
|
1621 // |
|
1622 void CVoIPAudioServerSession::GetBitrateComplete(TInt aError) |
|
1623 { |
|
1624 TRACE_PRN_FN_ENT; |
|
1625 TRACE_PRN_IF_ERR(aError); |
|
1626 |
|
1627 TVoIPMsgBufPckg p; |
|
1628 iShared.iMutex.Wait(); |
|
1629 p().iUint = iShared.iCodecSettings.iBitrate; |
|
1630 p().iStatus = aError; |
|
1631 iShared.iMutex.Signal(); |
|
1632 TRAPD(err, iMessage.WriteL(0, p)); |
|
1633 iMessage.Complete(err); |
|
1634 iMsgQueued = EFalse; |
|
1635 |
|
1636 TRACE_PRN_FN_EXT; |
|
1637 } |
|
1638 |
|
1639 // ---------------------------------------------------------------------------- |
|
1640 // CVoIPAudioServerSession::GetG711CodecModeComplete |
|
1641 // |
|
1642 // ---------------------------------------------------------------------------- |
|
1643 // |
|
1644 void CVoIPAudioServerSession::GetG711CodecModeComplete(TInt aError) |
|
1645 { |
|
1646 TRACE_PRN_FN_ENT; |
|
1647 TRACE_PRN_IF_ERR(aError); |
|
1648 |
|
1649 TVoIPMsgBufPckg p; |
|
1650 iShared.iMutex.Wait(); |
|
1651 p().iUint = TUint(iShared.iCodecSettings.iG711CodecMode); |
|
1652 iShared.iMutex.Signal(); |
|
1653 p().iStatus = aError; |
|
1654 TRAPD(err, iMessage.WriteL(0, p)); |
|
1655 iMessage.Complete(err); |
|
1656 iMsgQueued = EFalse; |
|
1657 |
|
1658 TRACE_PRN_FN_EXT; |
|
1659 } |
|
1660 |
|
1661 // ---------------------------------------------------------------------------- |
|
1662 // CVoIPAudioServerSession::GetIlbcCodecModeComplete |
|
1663 // |
|
1664 // ---------------------------------------------------------------------------- |
|
1665 // |
|
1666 void CVoIPAudioServerSession::GetIlbcCodecModeComplete(TInt aError) |
|
1667 { |
|
1668 TRACE_PRN_FN_ENT; |
|
1669 TRACE_PRN_IF_ERR(aError); |
|
1670 |
|
1671 TVoIPMsgBufPckg p; |
|
1672 iShared.iMutex.Wait(); |
|
1673 p().iUint = TUint(iShared.iCodecSettings.iILBCCodecMode); |
|
1674 iShared.iMutex.Signal(); |
|
1675 p().iStatus = aError; |
|
1676 TRAPD(err, iMessage.WriteL(0, p)); |
|
1677 iMessage.Complete(err); |
|
1678 iMsgQueued = EFalse; |
|
1679 |
|
1680 TRACE_PRN_FN_EXT; |
|
1681 } |
|
1682 |
|
1683 // ---------------------------------------------------------------------------- |
|
1684 // CVoIPAudioServerSession::GetFrameModeComplete |
|
1685 // |
|
1686 // ---------------------------------------------------------------------------- |
|
1687 // |
|
1688 void CVoIPAudioServerSession::GetFrameModeComplete(TInt aError) |
|
1689 { |
|
1690 TRACE_PRN_FN_ENT; |
|
1691 TRACE_PRN_IF_ERR(aError); |
|
1692 |
|
1693 TVoIPMsgBufPckg p; |
|
1694 iShared.iMutex.Wait(); |
|
1695 p().iBool = iShared.iCodecSettings.iFrameMode; |
|
1696 iShared.iMutex.Signal(); |
|
1697 p().iStatus = aError; |
|
1698 TRAPD(err, iMessage.WriteL(0, p)); |
|
1699 iMessage.Complete(err); |
|
1700 iMsgQueued = EFalse; |
|
1701 |
|
1702 TRACE_PRN_FN_EXT; |
|
1703 } |
|
1704 |
|
1705 // ---------------------------------------------------------------------------- |
|
1706 // CVoIPAudioServerSession::GetFrameModeReqForECComplete |
|
1707 // |
|
1708 // ---------------------------------------------------------------------------- |
|
1709 // |
|
1710 void CVoIPAudioServerSession::GetFrameModeReqForECComplete(TInt aError) |
|
1711 { |
|
1712 TRACE_PRN_FN_ENT; |
|
1713 TRACE_PRN_IF_ERR(aError); |
|
1714 |
|
1715 TVoIPMsgBufPckg p; |
|
1716 iShared.iMutex.Wait(); |
|
1717 p().iBool = iShared.iCodecSettings.iFrameModeReqForEC; |
|
1718 iShared.iMutex.Signal(); |
|
1719 p().iStatus = aError; |
|
1720 TRAPD(err, iMessage.WriteL(0, p)); |
|
1721 iMessage.Complete(err); |
|
1722 iMsgQueued = EFalse; |
|
1723 |
|
1724 TRACE_PRN_FN_EXT; |
|
1725 } |
|
1726 |
|
1727 // ---------------------------------------------------------------------------- |
|
1728 // CVoIPAudioServerSession::GetVadComplete |
|
1729 // |
|
1730 // ---------------------------------------------------------------------------- |
|
1731 // |
|
1732 void CVoIPAudioServerSession::GetVadComplete(TInt aError) |
|
1733 { |
|
1734 TRACE_PRN_FN_ENT; |
|
1735 TRACE_PRN_IF_ERR(aError); |
|
1736 |
|
1737 TVoIPMsgBufPckg p; |
|
1738 iShared.iMutex.Wait(); |
|
1739 p().iBool = iShared.iCodecSettings.iVad; |
|
1740 iShared.iMutex.Signal(); |
|
1741 p().iStatus = aError; |
|
1742 TRAPD(err, iMessage.WriteL(0, p)); |
|
1743 iMessage.Complete(err); |
|
1744 iMsgQueued = EFalse; |
|
1745 |
|
1746 TRACE_PRN_FN_EXT; |
|
1747 } |
|
1748 |
|
1749 // ---------------------------------------------------------------------------- |
|
1750 // CVoIPAudioServerSession::GetCngComplete |
|
1751 // |
|
1752 // ---------------------------------------------------------------------------- |
|
1753 // |
|
1754 void CVoIPAudioServerSession::GetCngComplete(TInt aError) |
|
1755 { |
|
1756 TRACE_PRN_FN_ENT; |
|
1757 TRACE_PRN_IF_ERR(aError); |
|
1758 |
|
1759 TVoIPMsgBufPckg p; |
|
1760 iShared.iMutex.Wait(); |
|
1761 p().iBool = iShared.iCodecSettings.iCng; |
|
1762 iShared.iMutex.Signal(); |
|
1763 p().iStatus = aError; |
|
1764 TRAPD(err, iMessage.WriteL(0, p)); |
|
1765 iMessage.Complete(err); |
|
1766 iMsgQueued = EFalse; |
|
1767 |
|
1768 TRACE_PRN_FN_EXT; |
|
1769 } |
|
1770 |
|
1771 // ---------------------------------------------------------------------------- |
|
1772 // CVoIPAudioServerSession::GetPlcComplete |
|
1773 // |
|
1774 // ---------------------------------------------------------------------------- |
|
1775 // |
|
1776 void CVoIPAudioServerSession::GetPlcComplete(TInt aError) |
|
1777 { |
|
1778 TRACE_PRN_FN_ENT; |
|
1779 TRACE_PRN_IF_ERR(aError); |
|
1780 |
|
1781 TVoIPMsgBufPckg p; |
|
1782 iShared.iMutex.Wait(); |
|
1783 p().iBool = iShared.iCodecSettings.iPlc; |
|
1784 iShared.iMutex.Signal(); |
|
1785 p().iStatus = aError; |
|
1786 TRAPD(err, iMessage.WriteL(0, p)); |
|
1787 iMessage.Complete(err); |
|
1788 iMsgQueued = EFalse; |
|
1789 |
|
1790 TRACE_PRN_FN_EXT; |
|
1791 } |
|
1792 |
|
1793 // ----------------------------------------------------------------------------- |
|
1794 // CVoIPAudioServerSession::DetermineG711FrameRateL |
|
1795 // ----------------------------------------------------------------------------- |
|
1796 /* |
|
1797 void CVoIPAudioServerSession::DetermineG711FrameRateL() |
|
1798 { |
|
1799 if (iDevSound) |
|
1800 { |
|
1801 iDevSoundInitRequest = ETrue; |
|
1802 TMMFState state = EMMFStatePlaying; |
|
1803 |
|
1804 if (iSessionType == EUplink) |
|
1805 { |
|
1806 state = EMMFStateRecording; |
|
1807 } |
|
1808 TRAPD(err, iDevSound->InitializeL(*this, TFourCC(KMccFourCCIdG711), |
|
1809 state)); |
|
1810 |
|
1811 if (err != KErrNone) |
|
1812 { |
|
1813 delete iDevSound; |
|
1814 iDevSound = NULL; |
|
1815 iDevSoundInitRequest = EFalse; |
|
1816 } |
|
1817 } |
|
1818 }*/ |
|
1819 |
|
1820 // ----------------------------------------------------------------------------- |
|
1821 // CVoIPAudioServerSession::ReleaseQueuedMessage |
|
1822 // ----------------------------------------------------------------------------- |
|
1823 // |
|
1824 void CVoIPAudioServerSession::ReleaseQueuedMessage(TInt aError, TUint aFrmSize) |
|
1825 { |
|
1826 delete iDevSound; |
|
1827 iDevSound = NULL; |
|
1828 iDevSoundInitRequest = EFalse; |
|
1829 TVoIPMsgBufPckg p; |
|
1830 |
|
1831 if (iSessionType == EQueryEnc || iSessionType == EUplink) |
|
1832 { |
|
1833 p().iInt = iCodecsCountUp; |
|
1834 } |
|
1835 else if (iSessionType == EQueryDec || iSessionType == EDnlink) |
|
1836 { |
|
1837 p().iInt = iCodecsCountDn; |
|
1838 } |
|
1839 |
|
1840 p().iUint = aFrmSize; |
|
1841 p().iStatus = aError; |
|
1842 TRAPD(err, iMessage.WriteL(0, p)); |
|
1843 iMessage.Complete(err); |
|
1844 iMsgQueued = EFalse; |
|
1845 } |
|
1846 |
|
1847 // ----------------------------------------------------------------------------- |
|
1848 // CVoIPAudioServerSession::SendCmdToThread |
|
1849 // ----------------------------------------------------------------------------- |
|
1850 // |
|
1851 void CVoIPAudioServerSession::SendCmdToThread(const TInt aCommand, |
|
1852 const TInt aStatus) |
|
1853 { |
|
1854 if (iThread.Handle() > 0) |
|
1855 { |
|
1856 iMsgBuffer.iRequest = aCommand; |
|
1857 iMsgBuffer.iStatus = aStatus; |
|
1858 iITCMsgComQueue.Send(iMsgBuffer); |
|
1859 } |
|
1860 else |
|
1861 { |
|
1862 if (iMsgQueued) |
|
1863 { |
|
1864 iMessage.Complete(KErrCancel); |
|
1865 iMsgQueued = EFalse; |
|
1866 } |
|
1867 } |
|
1868 } |
|
1869 |
|
1870 // ----------------------------------------------------------------------------- |
|
1871 // CVoIPAudioServerSession::NotifyClient |
|
1872 // ----------------------------------------------------------------------------- |
|
1873 // |
|
1874 void CVoIPAudioServerSession::NotifyClient(const TInt aCommand, |
|
1875 const TInt aStatus, const TInt64 /*aInt64*/) |
|
1876 { |
|
1877 iMsgBuffer.iRequest = aCommand; |
|
1878 iMsgBuffer.iStatus = aStatus; |
|
1879 iMsgComQueue.Send(iMsgBuffer); |
|
1880 } |
|
1881 |
|
1882 // ----------------------------------------------------------------------------- |
|
1883 // CVoIPAudioServerSession::NotifyDtmfClient |
|
1884 // ----------------------------------------------------------------------------- |
|
1885 // |
|
1886 void CVoIPAudioServerSession::NotifyDtmfClient(const TInt aCommand, |
|
1887 const TInt aStatus) |
|
1888 { |
|
1889 iMsgBuffer.iRequest = aCommand; |
|
1890 iMsgBuffer.iStatus = aStatus; |
|
1891 iMsgComQueueDtmf.Send(iMsgBuffer); |
|
1892 } |
|
1893 |
|
1894 // CALBACKS |
|
1895 |
|
1896 // ----------------------------------------------------------------------------- |
|
1897 // CVoIPAudioServerSession::InitializeComplete |
|
1898 // |
|
1899 // From MDevSoundObserver |
|
1900 // ----------------------------------------------------------------------------- |
|
1901 // |
|
1902 void CVoIPAudioServerSession::InitializeComplete(TInt aError) |
|
1903 { |
|
1904 TRACE_PRN_FN_ENT; |
|
1905 TRACE_PRN_IF_ERR(aError); |
|
1906 |
|
1907 if (aError == KErrNone) |
|
1908 { |
|
1909 TMMFPrioritySettings pSet; |
|
1910 iShared.iMutex.Wait(); |
|
1911 pSet.iPref = iShared.iPreference; |
|
1912 pSet.iPriority = iShared.iPriority; |
|
1913 iShared.iMutex.Signal(); |
|
1914 |
|
1915 if (iDTMFTonePlayer && iDTMFTonePlayerInitRequest) |
|
1916 { |
|
1917 // initialized DTMF player |
|
1918 iDTMFTonePlayer->SetPrioritySettings(pSet); |
|
1919 iDTMFTonePlayer->SetVolume(iMaxVolume); |
|
1920 iToneLenOn = KDTMFToneLengthOn; |
|
1921 iToneLenOff = KDTMFToneLengthOff; |
|
1922 iToneLenPause = KDTMFToneLengthPause; |
|
1923 iDTMFTonePlayerInitRequest = EFalse; |
|
1924 |
|
1925 if (iSessionType == EUplink) |
|
1926 { |
|
1927 NotifyDtmfClient(ECmdDTMFOpenUplinkComplete, aError); |
|
1928 } |
|
1929 else |
|
1930 { |
|
1931 NotifyDtmfClient(ECmdDTMFOpenDnlinkComplete, aError); |
|
1932 } |
|
1933 } |
|
1934 else if (iDevSound && iDevSoundInitRequest) |
|
1935 { |
|
1936 // initialized standard player to check G711 frame rate |
|
1937 iDevSound->SetPrioritySettings(pSet); |
|
1938 iDevSoundInitRequest = EFalse; |
|
1939 |
|
1940 TInt err = KErrNone; |
|
1941 |
|
1942 if (iSessionType == EUplink) |
|
1943 { |
|
1944 TRAP(err, iDevSound->RecordInitL()); |
|
1945 } |
|
1946 else |
|
1947 { |
|
1948 TRAP(err, iDevSound->PlayInitL()); |
|
1949 } |
|
1950 |
|
1951 if (err != KErrNone) |
|
1952 { |
|
1953 ReleaseQueuedMessage(err); |
|
1954 } |
|
1955 } |
|
1956 } |
|
1957 else |
|
1958 { |
|
1959 if (iDevSound && iDevSoundInitRequest) |
|
1960 { |
|
1961 ReleaseQueuedMessage(aError); |
|
1962 } |
|
1963 } |
|
1964 |
|
1965 TRACE_PRN_FN_EXT; |
|
1966 } |
|
1967 |
|
1968 // ----------------------------------------------------------------------------- |
|
1969 // CVoIPAudioServerSession::ToneFinished |
|
1970 // |
|
1971 // From MDevSoundObserver |
|
1972 // ----------------------------------------------------------------------------- |
|
1973 // |
|
1974 void CVoIPAudioServerSession::ToneFinished(TInt aError) |
|
1975 { |
|
1976 TRACE_PRN_IF_ERR(aError); |
|
1977 |
|
1978 NotifyDtmfClient(ECmdDTMFTonePlayFinished, aError); |
|
1979 } |
|
1980 |
|
1981 // ----------------------------------------------------------------------------- |
|
1982 // CVoIPAudioServerSession::BufferToBeEmptied |
|
1983 // |
|
1984 // From MDevSoundObserver |
|
1985 // ----------------------------------------------------------------------------- |
|
1986 // |
|
1987 void CVoIPAudioServerSession::BufferToBeEmptied(CMMFBuffer* aBuffer) |
|
1988 { |
|
1989 CMMFDataBuffer* bufPtr = static_cast<CMMFDataBuffer*> (aBuffer); |
|
1990 TInt len = bufPtr->BufferSize(); |
|
1991 iDevSound->Stop(); |
|
1992 |
|
1993 if (len == KVoIPG711FrameLen10ms) |
|
1994 { |
|
1995 iShared.iMutex.Wait(); |
|
1996 iShared.iCodecSettings.iG711FrameRate = TVoIPCodecSettings::E10MS; |
|
1997 iShared.iMutex.Signal(); |
|
1998 } |
|
1999 |
|
2000 ReleaseQueuedMessage(KErrNone, len); |
|
2001 } |
|
2002 |
|
2003 // ----------------------------------------------------------------------------- |
|
2004 // CVoIPAudioServerSession::BufferToBeFilled |
|
2005 // |
|
2006 // From MDevSoundObserver |
|
2007 // ----------------------------------------------------------------------------- |
|
2008 // |
|
2009 void CVoIPAudioServerSession::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
2010 { |
|
2011 CMMFDataBuffer* bufPtr = static_cast<CMMFDataBuffer*> (aBuffer); |
|
2012 TInt len = bufPtr->RequestSize(); |
|
2013 iDevSound->Stop(); |
|
2014 |
|
2015 if (len == KVoIPG711FrameLen10ms) |
|
2016 { |
|
2017 iShared.iMutex.Wait(); |
|
2018 iShared.iCodecSettings.iG711FrameRate = TVoIPCodecSettings::E10MS; |
|
2019 iShared.iMutex.Signal(); |
|
2020 } |
|
2021 |
|
2022 ReleaseQueuedMessage(KErrNone, len); |
|
2023 |
|
2024 TRACE_PRN_FN_EXT; |
|
2025 } |
|
2026 |
|
2027 // ----------------------------------------------------------------------------- |
|
2028 // CVoIPAudioServerSession::RecordError |
|
2029 // |
|
2030 // From MDevSoundObserver |
|
2031 // ----------------------------------------------------------------------------- |
|
2032 // |
|
2033 void CVoIPAudioServerSession::RecordError(TInt aError) |
|
2034 { |
|
2035 ReleaseQueuedMessage(aError); |
|
2036 TRACE_PRN_IF_ERR(aError); |
|
2037 } |
|
2038 |
|
2039 // ----------------------------------------------------------------------------- |
|
2040 // CVoIPAudioServerSession::PlayError |
|
2041 // |
|
2042 // From MDevSoundObserver |
|
2043 // ----------------------------------------------------------------------------- |
|
2044 // |
|
2045 void CVoIPAudioServerSession::PlayError(TInt aError) |
|
2046 { |
|
2047 ReleaseQueuedMessage(aError); |
|
2048 TRACE_PRN_IF_ERR(aError); |
|
2049 } |
|
2050 |
|
2051 // ----------------------------------------------------------------------------- |
|
2052 // CVoIPAudioServerSession::MapcInitComplete |
|
2053 // |
|
2054 // From MMdaAudioPlayerCallback |
|
2055 // ----------------------------------------------------------------------------- |
|
2056 // |
|
2057 void CVoIPAudioServerSession::MapcInitComplete(TInt aError, |
|
2058 const TTimeIntervalMicroSeconds& aDuration) |
|
2059 { |
|
2060 TRACE_PRN_IF_ERR(aError); |
|
2061 |
|
2062 if (aError == KErrNone) |
|
2063 { |
|
2064 TInt vol = iRingTonePlayer->MaxVolume(); |
|
2065 iRingTonePlayer->SetVolume(vol / 2); |
|
2066 } |
|
2067 |
|
2068 NotifyClient(ECmdRingToneOpenComplete, aError, aDuration.Int64()); |
|
2069 } |
|
2070 |
|
2071 // ----------------------------------------------------------------------------- |
|
2072 // CVoIPAudioServerSession::MapcInitComplete |
|
2073 // |
|
2074 // From MMdaAudioPlayerCallback |
|
2075 // ----------------------------------------------------------------------------- |
|
2076 // |
|
2077 void CVoIPAudioServerSession::MapcPlayComplete(TInt aError) |
|
2078 { |
|
2079 TRACE_PRN_IF_ERR(aError); |
|
2080 NotifyClient(ECmdRingTonePlayComplete, aError); |
|
2081 } |
|
2082 |
|
2083 // ----------------------------------------------------------------------------- |
|
2084 // CVoIPAudioServerSession::DoHandleError |
|
2085 // |
|
2086 // From MThreadComObserver |
|
2087 // |
|
2088 // The recorder thread passes commands to this thread via an active object. |
|
2089 // ----------------------------------------------------------------------------- |
|
2090 // |
|
2091 void CVoIPAudioServerSession::DoHandleError(TInt /*aError*/) |
|
2092 { |
|
2093 /* DEBPRN1(_L("VoIP->CVoIPAudioServerSession[0x%x]::DoHandleError [%d] :>"), aError); |
|
2094 iShared.iMutex.Wait(); |
|
2095 TUserCommand cmd = iShared.iCmd; |
|
2096 iShared.iMutex.Signal(); |
|
2097 |
|
2098 if (iMsgQueued) |
|
2099 { |
|
2100 iMessage.Complete(aError); |
|
2101 iMsgQueued = EFalse; |
|
2102 } |
|
2103 else |
|
2104 { |
|
2105 NotifyClient(cmd, aError); |
|
2106 } |
|
2107 */ |
|
2108 } |
|
2109 |
|
2110 // ----------------------------------------------------------------------------- |
|
2111 // CVoIPAudioServerSession::DoHandleCmd |
|
2112 // |
|
2113 // From MThreadComObserver |
|
2114 // |
|
2115 // Threads pass complete async request events to this thread via an AO. |
|
2116 // ----------------------------------------------------------------------------- |
|
2117 // |
|
2118 void CVoIPAudioServerSession::DoHandleCmd(TExcType aExc, TInt aError) |
|
2119 { |
|
2120 TRACE_PRN_IF_ERR(aError); |
|
2121 |
|
2122 iShared.iMutex.Wait(); |
|
2123 TUserCommand cmd = iShared.iCmd; |
|
2124 iShared.iMutex.Signal(); |
|
2125 |
|
2126 if (aExc == EExcUserInterrupt) |
|
2127 { |
|
2128 switch (cmd) |
|
2129 { |
|
2130 case ECmdDownlinkInitComplete: |
|
2131 { |
|
2132 DownlinkInitComplete(aError); |
|
2133 break; |
|
2134 } |
|
2135 case ECmdUplinkInitComplete: |
|
2136 { |
|
2137 UplinkInitComplete(aError); |
|
2138 break; |
|
2139 } |
|
2140 case ECmdGetVolumeComplete: |
|
2141 { |
|
2142 GetVolumeComplete(aError); |
|
2143 break; |
|
2144 } |
|
2145 case ECmdGetGainComplete: |
|
2146 { |
|
2147 GetGainComplete(aError); |
|
2148 break; |
|
2149 } |
|
2150 case ECmdGetAudioDeviceComplete: |
|
2151 { |
|
2152 GetAudioDeviceComplete(aError); |
|
2153 break; |
|
2154 } |
|
2155 case ECmdGetSupportedBitratesComplete: |
|
2156 { |
|
2157 GetSupportedBitratesComplete(aError); |
|
2158 break; |
|
2159 } |
|
2160 case ECmdGetBitrateComplete: |
|
2161 { |
|
2162 GetBitrateComplete(aError); |
|
2163 break; |
|
2164 } |
|
2165 case ECmdGetG711CodecModeComplete: |
|
2166 { |
|
2167 GetG711CodecModeComplete(aError); |
|
2168 break; |
|
2169 } |
|
2170 case ECmdGetIlbcCodecModeComplete: |
|
2171 { |
|
2172 GetIlbcCodecModeComplete(aError); |
|
2173 break; |
|
2174 } |
|
2175 case ECmdGetFrameModeComplete: |
|
2176 { |
|
2177 GetFrameModeComplete(aError); |
|
2178 break; |
|
2179 } |
|
2180 case ECmdGetFrameModeReqForECComplete: |
|
2181 { |
|
2182 GetFrameModeReqForECComplete(aError); |
|
2183 break; |
|
2184 } |
|
2185 case ECmdGetVadComplete: |
|
2186 { |
|
2187 GetVadComplete(aError); |
|
2188 break; |
|
2189 } |
|
2190 case ECmdGetCngComplete: |
|
2191 { |
|
2192 GetCngComplete(aError); |
|
2193 break; |
|
2194 } |
|
2195 case ECmdGetPlcComplete: |
|
2196 { |
|
2197 GetPlcComplete(aError); |
|
2198 break; |
|
2199 } |
|
2200 case ECmdDnLinkError: |
|
2201 { |
|
2202 NotifyClient(ECmdDnLinkError, aError); |
|
2203 break; |
|
2204 } |
|
2205 case ECmdUpLinkError: |
|
2206 { |
|
2207 NotifyClient(ECmdUpLinkError, aError); |
|
2208 break; |
|
2209 } |
|
2210 default: |
|
2211 break; |
|
2212 } |
|
2213 } |
|
2214 } |
|
2215 |
|
2216 // End of file |