|
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 <AudioPreference.h> |
|
19 #include <AudioOutput.h> |
|
20 #include <mmcccodecinformation.h> |
|
21 #include <IlbcDecoderIntfc.h> |
|
22 #include <G711DecoderIntfc.h> |
|
23 #include <G729DecoderIntfc.h> |
|
24 #include <ErrorConcealmentIntfc.h> |
|
25 #include "tmsutility.h" |
|
26 #include "tmsipcallstream.h" |
|
27 |
|
28 using namespace TMS; |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // TMSIPDownlink::TMSIPDownlink |
|
32 // Standard Constructor |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 TMSIPDownlink::TMSIPDownlink() |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // TMSIPDownlink::~TMSIPDownlink |
|
41 // Standard Constructor |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 TMSIPDownlink::~TMSIPDownlink() |
|
45 { |
|
46 TRACE_PRN_FN_ENT; |
|
47 |
|
48 Stop(); |
|
49 |
|
50 delete iAudioOutput; |
|
51 delete iErrConcealmentIntfc; |
|
52 delete iG711DecoderIntfc; |
|
53 delete iG729DecoderIntfc; |
|
54 delete iIlbcDecoderIntfc; |
|
55 |
|
56 TRACE_PRN_FN_EXT; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // TMSIPDownlink::NewL |
|
61 // Symbian two-phase constructor |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 TMSIPDownlink* TMSIPDownlink::NewL(const guint32 codecID, |
|
65 const TMMFPrioritySettings priority) |
|
66 { |
|
67 TMSIPDownlink* self = new (ELeave) TMSIPDownlink(); |
|
68 CleanupStack::PushL(self); |
|
69 self->ConstructL(codecID, priority); |
|
70 CleanupStack::Pop(self); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // TMSIPDownlink::ConstructL |
|
76 // Part two of Symbian two phase construction |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void TMSIPDownlink::ConstructL(const guint32 codecID, |
|
80 const TMMFPrioritySettings priority) |
|
81 { |
|
82 TRACE_PRN_FN_ENT; |
|
83 |
|
84 iCodecID = codecID; |
|
85 iPriority = priority; |
|
86 |
|
87 // Client must set these before querying! |
|
88 iG711DecodeMode = TMS_G711_CODEC_MODE_ALAW; |
|
89 iILBCDecodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME; |
|
90 |
|
91 TRAPD(err, InitDevSoundL(EMMFStatePlaying, priority)); |
|
92 if (err != TMS_RESULT_SUCCESS) |
|
93 { |
|
94 User::Leave(err); |
|
95 } |
|
96 |
|
97 iMaxBufLen = ConfigureMedia(iCodecID); |
|
98 |
|
99 TRACE_PRN_FN_EXT; |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // TMSIPDownlink::Start |
|
104 // |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void TMSIPDownlink::Start() |
|
108 { |
|
109 TRACE_PRN_FN_ENT; |
|
110 |
|
111 gint err = TMS_RESULT_ILLEGAL_OPERATION; |
|
112 |
|
113 if (iStatus == EReady && iDevSound) |
|
114 { |
|
115 TRAP(err, iDevSound->PlayInitL()); |
|
116 TRACE_PRN_IF_ERR(err); |
|
117 |
|
118 #ifdef _DEBUG |
|
119 iSamplesPlayedCount = 0; |
|
120 #endif |
|
121 if (err != TMS_RESULT_SUCCESS) |
|
122 { |
|
123 iStatus = EReady; |
|
124 } |
|
125 } |
|
126 |
|
127 TRACE_PRN_FN_EXT; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // TMSIPDownlink::Stop |
|
132 // |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void TMSIPDownlink::Stop() |
|
136 { |
|
137 TRACE_PRN_FN_ENT; |
|
138 |
|
139 if (iStatus == EStreaming && iDevSound) |
|
140 { |
|
141 iDevSound->Stop(); |
|
142 iStatus = EReady; |
|
143 } |
|
144 |
|
145 TRACE_PRN_FN_EXT; |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // TMSIPDownlink::BufferToBeFilled |
|
150 // A reference to the buffer delivered from the DevSound is stored locally |
|
151 // for later use. It will be filled with the data passed from the client |
|
152 // when it calls BufferFilled. |
|
153 // |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void TMSIPDownlink::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
157 { |
|
158 // Store pointer to the received buffer |
|
159 iDevSoundBufPtr = static_cast<CMMFDataBuffer*>(aBuffer); |
|
160 iBufLen = iDevSoundBufPtr->RequestSize(); |
|
161 TRACE_PRN_N1(_L("TMS->DNL->BTBF: LEN[%d]"), iBufLen); |
|
162 |
|
163 #ifndef __WINSCW__ |
|
164 //TODO: revisit this! |
|
165 // The first AMR buffer returns 1 for no data frame. |
|
166 /*if (iCodecID == KMccFourCCIdAMRNB) |
|
167 { |
|
168 iBufLen = iMaxBufLen; |
|
169 }*/ |
|
170 #endif //__WINSCW__ |
|
171 // Create or adjust the chunk |
|
172 gint err = DoChunk(iBufLen, iMsgBuffer); |
|
173 |
|
174 if (err != TMS_RESULT_SUCCESS) |
|
175 { |
|
176 Stop(); |
|
177 iMsgBuffer.iStatus = err; |
|
178 } |
|
179 else |
|
180 { |
|
181 // Notify client there is buffer ready to be filled |
|
182 iMsgBuffer.iStatus = err; |
|
183 iMsgBuffer.iInt = iBufLen; |
|
184 iStatus = EStreaming; |
|
185 // If chunk is opened, we will expect a call from the client to |
|
186 // get chunk handle. When we get a call to copy chunk handle, |
|
187 // check these variables and see if they match. This is not |
|
188 // completely secure, but will provide some level of security |
|
189 if (iMsgBuffer.iBool == TRUE) |
|
190 { |
|
191 iWriteDataXferHndlToClient = TRUE; |
|
192 iKey = iMsgBuffer.iUint32; |
|
193 } |
|
194 } |
|
195 |
|
196 iMsgBuffer.iRequest = ECmdFillBuffer; |
|
197 err = iMsgQueue.Send(iMsgBuffer); |
|
198 |
|
199 TRACE_PRN_IF_ERR(err); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // TMSIPDownlink::BufferFilled |
|
204 // |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 void TMSIPDownlink::BufferFilled(const guint buflen) |
|
208 { |
|
209 TRACE_PRN_N1(_L("TMS->DNL->BF: LEN[%d]"), buflen); |
|
210 |
|
211 // Copy data over from chunk |
|
212 TPtr8 dataPtr(iChunk.Base(), buflen, iMaxBufLen); |
|
213 // RDebug::RawPrint(dataPtr); |
|
214 |
|
215 if (iStatus == EStreaming && iDevSound && iDevSoundBufPtr) |
|
216 { |
|
217 // Fill D/S buffer and send it for playback |
|
218 iDevSoundBufPtr->Data() = dataPtr; |
|
219 TRAP_IGNORE(iDevSoundBufPtr->SetRequestSizeL(buflen)); |
|
220 //try playing anyway |
|
221 iDevSound->PlayData(); |
|
222 } |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // TMSIPDownlink::SetCodecCi |
|
227 // |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 gint TMSIPDownlink::SetCodecCi() |
|
231 { |
|
232 TRAPD(err, SetCodecCiL()); |
|
233 return err; |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // TMSIPDownlink::SetCodecCiL |
|
238 // |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 void TMSIPDownlink::SetCodecCiL() |
|
242 { |
|
243 TRACE_PRN_FN_ENT; |
|
244 |
|
245 switch (iCodecID) |
|
246 { |
|
247 case KMccFourCCIdG711: |
|
248 { |
|
249 if (!iG711DecoderIntfc) |
|
250 { |
|
251 iG711DecoderIntfc = CG711DecoderIntfc::NewL(*iDevSound); |
|
252 } |
|
253 break; |
|
254 } |
|
255 case KMccFourCCIdG729: |
|
256 { |
|
257 if (!iG729DecoderIntfc) |
|
258 { |
|
259 iG729DecoderIntfc = CG729DecoderIntfc::NewL(*iDevSound); |
|
260 } |
|
261 break; |
|
262 } |
|
263 case KMccFourCCIdILBC: |
|
264 { |
|
265 if (!iIlbcDecoderIntfc) |
|
266 { |
|
267 iIlbcDecoderIntfc = CIlbcDecoderIntfc::NewL(*iDevSound); |
|
268 } |
|
269 break; |
|
270 } |
|
271 case KMccFourCCIdAMRNB: |
|
272 case KMMFFourCCCodePCM16: |
|
273 { |
|
274 break; |
|
275 } |
|
276 default: |
|
277 { |
|
278 User::Leave(TMS_RESULT_INVALID_ARGUMENT); |
|
279 break; |
|
280 } |
|
281 } |
|
282 |
|
283 if (!iErrConcealmentIntfc && iCodecID != KMMFFourCCCodePCM16) |
|
284 { |
|
285 iErrConcealmentIntfc = CErrorConcealmentIntfc::NewL(*iDevSound); |
|
286 } |
|
287 |
|
288 TRACE_PRN_FN_EXT; |
|
289 } |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // TMSIPDownlink::SetVolume |
|
293 // |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 gint TMSIPDownlink::SetVolume(const guint volume) |
|
297 { |
|
298 gint ret(TMS_RESULT_UNINITIALIZED_OBJECT); |
|
299 if (iDevSound) |
|
300 { |
|
301 iDevSound->SetVolume(volume); |
|
302 ret = TMS_RESULT_SUCCESS; |
|
303 } |
|
304 TRACE_PRN_N1(_L("TMS->DNL: SetVolume [%d]"), volume); |
|
305 return ret; |
|
306 } |
|
307 |
|
308 // ----------------------------------------------------------------------------- |
|
309 // TMSIPDownlink::GetVolume |
|
310 // |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 gint TMSIPDownlink::GetVolume(guint& volume) |
|
314 { |
|
315 gint ret(TMS_RESULT_UNINITIALIZED_OBJECT); |
|
316 if (iDevSound) |
|
317 { |
|
318 volume = iDevSound->Volume(); |
|
319 ret = TMS_RESULT_SUCCESS; |
|
320 } |
|
321 TRACE_PRN_N1(_L("TMS->DNL: GetVolume [%d]"), volume); |
|
322 return ret; |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // TMSIPDownlink::GetMaxVolume |
|
327 // |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 gint TMSIPDownlink::GetMaxVolume(guint& volume) |
|
331 { |
|
332 gint ret(TMS_RESULT_UNINITIALIZED_OBJECT); |
|
333 if (iDevSound) |
|
334 { |
|
335 volume = iDevSound->MaxVolume(); |
|
336 ret = TMS_RESULT_SUCCESS; |
|
337 } |
|
338 TRACE_PRN_N1(_L("TMS->DNL: MaxVolume [%d]"), volume); |
|
339 return ret; |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // TMSIPDownlink::GetDataXferChunkHndl |
|
344 // |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 gint TMSIPDownlink::GetDataXferChunkHndl(const TUint32 key, RChunk& chunk) |
|
348 { |
|
349 gint status = TMS_RESULT_DOES_NOT_EXIST; |
|
350 |
|
351 if (iChunk.Handle()) |
|
352 { |
|
353 if (iWriteDataXferHndlToClient && (iKey == key)) |
|
354 { |
|
355 chunk = iChunk; |
|
356 iWriteDataXferHndlToClient = FALSE; |
|
357 iKey = 0; |
|
358 status = TMS_RESULT_SUCCESS; |
|
359 } |
|
360 else |
|
361 { |
|
362 status = TMS_RESULT_ILLEGAL_OPERATION; |
|
363 } |
|
364 } |
|
365 |
|
366 TRACE_PRN_IF_ERR(status); |
|
367 return status; |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // TMSIPDownlink::SetIlbcCodecMode |
|
372 // |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 gint TMSIPDownlink::SetIlbcCodecMode(gint mode) |
|
376 { |
|
377 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
378 |
|
379 if (iStatus == EReady) |
|
380 { |
|
381 iILBCDecodeMode = mode; |
|
382 |
|
383 if (iIlbcDecoderIntfc && iCodecID == KMccFourCCIdILBC) |
|
384 { |
|
385 if (mode == TMS_ILBC_CODEC_MODE_20MS_FRAME) |
|
386 { |
|
387 err = iIlbcDecoderIntfc->SetDecoderMode( |
|
388 CIlbcDecoderIntfc::E20msFrame); |
|
389 TRACE_PRN_N(_L("TMS->DNL: iLBC Mode Set [20ms]")); |
|
390 } |
|
391 else if (mode == TMS_ILBC_CODEC_MODE_30MS_FRAME) |
|
392 { |
|
393 err = iIlbcDecoderIntfc->SetDecoderMode( |
|
394 CIlbcDecoderIntfc::E30msFrame); |
|
395 TRACE_PRN_N(_L("TMS->DNL: iLBC Mode Set [30ms]")); |
|
396 } |
|
397 } |
|
398 } |
|
399 |
|
400 TRACE_PRN_IF_ERR(err); |
|
401 return err; |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // TMSIPDownlink::GetIlbcCodecMode |
|
406 // |
|
407 // ----------------------------------------------------------------------------- |
|
408 // |
|
409 gint TMSIPDownlink::GetIlbcCodecMode(gint& mode) |
|
410 { |
|
411 // not available through CIs -> return cashed value |
|
412 mode = iILBCDecodeMode; |
|
413 TRACE_PRN_N1(_L("TMS->DNL: GetIlbcCodecMode [%d]"), mode); |
|
414 return TMS_RESULT_SUCCESS; |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // TMSIPDownlink::SetG711CodecMode |
|
419 // |
|
420 // ----------------------------------------------------------------------------- |
|
421 // |
|
422 gint TMSIPDownlink::SetG711CodecMode(gint mode) |
|
423 { |
|
424 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
425 |
|
426 if (iStatus == EReady) |
|
427 { |
|
428 iG711DecodeMode = mode; |
|
429 |
|
430 if (iG711DecoderIntfc && iCodecID == KMccFourCCIdG711) |
|
431 { |
|
432 if (mode == TMS_G711_CODEC_MODE_ALAW) |
|
433 { |
|
434 err = iG711DecoderIntfc->SetDecoderMode( |
|
435 CG711DecoderIntfc::EDecALaw); |
|
436 TRACE_PRN_N(_L("TMS->DNL: G711 Mode Set [ALaw]")); |
|
437 } |
|
438 else if (mode == TMS_G711_CODEC_MODE_MULAW) |
|
439 { |
|
440 err = iG711DecoderIntfc->SetDecoderMode( |
|
441 CG711DecoderIntfc::EDecULaw); |
|
442 TRACE_PRN_N(_L("TMS->DNL: G711 Mode Set [uLaw]")); |
|
443 } |
|
444 } |
|
445 } |
|
446 |
|
447 TRACE_PRN_IF_ERR(err); |
|
448 return err; |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // TMSIPDownlink::GetG711CodecMode |
|
453 // |
|
454 // ----------------------------------------------------------------------------- |
|
455 // |
|
456 gint TMSIPDownlink::GetG711CodecMode(gint& mode) |
|
457 { |
|
458 // not available through CIs -> return cached value |
|
459 mode = iG711DecodeMode; |
|
460 TRACE_PRN_N1(_L("TMS->DNL: GetG711CodecMode [%d]"), mode); |
|
461 return TMS_RESULT_SUCCESS; |
|
462 } |
|
463 |
|
464 // ----------------------------------------------------------------------------- |
|
465 // TMSIPDownlink::FrameModeRqrdForEC |
|
466 // |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 gint TMSIPDownlink::FrameModeRqrdForEC(gboolean& frmodereq) |
|
470 { |
|
471 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
472 |
|
473 if (iStatus == EReady) |
|
474 { |
|
475 if (iErrConcealmentIntfc) |
|
476 { |
|
477 err = iErrConcealmentIntfc->FrameModeRqrdForEC(frmodereq); |
|
478 TRACE_PRN_N1(_L("TMS->DNL: FrameModeRqrdForEC [%d]"), frmodereq); |
|
479 } |
|
480 } |
|
481 |
|
482 TRACE_PRN_IF_ERR(err); |
|
483 return err; |
|
484 } |
|
485 |
|
486 // ----------------------------------------------------------------------------- |
|
487 // TMSIPDownlink::SetFrameMode |
|
488 // |
|
489 // ----------------------------------------------------------------------------- |
|
490 // |
|
491 gint TMSIPDownlink::SetFrameMode(const gboolean frmode) |
|
492 { |
|
493 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
494 |
|
495 if (iStatus == EReady) |
|
496 { |
|
497 iFrameMode = frmode; |
|
498 |
|
499 if (iErrConcealmentIntfc) |
|
500 { |
|
501 err = iErrConcealmentIntfc->SetFrameMode(frmode); |
|
502 TRACE_PRN_N1(_L("TMS->DNL: SetFrameMode [%d]"), frmode); |
|
503 } |
|
504 } |
|
505 |
|
506 TRACE_PRN_IF_ERR(err); |
|
507 return err; |
|
508 } |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // TMSIPDownlink::GetFrameMode |
|
512 // |
|
513 // ----------------------------------------------------------------------------- |
|
514 // |
|
515 gint TMSIPDownlink::GetFrameMode(gboolean& frmode) |
|
516 { |
|
517 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
518 |
|
519 if (iErrConcealmentIntfc) |
|
520 { |
|
521 // not available through CIs -> return cached value |
|
522 frmode = iFrameMode; |
|
523 TRACE_PRN_N1(_L("TMS->DNL: GetFrameMode [%d]"), frmode); |
|
524 err = TMS_RESULT_SUCCESS; |
|
525 } |
|
526 |
|
527 TRACE_PRN_IF_ERR(err); |
|
528 return err; |
|
529 } |
|
530 |
|
531 // ----------------------------------------------------------------------------- |
|
532 // TMSIPDownlink::ConcealErrorForNextBuffer |
|
533 // |
|
534 // ----------------------------------------------------------------------------- |
|
535 // |
|
536 gint TMSIPDownlink::ConcealErrorForNextBuffer() |
|
537 { |
|
538 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
539 |
|
540 if (iErrConcealmentIntfc) |
|
541 { |
|
542 err = iErrConcealmentIntfc->ConcealErrorForNextBuffer(); |
|
543 TRACE_PRN_N(_L("TMS->DNL: ConcealErrorForNextBuffer")); |
|
544 } |
|
545 |
|
546 TRACE_PRN_IF_ERR(err); |
|
547 return err; |
|
548 } |
|
549 |
|
550 // ----------------------------------------------------------------------------- |
|
551 // TMSIPDownlink::SetCng |
|
552 // |
|
553 // ----------------------------------------------------------------------------- |
|
554 // |
|
555 gint TMSIPDownlink::SetCng(const TMSFormatType fmttype, const gboolean cng) |
|
556 { |
|
557 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
558 |
|
559 if (iStatus == EReady) |
|
560 { |
|
561 if (fmttype == TMS_FORMAT_G711 && iG711DecoderIntfc) |
|
562 { |
|
563 err = iG711DecoderIntfc->SetCng(cng); |
|
564 TRACE_PRN_N1(_L("TMS->DNL: SetCng [%d]"), cng); |
|
565 } |
|
566 else if (fmttype == TMS_FORMAT_ILBC && iIlbcDecoderIntfc) |
|
567 { |
|
568 err = iIlbcDecoderIntfc->SetCng(cng); |
|
569 TRACE_PRN_N1(_L("TMS->DNL: SetCng [%d]"), cng); |
|
570 } |
|
571 } |
|
572 |
|
573 TRACE_PRN_IF_ERR(err); |
|
574 return err; |
|
575 } |
|
576 |
|
577 // ----------------------------------------------------------------------------- |
|
578 // TMSIPDownlink::GetCng |
|
579 // |
|
580 // ----------------------------------------------------------------------------- |
|
581 // |
|
582 gint TMSIPDownlink::GetCng(const TMSFormatType fmttype, gboolean& cng) |
|
583 { |
|
584 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
585 |
|
586 if (iStatus == EReady) |
|
587 { |
|
588 if (fmttype == TMS_FORMAT_G711 && iG711DecoderIntfc) |
|
589 { |
|
590 err = iG711DecoderIntfc->GetCng(cng); |
|
591 TRACE_PRN_N1(_L("TMS->DNL: GetCng [%d]"), cng); |
|
592 } |
|
593 else if (fmttype == TMS_FORMAT_ILBC && iIlbcDecoderIntfc) |
|
594 { |
|
595 err = iIlbcDecoderIntfc->GetCng(cng); |
|
596 TRACE_PRN_N1(_L("TMS->DNL: GetCng [%d]"), cng); |
|
597 } |
|
598 } |
|
599 |
|
600 TRACE_PRN_IF_ERR(err); |
|
601 return err; |
|
602 } |
|
603 |
|
604 // ----------------------------------------------------------------------------- |
|
605 // TMSIPDownlink::SetPlc |
|
606 // |
|
607 // ----------------------------------------------------------------------------- |
|
608 // |
|
609 gint TMSIPDownlink::SetPlc(const TMSFormatType fmttype, const gboolean plc) |
|
610 { |
|
611 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
612 |
|
613 if (iStatus == EReady) |
|
614 { |
|
615 if (fmttype == TMS_FORMAT_G711 && iG711DecoderIntfc) |
|
616 { |
|
617 iPlc = plc; |
|
618 err = iG711DecoderIntfc->SetPlc(iPlc); |
|
619 TRACE_PRN_N1(_L("TMS->DNL: SetPlc [%d]"), plc); |
|
620 } |
|
621 } |
|
622 |
|
623 TRACE_PRN_IF_ERR(err); |
|
624 return err; |
|
625 } |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // TMSIPDownlink::GetPlc |
|
629 // |
|
630 // ----------------------------------------------------------------------------- |
|
631 // |
|
632 gint TMSIPDownlink::GetPlc(const TMSFormatType fmttype, gboolean& plc) |
|
633 { |
|
634 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
635 |
|
636 if (fmttype == TMS_FORMAT_G711 && iG711DecoderIntfc) |
|
637 { |
|
638 // not available through CIs -> return cached value |
|
639 plc = iPlc; |
|
640 err = TMS_RESULT_SUCCESS; |
|
641 TRACE_PRN_N1(_L("TMS->DNL: GetPlc [%d]"), plc); |
|
642 } |
|
643 |
|
644 TRACE_PRN_IF_ERR(err); |
|
645 return err; |
|
646 } |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // TMSIPDownlink::BadLsfNextBuffer |
|
650 // |
|
651 // ----------------------------------------------------------------------------- |
|
652 // |
|
653 gint TMSIPDownlink::BadLsfNextBuffer() |
|
654 { |
|
655 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
656 |
|
657 if (iStatus == EStreaming) |
|
658 { |
|
659 if (iCodecID == KMccFourCCIdG729 && iG729DecoderIntfc) |
|
660 { |
|
661 err = iG729DecoderIntfc->BadLsfNextBuffer(); |
|
662 TRACE_PRN_N(_L("TMS->DNL: BadLsfNextBuffer")); |
|
663 } |
|
664 } |
|
665 |
|
666 TRACE_PRN_IF_ERR(err); |
|
667 return err; |
|
668 } |
|
669 |
|
670 // ----------------------------------------------------------------------------- |
|
671 // TMSIPDownlink::SetAudioDeviceL |
|
672 // |
|
673 // ----------------------------------------------------------------------------- |
|
674 void TMSIPDownlink::SetAudioDeviceL(TMSAudioOutput output) |
|
675 { |
|
676 TRACE_PRN_FN_ENT; |
|
677 |
|
678 if (!iAudioOutput) |
|
679 { |
|
680 iAudioOutput = CAudioOutput::NewL(*iDevSound); |
|
681 } |
|
682 |
|
683 if (iAudioOutput) |
|
684 { |
|
685 // ENoPreference=0, EAll=1, ENoOutput=2, EPrivate=3, EPublic=4 |
|
686 CAudioOutput::TAudioOutputPreference outputDev; |
|
687 |
|
688 switch (output) |
|
689 { |
|
690 case TMS_AUDIO_OUTPUT_PRIVATE: |
|
691 case TMS_AUDIO_OUTPUT_HANDSET: |
|
692 outputDev = CAudioOutput::EPrivate; |
|
693 break; |
|
694 case TMS_AUDIO_OUTPUT_PUBLIC: |
|
695 case TMS_AUDIO_OUTPUT_LOUDSPEAKER: |
|
696 outputDev = CAudioOutput::EPublic; |
|
697 break; |
|
698 default: // Use default device routing |
|
699 outputDev = CAudioOutput::ENoPreference; |
|
700 break; |
|
701 } |
|
702 |
|
703 iAudioOutput->SetAudioOutputL(outputDev); |
|
704 TRACE_PRN_N1(_L("TMS->DNL: SetAudioDeviceL [%d]"), outputDev); |
|
705 } |
|
706 |
|
707 TRACE_PRN_FN_EXT; |
|
708 } |
|
709 |
|
710 // ----------------------------------------------------------------------------- |
|
711 // TMSIPDownlink::GetAudioDeviceL |
|
712 // |
|
713 // ----------------------------------------------------------------------------- |
|
714 // |
|
715 void TMSIPDownlink::GetAudioDeviceL(TMSAudioOutput& output) |
|
716 { |
|
717 TRACE_PRN_FN_ENT; |
|
718 |
|
719 if (!iAudioOutput) |
|
720 { |
|
721 iAudioOutput = CAudioOutput::NewL(*iDevSound); |
|
722 } |
|
723 |
|
724 if (iAudioOutput) |
|
725 { |
|
726 CAudioOutput::TAudioOutputPreference outputDev = |
|
727 iAudioOutput->AudioOutput(); |
|
728 |
|
729 switch (outputDev) |
|
730 { |
|
731 case CAudioOutput::ENoPreference: |
|
732 case CAudioOutput::EAll: |
|
733 case CAudioOutput::ENoOutput: |
|
734 case CAudioOutput::EPrivate: |
|
735 output = TMS_AUDIO_OUTPUT_PRIVATE; |
|
736 break; |
|
737 case CAudioOutput::EPublic: |
|
738 output = TMS_AUDIO_OUTPUT_PUBLIC; |
|
739 break; |
|
740 default: |
|
741 output = TMS_AUDIO_OUTPUT_PRIVATE; |
|
742 break; |
|
743 } |
|
744 } |
|
745 |
|
746 TRACE_PRN_FN_EXT; |
|
747 } |
|
748 |
|
749 // CALLBACKS |
|
750 |
|
751 // ----------------------------------------------------------------------------- |
|
752 // TMSIPDownlink::InitializeComplete |
|
753 // A callback from the DevSound indicating completion of the initialization. |
|
754 // It will send config data to the D/S and configure the encoder via CI. |
|
755 // If everything goes well, the state of the thread is set EReady. |
|
756 // The initialization completion message is sent back to the main thread. |
|
757 // ----------------------------------------------------------------------------- |
|
758 // |
|
759 void TMSIPDownlink::InitializeComplete(TInt aError) |
|
760 { |
|
761 TRACE_PRN_FN_ENT; |
|
762 |
|
763 gint err = aError; |
|
764 |
|
765 if (err == TMS_RESULT_SUCCESS && iDevSound) |
|
766 { |
|
767 TMMFCapabilities conf; |
|
768 conf = iDevSound->Config(); |
|
769 conf.iRate = EMMFSampleRate8000Hz; |
|
770 conf.iChannels = EMMFMono; |
|
771 TRAP(err, iDevSound->SetConfigL(conf)); |
|
772 if (err == TMS_RESULT_SUCCESS) |
|
773 { |
|
774 // We are ready to stream even in case of later CI setting failure |
|
775 iStatus = EReady; |
|
776 iMaxVolume = iDevSound->MaxVolume(); |
|
777 } |
|
778 |
|
779 // Init Custom Interface API to the decoder |
|
780 err = SetCodecCi(); |
|
781 if (err != TMS_RESULT_SUCCESS) |
|
782 { |
|
783 // DEBUG only |
|
784 // Can ignore error - although decoder is not fully configured but |
|
785 // it can still run in the default mode. |
|
786 TRACE_PRN_IF_ERR(err); |
|
787 } |
|
788 } |
|
789 |
|
790 // TODO: Notify client |
|
791 |
|
792 TRACE_PRN_IF_ERR(err); |
|
793 TRACE_PRN_FN_EXT; |
|
794 } |
|
795 |
|
796 // ----------------------------------------------------------------------------- |
|
797 // TMSIPDownlink::PlayError |
|
798 // From MDevSoundObserver |
|
799 // Record error is send to client over comm channel. |
|
800 // The state of recorder is rolled back to EReady. |
|
801 // ----------------------------------------------------------------------------- |
|
802 // |
|
803 void TMSIPDownlink::PlayError(TInt /*aError*/) |
|
804 { |
|
805 //TRACE_PRN_IF_ERR(aError); |
|
806 |
|
807 #ifdef _DEBUG |
|
808 iSamplesPlayedCount = 0; |
|
809 #endif |
|
810 iStatus = EReady; |
|
811 |
|
812 // TODO: Notify client |
|
813 } |
|
814 |
|
815 // End of file |