|
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 #ifndef __IPCALLSTREAM_H |
|
19 #define __IPCALLSTREAM_H |
|
20 |
|
21 //#define __PLAY_WAV_FROM_FILE__ |
|
22 |
|
23 #include <e32msgqueue.h> |
|
24 #include <mmfbase.h> |
|
25 #include <tms.h> |
|
26 #include "tmsgstreamer.h" |
|
27 #include "tmsshared.h" |
|
28 #include "tmsclientserver.h" |
|
29 |
|
30 #ifdef __USE_GSTREAMER__ |
|
31 #include <gst.h> |
|
32 #include "gstg711encoderinterface.h" |
|
33 #include "gstspeechencoderconfig.h" |
|
34 #include "gsterrorconcealmentinterface.h" |
|
35 #include "gstg711decoderinterface.h" |
|
36 #include "gstilbcdecoderinterface.h" |
|
37 #include "gstilbcencoderinterface.h" |
|
38 #include "gstg729encoderinterface.h" |
|
39 #include "gstg729decoderinterface.h" |
|
40 #else //__USE_GSTREAMER__ |
|
41 #include <sounddevice.h> |
|
42 #include <voipdownlinkstream.h> |
|
43 #include <voipuplinkstream.h> |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 class CAudioOutput; |
|
47 class CErrorConcealmentIntfc; |
|
48 class CSpeechEncoderConfig; |
|
49 class CG711DecoderIntfc; |
|
50 class CG729DecoderIntfc; |
|
51 class CIlbcDecoderIntfc; |
|
52 class CG711EncoderIntfc; |
|
53 class CG729EncoderIntfc; |
|
54 class CIlbcEncoderIntfc; |
|
55 #endif //__USE_GSTREAMER__ |
|
56 |
|
57 namespace TMS { |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // Class Name: TMSIPCallStreamBase |
|
61 // |
|
62 // Base abstract class for creating VoIP uplink and downlink streams. |
|
63 // ----------------------------------------------------------------------------- |
|
64 class TMSIPCallStreamBase : public CBase |
|
65 #ifndef __USE_GSTREAMER__ |
|
66 , public MDevSoundObserver |
|
67 #endif //__USE_GSTREAMER__ |
|
68 { |
|
69 public: |
|
70 enum TStreamState |
|
71 { |
|
72 ENotReady, // not initialized |
|
73 EReady, // initialized and ready for streaming |
|
74 EStreaming |
|
75 // active streaming |
|
76 }; |
|
77 |
|
78 public: |
|
79 virtual ~TMSIPCallStreamBase(); |
|
80 |
|
81 virtual void Start() = 0; |
|
82 virtual void Stop() = 0; |
|
83 virtual gint SetCodecCi() = 0; |
|
84 |
|
85 #ifndef __USE_GSTREAMER__ |
|
86 void InitDevSoundL(const TMMFState aDevSoundState, |
|
87 const TMMFPrioritySettings priority); |
|
88 #endif //__USE_GSTREAMER__ |
|
89 void SetMsgQueue(const RMsgQueue<TmsMsgBuf> aMsgQueue); |
|
90 gint DoChunk(const gint aDataLen, TmsMsgBuf& aMsgBuffer); |
|
91 gint ConfigureMedia(const guint32 aCodecID); |
|
92 |
|
93 protected: |
|
94 #ifndef __USE_GSTREAMER__ |
|
95 // From MDevSoundObserver |
|
96 virtual void InitializeComplete(TInt aError) = 0; |
|
97 virtual void BufferToBeEmptied(CMMFBuffer* /*aBuffer*/) {} |
|
98 virtual void RecordError(TInt /*aError*/) {} |
|
99 virtual void BufferToBeFilled(CMMFBuffer* /*aBuffer*/) {} |
|
100 virtual void PlayError(TInt /*aError*/) {} |
|
101 virtual void ToneFinished(TInt /*aError*/) {} |
|
102 virtual void ConvertError(TInt /*aError*/) {} |
|
103 virtual void DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/) {} |
|
104 virtual void SendEventToClient(const TMMFEvent& /*aEvent*/) {} |
|
105 #endif //__USE_GSTREAMER__ |
|
106 |
|
107 protected: |
|
108 |
|
109 CActiveScheduler* iActiveScheduler; |
|
110 TStreamState iStatus; |
|
111 |
|
112 #ifndef __USE_GSTREAMER__ |
|
113 CMMFDevSound* iDevSound; |
|
114 CMMFDataBuffer* iDevSoundBufPtr; |
|
115 #endif //__USE_GSTREAMER__ |
|
116 |
|
117 RMsgQueue<TmsMsgBuf> iMsgQueue; // ITC back to client |
|
118 TmsMsgBuf iMsgBuffer; |
|
119 RChunk iChunk; |
|
120 gint iMaxBufLen; |
|
121 guint32 iCodecID; |
|
122 TMMFPrioritySettings iPriority; |
|
123 const gchar* iMediaType; |
|
124 |
|
125 gint iG711DecodeMode; |
|
126 gint iILBCDecodeMode; |
|
127 gint iG711EncodeMode; |
|
128 gint iILBCEncodeMode; |
|
129 gint iBufLen; |
|
130 TBool iWriteDataXferHndlToClient; |
|
131 TUint32 iKey; |
|
132 }; |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // Class Name: TMSIPDownlink |
|
136 // |
|
137 // Class handling VoIP downlink stream object. |
|
138 // ----------------------------------------------------------------------------- |
|
139 class TMSIPDownlink : public TMSIPCallStreamBase |
|
140 { |
|
141 public: |
|
142 virtual ~TMSIPDownlink(); |
|
143 |
|
144 #ifdef __USE_GSTREAMER__ |
|
145 static void cb_raw_playback_handoff(GstElement* appsrc, guint size); |
|
146 static gboolean bus_call(GstBus* bus, GstMessage* msg, gpointer data); |
|
147 #endif //__USE_GSTREAMER__ |
|
148 static TMSIPDownlink* NewL(const guint32 codecID, |
|
149 const TMMFPrioritySettings priority); |
|
150 TMSIPDownlink(); |
|
151 void ConstructL(const guint32 codecID, |
|
152 const TMMFPrioritySettings priority); |
|
153 |
|
154 gint SetCodecCi(); |
|
155 void Start(); |
|
156 void Stop(); |
|
157 void BufferFilled(const guint buflen); |
|
158 gint SetVolume(const guint volume); |
|
159 gint GetVolume(guint& volume); |
|
160 gint GetMaxVolume(guint& volume); |
|
161 gint GetDataXferChunkHndl(const TUint32 key, RChunk& chunk); |
|
162 |
|
163 // For CIs |
|
164 gint SetIlbcCodecMode(const gint mode); |
|
165 gint GetIlbcCodecMode(gint& mode); |
|
166 gint SetG711CodecMode(const gint mode); |
|
167 gint GetG711CodecMode(gint& mode); |
|
168 gint FrameModeRqrdForEC(gboolean& frmodereq); |
|
169 gint SetFrameMode(gboolean frmode); |
|
170 gint GetFrameMode(gboolean& frmode); |
|
171 gint ConcealErrorForNextBuffer(); |
|
172 gint SetCng(const TMSFormatType fmttype, const gboolean cng); |
|
173 gint GetCng(const TMSFormatType fmttype, gboolean& cng); |
|
174 gint SetPlc(const TMSFormatType fmttype, const gboolean plc); |
|
175 gint GetPlc(const TMSFormatType fmttype, gboolean& plc); |
|
176 gint BadLsfNextBuffer(); |
|
177 |
|
178 void SetAudioDeviceL(TMSAudioOutput output); |
|
179 void GetAudioDeviceL(TMSAudioOutput& output); |
|
180 |
|
181 private: |
|
182 void SetCodecCiL(); |
|
183 |
|
184 #ifdef __USE_GSTREAMER__ |
|
185 void BufferToBeFilled(); |
|
186 gint gst_play_raw(); |
|
187 gint gst_initialize_play(); |
|
188 #else //__USE_GSTREAMER__ |
|
189 // From MDevSoundObserver |
|
190 virtual void BufferToBeFilled(CMMFBuffer* aBuffer); |
|
191 virtual void InitializeComplete(TInt aError); |
|
192 virtual void PlayError(TInt aError); |
|
193 #endif //__USE_GSTREAMER__ |
|
194 |
|
195 private: |
|
196 |
|
197 gboolean iFrameMode; |
|
198 gboolean iPlc; |
|
199 gint iMaxVolume; |
|
200 |
|
201 #ifndef __USE_GSTREAMER__ |
|
202 CAudioOutput* iAudioOutput; |
|
203 CErrorConcealmentIntfc* iErrConcealmentIntfc; |
|
204 CG711DecoderIntfc* iG711DecoderIntfc; |
|
205 CG729DecoderIntfc* iG729DecoderIntfc; |
|
206 CIlbcDecoderIntfc* iIlbcDecoderIntfc; |
|
207 #else //__USE_GSTREAMER__ |
|
208 GstErrorConcealmentIntfc* iErrConcealmentIntfc; |
|
209 GstG711DecoderIntfc* iG711DecoderIntfc; |
|
210 GstG729DecoderIntfc* iG729DecoderIntfc; |
|
211 GstIlbcDecoderIntfc* iIlbcDecoderIntfc; |
|
212 GstElement* iPipelinePlay; |
|
213 GstElement* iAppSrc; |
|
214 GstElement* iSink; |
|
215 GstBus* iBusPlay; |
|
216 #endif //__USE_GSTREAMER__ |
|
217 #ifdef _DEBUG |
|
218 gint iSamplesPlayedCount; |
|
219 #endif |
|
220 |
|
221 #ifdef __PLAY_WAV_FROM_FILE__ |
|
222 RFile iFile; |
|
223 gint fsize; |
|
224 gint iReadSize; |
|
225 gint iReadBytes; |
|
226 RFs iFs; |
|
227 HBufC8* fbuf; |
|
228 #endif |
|
229 }; |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // Class Name: TMSIPUplink |
|
233 // |
|
234 // Class handling VoIP uplink stream. |
|
235 // ----------------------------------------------------------------------------- |
|
236 class TMSIPUplink : public TMSIPCallStreamBase |
|
237 { |
|
238 public: |
|
239 virtual ~TMSIPUplink(); |
|
240 |
|
241 #ifdef __USE_GSTREAMER__ |
|
242 static void cb_record_raw_handoff(GstElement *sink); |
|
243 static gboolean bus_call(GstBus* bus, GstMessage* msg, gpointer data); |
|
244 #endif //__USE_GSTREAMER__ |
|
245 static TMSIPUplink* NewL(const guint32 codecID, |
|
246 const TMMFPrioritySettings priority); |
|
247 TMSIPUplink(); |
|
248 void ConstructL(const guint32 codecID, |
|
249 const TMMFPrioritySettings priority); |
|
250 |
|
251 gint SetCodecCi(); |
|
252 void Start(); |
|
253 void Stop(); |
|
254 void BufferEmptied(); |
|
255 gint SetGain(const guint gain); |
|
256 gint GetGain(guint& gain); |
|
257 gint GetMaxGain(guint& gain); |
|
258 gint GetDataXferChunkHndl(const TUint32 key, RChunk& chunk); |
|
259 |
|
260 // For CIs |
|
261 gint SetIlbcCodecMode(const gint mode); |
|
262 gint GetIlbcCodecMode(gint& mode); |
|
263 gint SetG711CodecMode(const gint mode); |
|
264 gint GetG711CodecMode(gint& mode); |
|
265 gint GetSupportedBitrates(RArray<TUint>& bitrates); |
|
266 gint SetBitrate(guint bitrate); |
|
267 gint GetBitrate(guint& bitrate); |
|
268 gint SetVad(const TMSFormatType fmttype, const gboolean vad); |
|
269 gint GetVad(const TMSFormatType fmttype, gboolean& vad); |
|
270 |
|
271 private: |
|
272 void SetCodecCiL(); |
|
273 |
|
274 #ifdef __USE_GSTREAMER__ |
|
275 void BufferToBeEmptied(); |
|
276 gint gst_record_raw(); |
|
277 gint gst_initialize_record(); |
|
278 #else //__USE_GSTREAMER__ |
|
279 // From MDevSoundObserver |
|
280 virtual void BufferToBeEmptied(CMMFBuffer* aBuffer); |
|
281 virtual void InitializeComplete(TInt aError); |
|
282 virtual void RecordError(TInt /*aError*/); |
|
283 #endif //__USE_GSTREAMER__ |
|
284 |
|
285 private: |
|
286 gint iMaxGain; |
|
287 |
|
288 #ifndef __USE_GSTREAMER__ |
|
289 CSpeechEncoderConfig* iSpeechEncoderConfig; |
|
290 CG711EncoderIntfc* iG711EncoderIntfc; |
|
291 CG729EncoderIntfc* iG729EncoderIntfc; |
|
292 CIlbcEncoderIntfc* iIlbcEncoderIntfc; |
|
293 #else //__USE_GSTREAMER__ |
|
294 GstSpeechEncoderConfigIntfc* iSpeechEncoderConfig; |
|
295 GstG711EncoderIntfc* iG711EncoderIntfc; |
|
296 GstG729EncoderIntfc* iG729EncoderIntfc; |
|
297 GstIlbcEncoderIntfc* iIlbcEncoderIntfc; |
|
298 GstElement* iPipelineRec; |
|
299 GstElement* iSource; |
|
300 GstElement* iAppSink; |
|
301 GstBus* iBusRec; |
|
302 #endif //__USE_GSTREAMER__ |
|
303 #ifdef _DEBUG |
|
304 gint iSamplesRecCount; |
|
305 #endif |
|
306 }; |
|
307 |
|
308 } //namespace TMS |
|
309 |
|
310 #endif //__IPCALLSTREAM_H |
|
311 |
|
312 // End of file |