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 const gint retrytime) |
65 TMSIPUplink* self = new (ELeave) TMSIPUplink(); |
66 { |
|
67 TMSIPUplink* self = new (ELeave) TMSIPUplink(observer); |
66 CleanupStack::PushL(self); |
68 CleanupStack::PushL(self); |
67 self->ConstructL(codecID, priority); |
69 self->ConstructL(codecID, priority, retrytime); |
68 CleanupStack::Pop(self); |
70 CleanupStack::Pop(self); |
69 return self; |
71 return self; |
70 } |
72 } |
71 |
73 |
72 // ----------------------------------------------------------------------------- |
74 // ----------------------------------------------------------------------------- |
73 // TMSIPUplink::ConstructL |
75 // TMSIPUplink::ConstructL |
74 // Part two of Symbian two phase construction |
76 // Part two of Symbian two phase construction |
75 // ----------------------------------------------------------------------------- |
77 // ----------------------------------------------------------------------------- |
76 // |
78 // |
77 void TMSIPUplink::ConstructL(const guint32 codecID, |
79 void TMSIPUplink::ConstructL(const guint32 codecID, |
78 const TMMFPrioritySettings priority) |
80 const TMMFPrioritySettings priority, const gint /*retrytime*/) |
79 { |
81 { |
80 TRACE_PRN_FN_ENT; |
82 TRACE_PRN_FN_ENT; |
81 |
|
82 iCodecID = codecID; |
83 iCodecID = codecID; |
83 iPriority = priority; |
84 iPriority = priority; |
84 |
85 |
85 // Client must set these before querying! |
86 // Client must set these before querying! |
86 iG711EncodeMode = TMS_G711_CODEC_MODE_ALAW; |
87 iG711EncodeMode = TMS_G711_CODEC_MODE_ALAW; |
87 iILBCEncodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME; |
88 iILBCEncodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME; |
88 |
|
89 TRAPD(err, InitDevSoundL(EMMFStateRecording, priority)); |
89 TRAPD(err, InitDevSoundL(EMMFStateRecording, priority)); |
90 if (err != TMS_RESULT_SUCCESS) |
90 if (err != TMS_RESULT_SUCCESS) |
91 { |
91 { |
92 User::Leave(err); |
92 User::Leave(err); |
93 } |
93 } |
94 |
94 |
95 iMaxBufLen = ConfigureMedia(iCodecID); |
95 iMaxBufLen = ConfigureMedia(iCodecID); |
96 |
|
97 TRACE_PRN_FN_EXT; |
96 TRACE_PRN_FN_EXT; |
98 } |
97 } |
99 |
98 |
100 // ----------------------------------------------------------------------------- |
99 // ----------------------------------------------------------------------------- |
101 // TMSIPUplink::Start |
100 // TMSIPUplink::Start |
102 // |
101 // |
103 // ----------------------------------------------------------------------------- |
102 // ----------------------------------------------------------------------------- |
104 // |
103 // |
105 void TMSIPUplink::Start() |
104 void TMSIPUplink::Start(const gint /*retrytime*/) |
106 { |
105 { |
107 TRACE_PRN_FN_ENT; |
106 TRACE_PRN_FN_ENT; |
108 |
107 |
109 gint err = TMS_RESULT_ILLEGAL_OPERATION; |
108 gint err = TMS_RESULT_ILLEGAL_OPERATION; |
110 iWriteDataXferHndlToClient = FALSE; |
109 iWriteDataXferHndlToClient = FALSE; |
142 if (iStatus == EStreaming && iDevSound) |
134 if (iStatus == EStreaming && iDevSound) |
143 { |
135 { |
144 iDevSound->Stop(); |
136 iDevSound->Stop(); |
145 iStatus = EReady; |
137 iStatus = EReady; |
146 } |
138 } |
147 else |
|
148 { |
|
149 //TODO: Notify main thread |
|
150 } |
|
151 TRACE_PRN_FN_EXT; |
139 TRACE_PRN_FN_EXT; |
152 } |
140 } |
153 |
141 |
154 // ----------------------------------------------------------------------------- |
142 // ----------------------------------------------------------------------------- |
155 // TMSIPUplink::BufferToBeEmptied |
143 // TMSIPUplink::BufferToBeEmptied |
156 // From MDevSoundObserver |
144 // From MDevSoundObserver |
157 // ----------------------------------------------------------------------------- |
145 // ----------------------------------------------------------------------------- |
158 // |
146 // |
159 void TMSIPUplink::BufferToBeEmptied(CMMFBuffer* aBuffer) |
147 void TMSIPUplink::BufferToBeEmptied(CMMFBuffer* aBuffer) |
160 { |
148 { |
161 iDevSoundBufPtr = static_cast<CMMFDataBuffer*>(aBuffer); |
149 iDevSoundBufPtr = static_cast<CMMFDataBuffer*> (aBuffer); |
162 TDes8& data = iDevSoundBufPtr->Data(); |
150 TDes8& data = iDevSoundBufPtr->Data(); |
163 |
|
164 iBufLen = iDevSoundBufPtr->BufferSize(); |
151 iBufLen = iDevSoundBufPtr->BufferSize(); |
165 TRACE_PRN_N1(_L("TMS->UPL: BTBE->LEN [%d]"), iBufLen); |
152 TRACE_PRN_N1(_L("TMS->UPL: BTBE->LEN [%d]"), iBufLen); |
166 |
153 |
167 // Adjust/create RChunk if necessary |
154 // Adjust/create RChunk if necessary |
168 gint err = DoChunk(iBufLen, iMsgBuffer); |
155 gint err = DoChunk(iBufLen, iMsgBuffer); |
632 // |
613 // |
633 void TMSIPUplink::InitializeComplete(TInt aError) |
614 void TMSIPUplink::InitializeComplete(TInt aError) |
634 { |
615 { |
635 TRACE_PRN_FN_ENT; |
616 TRACE_PRN_FN_ENT; |
636 |
617 |
637 gint err = aError; |
618 gint status = aError; |
638 |
619 |
639 if (err == TMS_RESULT_SUCCESS && iDevSound) |
620 if (status == TMS_RESULT_SUCCESS && iDevSound) |
640 { |
621 { |
641 TMMFCapabilities conf; |
622 TMMFCapabilities conf; |
642 conf = iDevSound->Config(); |
623 conf = iDevSound->Config(); |
643 conf.iRate = EMMFSampleRate8000Hz; |
624 conf.iRate = EMMFSampleRate8000Hz; |
644 conf.iChannels = EMMFMono; |
625 conf.iChannels = EMMFMono; |
645 TRAP(err, iDevSound->SetConfigL(conf)); |
626 TRAP(status, iDevSound->SetConfigL(conf)); |
646 if (err == TMS_RESULT_SUCCESS) |
627 if (status == TMS_RESULT_SUCCESS) |
647 { |
628 { |
648 // We are ready to stream even in case of CI setting failure |
629 // We are ready to stream even in case of CI setting failure |
649 iStatus = EReady; |
630 iStatus = EReady; |
650 iMaxGain = iDevSound->MaxGain(); |
631 iMaxGain = iDevSound->MaxGain(); |
651 } |
632 } |
652 |
633 |
653 // Init Custom Interface API to the Encoder |
634 // Init Custom Interface API to the Encoder. Any return error can |
654 err = SetCodecCi(); |
635 // be ignored as codec can still run in the default mode even if not |
655 if (err != TMS_RESULT_SUCCESS) |
636 // fully configured. |
656 { |
637 SetCodecCi(); |
657 // DEBUG only |
638 } |
658 // Can ignore error - although encoder is not fully configured but |
639 |
659 // it can still run in the default mode. |
640 iObserver.UplinkInitCompleted(status); |
660 TRACE_PRN_IF_ERR(err); |
641 TRACE_PRN_IF_ERR(status); |
661 } |
|
662 } |
|
663 |
|
664 // TODO: Notify client |
|
665 |
|
666 TRACE_PRN_IF_ERR(err); |
|
667 TRACE_PRN_FN_EXT; |
642 TRACE_PRN_FN_EXT; |
668 } |
643 } |
669 |
644 |
670 // ----------------------------------------------------------------------------- |
645 // ----------------------------------------------------------------------------- |
671 // TMSIPUplink::RecordError |
646 // TMSIPUplink::RecordError |
672 // From MDevSoundObserver |
647 // From MDevSoundObserver |
673 // Recording error is send to the main thread. |
648 // Recording error is send to the main thread. |
674 // The state of recorder is rolled back to EReady. |
649 // The state of recorder is rolled back to EReady. |
675 // ----------------------------------------------------------------------------- |
650 // ----------------------------------------------------------------------------- |
676 // |
651 // |
677 void TMSIPUplink::RecordError(TInt /*aError*/) |
652 void TMSIPUplink::RecordError(TInt aError) |
678 { |
653 { |
679 //TRACE_PRN_IF_ERR(aError); |
|
680 |
|
681 #ifdef _DEBUG |
|
682 iSamplesRecCount = 0; |
|
683 #endif |
|
684 iStatus = EReady; |
654 iStatus = EReady; |
685 |
655 iObserver.UplinkStarted(aError); |
686 // TODO: Notify client |
656 TRACE_PRN_IF_ERR(aError); |
687 } |
657 } |
688 |
658 |
689 // End of file |
659 // End of file |
690 |
660 |