|
1 /* |
|
2 * Copyright (c) 2009 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: Telephony Multimedia Service |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32svr.h> |
|
19 #include <e32uid.h> |
|
20 #include <e32capability.h> |
|
21 #include "tmsutility.h" |
|
22 #include "tmsclientserver.h" |
|
23 #include "tmsserver.h" |
|
24 #include "tmsservershutdown.h" |
|
25 #include "tmsserversession.h" |
|
26 #include "tmscallserverstartparam.h" |
|
27 #include "tmscallserver.h" |
|
28 #include "tmscallclisrv.h" |
|
29 #include "globaleffectssettings.h" |
|
30 #include "tareventhandler.h" |
|
31 #include "cspaudiohandler.h" |
|
32 |
|
33 using namespace TMS; |
|
34 |
|
35 // CONSTANTS |
|
36 const TInt KShutDownDelayTime = 5000000; // 5 sec delay time |
|
37 const TInt KOutputsArraySize = 10; |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // TMSServer::NewL |
|
41 // |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 TMSServer* TMSServer::NewL() |
|
45 { |
|
46 TMSServer* self = new (ELeave) TMSServer; |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // TMSServer::TMSServer |
|
55 // |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 TMSServer::TMSServer() : |
|
59 CServer2(CActive::EPriorityHigh, ESharableSessions), |
|
60 iSession(0) |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // TMSServer::~TMSServer |
|
66 // |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 TMSServer::~TMSServer() |
|
70 { |
|
71 TRACE_PRN_FN_ENT; |
|
72 |
|
73 delete iShutdownTimer; |
|
74 iTMSCallServList.ResetAndDestroy(); |
|
75 iTMSCallServList.Close(); |
|
76 iDnlCodecs.Reset(); |
|
77 iDnlCodecs.Close(); |
|
78 iUplCodecs.Reset(); |
|
79 iUplCodecs.Close(); |
|
80 delete iEffectSettings; |
|
81 CancelRoutingNotifier(); |
|
82 CancelCenRepHandler(); |
|
83 |
|
84 TRACE_PRN_FN_EXT; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // TMSServer::NewSessionL |
|
89 // |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 CSession2* TMSServer::NewSessionL(const TVersion& aVersion, |
|
93 const RMessage2& aMessage) const |
|
94 { |
|
95 TRACE_PRN_FN_ENT; |
|
96 |
|
97 if (!aMessage.HasCapability(ECapabilityMultimediaDD)) |
|
98 { |
|
99 User::Leave(KErrPermissionDenied); |
|
100 } |
|
101 |
|
102 const TVersion version(KTMSServMajorVersionNumber, |
|
103 KTMSServMinorVersionNumber, |
|
104 KTMSServBuildVersionNumber); |
|
105 |
|
106 if (!User::QueryVersionSupported(version, aVersion)) |
|
107 { |
|
108 User::Leave(KErrNotSupported); |
|
109 } |
|
110 |
|
111 TMSServerSession* session = TMSServerSession::NewL(*((TMSServer*) this)); |
|
112 |
|
113 TRACE_PRN_FN_EXT; |
|
114 return session; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // TMSServer::ConstructL |
|
119 // |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void TMSServer::ConstructL() |
|
123 { |
|
124 TRACE_PRN_FN_ENT; |
|
125 |
|
126 iShutdownTimer = TMSServerShutDown::NewL(); |
|
127 StartL(KTMSServerName); |
|
128 RThread().SetPriority(EPriorityRealTime); |
|
129 iEffectSettings = GlobalEffectsSettings::NewL(); |
|
130 iTarHandler = NULL; |
|
131 iAudioCenRepHandler = NULL; |
|
132 iCurrentRouting = TMS_AUDIO_OUTPUT_NONE; |
|
133 |
|
134 TRACE_PRN_FN_EXT; |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // TMSServer::AddSession |
|
139 // |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void TMSServer::AddSession() |
|
143 { |
|
144 iSession++; |
|
145 // If shutdown timer is active, cancel it here. |
|
146 iShutdownTimer->Cancel(); |
|
147 |
|
148 TRACE_PRN_N1(_L("TMS->SRV: AddSession->Active Sessions: [%d]"), iSession); |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // TMSServer::DropSession |
|
153 // |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void TMSServer::DropSession() |
|
157 { |
|
158 iSession--; |
|
159 |
|
160 // If session count is zero, start server shutdown |
|
161 if (iSession == 0) |
|
162 { |
|
163 iShutdownTimer->SetDelay(TTimeIntervalMicroSeconds32( |
|
164 KShutDownDelayTime)); |
|
165 } |
|
166 |
|
167 TRACE_PRN_N1(_L("TMS->DNL: DropSession->Active Sessions: [%d]"), iSession); |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // TMSServer::SessionCount |
|
172 // |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 TInt TMSServer::SessionCount() |
|
176 { |
|
177 return iSession; |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // TMSServer::SetDnLinkSession |
|
182 // |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 void TMSServer::SetDnLinkSession(TBool aSession) |
|
186 { |
|
187 iDnlinkSession = aSession; |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // TMSServer::SetUpLinkSession |
|
192 // |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 void TMSServer::SetUpLinkSession(TBool aSession) |
|
196 { |
|
197 iUplinkSession = aSession; |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // TMSServer::HasDnLinkSession |
|
202 // |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 TBool TMSServer::HasDnLinkSession() const |
|
206 { |
|
207 return iDnlinkSession; |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // TMSServer::HasUpLinkSession |
|
212 // |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 TBool TMSServer::HasUpLinkSession() const |
|
216 { |
|
217 return iUplinkSession; |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // TMSServer::GetNewTMSCallSessionHandleL |
|
222 // |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void TMSServer::GetNewTMSCallSessionHandleL(RHandleBase& aHandle) |
|
226 { |
|
227 TRACE_PRN_FN_ENT; |
|
228 |
|
229 TInt i = 0; |
|
230 while (i < iTMSCallServList.Count()) |
|
231 { |
|
232 CStartAndMonitorTMSCallThread* callThread = iTMSCallServList[i]; |
|
233 if (!callThread->IsActive()) |
|
234 { |
|
235 iTMSCallServList.Remove(i); |
|
236 delete callThread; |
|
237 } |
|
238 else |
|
239 { |
|
240 i++; |
|
241 } |
|
242 } |
|
243 iTMSCallServList.Compress(); |
|
244 |
|
245 TMSCallProxyLocal tmsCallSessionHandle; |
|
246 User::LeaveIfError(StartTMSCallServer(tmsCallSessionHandle)); |
|
247 aHandle = tmsCallSessionHandle; |
|
248 TRACE_PRN_FN_EXT; |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // TMSServer::StartTMSCallServer |
|
253 // |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 TInt TMSServer::StartTMSCallServer(TMSCallProxyLocal& aHandle) |
|
257 { |
|
258 TRACE_PRN_FN_ENT; |
|
259 TInt status = KErrNone; |
|
260 |
|
261 CStartAndMonitorTMSCallThread* callServerThread = NULL; |
|
262 TRAP(status, callServerThread = |
|
263 CStartAndMonitorTMSCallThread::NewL(const_cast<TMSServer*>(this))); |
|
264 if (status != KErrNone) |
|
265 { |
|
266 delete callServerThread; |
|
267 } |
|
268 else |
|
269 { |
|
270 status = iTMSCallServList.Append(callServerThread); |
|
271 if (callServerThread && status == KErrNone) |
|
272 { |
|
273 status = callServerThread->StartTMSCallServer(aHandle); |
|
274 TInt count = 0; |
|
275 count = iTMSCallServList.Count(); |
|
276 |
|
277 iTMSCallServList[count - 1]->iTMSCallProxyLocal = aHandle; |
|
278 |
|
279 //cache global vol and global gain to call server thread. |
|
280 TInt volume; |
|
281 switch (iCurrentRouting) |
|
282 { |
|
283 case TMS_AUDIO_OUTPUT_PUBLIC: |
|
284 case TMS_AUDIO_OUTPUT_LOUDSPEAKER: |
|
285 { |
|
286 iEffectSettings->GetLoudSpkrVolume(volume); |
|
287 } |
|
288 break; |
|
289 default: |
|
290 { |
|
291 iEffectSettings->GetEarPieceVolume(volume); |
|
292 } |
|
293 break; |
|
294 } |
|
295 aHandle.SendToCallServer(TMS_EFFECT_GLOBAL_VOL_SET, volume); |
|
296 aHandle.SendToCallServer(TMS_EFFECT_GLOBAL_GAIN_SET, |
|
297 iEffectSettings->Gain()); |
|
298 } |
|
299 else |
|
300 { |
|
301 delete callServerThread; |
|
302 } |
|
303 } |
|
304 |
|
305 TRACE_PRN_FN_EXT; |
|
306 return status; |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // TMSServer::StartRoutingNotifierL |
|
311 // |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void TMSServer::StartRoutingNotifierL() |
|
315 { |
|
316 if (!iTarHandler) |
|
317 { |
|
318 iTarHandler = CTarEventHandler::NewL((const_cast<TMSServer*> (this))); |
|
319 } |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // TMSServer::CancelRoutingNotifier |
|
324 // |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 void TMSServer::CancelRoutingNotifier() |
|
328 { |
|
329 delete iTarHandler; |
|
330 iTarHandler = NULL; |
|
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // TMSServer::StartCenRepHandlerL |
|
335 // |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 void TMSServer::StartCenRepHandlerL() |
|
339 { |
|
340 #ifdef _USE_TELEPHONY_CENREP_ |
|
341 if (!iAudioCenRepHandler) |
|
342 { |
|
343 iAudioCenRepHandler = CSPAudioHandler::NewL( |
|
344 (const_cast<TMSServer*> (this))); |
|
345 } |
|
346 #endif |
|
347 } |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // TMSServer::CancelCenRepHandler |
|
351 // |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 void TMSServer::CancelCenRepHandler() |
|
355 { |
|
356 delete iAudioCenRepHandler; |
|
357 iAudioCenRepHandler = NULL; |
|
358 } |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // TMSServer::SetOutput |
|
362 // |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 TInt TMSServer::SetOutput(CSession2* /*sid*/, TInt output) |
|
366 { |
|
367 TRACE_PRN_FN_ENT; |
|
368 TInt status(KErrNone); |
|
369 |
|
370 status = SendMessageToCallServ(TMS_ROUTING_OUTPUT_SET, output); |
|
371 |
|
372 if (status == KErrNone) |
|
373 { |
|
374 iCurrentRouting = output; |
|
375 } |
|
376 |
|
377 TRACE_PRN_FN_EXT; |
|
378 return status; |
|
379 } |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // TMSServer::GetOutput |
|
383 // |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 TInt TMSServer::GetOutput(const RMessage2& aMessage) |
|
387 { |
|
388 TRACE_PRN_FN_ENT; |
|
389 |
|
390 TUint output; |
|
391 TInt i = 0; |
|
392 TInt status(KErrNone); |
|
393 while (i < iTMSCallServList.Count()) |
|
394 { |
|
395 CStartAndMonitorTMSCallThread* callThread = iTMSCallServList[i]; |
|
396 |
|
397 if (callThread) |
|
398 { |
|
399 status = callThread->iTMSCallProxyLocal.ReceiveFromCallServer( |
|
400 TMS_ROUTING_OUTPUT_GET, output); |
|
401 if (status != KErrNone) |
|
402 { |
|
403 break; |
|
404 } |
|
405 } |
|
406 i++; |
|
407 } |
|
408 TPckgBuf<TInt> p(output); |
|
409 aMessage.Write(0, p); |
|
410 aMessage.Complete(KErrNone); |
|
411 TRACE_PRN_FN_EXT; |
|
412 return KErrNone; |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // TMSServer::GetPreviousOutput |
|
417 // |
|
418 // ----------------------------------------------------------------------------- |
|
419 // |
|
420 TInt TMSServer::GetPreviousOutput(const RMessage2& aMessage) |
|
421 { |
|
422 TRACE_PRN_FN_ENT; |
|
423 TUint output; |
|
424 TInt i = 0; |
|
425 TInt status(KErrNone); |
|
426 while (i < iTMSCallServList.Count()) |
|
427 { |
|
428 CStartAndMonitorTMSCallThread* callThread = iTMSCallServList[i]; |
|
429 |
|
430 if (callThread) |
|
431 { |
|
432 status = callThread->iTMSCallProxyLocal.ReceiveFromCallServer( |
|
433 TMS_ROUTING_PREVIOUSOUTPUT_GET, output); |
|
434 if (status != KErrNone) |
|
435 { |
|
436 break; |
|
437 } |
|
438 } |
|
439 i++; |
|
440 } |
|
441 TPckgBuf<TInt> p(output); |
|
442 aMessage.Write(0, p); |
|
443 aMessage.Complete(KErrNone); |
|
444 TRACE_PRN_FN_EXT; |
|
445 return status; |
|
446 } |
|
447 |
|
448 // ----------------------------------------------------------------------------- |
|
449 // TMSServer::GetAvailableOutputs |
|
450 // |
|
451 // ----------------------------------------------------------------------------- |
|
452 // |
|
453 TInt TMSServer::GetAvailableOutputs(const RMessage2& aMessage) |
|
454 { |
|
455 TRAPD(status, GetAvailableOutputsL(aMessage)); |
|
456 return status; |
|
457 } |
|
458 |
|
459 // ----------------------------------------------------------------------------- |
|
460 // TMSServer::GetAvailableOutputsL |
|
461 // |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 void TMSServer::GetAvailableOutputsL(const RMessage2& aMessage) |
|
465 { |
|
466 TRACE_PRN_FN_ENT; |
|
467 |
|
468 TInt status = KErrNone; |
|
469 OutputVector outputs; |
|
470 HBufC8* buf = HBufC8::NewLC(KOutputsArraySize * sizeof(TUint32)); |
|
471 TPtr8 ptr = buf->Des(); |
|
472 TPckgBuf<TInt> countpkg; |
|
473 TIpcArgs args; |
|
474 args.Set(0, &countpkg); |
|
475 args.Set(1, &ptr); |
|
476 |
|
477 TInt i = 0; |
|
478 |
|
479 while (i < iTMSCallServList.Count()) |
|
480 { |
|
481 CStartAndMonitorTMSCallThread* callThread = iTMSCallServList[i]; |
|
482 |
|
483 if (callThread) |
|
484 { |
|
485 status = callThread->iTMSCallProxyLocal.ReceiveFromCallServer( |
|
486 TMS_ROUTING_AVAILABLE_OUTPUT_GET, args); |
|
487 if (status != KErrNone) |
|
488 { |
|
489 break; |
|
490 } |
|
491 } |
|
492 i++; |
|
493 } |
|
494 |
|
495 aMessage.WriteL(0, countpkg); |
|
496 aMessage.WriteL(1, buf->Des()); |
|
497 aMessage.Complete(status); |
|
498 |
|
499 CleanupStack::PopAndDestroy(buf); |
|
500 |
|
501 TRACE_PRN_FN_EXT; |
|
502 } |
|
503 |
|
504 // ----------------------------------------------------------------------------- |
|
505 // TMSServer::GetMaxLevel |
|
506 // |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 TInt TMSServer::GetMaxLevel(const RMessage2& aMessage) |
|
510 { |
|
511 TRACE_PRN_FN_ENT; |
|
512 TInt status(KErrNone); |
|
513 TPckgBuf<TUint> pckg; |
|
514 |
|
515 pckg() = iEffectSettings->MaxVolume(); |
|
516 if (status == KErrNone) |
|
517 { |
|
518 status = aMessage.Write(0, pckg); |
|
519 aMessage.Complete(status); |
|
520 } |
|
521 TRACE_PRN_FN_EXT; |
|
522 return status; |
|
523 } |
|
524 |
|
525 // ----------------------------------------------------------------------------- |
|
526 // TMSServer::GetLevel |
|
527 // |
|
528 // ----------------------------------------------------------------------------- |
|
529 // |
|
530 TInt TMSServer::GetLevel(const RMessage2& aMessage) |
|
531 { |
|
532 TRACE_PRN_FN_ENT; |
|
533 TInt status(KErrNone); |
|
534 TPckgBuf<TUint> pckg; |
|
535 TInt volume; |
|
536 |
|
537 switch (iCurrentRouting) |
|
538 { |
|
539 case TMS_AUDIO_OUTPUT_PUBLIC: |
|
540 case TMS_AUDIO_OUTPUT_LOUDSPEAKER: |
|
541 iEffectSettings->GetLoudSpkrVolume(volume); |
|
542 break; |
|
543 default: |
|
544 iEffectSettings->GetEarPieceVolume(volume); |
|
545 break; |
|
546 } |
|
547 |
|
548 pckg() = volume; |
|
549 if (status == KErrNone) |
|
550 { |
|
551 aMessage.Write(0, pckg); |
|
552 aMessage.Complete(status); |
|
553 } |
|
554 |
|
555 TRACE_PRN_FN_EXT; |
|
556 return status; |
|
557 } |
|
558 |
|
559 // ----------------------------------------------------------------------------- |
|
560 // TMSServer::SetLevel |
|
561 // |
|
562 // ----------------------------------------------------------------------------- |
|
563 // |
|
564 TInt TMSServer::SetLevel(CSession2* /*sid*/, TBool tmsclient, TInt level) |
|
565 { |
|
566 TRACE_PRN_FN_ENT; |
|
567 TInt status(KErrNone); |
|
568 |
|
569 status = SendMessageToCallServ(TMS_EFFECT_GLOBAL_VOL_SET, level); |
|
570 |
|
571 if (status == KErrNone) |
|
572 { |
|
573 switch (iCurrentRouting) |
|
574 { |
|
575 case TMS_AUDIO_OUTPUT_PUBLIC: |
|
576 case TMS_AUDIO_OUTPUT_LOUDSPEAKER: |
|
577 { |
|
578 if (tmsclient && iAudioCenRepHandler) |
|
579 { |
|
580 iAudioCenRepHandler->SetLoudSpeakerVol(level); |
|
581 } |
|
582 iEffectSettings->SetLoudSpkrVolume(level); |
|
583 } |
|
584 break; |
|
585 case TMS_AUDIO_OUTPUT_NONE: |
|
586 case TMS_AUDIO_OUTPUT_PRIVATE: |
|
587 case TMS_AUDIO_OUTPUT_HANDSET: |
|
588 case TMS_AUDIO_OUTPUT_WIRED_ACCESSORY: |
|
589 case TMS_AUDIO_OUTPUT_ACCESSORY: |
|
590 case TMS_AUDIO_OUTPUT_ETTY: |
|
591 { |
|
592 if (tmsclient && iAudioCenRepHandler) |
|
593 { |
|
594 iAudioCenRepHandler->SetEarPieceVol(level); |
|
595 } |
|
596 iEffectSettings->SetEarPieceVolume(level); |
|
597 } |
|
598 break; |
|
599 default: |
|
600 break; |
|
601 } |
|
602 |
|
603 iSessionIter.SetToFirst(); |
|
604 TMSServerSession* serverSession = |
|
605 static_cast<TMSServerSession*> (iSessionIter++); |
|
606 |
|
607 while (serverSession != NULL) |
|
608 { |
|
609 serverSession->HandleGlobalEffectChange( |
|
610 TMS_EVENT_EFFECT_VOL_CHANGED); |
|
611 |
|
612 serverSession = static_cast<TMSServerSession*> (iSessionIter++); |
|
613 } |
|
614 } |
|
615 |
|
616 TRACE_PRN_FN_EXT; |
|
617 return status; |
|
618 } |
|
619 |
|
620 // ----------------------------------------------------------------------------- |
|
621 // TMSServer::GetMaxGain |
|
622 // |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 TInt TMSServer::GetMaxGain(const RMessage2& aMessage) |
|
626 { |
|
627 TRACE_PRN_FN_ENT; |
|
628 TInt status(KErrNone); |
|
629 TPckgBuf<TUint> pckg; |
|
630 |
|
631 pckg() = iEffectSettings->MaxGain(); |
|
632 if (status == KErrNone) |
|
633 { |
|
634 status = aMessage.Write(0, pckg); |
|
635 aMessage.Complete(status); |
|
636 } |
|
637 |
|
638 TRACE_PRN_FN_EXT; |
|
639 return status; |
|
640 } |
|
641 |
|
642 // ----------------------------------------------------------------------------- |
|
643 // TMSServer::GetGain |
|
644 // |
|
645 // ----------------------------------------------------------------------------- |
|
646 // |
|
647 TInt TMSServer::GetGain(const RMessage2& aMessage) |
|
648 { |
|
649 TRACE_PRN_FN_ENT; |
|
650 TInt status(KErrNone); |
|
651 TPckgBuf<TUint> pckg; |
|
652 |
|
653 pckg() = iEffectSettings->Gain(); |
|
654 if (status == KErrNone) |
|
655 { |
|
656 status = aMessage.Write(0, pckg); |
|
657 aMessage.Complete(status); |
|
658 } |
|
659 |
|
660 TRACE_PRN_FN_EXT; |
|
661 return status; |
|
662 } |
|
663 |
|
664 // ----------------------------------------------------------------------------- |
|
665 // TMSServer::SetGain |
|
666 // |
|
667 // ----------------------------------------------------------------------------- |
|
668 // |
|
669 TInt TMSServer::SetGain(CSession2* /*sid*/, TInt level) |
|
670 { |
|
671 TRACE_PRN_FN_ENT; |
|
672 TInt status(KErrNone); |
|
673 |
|
674 status = SendMessageToCallServ(TMS_EFFECT_GLOBAL_GAIN_SET, level); |
|
675 |
|
676 if (status == KErrNone) |
|
677 { |
|
678 iEffectSettings->SetGain(level); |
|
679 iSessionIter.SetToFirst(); |
|
680 |
|
681 TMSServerSession* serverSession = |
|
682 static_cast<TMSServerSession*> (iSessionIter++); |
|
683 |
|
684 while (serverSession != NULL) |
|
685 { |
|
686 serverSession->HandleGlobalEffectChange( |
|
687 TMS_EVENT_EFFECT_GAIN_CHANGED); |
|
688 serverSession = static_cast<TMSServerSession*> (iSessionIter++); |
|
689 } |
|
690 } |
|
691 |
|
692 TRACE_PRN_FN_EXT; |
|
693 return status; |
|
694 } |
|
695 |
|
696 // ----------------------------------------------------------------------------- |
|
697 // TMSServer::GetSupportedCodecs |
|
698 // |
|
699 // ----------------------------------------------------------------------------- |
|
700 // |
|
701 TInt TMSServer::GetSupportedCodecs(const TMSStreamType strmType, |
|
702 RArray<TFourCC>*& aCodecs) |
|
703 { |
|
704 if (strmType == TMS_STREAM_UPLINK) |
|
705 { |
|
706 aCodecs = &iUplCodecs; |
|
707 } |
|
708 else if (strmType == TMS_STREAM_DOWNLINK) |
|
709 { |
|
710 aCodecs = &iDnlCodecs; |
|
711 } |
|
712 return KErrNone; |
|
713 } |
|
714 |
|
715 // ----------------------------------------------------------------------------- |
|
716 // TMSServer::SendMessageToCallServ |
|
717 // |
|
718 // ----------------------------------------------------------------------------- |
|
719 // |
|
720 TInt TMSServer::SendMessageToCallServ(TInt func, TInt value) |
|
721 { |
|
722 TInt status(KErrNone); |
|
723 TInt i = 0; |
|
724 while (i < iTMSCallServList.Count()) |
|
725 { |
|
726 CStartAndMonitorTMSCallThread* callThread = iTMSCallServList[i]; |
|
727 |
|
728 if (callThread) |
|
729 { |
|
730 if (!callThread->IsActive()) |
|
731 { |
|
732 iTMSCallServList.Remove(i); |
|
733 delete callThread; |
|
734 } |
|
735 else |
|
736 { |
|
737 status = callThread->iTMSCallProxyLocal.SendToCallServer( |
|
738 func, value); |
|
739 if (status != KErrNone) |
|
740 { |
|
741 break; |
|
742 } |
|
743 } |
|
744 } |
|
745 i++; |
|
746 } |
|
747 return status; |
|
748 } |
|
749 |
|
750 // ----------------------------------------------------------------------------- |
|
751 // TMSServer::SendMessageToCallServ |
|
752 // |
|
753 // ----------------------------------------------------------------------------- |
|
754 // |
|
755 TInt TMSServer::SendMessageToCallServ(TInt func, TIpcArgs args) |
|
756 { |
|
757 TInt status(KErrNone); |
|
758 TInt i = 0; |
|
759 while (i < iTMSCallServList.Count()) |
|
760 { |
|
761 CStartAndMonitorTMSCallThread* callThread = iTMSCallServList[i]; |
|
762 |
|
763 if (callThread) |
|
764 { |
|
765 if (!callThread->IsActive()) |
|
766 { |
|
767 iTMSCallServList.Remove(i); |
|
768 delete callThread; |
|
769 } |
|
770 else |
|
771 { |
|
772 status = callThread->iTMSCallProxyLocal.SendToCallServer( |
|
773 func, args); |
|
774 if (status != KErrNone) |
|
775 { |
|
776 break; |
|
777 } |
|
778 } |
|
779 } |
|
780 i++; |
|
781 } |
|
782 return status; |
|
783 } |
|
784 |
|
785 // ----------------------------------------------------------------------------- |
|
786 // TMSServer::NotifyTarClients |
|
787 // |
|
788 // ----------------------------------------------------------------------------- |
|
789 // |
|
790 TInt TMSServer::NotifyTarClients(TRoutingMsgBufPckg routingpckg) |
|
791 { |
|
792 iCurrentRouting = routingpckg().iOutput; |
|
793 iSessionIter.SetToFirst(); |
|
794 TMSServerSession* serverSession = |
|
795 static_cast<TMSServerSession*> (iSessionIter++); |
|
796 |
|
797 while (serverSession != NULL) |
|
798 { |
|
799 serverSession->HandleRoutingChange(routingpckg); |
|
800 serverSession = static_cast<TMSServerSession*> (iSessionIter++); |
|
801 } |
|
802 return KErrNone; |
|
803 } |
|
804 |
|
805 // ----------------------------------------------------------------------------- |
|
806 // RunServerL |
|
807 // |
|
808 // ----------------------------------------------------------------------------- |
|
809 // |
|
810 static void RunServerL() |
|
811 { |
|
812 TRACE_PRN_N(_L("TMS->RunServerL")); |
|
813 |
|
814 // Create and install the active scheduler we need |
|
815 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
816 CleanupStack::PushL(scheduler); |
|
817 CActiveScheduler::Install(scheduler); |
|
818 |
|
819 // Create the server (leave it on the cleanup stack) |
|
820 TMSServer* server = TMSServer::NewL(); |
|
821 |
|
822 // Initialisation complete, now signal the client |
|
823 RProcess::Rendezvous(KErrNone); |
|
824 |
|
825 // Start the scheduler and wait for client requests |
|
826 CActiveScheduler::Start(); |
|
827 |
|
828 // Ready to exit. |
|
829 // Cleanup scheduler and delete the server |
|
830 delete server; |
|
831 CleanupStack::PopAndDestroy(scheduler); |
|
832 |
|
833 TRACE_PRN_N(_L("TMS->RunServerL - TMS server closed")); |
|
834 } |
|
835 |
|
836 // ----------------------------------------------------------------------------- |
|
837 // CStartAndMonitorTMSCallThread::CStartAndMonitorTMSCallThread |
|
838 // Perhaps we need to move this to a .cpp? |
|
839 // ----------------------------------------------------------------------------- |
|
840 // |
|
841 CStartAndMonitorTMSCallThread::CStartAndMonitorTMSCallThread( |
|
842 TMSServer* aServer) : |
|
843 CActive(EPriorityStandard), |
|
844 iTMSServer(aServer) |
|
845 { |
|
846 TRACE_PRN_FN_ENT; |
|
847 CActiveScheduler::Add(this); |
|
848 TRACE_PRN_FN_EXT; |
|
849 } |
|
850 |
|
851 // ----------------------------------------------------------------------------- |
|
852 // CStartAndMonitorTMSCallThread::~CStartAndMonitorTMSCallThread |
|
853 // |
|
854 // ----------------------------------------------------------------------------- |
|
855 // |
|
856 CStartAndMonitorTMSCallThread::~CStartAndMonitorTMSCallThread() |
|
857 { |
|
858 TRACE_PRN_FN_ENT; |
|
859 Cancel(); |
|
860 TRACE_PRN_FN_EXT; |
|
861 } |
|
862 |
|
863 // ----------------------------------------------------------------------------- |
|
864 // CStartAndMonitorTMSCallThread::NewL |
|
865 // |
|
866 // ----------------------------------------------------------------------------- |
|
867 // |
|
868 CStartAndMonitorTMSCallThread* CStartAndMonitorTMSCallThread::NewL( |
|
869 TMSServer* aServer) |
|
870 { |
|
871 TRACE_PRN_FN_ENT; |
|
872 CStartAndMonitorTMSCallThread* self = |
|
873 new (ELeave) CStartAndMonitorTMSCallThread(aServer); |
|
874 CleanupStack::PushL(self); |
|
875 self->ConstructL(); |
|
876 CleanupStack::Pop(self); |
|
877 TRACE_PRN_FN_EXT; |
|
878 return self; |
|
879 } |
|
880 |
|
881 // ----------------------------------------------------------------------------- |
|
882 // CStartAndMonitorTMSCallThread::ConstructL |
|
883 // |
|
884 // ----------------------------------------------------------------------------- |
|
885 // |
|
886 void CStartAndMonitorTMSCallThread::ConstructL() |
|
887 { |
|
888 TRACE_PRN_FN_ENT; |
|
889 TRACE_PRN_FN_EXT; |
|
890 } |
|
891 |
|
892 // ----------------------------------------------------------------------------- |
|
893 // CStartAndMonitorTMSCallThread::StartTMSCallServer |
|
894 // |
|
895 // ----------------------------------------------------------------------------- |
|
896 // |
|
897 TInt CStartAndMonitorTMSCallThread::StartTMSCallServer(TMSCallProxyLocal& aHndl) |
|
898 { |
|
899 TRACE_PRN_FN_ENT; |
|
900 |
|
901 TInt status(KErrNone); |
|
902 TMSCallServerStartParam start(iTMSServer, iCallSrvrHndl); |
|
903 const TUidType serverUid(KNullUid, KNullUid, KUidTMSCallServerUid3); |
|
904 TThreadFunction serverFunc = TMSCallServer::StartThread; |
|
905 |
|
906 status = iServerThread.Create(_L(""), |
|
907 serverFunc, |
|
908 KTMSCallServerStackSize, |
|
909 KTMSCallServerInitHeapSize, |
|
910 KTMSCallServerMaxHeapSize, |
|
911 &start, |
|
912 EOwnerProcess); |
|
913 |
|
914 if (status != KErrNone) |
|
915 { |
|
916 return status; |
|
917 } |
|
918 |
|
919 //NOTE: set priority to EPriorityRealTime or speech codec audio will choke. |
|
920 iServerThread.SetPriority(EPriorityRealTime); |
|
921 |
|
922 // Synchronise with the server |
|
923 TRequestStatus reqStatus; |
|
924 iServerThread.Rendezvous(reqStatus); |
|
925 |
|
926 if (reqStatus != KRequestPending) |
|
927 { |
|
928 iServerThread.Kill(0); |
|
929 } |
|
930 else |
|
931 { |
|
932 // Start the test harness |
|
933 iServerThread.Resume(); |
|
934 // Server will call the reciprocal static synchronise call |
|
935 } |
|
936 |
|
937 User::WaitForRequest(reqStatus); // wait for start or death |
|
938 if (reqStatus.Int() != KErrNone) |
|
939 { |
|
940 iServerThread.Close(); |
|
941 iCallSrvrHndl.Close(); |
|
942 return reqStatus.Int(); |
|
943 } |
|
944 status = aHndl.Open(iCallSrvrHndl); |
|
945 |
|
946 if (status != KErrNone) |
|
947 { |
|
948 iServerThread.Close(); |
|
949 iCallSrvrHndl.Close(); |
|
950 return status; |
|
951 } |
|
952 aHndl.ShareProtected(); |
|
953 iServerThread.Logon(iStatus); |
|
954 SetActive(); |
|
955 |
|
956 TRACE_PRN_FN_EXT; |
|
957 return KErrNone; |
|
958 } |
|
959 |
|
960 // ----------------------------------------------------------------------------- |
|
961 // CStartAndMonitorTMSCallThread::RunL |
|
962 // From CActive |
|
963 // ----------------------------------------------------------------------------- |
|
964 // |
|
965 void CStartAndMonitorTMSCallThread::RunL() |
|
966 { |
|
967 TRACE_PRN_FN_ENT; |
|
968 iServerThread.Close(); |
|
969 //NOTE: This is causing a panic when closing down tms server. |
|
970 //iCallSrvrHndl.Close(); |
|
971 TRACE_PRN_FN_EXT; |
|
972 } |
|
973 |
|
974 // ----------------------------------------------------------------------------- |
|
975 // CStartAndMonitorTMSCallThread::DoCancel |
|
976 // From CActive |
|
977 // ----------------------------------------------------------------------------- |
|
978 // |
|
979 void CStartAndMonitorTMSCallThread::DoCancel() |
|
980 { |
|
981 TRACE_PRN_FN_ENT; |
|
982 iServerThread.LogonCancel(iStatus); |
|
983 TRACE_PRN_FN_EXT; |
|
984 } |
|
985 |
|
986 // ----------------------------------------------------------------------------- |
|
987 // TMSCallProxyLocal::Open |
|
988 // Perhaps we need to move this to a .cpp? |
|
989 // ----------------------------------------------------------------------------- |
|
990 TInt TMSCallProxyLocal::Open(RServer2& aTMSCallServerHandle) |
|
991 { |
|
992 TRACE_PRN_FN_ENT; |
|
993 TInt status(KErrNotSupported); |
|
994 status = CreateSession(aTMSCallServerHandle, |
|
995 TVersion(KTMSCallServerMajorVersionNumber, |
|
996 KTMSCallServerMinorVersionNumber, |
|
997 KTMSCallServerBuildVersionNumber), |
|
998 -1, |
|
999 EIpcSession_GlobalSharable); |
|
1000 TRACE_PRN_FN_EXT; |
|
1001 return status; |
|
1002 } |
|
1003 |
|
1004 // ----------------------------------------------------------------------------- |
|
1005 // TMSCallProxyLocal::SendToCallServer |
|
1006 // |
|
1007 // ----------------------------------------------------------------------------- |
|
1008 // |
|
1009 TInt TMSCallProxyLocal::SendToCallServer(TInt aFunc, TUint value) |
|
1010 { |
|
1011 TInt status(KErrNone); |
|
1012 status = SendReceive(aFunc, TIpcArgs(value)); |
|
1013 return status; |
|
1014 } |
|
1015 |
|
1016 // ----------------------------------------------------------------------------- |
|
1017 // TMSCallProxyLocal::SendToCallServer |
|
1018 // |
|
1019 // ----------------------------------------------------------------------------- |
|
1020 // |
|
1021 TInt TMSCallProxyLocal::SendToCallServer(TInt aFunc, TIpcArgs args) |
|
1022 { |
|
1023 TInt status(KErrNone); |
|
1024 status = SendReceive(aFunc, args); |
|
1025 return status; |
|
1026 } |
|
1027 |
|
1028 // ----------------------------------------------------------------------------- |
|
1029 // TMSCallProxyLocal::ReceiveFromCallServer |
|
1030 // |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // |
|
1033 TInt TMSCallProxyLocal::ReceiveFromCallServer(TInt aFunc, TUint& value) |
|
1034 { |
|
1035 TInt status(KErrNone); |
|
1036 TPckgBuf<TUint> pckg; |
|
1037 TIpcArgs args(&pckg); |
|
1038 status = SendReceive(aFunc, args); |
|
1039 if (status == KErrNone) |
|
1040 { |
|
1041 value = pckg(); |
|
1042 } |
|
1043 return status; |
|
1044 } |
|
1045 |
|
1046 // ----------------------------------------------------------------------------- |
|
1047 // TMSCallProxyLocal::ReceiveFromCallServer |
|
1048 // |
|
1049 // ----------------------------------------------------------------------------- |
|
1050 // |
|
1051 TInt TMSCallProxyLocal::ReceiveFromCallServer(TInt aFunc, TIpcArgs args) |
|
1052 { |
|
1053 TInt status(KErrNone); |
|
1054 status = SendReceive(aFunc, args); |
|
1055 return status; |
|
1056 } |
|
1057 |
|
1058 // ----------------------------------------------------------------------------- |
|
1059 // E32Main |
|
1060 // Entry point for the server |
|
1061 // ----------------------------------------------------------------------------- |
|
1062 // |
|
1063 TInt E32Main() |
|
1064 { |
|
1065 __UHEAP_MARK; |
|
1066 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
1067 TInt r = KErrNoMemory; |
|
1068 if (cleanup) |
|
1069 { |
|
1070 TRAP(r, RunServerL()); |
|
1071 delete cleanup; |
|
1072 } |
|
1073 __UHEAP_MARKEND; |
|
1074 return r; |
|
1075 } |
|
1076 |
|
1077 // End of file |