30 // ----------------------------------------------------------------------------- |
30 // ----------------------------------------------------------------------------- |
31 // TMSIPDownlink::TMSIPDownlink |
31 // TMSIPDownlink::TMSIPDownlink |
32 // Standard Constructor |
32 // Standard Constructor |
33 // ----------------------------------------------------------------------------- |
33 // ----------------------------------------------------------------------------- |
34 // |
34 // |
35 TMSIPDownlink::TMSIPDownlink() |
35 TMSIPDownlink::TMSIPDownlink(TMSIPDevSoundObserver& observer) : |
|
36 TMSIPCallStreamBase(observer) |
36 { |
37 { |
37 } |
38 } |
38 |
39 |
39 // ----------------------------------------------------------------------------- |
40 // ----------------------------------------------------------------------------- |
40 // TMSIPDownlink::~TMSIPDownlink |
41 // TMSIPDownlink::~TMSIPDownlink |
59 // ----------------------------------------------------------------------------- |
60 // ----------------------------------------------------------------------------- |
60 // TMSIPDownlink::NewL |
61 // TMSIPDownlink::NewL |
61 // Symbian two-phase constructor |
62 // Symbian two-phase constructor |
62 // ----------------------------------------------------------------------------- |
63 // ----------------------------------------------------------------------------- |
63 // |
64 // |
64 TMSIPDownlink* TMSIPDownlink::NewL(const guint32 codecID, |
65 TMSIPDownlink* TMSIPDownlink::NewL(TMSIPDevSoundObserver& observer, |
65 const TMMFPrioritySettings priority) |
66 const guint32 codecID, const TMMFPrioritySettings priority) |
66 { |
67 { |
67 TMSIPDownlink* self = new (ELeave) TMSIPDownlink(); |
68 TMSIPDownlink* self = new (ELeave) TMSIPDownlink(observer); |
68 CleanupStack::PushL(self); |
69 CleanupStack::PushL(self); |
69 self->ConstructL(codecID, priority); |
70 self->ConstructL(codecID, priority); |
70 CleanupStack::Pop(self); |
71 CleanupStack::Pop(self); |
71 return self; |
72 return self; |
72 } |
73 } |
78 // |
79 // |
79 void TMSIPDownlink::ConstructL(const guint32 codecID, |
80 void TMSIPDownlink::ConstructL(const guint32 codecID, |
80 const TMMFPrioritySettings priority) |
81 const TMMFPrioritySettings priority) |
81 { |
82 { |
82 TRACE_PRN_FN_ENT; |
83 TRACE_PRN_FN_ENT; |
83 |
|
84 iCodecID = codecID; |
84 iCodecID = codecID; |
85 iPriority = priority; |
85 iPriority = priority; |
86 |
86 |
87 // Client must set these before querying! |
87 // Client must set these before querying! |
88 iG711DecodeMode = TMS_G711_CODEC_MODE_ALAW; |
88 iG711DecodeMode = TMS_G711_CODEC_MODE_ALAW; |
89 iILBCDecodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME; |
89 iILBCDecodeMode = TMS_ILBC_CODEC_MODE_20MS_FRAME; |
90 |
|
91 TRAPD(err, InitDevSoundL(EMMFStatePlaying, priority)); |
90 TRAPD(err, InitDevSoundL(EMMFStatePlaying, priority)); |
92 if (err != TMS_RESULT_SUCCESS) |
91 if (err != TMS_RESULT_SUCCESS) |
93 { |
92 { |
94 User::Leave(err); |
93 User::Leave(err); |
95 } |
94 } |
96 |
95 |
97 iMaxBufLen = ConfigureMedia(iCodecID); |
96 iMaxBufLen = ConfigureMedia(iCodecID); |
98 |
|
99 TRACE_PRN_FN_EXT; |
97 TRACE_PRN_FN_EXT; |
100 } |
98 } |
101 |
99 |
102 // ----------------------------------------------------------------------------- |
100 // ----------------------------------------------------------------------------- |
103 // TMSIPDownlink::Start |
101 // TMSIPDownlink::Start |
105 // ----------------------------------------------------------------------------- |
103 // ----------------------------------------------------------------------------- |
106 // |
104 // |
107 void TMSIPDownlink::Start() |
105 void TMSIPDownlink::Start() |
108 { |
106 { |
109 TRACE_PRN_FN_ENT; |
107 TRACE_PRN_FN_ENT; |
110 |
|
111 gint err = TMS_RESULT_ILLEGAL_OPERATION; |
108 gint err = TMS_RESULT_ILLEGAL_OPERATION; |
112 |
109 |
113 if (iStatus == EReady && iDevSound) |
110 if (iStatus == EReady && iDevSound) |
114 { |
111 { |
115 TRAP(err, iDevSound->PlayInitL()); |
112 TRAP(err, iDevSound->PlayInitL()); |
116 TRACE_PRN_IF_ERR(err); |
113 TRACE_PRN_IF_ERR(err); |
117 |
|
118 #ifdef _DEBUG |
|
119 iSamplesPlayedCount = 0; |
|
120 #endif |
|
121 if (err != TMS_RESULT_SUCCESS) |
114 if (err != TMS_RESULT_SUCCESS) |
122 { |
115 { |
123 iStatus = EReady; |
116 iStatus = EReady; |
124 } |
117 iObserver.DownlinkStarted(err); |
125 } |
118 } |
126 |
119 } |
127 TRACE_PRN_FN_EXT; |
120 TRACE_PRN_FN_EXT; |
128 } |
121 } |
129 |
122 |
130 // ----------------------------------------------------------------------------- |
123 // ----------------------------------------------------------------------------- |
131 // TMSIPDownlink::Stop |
124 // TMSIPDownlink::Stop |
154 // ----------------------------------------------------------------------------- |
146 // ----------------------------------------------------------------------------- |
155 // |
147 // |
156 void TMSIPDownlink::BufferToBeFilled(CMMFBuffer* aBuffer) |
148 void TMSIPDownlink::BufferToBeFilled(CMMFBuffer* aBuffer) |
157 { |
149 { |
158 // Store pointer to the received buffer |
150 // Store pointer to the received buffer |
159 iDevSoundBufPtr = static_cast<CMMFDataBuffer*>(aBuffer); |
151 iDevSoundBufPtr = static_cast<CMMFDataBuffer*> (aBuffer); |
160 iBufLen = iDevSoundBufPtr->RequestSize(); |
152 iBufLen = iDevSoundBufPtr->RequestSize(); |
161 TRACE_PRN_N1(_L("TMS->DNL->BTBF: LEN[%d]"), iBufLen); |
153 TRACE_PRN_N1(_L("TMS->DNL->BTBF: LEN[%d]"), iBufLen); |
162 |
154 |
163 #ifndef __WINSCW__ |
155 #ifndef __WINSCW__ |
164 //TODO: revisit this! |
156 //TODO: Is this still true? |
165 // The first AMR buffer returns 1 for no data frame. |
157 // The first AMR buffer returns 1 for no data frame. |
166 /*if (iCodecID == KMccFourCCIdAMRNB) |
158 /*if (iCodecID == KMccFourCCIdAMRNB) |
167 { |
159 { |
168 iBufLen = iMaxBufLen; |
160 iBufLen = iMaxBufLen; |
169 }*/ |
161 }*/ |
170 #endif //__WINSCW__ |
162 #endif //__WINSCW__ |
|
163 |
171 // Create or adjust the chunk |
164 // Create or adjust the chunk |
172 gint err = DoChunk(iBufLen, iMsgBuffer); |
165 gint err = DoChunk(iBufLen, iMsgBuffer); |
173 |
166 |
174 if (err != TMS_RESULT_SUCCESS) |
167 if (err != TMS_RESULT_SUCCESS) |
175 { |
168 { |
180 { |
173 { |
181 // Notify client there is buffer ready to be filled |
174 // Notify client there is buffer ready to be filled |
182 iMsgBuffer.iStatus = err; |
175 iMsgBuffer.iStatus = err; |
183 iMsgBuffer.iInt = iBufLen; |
176 iMsgBuffer.iInt = iBufLen; |
184 iStatus = EStreaming; |
177 iStatus = EStreaming; |
|
178 |
185 // If chunk is opened, we will expect a call from the client to |
179 // 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, |
180 // get chunk handle. When we get a call to copy chunk handle, |
187 // check these variables and see if they match. This is not |
181 // check these variables and see if they match. This is not |
188 // completely secure, but will provide some level of security |
182 // completely secure, but will provide some level of security |
189 if (iMsgBuffer.iBool == TRUE) |
183 if (iMsgBuffer.iBool == TRUE) |
208 { |
201 { |
209 TRACE_PRN_N1(_L("TMS->DNL->BF: LEN[%d]"), buflen); |
202 TRACE_PRN_N1(_L("TMS->DNL->BF: LEN[%d]"), buflen); |
210 |
203 |
211 // Copy data over from chunk |
204 // Copy data over from chunk |
212 TPtr8 dataPtr(iChunk.Base(), buflen, iMaxBufLen); |
205 TPtr8 dataPtr(iChunk.Base(), buflen, iMaxBufLen); |
213 // RDebug::RawPrint(dataPtr); |
206 //RDebug::RawPrint(dataPtr); |
214 |
207 |
215 if (iStatus == EStreaming && iDevSound && iDevSoundBufPtr) |
208 if (iStatus == EStreaming && iDevSound && iDevSoundBufPtr) |
216 { |
209 { |
217 // Fill D/S buffer and send it for playback |
210 // Fill D/S buffer and send it for playback |
218 iDevSoundBufPtr->Data() = dataPtr; |
211 iDevSoundBufPtr->Data() = dataPtr; |
521 // not available through CIs -> return cached value |
509 // not available through CIs -> return cached value |
522 frmode = iFrameMode; |
510 frmode = iFrameMode; |
523 TRACE_PRN_N1(_L("TMS->DNL: GetFrameMode [%d]"), frmode); |
511 TRACE_PRN_N1(_L("TMS->DNL: GetFrameMode [%d]"), frmode); |
524 err = TMS_RESULT_SUCCESS; |
512 err = TMS_RESULT_SUCCESS; |
525 } |
513 } |
526 |
|
527 TRACE_PRN_IF_ERR(err); |
514 TRACE_PRN_IF_ERR(err); |
528 return err; |
515 return err; |
529 } |
516 } |
530 |
517 |
531 // ----------------------------------------------------------------------------- |
518 // ----------------------------------------------------------------------------- |
638 // not available through CIs -> return cached value |
621 // not available through CIs -> return cached value |
639 plc = iPlc; |
622 plc = iPlc; |
640 err = TMS_RESULT_SUCCESS; |
623 err = TMS_RESULT_SUCCESS; |
641 TRACE_PRN_N1(_L("TMS->DNL: GetPlc [%d]"), plc); |
624 TRACE_PRN_N1(_L("TMS->DNL: GetPlc [%d]"), plc); |
642 } |
625 } |
643 |
|
644 TRACE_PRN_IF_ERR(err); |
626 TRACE_PRN_IF_ERR(err); |
645 return err; |
627 return err; |
646 } |
628 } |
647 |
629 |
648 // ----------------------------------------------------------------------------- |
630 // ----------------------------------------------------------------------------- |
757 // ----------------------------------------------------------------------------- |
738 // ----------------------------------------------------------------------------- |
758 // |
739 // |
759 void TMSIPDownlink::InitializeComplete(TInt aError) |
740 void TMSIPDownlink::InitializeComplete(TInt aError) |
760 { |
741 { |
761 TRACE_PRN_FN_ENT; |
742 TRACE_PRN_FN_ENT; |
762 |
743 gint status = aError; |
763 gint err = aError; |
744 |
764 |
745 if (status == TMS_RESULT_SUCCESS && iDevSound) |
765 if (err == TMS_RESULT_SUCCESS && iDevSound) |
|
766 { |
746 { |
767 TMMFCapabilities conf; |
747 TMMFCapabilities conf; |
768 conf = iDevSound->Config(); |
748 conf = iDevSound->Config(); |
769 conf.iRate = EMMFSampleRate8000Hz; |
749 conf.iRate = EMMFSampleRate8000Hz; |
770 conf.iChannels = EMMFMono; |
750 conf.iChannels = EMMFMono; |
771 TRAP(err, iDevSound->SetConfigL(conf)); |
751 TRAP(status, iDevSound->SetConfigL(conf)); |
772 if (err == TMS_RESULT_SUCCESS) |
752 if (status == TMS_RESULT_SUCCESS) |
773 { |
753 { |
774 // We are ready to stream even in case of later CI setting failure |
754 // We are ready to stream even in case of later CI setting failure |
775 iStatus = EReady; |
755 iStatus = EReady; |
776 iMaxVolume = iDevSound->MaxVolume(); |
756 iMaxVolume = iDevSound->MaxVolume(); |
777 } |
757 } |
778 |
758 |
779 // Init Custom Interface API to the decoder |
759 // Init Custom Interface API to the Decoder. Any return error can |
780 err = SetCodecCi(); |
760 // be ignored as codec can still run in the default mode even if not |
781 if (err != TMS_RESULT_SUCCESS) |
761 // fully configured. |
782 { |
762 SetCodecCi(); |
783 // DEBUG only |
763 } |
784 // Can ignore error - although decoder is not fully configured but |
764 |
785 // it can still run in the default mode. |
765 iObserver.DownlinkInitCompleted(status); |
786 TRACE_PRN_IF_ERR(err); |
766 TRACE_PRN_IF_ERR(status); |
787 } |
|
788 } |
|
789 |
|
790 // TODO: Notify client |
|
791 |
|
792 TRACE_PRN_IF_ERR(err); |
|
793 TRACE_PRN_FN_EXT; |
767 TRACE_PRN_FN_EXT; |
794 } |
768 } |
795 |
769 |
796 // ----------------------------------------------------------------------------- |
770 // ----------------------------------------------------------------------------- |
797 // TMSIPDownlink::PlayError |
771 // TMSIPDownlink::PlayError |
798 // From MDevSoundObserver |
772 // From MDevSoundObserver |
799 // Record error is send to client over comm channel. |
773 // Record error is send to client over comm channel. |
800 // The state of recorder is rolled back to EReady. |
774 // The state of recorder is rolled back to EReady. |
801 // ----------------------------------------------------------------------------- |
775 // ----------------------------------------------------------------------------- |
802 // |
776 // |
803 void TMSIPDownlink::PlayError(TInt /*aError*/) |
777 void TMSIPDownlink::PlayError(TInt aError) |
804 { |
778 { |
805 //TRACE_PRN_IF_ERR(aError); |
|
806 |
|
807 #ifdef _DEBUG |
|
808 iSamplesPlayedCount = 0; |
|
809 #endif |
|
810 iStatus = EReady; |
779 iStatus = EReady; |
811 |
780 iObserver.DownlinkStarted(aError); |
812 // TODO: Notify client |
781 TRACE_PRN_IF_ERR(aError); |
813 } |
782 } |
814 |
783 |
815 // End of file |
784 // End of file |