|
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 <mmcccodecinformation.h> |
|
20 #include <IlbcEncoderIntfc.h> |
|
21 #include <G711EncoderIntfc.h> |
|
22 #include <G729EncoderIntfc.h> |
|
23 #include <SpeechEncoderConfig.h> |
|
24 #include "tmsutility.h" |
|
25 #include "tmsipcallstream.h" |
|
26 |
|
27 using namespace TMS; |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // TMSIPUplink::TMSIPUplink |
|
31 // Standard Constructor |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 TMSIPUplink::TMSIPUplink() |
|
35 { |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // TMSIPUplink::~TMSIPUplink |
|
40 // Standard Constructor |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 TMSIPUplink::~TMSIPUplink() |
|
44 { |
|
45 TRACE_PRN_FN_ENT; |
|
46 |
|
47 Stop(); |
|
48 |
|
49 delete iSpeechEncoderConfig; |
|
50 delete iG711EncoderIntfc; |
|
51 delete iG729EncoderIntfc; |
|
52 delete iIlbcEncoderIntfc; |
|
53 |
|
54 TRACE_PRN_FN_EXT; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // TMSIPUplink::NewL |
|
59 // Symbian two-phase constructor |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 TMSIPUplink* TMSIPUplink::NewL(const guint32 codecID, |
|
63 const TMMFPrioritySettings priority) |
|
64 { |
|
65 TMSIPUplink* self = new (ELeave) TMSIPUplink(); |
|
66 CleanupStack::PushL(self); |
|
67 self->ConstructL(codecID, priority); |
|
68 CleanupStack::Pop(self); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // TMSIPUplink::ConstructL |
|
74 // Part two of Symbian two phase construction |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void TMSIPUplink::ConstructL(const guint32 codecID, |
|
78 const TMMFPrioritySettings priority) |
|
79 { |
|
80 TRACE_PRN_FN_ENT; |
|
81 |
|
82 iCodecID = codecID; |
|
83 iPriority = priority; |
|
84 |
|
85 // Client must set these before querying! |
|
86 iG711EncodeMode = TMS_G711_CODEC_MODE_ALAW; |
|
87 iILBCEncodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME; |
|
88 |
|
89 TRAPD(err, InitDevSoundL(EMMFStateRecording, priority)); |
|
90 if (err != TMS_RESULT_SUCCESS) |
|
91 { |
|
92 User::Leave(err); |
|
93 } |
|
94 |
|
95 iMaxBufLen = ConfigureMedia(iCodecID); |
|
96 |
|
97 TRACE_PRN_FN_EXT; |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // TMSIPUplink::Start |
|
102 // |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void TMSIPUplink::Start() |
|
106 { |
|
107 TRACE_PRN_FN_ENT; |
|
108 |
|
109 gint err = TMS_RESULT_ILLEGAL_OPERATION; |
|
110 iWriteDataXferHndlToClient = FALSE; |
|
111 |
|
112 if (iStatus == EReady && iDevSound) |
|
113 { |
|
114 TRAP(err, iDevSound->RecordInitL()); |
|
115 TRACE_PRN_IF_ERR(err); |
|
116 |
|
117 if (err != TMS_RESULT_SUCCESS) |
|
118 { |
|
119 //TODO: Notify main thread |
|
120 iStatus = EReady; |
|
121 } |
|
122 #ifdef _DEBUG |
|
123 else |
|
124 { |
|
125 iSamplesRecCount = 0; |
|
126 } |
|
127 #endif |
|
128 } |
|
129 |
|
130 TRACE_PRN_FN_EXT; |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // TMSIPUplink::Stop |
|
135 // |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void TMSIPUplink::Stop() |
|
139 { |
|
140 TRACE_PRN_FN_ENT; |
|
141 |
|
142 if (iStatus == EStreaming && iDevSound) |
|
143 { |
|
144 iDevSound->Stop(); |
|
145 iStatus = EReady; |
|
146 } |
|
147 else |
|
148 { |
|
149 //TODO: Notify main thread |
|
150 } |
|
151 TRACE_PRN_FN_EXT; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // TMSIPUplink::BufferToBeEmptied |
|
156 // From MDevSoundObserver |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void TMSIPUplink::BufferToBeEmptied(CMMFBuffer* aBuffer) |
|
160 { |
|
161 iDevSoundBufPtr = static_cast<CMMFDataBuffer*>(aBuffer); |
|
162 TDes8& data = iDevSoundBufPtr->Data(); |
|
163 |
|
164 iBufLen = iDevSoundBufPtr->BufferSize(); |
|
165 TRACE_PRN_N1(_L("TMS->UPL: BTBE->LEN [%d]"), iBufLen); |
|
166 |
|
167 // Adjust/create RChunk if necessary |
|
168 gint err = DoChunk(iBufLen, iMsgBuffer); |
|
169 |
|
170 if (err != TMS_RESULT_SUCCESS) |
|
171 { |
|
172 Stop(); |
|
173 iMsgBuffer.iStatus = err; |
|
174 } |
|
175 else |
|
176 { |
|
177 // Pass buffer parameters to the client |
|
178 iMsgBuffer.iStatus = err; |
|
179 iMsgBuffer.iInt = iBufLen; |
|
180 |
|
181 // Copy data over to RChunk |
|
182 TPtr8 dataPtr(iChunk.Base(), iBufLen, iBufLen); |
|
183 dataPtr = data; |
|
184 iStatus = EStreaming; |
|
185 |
|
186 // If chunk is opened, we will expect a call from the client to |
|
187 // get chunk handle. When we get a call to copy chunk handle, |
|
188 // check these variables and see if they match. This is not |
|
189 // completely secure, but will provide some level of security. |
|
190 if (iMsgBuffer.iBool == TRUE) |
|
191 { |
|
192 iWriteDataXferHndlToClient = TRUE; |
|
193 iKey = iMsgBuffer.iUint32; |
|
194 } |
|
195 } |
|
196 |
|
197 // Notify client there is buffer ready to be emptied |
|
198 iMsgBuffer.iRequest = ECmdEmptyBuffer; |
|
199 err = iMsgQueue.Send(iMsgBuffer); |
|
200 TRACE_PRN_IF_ERR(err); |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // TMSIPUplink::BufferEmptied |
|
205 // |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void TMSIPUplink::BufferEmptied() |
|
209 { |
|
210 //TRACE_PRN_N(_L("TMS->UPL->BE")); |
|
211 if (iDevSound) |
|
212 { |
|
213 iDevSound->RecordData(); |
|
214 } |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // TMSIPUplink::SetCodecCi |
|
219 // |
|
220 // ----------------------------------------------------------------------------- |
|
221 // |
|
222 gint TMSIPUplink::SetCodecCi() |
|
223 { |
|
224 TRAPD(err, SetCodecCiL()); |
|
225 return err; |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // TMSIPUplink::SetCodecCiL |
|
230 // |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 void TMSIPUplink::SetCodecCiL() |
|
234 { |
|
235 TRACE_PRN_FN_ENT; |
|
236 |
|
237 switch (iCodecID) |
|
238 { |
|
239 case KMccFourCCIdG711: |
|
240 { |
|
241 if (!iG711EncoderIntfc) |
|
242 { |
|
243 iG711EncoderIntfc = CG711EncoderIntfc::NewL(*iDevSound); |
|
244 } |
|
245 break; |
|
246 } |
|
247 case KMccFourCCIdG729: |
|
248 { |
|
249 if (!iG729EncoderIntfc) |
|
250 { |
|
251 iG729EncoderIntfc = CG729EncoderIntfc::NewL(*iDevSound); |
|
252 } |
|
253 break; |
|
254 } |
|
255 case KMccFourCCIdILBC: |
|
256 { |
|
257 if (!iIlbcEncoderIntfc) |
|
258 { |
|
259 iIlbcEncoderIntfc = CIlbcEncoderIntfc::NewL(*iDevSound); |
|
260 } |
|
261 break; |
|
262 } |
|
263 case KMccFourCCIdAMRNB: |
|
264 case KMMFFourCCCodePCM16: |
|
265 { |
|
266 break; |
|
267 } |
|
268 default: |
|
269 { |
|
270 User::Leave(TMS_RESULT_INVALID_ARGUMENT); |
|
271 break; |
|
272 } |
|
273 } |
|
274 |
|
275 if (!iSpeechEncoderConfig && iCodecID != KMMFFourCCCodePCM16) |
|
276 { |
|
277 iSpeechEncoderConfig = CSpeechEncoderConfig::NewL(*iDevSound); |
|
278 } |
|
279 |
|
280 TRACE_PRN_FN_EXT; |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // TMSIPUplink::SetGain |
|
285 // |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 gint TMSIPUplink::SetGain(const guint gain) |
|
289 { |
|
290 gint status(TMS_RESULT_UNINITIALIZED_OBJECT); |
|
291 if (iDevSound) |
|
292 { |
|
293 iDevSound->SetGain(gain); |
|
294 status = TMS_RESULT_SUCCESS; |
|
295 } |
|
296 TRACE_PRN_N1(_L("TMS->UPL: SetGain [%d]"), gain); |
|
297 return status; |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // TMSIPUplink::GetGain |
|
302 // |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 gint TMSIPUplink::GetGain(guint& gain) |
|
306 { |
|
307 gint status(TMS_RESULT_UNINITIALIZED_OBJECT); |
|
308 if (iDevSound) |
|
309 { |
|
310 gain = iDevSound->Gain(); |
|
311 status = TMS_RESULT_SUCCESS; |
|
312 } |
|
313 TRACE_PRN_N1(_L("TMS->UPL: GetGain [%d]"), gain); |
|
314 return status; |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // TMSIPUplink::GetMaxGain |
|
319 // |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 gint TMSIPUplink::GetMaxGain(guint& gain) |
|
323 { |
|
324 gint status(TMS_RESULT_UNINITIALIZED_OBJECT); |
|
325 if (iDevSound) |
|
326 { |
|
327 gain = iDevSound->MaxGain(); |
|
328 status = TMS_RESULT_SUCCESS; |
|
329 } |
|
330 TRACE_PRN_N1(_L("TMS->UPL: MaxGain [%d]"), gain); |
|
331 return status; |
|
332 } |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // TMSIPUplink::GetDataXferChunkHndl |
|
336 // |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 gint TMSIPUplink::GetDataXferChunkHndl(const TUint32 key, RChunk& chunk) |
|
340 { |
|
341 gint status = TMS_RESULT_SUCCESS; |
|
342 |
|
343 if (iChunk.Handle()) |
|
344 { |
|
345 if (iWriteDataXferHndlToClient && (iKey == key)) |
|
346 { |
|
347 chunk = iChunk; |
|
348 iWriteDataXferHndlToClient = FALSE; |
|
349 iKey = 0; |
|
350 } |
|
351 else |
|
352 { |
|
353 status = TMS_RESULT_ILLEGAL_OPERATION; |
|
354 } |
|
355 } |
|
356 |
|
357 return status; |
|
358 } |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // TMSIPUplink::SetIlbcCodecMode |
|
362 // |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 gint TMSIPUplink::SetIlbcCodecMode(const gint mode) |
|
366 { |
|
367 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
368 |
|
369 if (iStatus == EReady) |
|
370 { |
|
371 iILBCEncodeMode = mode; |
|
372 |
|
373 if (iIlbcEncoderIntfc && iCodecID == KMccFourCCIdILBC) |
|
374 { |
|
375 if (mode == TMS_ILBC_CODEC_MODE_20MS_FRAME) |
|
376 { |
|
377 err = iIlbcEncoderIntfc->SetEncoderMode( |
|
378 CIlbcEncoderIntfc::E20msFrame); |
|
379 TRACE_PRN_N(_L("TMS->UPL: SetIlbcCodecMode [20ms Frame]")); |
|
380 } |
|
381 else if (mode == TMS_ILBC_CODEC_MODE_30MS_FRAME) |
|
382 { |
|
383 err = iIlbcEncoderIntfc->SetEncoderMode( |
|
384 CIlbcEncoderIntfc::E30msFrame); |
|
385 TRACE_PRN_N(_L("TMS->UPL: SetIlbcCodecMode [30ms Frame]")); |
|
386 } |
|
387 } |
|
388 } |
|
389 |
|
390 TRACE_PRN_IF_ERR(err); |
|
391 return err; |
|
392 } |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // TMSIPUplink::GetIlbcCodecMode |
|
396 // |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 gint TMSIPUplink::GetIlbcCodecMode(gint& mode) |
|
400 { |
|
401 // not available through CIs -> return cached value |
|
402 mode = iILBCEncodeMode; |
|
403 TRACE_PRN_N1(_L("TMS->UPL: GetIlbcCodecMode [%d]"), mode); |
|
404 return TMS_RESULT_SUCCESS; |
|
405 } |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // TMSIPUplink::SetG711CodecMode |
|
409 // |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 gint TMSIPUplink::SetG711CodecMode(const gint mode) |
|
413 { |
|
414 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
415 |
|
416 if (iStatus == EReady) |
|
417 { |
|
418 iG711EncodeMode = mode; |
|
419 |
|
420 if (iG711EncoderIntfc && iCodecID == KMccFourCCIdG711) |
|
421 { |
|
422 if (mode == TMS_G711_CODEC_MODE_ALAW) |
|
423 { |
|
424 err = iG711EncoderIntfc->SetEncoderMode( |
|
425 CG711EncoderIntfc::EEncALaw); |
|
426 TRACE_PRN_N(_L("TMS->UPL: SetG711CodecMode [ALaw]")); |
|
427 } |
|
428 else if (mode == TMS_G711_CODEC_MODE_MULAW) |
|
429 { |
|
430 err = iG711EncoderIntfc->SetEncoderMode( |
|
431 CG711EncoderIntfc::EEncULaw); |
|
432 TRACE_PRN_N(_L("TMS->UPL: SetG711CodecMode [uLaw]")); |
|
433 } |
|
434 } |
|
435 } |
|
436 |
|
437 TRACE_PRN_IF_ERR(err); |
|
438 return err; |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // TMSIPUplink::GetG711CodecMode |
|
443 // |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 gint TMSIPUplink::GetG711CodecMode(gint& mode) |
|
447 { |
|
448 // not available through CIs -> return cached value |
|
449 mode = iG711EncodeMode; |
|
450 TRACE_PRN_N1(_L("TMS->UPL: GetG711CodecMode [%d]"), mode); |
|
451 return TMS_RESULT_SUCCESS; |
|
452 } |
|
453 |
|
454 // ----------------------------------------------------------------------------- |
|
455 // TMSIPUplink::GetSupportedBitrates |
|
456 // |
|
457 // ----------------------------------------------------------------------------- |
|
458 // |
|
459 gint TMSIPUplink::GetSupportedBitrates(RArray<guint>& bitrates) |
|
460 { |
|
461 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
462 bitrates.Reset(); |
|
463 |
|
464 if (iSpeechEncoderConfig) |
|
465 { |
|
466 err = iSpeechEncoderConfig->GetSupportedBitrates(bitrates); |
|
467 } |
|
468 |
|
469 TRACE_PRN_IF_ERR(err); |
|
470 return err; |
|
471 } |
|
472 |
|
473 // ----------------------------------------------------------------------------- |
|
474 // TMSIPUplink::SetBitrate |
|
475 // |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 gint TMSIPUplink::SetBitrate(guint bitrate) |
|
479 { |
|
480 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
481 |
|
482 if (iSpeechEncoderConfig) |
|
483 { |
|
484 err = iSpeechEncoderConfig->SetBitrate(bitrate); |
|
485 TRACE_PRN_N1(_L("TMS->UPL: SetBitrate [%d]"), bitrate); |
|
486 } |
|
487 |
|
488 TRACE_PRN_IF_ERR(err); |
|
489 return err; |
|
490 } |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // TMSIPUplink::GetBitrate |
|
494 // |
|
495 // ----------------------------------------------------------------------------- |
|
496 // |
|
497 gint TMSIPUplink::GetBitrate(guint& bitrate) |
|
498 { |
|
499 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
500 |
|
501 if (iSpeechEncoderConfig) |
|
502 { |
|
503 err = iSpeechEncoderConfig->GetBitrate(bitrate); |
|
504 TRACE_PRN_N1(_L("TMS->UPL: GetBitrate [%d]"), bitrate); |
|
505 } |
|
506 |
|
507 TRACE_PRN_IF_ERR(err); |
|
508 return err; |
|
509 } |
|
510 |
|
511 // ----------------------------------------------------------------------------- |
|
512 // TMSIPUplink::SetVad |
|
513 // |
|
514 // ----------------------------------------------------------------------------- |
|
515 // |
|
516 gint TMSIPUplink::SetVad(const TMSFormatType fmttype, const gboolean vad) |
|
517 { |
|
518 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
519 |
|
520 switch (fmttype) |
|
521 { |
|
522 case TMS_FORMAT_G711: |
|
523 { |
|
524 if (iG711EncoderIntfc) |
|
525 { |
|
526 err = iG711EncoderIntfc->SetVadMode(vad); |
|
527 TRACE_PRN_N1(_L("TMS->UPL: SetVad [%d]"), vad); |
|
528 } |
|
529 break; |
|
530 } |
|
531 case TMS_FORMAT_G729: |
|
532 { |
|
533 if (iG729EncoderIntfc) |
|
534 { |
|
535 err = iG729EncoderIntfc->SetVadMode(vad); |
|
536 TRACE_PRN_N1(_L("TMS->UPL: SetVad [%d]"), vad); |
|
537 } |
|
538 break; |
|
539 } |
|
540 case TMS_FORMAT_ILBC: |
|
541 { |
|
542 if (iIlbcEncoderIntfc) |
|
543 { |
|
544 err = iIlbcEncoderIntfc->SetVadMode(vad); |
|
545 TRACE_PRN_N1(_L("TMS->UPL: SetVad [%d]"), vad); |
|
546 } |
|
547 break; |
|
548 } |
|
549 case TMS_FORMAT_AMR: |
|
550 { |
|
551 if (iSpeechEncoderConfig) |
|
552 { |
|
553 err = iSpeechEncoderConfig->SetVadMode(vad); |
|
554 TRACE_PRN_N1(_L("TMS->UPL: SetVad [%d]"), vad); |
|
555 } |
|
556 break; |
|
557 } |
|
558 default: |
|
559 { |
|
560 break; //TMS_RESULT_DOES_NOT_EXIST |
|
561 } |
|
562 } |
|
563 |
|
564 TRACE_PRN_IF_ERR(err); |
|
565 return err; |
|
566 } |
|
567 |
|
568 // ----------------------------------------------------------------------------- |
|
569 // TMSIPUplink::GetVad |
|
570 // |
|
571 // ----------------------------------------------------------------------------- |
|
572 // |
|
573 gint TMSIPUplink::GetVad(const TMSFormatType fmttype, gboolean& vad) |
|
574 { |
|
575 gint err = TMS_RESULT_DOES_NOT_EXIST; |
|
576 |
|
577 switch (fmttype) |
|
578 { |
|
579 case TMS_FORMAT_G711: |
|
580 { |
|
581 if (iG711EncoderIntfc) |
|
582 { |
|
583 err = iG711EncoderIntfc->GetVadMode(vad); |
|
584 TRACE_PRN_N1(_L("TMS->UPL: GetVad [%d]"), vad); |
|
585 } |
|
586 break; |
|
587 } |
|
588 case TMS_FORMAT_G729: |
|
589 { |
|
590 if (iG729EncoderIntfc) |
|
591 { |
|
592 err = iG729EncoderIntfc->GetVadMode(vad); |
|
593 TRACE_PRN_N1(_L("TMS->UPL: GetVad [%d]"), vad); |
|
594 } |
|
595 break; |
|
596 } |
|
597 case TMS_FORMAT_ILBC: |
|
598 { |
|
599 if (iIlbcEncoderIntfc) |
|
600 { |
|
601 err = iIlbcEncoderIntfc->GetVadMode(vad); |
|
602 TRACE_PRN_N1(_L("TMS->UPL: GetVad [%d]"), vad); |
|
603 } |
|
604 break; |
|
605 } |
|
606 case TMS_FORMAT_AMR: |
|
607 { |
|
608 if (iSpeechEncoderConfig) |
|
609 { |
|
610 err = iSpeechEncoderConfig->GetVadMode(vad); |
|
611 TRACE_PRN_N1(_L("TMS->UPL: GetVad [%d]"), vad); |
|
612 } |
|
613 break; |
|
614 } |
|
615 default: |
|
616 { |
|
617 break; //TMS_RESULT_DOES_NOT_EXIST |
|
618 } |
|
619 } |
|
620 |
|
621 TRACE_PRN_IF_ERR(err); |
|
622 return err; |
|
623 } |
|
624 |
|
625 // ----------------------------------------------------------------------------- |
|
626 // TMSIPUplink::InitializeComplete |
|
627 // A callback from the DevSound indicating completion of the initialization. |
|
628 // It will send config data to the D/S and configure the encoder via CI. |
|
629 // If everything goes well, the state of the thread is set EReady. |
|
630 // The initialization completion message is sent back to the main thread. |
|
631 // ----------------------------------------------------------------------------- |
|
632 // |
|
633 void TMSIPUplink::InitializeComplete(TInt aError) |
|
634 { |
|
635 TRACE_PRN_FN_ENT; |
|
636 |
|
637 gint err = aError; |
|
638 |
|
639 if (err == TMS_RESULT_SUCCESS && iDevSound) |
|
640 { |
|
641 TMMFCapabilities conf; |
|
642 conf = iDevSound->Config(); |
|
643 conf.iRate = EMMFSampleRate8000Hz; |
|
644 conf.iChannels = EMMFMono; |
|
645 TRAP(err, iDevSound->SetConfigL(conf)); |
|
646 if (err == TMS_RESULT_SUCCESS) |
|
647 { |
|
648 // We are ready to stream even in case of CI setting failure |
|
649 iStatus = EReady; |
|
650 iMaxGain = iDevSound->MaxGain(); |
|
651 } |
|
652 |
|
653 // Init Custom Interface API to the Encoder |
|
654 err = SetCodecCi(); |
|
655 if (err != TMS_RESULT_SUCCESS) |
|
656 { |
|
657 // DEBUG only |
|
658 // Can ignore error - although encoder is not fully configured but |
|
659 // it can still run in the default mode. |
|
660 TRACE_PRN_IF_ERR(err); |
|
661 } |
|
662 } |
|
663 |
|
664 // TODO: Notify client |
|
665 |
|
666 TRACE_PRN_IF_ERR(err); |
|
667 TRACE_PRN_FN_EXT; |
|
668 } |
|
669 |
|
670 // ----------------------------------------------------------------------------- |
|
671 // TMSIPUplink::RecordError |
|
672 // From MDevSoundObserver |
|
673 // Recording error is send to the main thread. |
|
674 // The state of recorder is rolled back to EReady. |
|
675 // ----------------------------------------------------------------------------- |
|
676 // |
|
677 void TMSIPUplink::RecordError(TInt /*aError*/) |
|
678 { |
|
679 //TRACE_PRN_IF_ERR(aError); |
|
680 |
|
681 #ifdef _DEBUG |
|
682 iSamplesRecCount = 0; |
|
683 #endif |
|
684 iStatus = EReady; |
|
685 |
|
686 // TODO: Notify client |
|
687 } |
|
688 |
|
689 // End of file |
|
690 |