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