29 // ----------------------------------------------------------------------------- |
29 // ----------------------------------------------------------------------------- |
30 // TMSIPUplink::TMSIPUplink |
30 // TMSIPUplink::TMSIPUplink |
31 // Standard Constructor |
31 // Standard Constructor |
32 // ----------------------------------------------------------------------------- |
32 // ----------------------------------------------------------------------------- |
33 // |
33 // |
34 TMSIPUplink::TMSIPUplink() |
34 TMSIPUplink::TMSIPUplink(TMSIPDevSoundObserver& observer) : |
|
35 TMSIPCallStreamBase(observer) |
35 { |
36 { |
36 } |
37 } |
37 |
38 |
38 // ----------------------------------------------------------------------------- |
39 // ----------------------------------------------------------------------------- |
39 // TMSIPUplink::~TMSIPUplink |
40 // TMSIPUplink::~TMSIPUplink |
57 // ----------------------------------------------------------------------------- |
58 // ----------------------------------------------------------------------------- |
58 // TMSIPUplink::NewL |
59 // TMSIPUplink::NewL |
59 // Symbian two-phase constructor |
60 // Symbian two-phase constructor |
60 // ----------------------------------------------------------------------------- |
61 // ----------------------------------------------------------------------------- |
61 // |
62 // |
62 TMSIPUplink* TMSIPUplink::NewL(const guint32 codecID, |
63 TMSIPUplink* TMSIPUplink::NewL(TMSIPDevSoundObserver& observer, |
63 const TMMFPrioritySettings priority) |
64 const guint32 codecID, const TMMFPrioritySettings priority) |
64 { |
65 { |
65 TMSIPUplink* self = new (ELeave) TMSIPUplink(); |
66 TMSIPUplink* self = new (ELeave) TMSIPUplink(observer); |
66 CleanupStack::PushL(self); |
67 CleanupStack::PushL(self); |
67 self->ConstructL(codecID, priority); |
68 self->ConstructL(codecID, priority); |
68 CleanupStack::Pop(self); |
69 CleanupStack::Pop(self); |
69 return self; |
70 return self; |
70 } |
71 } |
76 // |
77 // |
77 void TMSIPUplink::ConstructL(const guint32 codecID, |
78 void TMSIPUplink::ConstructL(const guint32 codecID, |
78 const TMMFPrioritySettings priority) |
79 const TMMFPrioritySettings priority) |
79 { |
80 { |
80 TRACE_PRN_FN_ENT; |
81 TRACE_PRN_FN_ENT; |
81 |
|
82 iCodecID = codecID; |
82 iCodecID = codecID; |
83 iPriority = priority; |
83 iPriority = priority; |
84 |
84 |
85 // Client must set these before querying! |
85 // Client must set these before querying! |
86 iG711EncodeMode = TMS_G711_CODEC_MODE_ALAW; |
86 iG711EncodeMode = TMS_G711_CODEC_MODE_ALAW; |
87 iILBCEncodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME; |
87 iILBCEncodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME; |
88 |
|
89 TRAPD(err, InitDevSoundL(EMMFStateRecording, priority)); |
88 TRAPD(err, InitDevSoundL(EMMFStateRecording, priority)); |
90 if (err != TMS_RESULT_SUCCESS) |
89 if (err != TMS_RESULT_SUCCESS) |
91 { |
90 { |
92 User::Leave(err); |
91 User::Leave(err); |
93 } |
92 } |
94 |
93 |
95 iMaxBufLen = ConfigureMedia(iCodecID); |
94 iMaxBufLen = ConfigureMedia(iCodecID); |
96 |
|
97 TRACE_PRN_FN_EXT; |
95 TRACE_PRN_FN_EXT; |
98 } |
96 } |
99 |
97 |
100 // ----------------------------------------------------------------------------- |
98 // ----------------------------------------------------------------------------- |
101 // TMSIPUplink::Start |
99 // TMSIPUplink::Start |
114 TRAP(err, iDevSound->RecordInitL()); |
112 TRAP(err, iDevSound->RecordInitL()); |
115 TRACE_PRN_IF_ERR(err); |
113 TRACE_PRN_IF_ERR(err); |
116 |
114 |
117 if (err != TMS_RESULT_SUCCESS) |
115 if (err != TMS_RESULT_SUCCESS) |
118 { |
116 { |
119 //TODO: Notify main thread |
|
120 iStatus = EReady; |
117 iStatus = EReady; |
121 } |
118 iObserver.UplinkStarted(err); |
122 #ifdef _DEBUG |
119 } |
123 else |
120 } |
124 { |
|
125 iSamplesRecCount = 0; |
|
126 } |
|
127 #endif |
|
128 } |
|
129 |
|
130 TRACE_PRN_FN_EXT; |
121 TRACE_PRN_FN_EXT; |
131 } |
122 } |
132 |
123 |
133 // ----------------------------------------------------------------------------- |
124 // ----------------------------------------------------------------------------- |
134 // TMSIPUplink::Stop |
125 // TMSIPUplink::Stop |
142 if (iStatus == EStreaming && iDevSound) |
133 if (iStatus == EStreaming && iDevSound) |
143 { |
134 { |
144 iDevSound->Stop(); |
135 iDevSound->Stop(); |
145 iStatus = EReady; |
136 iStatus = EReady; |
146 } |
137 } |
147 else |
|
148 { |
|
149 //TODO: Notify main thread |
|
150 } |
|
151 TRACE_PRN_FN_EXT; |
138 TRACE_PRN_FN_EXT; |
152 } |
139 } |
153 |
140 |
154 // ----------------------------------------------------------------------------- |
141 // ----------------------------------------------------------------------------- |
155 // TMSIPUplink::BufferToBeEmptied |
142 // TMSIPUplink::BufferToBeEmptied |
156 // From MDevSoundObserver |
143 // From MDevSoundObserver |
157 // ----------------------------------------------------------------------------- |
144 // ----------------------------------------------------------------------------- |
158 // |
145 // |
159 void TMSIPUplink::BufferToBeEmptied(CMMFBuffer* aBuffer) |
146 void TMSIPUplink::BufferToBeEmptied(CMMFBuffer* aBuffer) |
160 { |
147 { |
161 iDevSoundBufPtr = static_cast<CMMFDataBuffer*>(aBuffer); |
148 iDevSoundBufPtr = static_cast<CMMFDataBuffer*> (aBuffer); |
162 TDes8& data = iDevSoundBufPtr->Data(); |
149 TDes8& data = iDevSoundBufPtr->Data(); |
163 |
|
164 iBufLen = iDevSoundBufPtr->BufferSize(); |
150 iBufLen = iDevSoundBufPtr->BufferSize(); |
165 TRACE_PRN_N1(_L("TMS->UPL: BTBE->LEN [%d]"), iBufLen); |
151 TRACE_PRN_N1(_L("TMS->UPL: BTBE->LEN [%d]"), iBufLen); |
166 |
152 |
167 // Adjust/create RChunk if necessary |
153 // Adjust/create RChunk if necessary |
168 gint err = DoChunk(iBufLen, iMsgBuffer); |
154 gint err = DoChunk(iBufLen, iMsgBuffer); |
482 if (iSpeechEncoderConfig) |
464 if (iSpeechEncoderConfig) |
483 { |
465 { |
484 err = iSpeechEncoderConfig->SetBitrate(bitrate); |
466 err = iSpeechEncoderConfig->SetBitrate(bitrate); |
485 TRACE_PRN_N1(_L("TMS->UPL: SetBitrate [%d]"), bitrate); |
467 TRACE_PRN_N1(_L("TMS->UPL: SetBitrate [%d]"), bitrate); |
486 } |
468 } |
487 |
|
488 TRACE_PRN_IF_ERR(err); |
469 TRACE_PRN_IF_ERR(err); |
489 return err; |
470 return err; |
490 } |
471 } |
491 |
472 |
492 // ----------------------------------------------------------------------------- |
473 // ----------------------------------------------------------------------------- |
501 if (iSpeechEncoderConfig) |
482 if (iSpeechEncoderConfig) |
502 { |
483 { |
503 err = iSpeechEncoderConfig->GetBitrate(bitrate); |
484 err = iSpeechEncoderConfig->GetBitrate(bitrate); |
504 TRACE_PRN_N1(_L("TMS->UPL: GetBitrate [%d]"), bitrate); |
485 TRACE_PRN_N1(_L("TMS->UPL: GetBitrate [%d]"), bitrate); |
505 } |
486 } |
506 |
|
507 TRACE_PRN_IF_ERR(err); |
487 TRACE_PRN_IF_ERR(err); |
508 return err; |
488 return err; |
509 } |
489 } |
510 |
490 |
511 // ----------------------------------------------------------------------------- |
491 // ----------------------------------------------------------------------------- |
632 // |
612 // |
633 void TMSIPUplink::InitializeComplete(TInt aError) |
613 void TMSIPUplink::InitializeComplete(TInt aError) |
634 { |
614 { |
635 TRACE_PRN_FN_ENT; |
615 TRACE_PRN_FN_ENT; |
636 |
616 |
637 gint err = aError; |
617 gint status = aError; |
638 |
618 |
639 if (err == TMS_RESULT_SUCCESS && iDevSound) |
619 if (status == TMS_RESULT_SUCCESS && iDevSound) |
640 { |
620 { |
641 TMMFCapabilities conf; |
621 TMMFCapabilities conf; |
642 conf = iDevSound->Config(); |
622 conf = iDevSound->Config(); |
643 conf.iRate = EMMFSampleRate8000Hz; |
623 conf.iRate = EMMFSampleRate8000Hz; |
644 conf.iChannels = EMMFMono; |
624 conf.iChannels = EMMFMono; |
645 TRAP(err, iDevSound->SetConfigL(conf)); |
625 TRAP(status, iDevSound->SetConfigL(conf)); |
646 if (err == TMS_RESULT_SUCCESS) |
626 if (status == TMS_RESULT_SUCCESS) |
647 { |
627 { |
648 // We are ready to stream even in case of CI setting failure |
628 // We are ready to stream even in case of CI setting failure |
649 iStatus = EReady; |
629 iStatus = EReady; |
650 iMaxGain = iDevSound->MaxGain(); |
630 iMaxGain = iDevSound->MaxGain(); |
651 } |
631 } |
652 |
632 |
653 // Init Custom Interface API to the Encoder |
633 // Init Custom Interface API to the Encoder. Any return error can |
654 err = SetCodecCi(); |
634 // be ignored as codec can still run in the default mode even if not |
655 if (err != TMS_RESULT_SUCCESS) |
635 // fully configured. |
656 { |
636 SetCodecCi(); |
657 // DEBUG only |
637 } |
658 // Can ignore error - although encoder is not fully configured but |
638 |
659 // it can still run in the default mode. |
639 iObserver.UplinkInitCompleted(status); |
660 TRACE_PRN_IF_ERR(err); |
640 TRACE_PRN_IF_ERR(status); |
661 } |
|
662 } |
|
663 |
|
664 // TODO: Notify client |
|
665 |
|
666 TRACE_PRN_IF_ERR(err); |
|
667 TRACE_PRN_FN_EXT; |
641 TRACE_PRN_FN_EXT; |
668 } |
642 } |
669 |
643 |
670 // ----------------------------------------------------------------------------- |
644 // ----------------------------------------------------------------------------- |
671 // TMSIPUplink::RecordError |
645 // TMSIPUplink::RecordError |
672 // From MDevSoundObserver |
646 // From MDevSoundObserver |
673 // Recording error is send to the main thread. |
647 // Recording error is send to the main thread. |
674 // The state of recorder is rolled back to EReady. |
648 // The state of recorder is rolled back to EReady. |
675 // ----------------------------------------------------------------------------- |
649 // ----------------------------------------------------------------------------- |
676 // |
650 // |
677 void TMSIPUplink::RecordError(TInt /*aError*/) |
651 void TMSIPUplink::RecordError(TInt aError) |
678 { |
652 { |
679 //TRACE_PRN_IF_ERR(aError); |
|
680 |
|
681 #ifdef _DEBUG |
|
682 iSamplesRecCount = 0; |
|
683 #endif |
|
684 iStatus = EReady; |
653 iStatus = EReady; |
685 |
654 iObserver.UplinkStarted(aError); |
686 // TODO: Notify client |
655 TRACE_PRN_IF_ERR(aError); |
687 } |
656 } |
688 |
657 |
689 // End of file |
658 // End of file |
690 |
659 |