|
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: QTMS Voip test |
|
15 * |
|
16 */ |
|
17 #include <QObject> |
|
18 #include <QtTest/QtTest> |
|
19 #include "qtestmains60.h" |
|
20 |
|
21 #include <qtms.h> |
|
22 #include <qtmsfactory.h> |
|
23 #include <qtmscall.h> |
|
24 #include <qtmsstream.h> |
|
25 #include <tmsstreamobsrvr.h> |
|
26 #include <qtmsformat.h> |
|
27 |
|
28 #include <qtmspcmformat.h> |
|
29 #include <qtmsamrformat.h> |
|
30 #include <qtmsilbcformat.h> |
|
31 #include <qtmsg711format.h> |
|
32 #include <qtmsg729format.h> |
|
33 |
|
34 #include <qtmsclientsink.h> |
|
35 #include <qtmsclientsource.h> |
|
36 #include <qtmsvolumeeffect.h> |
|
37 #include <qtmsgaineffect.h> |
|
38 #include <qtmsglobalvoleffect.h> |
|
39 #include <qtmsglobalgaineffect.h> |
|
40 #include <qtmsglobalrouting.h> |
|
41 |
|
42 #include <qtmsbuffer.h> |
|
43 #include <qtmsdtmf.h> |
|
44 #include <qtmsringtone.h> |
|
45 #include <qtmsinbandtone.h> |
|
46 #include <tmsbuffer.h> |
|
47 |
|
48 |
|
49 // CONSTANTS |
|
50 #define __TEST_CODE_COVERAGE__ |
|
51 |
|
52 using namespace QTMS; |
|
53 |
|
54 class QTmsVoipTest : public QObject |
|
55 { |
|
56 Q_OBJECT |
|
57 private slots: |
|
58 void initTestCase(); |
|
59 void init(); |
|
60 void cleanup(); |
|
61 void SupportedFormats(); |
|
62 void CreateRouting_data(); |
|
63 void CreateRouting(); |
|
64 void CreateGlobalVol(); |
|
65 void CreateGlobalGain(); |
|
66 void CreateFormat_data(); |
|
67 void CreateFormat(); |
|
68 void CreateStreamVol(); |
|
69 void CreateStreamGain(); |
|
70 void CreateDnlinkDtmf(); |
|
71 void CreateBuffer(); |
|
72 |
|
73 void cleanupTestCase(); |
|
74 public slots: |
|
75 //From TMSClientSourceObserver |
|
76 void FillBuffer(TMS::TMSBuffer& buffer); |
|
77 void BufferProcessed(TMS::TMSBuffer* buffer, gint reason); |
|
78 //From TMSClientSinkObserver |
|
79 void ProcessBuffer(const TMS::TMSBuffer* buffer); |
|
80 //From TMSStreamObserver |
|
81 void TMSStreamEvent(const QTMSStream& stream, QTMSSignalEvent event); |
|
82 //From TMSClientSinkObserver |
|
83 void EffectsEvent(const QTMSEffect& tmseffect, QTMSSignalEvent event); |
|
84 //From TMSGlobalRoutingObserver |
|
85 void GlobalRoutingEvent(const QTMSGlobalRouting& routing, |
|
86 QTMSSignalEvent event, QTMSAudioOutput output); |
|
87 //From TMSRingToneObserver |
|
88 void RingtoneEvent(const QTMSRingTone& rt, QTMSSignalEvent event); |
|
89 //From TMSDTMFObserver |
|
90 void DTMFEvent(const QTMSDTMF& dtmf, QTMSSignalEvent event); |
|
91 |
|
92 private: |
|
93 |
|
94 void VoipCallSetup(); |
|
95 |
|
96 void SupportedUplinkFormats(); |
|
97 void SupportedDnlinkFormats(); |
|
98 |
|
99 void CreateUplink(); |
|
100 void CreateDnlink(); |
|
101 |
|
102 void CreateMicSource(); |
|
103 void AddMicSourceToStream(); |
|
104 |
|
105 void CreateClientSink(); |
|
106 void AddClientSinkToStream(); |
|
107 |
|
108 void CreateClientSource(); |
|
109 void AddClientSourceToStream(); |
|
110 |
|
111 void CreateSpeakerSink(); |
|
112 void AddSpeakerSinkToStream(); |
|
113 |
|
114 void InitUplink(); |
|
115 void InitDnlink(); |
|
116 |
|
117 void DeinitUplink(); |
|
118 void DeinitDnlink(); |
|
119 |
|
120 void StartUplink(); |
|
121 void StopUplink(); |
|
122 void StartDnlink(); |
|
123 |
|
124 void ResetUplnkFormat(); |
|
125 void ResetDnlnkFormat(); |
|
126 |
|
127 void StreamVol(); |
|
128 void StreamGain(); |
|
129 |
|
130 void CloseUplink(); |
|
131 void CloseDownlink(); |
|
132 |
|
133 void DisplayFormat(QTMSFormatType format); |
|
134 void StopDnlink(); |
|
135 void CreateRingTone(); |
|
136 |
|
137 void ToggleVad(); |
|
138 void GetVad(); |
|
139 void ToggleCng(); |
|
140 void GetCng(); |
|
141 void TogglePlc(); |
|
142 void GetPlc(); |
|
143 |
|
144 void SelectMinBitrate(); |
|
145 void SelectMaxBitrate(); |
|
146 void SetBitrate(guint bitrate); |
|
147 void GetSupportedBitrates(); |
|
148 gint GetSupportedBitrates(BitRateVector& aBrArr); |
|
149 void GetBitrate(); |
|
150 |
|
151 void SetDnLinkG711ALAW(); |
|
152 void SetDnLinkG711uLAW(); |
|
153 void SetDnLinkILBC20MS(); |
|
154 void SetDnLinkILBC30MS(); |
|
155 void SetUpLinkG711ALAW(); |
|
156 void SetUpLinkG711uLAW(); |
|
157 void SetUpLinkILBC20MS(); |
|
158 void SetUpLinkILBC30MS(); |
|
159 void GetDnLinkG711Mode(); |
|
160 void GetDnLinkILBCMode(); |
|
161 void GetUpLinkG711Mode(); |
|
162 void GetUpLinkILBCMode(); |
|
163 |
|
164 void DisplayDevice(QTMSAudioOutput device); |
|
165 |
|
166 private: |
|
167 QTMSFactory *m_Factory; |
|
168 QTMSCall *m_Call; |
|
169 QTMSDTMF *m_Dnlnkdtmf; |
|
170 QTMSStream *m_Dnlink; |
|
171 QTMSStream *m_Uplink; |
|
172 |
|
173 QTMSSource *m_MicSource; |
|
174 QTMSSource *m_ClientSource; |
|
175 QTMSSink *m_ClientSink; |
|
176 QTMSSink *m_SpeakerSink; |
|
177 |
|
178 QTMSFormat *m_G711EncFormatIntfc; |
|
179 QTMSFormat *m_G711DecFormatIntfc; |
|
180 QTMSFormat *m_G729EncFormatIntfc; |
|
181 QTMSFormat *m_G729DecFormatIntfc; |
|
182 QTMSFormat *m_ILBCEncFormatIntfc; |
|
183 QTMSFormat *m_ILBCDecFormatIntfc; |
|
184 QTMSFormat *m_AMRNBEncFormatIntfc; |
|
185 QTMSFormat *m_AMRNBDecFormatIntfc; |
|
186 QTMSFormat *m_PCM16EncFormatIntfc; |
|
187 QTMSFormat *m_PCM16DecFormatIntfc; |
|
188 |
|
189 QTMS::FormatVector m_UplCodecs; |
|
190 QTMS::FormatVector m_DnlCodecs; |
|
191 |
|
192 BitRateVector m_BitratesVector; |
|
193 guint iBitrate; |
|
194 |
|
195 QTMSEffect *m_Vol; |
|
196 QTMSEffect *m_Gain; |
|
197 QTMSEffect *m_GlobalVol; |
|
198 QTMSEffect *m_GlobalGain; |
|
199 QTMSGlobalRouting *m_Routing; |
|
200 |
|
201 QTMSFormatType m_DnLinkCodec; |
|
202 QTMSFormatType m_UpLinkCodec; |
|
203 |
|
204 QSignalSpy *m_UplinkSpy; |
|
205 QSignalSpy *m_DnlinkSpy; |
|
206 QSignalSpy *m_RoutingSpy; |
|
207 |
|
208 gboolean m_Vad; |
|
209 gboolean m_Cng; |
|
210 gboolean m_Plc; |
|
211 |
|
212 }; |
|
213 |
|
214 void QTmsVoipTest::initTestCase() |
|
215 { |
|
216 qDebug("Start QTms Voip tests"); |
|
217 |
|
218 g_setenv("G_SLICE", "always-malloc", 1); |
|
219 |
|
220 qRegisterMetaType<QTMSSignalEvent>("QTMSSignalEvent"); |
|
221 qRegisterMetaType<QTMSAudioOutput>("QTMSAudioOutput"); |
|
222 |
|
223 } |
|
224 |
|
225 void QTmsVoipTest::cleanupTestCase() |
|
226 { |
|
227 qDebug("End QTms tests"); |
|
228 } |
|
229 |
|
230 void QTmsVoipTest::init() |
|
231 { |
|
232 qDebug("****NEW TEST****"); |
|
233 m_Factory = NULL; |
|
234 m_Call = NULL; |
|
235 m_Dnlink = NULL; |
|
236 m_Uplink = NULL; |
|
237 m_MicSource = NULL; |
|
238 m_ClientSource = NULL; |
|
239 m_SpeakerSink = NULL; |
|
240 m_ClientSink = NULL; |
|
241 m_Vol = NULL; |
|
242 m_Gain = NULL; |
|
243 m_GlobalVol = NULL; |
|
244 m_GlobalGain = NULL; |
|
245 m_Routing = NULL; |
|
246 m_Dnlnkdtmf = NULL; |
|
247 |
|
248 m_G711EncFormatIntfc = NULL; |
|
249 m_G711DecFormatIntfc = NULL; |
|
250 m_G729EncFormatIntfc = NULL; |
|
251 m_G729DecFormatIntfc = NULL; |
|
252 m_ILBCEncFormatIntfc = NULL; |
|
253 m_ILBCDecFormatIntfc = NULL; |
|
254 m_AMRNBEncFormatIntfc = NULL; |
|
255 m_AMRNBDecFormatIntfc = NULL; |
|
256 m_PCM16EncFormatIntfc = NULL; |
|
257 m_PCM16DecFormatIntfc = NULL; |
|
258 |
|
259 m_UplinkSpy = NULL; |
|
260 m_DnlinkSpy = NULL; |
|
261 |
|
262 QTMSVer *ver(NULL); |
|
263 gint status; |
|
264 status = QTMSFactory::CreateFactory(m_Factory, *ver); |
|
265 |
|
266 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
267 |
|
268 VoipCallSetup(); |
|
269 |
|
270 CreateUplink(); |
|
271 CreateDnlink(); |
|
272 |
|
273 CreateMicSource(); |
|
274 AddMicSourceToStream(); |
|
275 |
|
276 CreateClientSink(); |
|
277 AddClientSinkToStream(); |
|
278 |
|
279 CreateClientSource(); |
|
280 AddClientSourceToStream(); |
|
281 |
|
282 CreateSpeakerSink(); |
|
283 AddSpeakerSinkToStream(); |
|
284 |
|
285 } |
|
286 void QTmsVoipTest::cleanup() |
|
287 { |
|
288 qDebug("****END TEST******"); |
|
289 |
|
290 ResetUplnkFormat(); |
|
291 ResetDnlnkFormat(); |
|
292 |
|
293 CloseUplink(); |
|
294 CloseDownlink(); |
|
295 |
|
296 if (m_MicSource) |
|
297 m_Factory->DeleteSource(m_MicSource); |
|
298 if (m_ClientSource) |
|
299 m_Factory->DeleteSource(m_ClientSource); |
|
300 if (m_ClientSink) |
|
301 m_Factory->DeleteSink(m_ClientSink); |
|
302 if (m_SpeakerSink) |
|
303 m_Factory->DeleteSink(m_SpeakerSink); |
|
304 |
|
305 if (m_Dnlnkdtmf) |
|
306 m_Factory->DeleteDTMF(m_Dnlnkdtmf); |
|
307 |
|
308 if (m_Vol) |
|
309 m_Factory->DeleteEffect(m_Vol); |
|
310 if (m_Gain) |
|
311 m_Factory->DeleteEffect(m_Gain); |
|
312 if (m_GlobalVol) |
|
313 m_Factory->DeleteEffect(m_GlobalVol); |
|
314 if (m_GlobalGain) |
|
315 m_Factory->DeleteEffect(m_GlobalGain); |
|
316 |
|
317 if (m_Routing) |
|
318 m_Factory->DeleteGlobalRouting(m_Routing); |
|
319 |
|
320 if (m_PCM16EncFormatIntfc) |
|
321 m_Factory->DeleteFormat(m_PCM16EncFormatIntfc); |
|
322 if (m_ILBCEncFormatIntfc) |
|
323 m_Factory->DeleteFormat(m_ILBCEncFormatIntfc); |
|
324 if (m_AMRNBEncFormatIntfc) |
|
325 m_Factory->DeleteFormat(m_AMRNBEncFormatIntfc); |
|
326 if (m_G711EncFormatIntfc) |
|
327 m_Factory->DeleteFormat(m_G711EncFormatIntfc); |
|
328 if (m_G729EncFormatIntfc) |
|
329 m_Factory->DeleteFormat(m_G729EncFormatIntfc); |
|
330 if (m_PCM16DecFormatIntfc) |
|
331 m_Factory->DeleteFormat(m_PCM16DecFormatIntfc); |
|
332 if (m_ILBCDecFormatIntfc) |
|
333 m_Factory->DeleteFormat(m_ILBCDecFormatIntfc); |
|
334 if (m_AMRNBDecFormatIntfc) |
|
335 m_Factory->DeleteFormat(m_AMRNBDecFormatIntfc); |
|
336 if (m_G711DecFormatIntfc) |
|
337 m_Factory->DeleteFormat(m_G711DecFormatIntfc); |
|
338 if (m_G729DecFormatIntfc) |
|
339 m_Factory->DeleteFormat(m_G729DecFormatIntfc); |
|
340 |
|
341 if (m_Uplink) |
|
342 m_Call->DeleteStream(m_Uplink); |
|
343 if (m_Dnlink) |
|
344 m_Call->DeleteStream(m_Dnlink); |
|
345 |
|
346 if (m_Call) |
|
347 m_Factory->DeleteCall(m_Call); |
|
348 |
|
349 if (m_Factory) |
|
350 delete m_Factory; |
|
351 |
|
352 } |
|
353 |
|
354 void QTmsVoipTest::VoipCallSetup() |
|
355 { |
|
356 gint status(QTMS_RESULT_SUCCESS); |
|
357 if (m_Factory && !m_Call) |
|
358 { |
|
359 gboolean issupported(FALSE); |
|
360 m_Factory->IsCallTypeSupported(QTMS_CALL_IP,issupported); |
|
361 QVERIFY(issupported == TRUE); |
|
362 status = m_Factory->CreateCall(QTMS_CALL_IP, m_Call, 0); |
|
363 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
364 guint ctxid; |
|
365 m_Call->GetCallContextId(ctxid); |
|
366 } |
|
367 |
|
368 } |
|
369 |
|
370 void QTmsVoipTest::SupportedFormats() |
|
371 { |
|
372 SupportedUplinkFormats(); |
|
373 SupportedDnlinkFormats(); |
|
374 } |
|
375 |
|
376 void QTmsVoipTest::SupportedUplinkFormats() |
|
377 { |
|
378 gint status(QTMS_RESULT_SUCCESS); |
|
379 status = m_Factory->GetSupportedFormats(QTMS_STREAM_UPLINK,m_UplCodecs); |
|
380 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
381 |
|
382 qDebug("Supported UPL codecs"); |
|
383 std::vector<QTMSFormat*>::iterator codecs = m_UplCodecs.begin(); |
|
384 QTMSFormatType fmttype; |
|
385 for (; codecs < m_UplCodecs.end(); codecs++) |
|
386 { |
|
387 (*codecs)->GetType(fmttype); |
|
388 DisplayFormat(fmttype); |
|
389 } |
|
390 gint size = m_UplCodecs.size(); |
|
391 for (gint i = 0; i < size; i++) |
|
392 { |
|
393 codecs = m_UplCodecs.begin(); |
|
394 m_Factory->DeleteFormat(*codecs); |
|
395 m_UplCodecs.erase(codecs); |
|
396 } |
|
397 |
|
398 } |
|
399 |
|
400 void QTmsVoipTest::SupportedDnlinkFormats() |
|
401 { |
|
402 gint status(QTMS_RESULT_SUCCESS); |
|
403 status = m_Factory->GetSupportedFormats(QTMS_STREAM_DOWNLINK,m_DnlCodecs); |
|
404 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
405 |
|
406 qDebug("Supported DNL codecs"); |
|
407 std::vector<QTMSFormat*>::iterator codecs = m_DnlCodecs.begin(); |
|
408 QTMSFormatType fmttype; |
|
409 for (; codecs < m_DnlCodecs.end(); codecs++) |
|
410 { |
|
411 (*codecs)->GetType(fmttype); |
|
412 DisplayFormat(fmttype); |
|
413 } |
|
414 gint size = m_DnlCodecs.size(); |
|
415 for (gint i = 0; i < size; i++) |
|
416 { |
|
417 codecs = m_DnlCodecs.begin(); |
|
418 m_Factory->DeleteFormat(*codecs); |
|
419 m_DnlCodecs.erase(codecs); |
|
420 } |
|
421 } |
|
422 |
|
423 |
|
424 void QTmsVoipTest::DisplayFormat(QTMSFormatType format) |
|
425 { |
|
426 switch (format) |
|
427 { |
|
428 case QTMS_FORMAT_AMR: |
|
429 qDebug("AMR-NB"); |
|
430 break; |
|
431 case QTMS_FORMAT_G711: |
|
432 qDebug("G.711"); |
|
433 break; |
|
434 case QTMS_FORMAT_G729: |
|
435 qDebug("G.729"); |
|
436 break; |
|
437 case QTMS_FORMAT_ILBC: |
|
438 qDebug("iLBC"); |
|
439 break; |
|
440 case QTMS_FORMAT_PCM: |
|
441 qDebug("PCM-16"); |
|
442 break; |
|
443 default: |
|
444 break; |
|
445 } |
|
446 } |
|
447 |
|
448 void QTmsVoipTest::CreateUplink() |
|
449 { |
|
450 gint status(QTMS_RESULT_SUCCESS); |
|
451 |
|
452 if (m_Call) |
|
453 { |
|
454 status = m_Call->CreateStream(QTMS_STREAM_UPLINK, m_Uplink); |
|
455 |
|
456 m_UplinkSpy = new QSignalSpy(m_Uplink, |
|
457 SIGNAL(TMSStreamEvent(const QTMSStream&, QTMSSignalEvent))); |
|
458 |
|
459 QVERIFY( m_UplinkSpy->isValid() ); |
|
460 |
|
461 // QCOMPARE(m_UplinkSpy->count(), 0 ); |
|
462 |
|
463 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
464 connect(m_Uplink, |
|
465 SIGNAL(TMSStreamEvent(const QTMSStream&, QTMSSignalEvent)), |
|
466 this, |
|
467 SLOT(TMSStreamEvent(const QTMSStream&, QTMSSignalEvent))); |
|
468 } |
|
469 } |
|
470 |
|
471 void QTmsVoipTest::CreateDnlink() |
|
472 { |
|
473 gint status(QTMS_RESULT_SUCCESS); |
|
474 |
|
475 if (m_Call) |
|
476 { |
|
477 status = m_Call->CreateStream(QTMS_STREAM_DOWNLINK, m_Dnlink); |
|
478 |
|
479 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
480 |
|
481 m_DnlinkSpy = new QSignalSpy(m_Dnlink, |
|
482 SIGNAL(TMSStreamEvent(const QTMSStream&, QTMSSignalEvent))); |
|
483 |
|
484 QVERIFY( m_DnlinkSpy->isValid() ); |
|
485 |
|
486 // QCOMPARE(m_DnlinkSpy->count(), 0 ); |
|
487 |
|
488 connect(m_Dnlink, |
|
489 SIGNAL(TMSStreamEvent(const QTMSStream&, QTMSSignalEvent)), |
|
490 this, |
|
491 SLOT(TMSStreamEvent(const QTMSStream&, QTMSSignalEvent))); |
|
492 } |
|
493 } |
|
494 |
|
495 void QTmsVoipTest::CreateClientSource() |
|
496 { |
|
497 gint status(QTMS_RESULT_SUCCESS); |
|
498 if (m_Factory && !m_ClientSource) |
|
499 { |
|
500 status = m_Factory->CreateSource(QTMS_SOURCE_CLIENT, m_ClientSource); |
|
501 } |
|
502 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
503 } |
|
504 |
|
505 |
|
506 void QTmsVoipTest::AddClientSourceToStream() |
|
507 { |
|
508 gint status(QTMS_RESULT_SUCCESS); |
|
509 if (m_Dnlink && m_ClientSource) |
|
510 { |
|
511 connect(static_cast<QTMSClientSource*> (m_ClientSource), |
|
512 SIGNAL(FillBuffer(TMS::TMSBuffer&)), this, |
|
513 SLOT(FillBuffer(TMS::TMSBuffer&))); |
|
514 status = m_Dnlink->AddSource(m_ClientSource); |
|
515 |
|
516 #ifdef __TEST_CODE_COVERAGE__ |
|
517 QTMSSourceType st; |
|
518 static_cast<QTMSClientSource*>(m_ClientSource)->GetType(st); |
|
519 gboolean enqueue(FALSE); |
|
520 static_cast<QTMSClientSource*>(m_ClientSource)->GetEnqueueMode(enqueue); |
|
521 static_cast<QTMSClientSource*>(m_ClientSource)->SetEnqueueMode(FALSE); |
|
522 static_cast<QTMSClientSource*>(m_ClientSource)->Flush(); |
|
523 #endif //__TEST_CODE_COVERAGE__ |
|
524 } |
|
525 |
|
526 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
527 } |
|
528 |
|
529 |
|
530 void QTmsVoipTest::CreateClientSink() |
|
531 { |
|
532 gint status(QTMS_RESULT_SUCCESS); |
|
533 |
|
534 if (m_Factory && !m_ClientSink) |
|
535 { |
|
536 status = m_Factory->CreateSink(QTMS_SINK_CLIENT, m_ClientSink); |
|
537 } |
|
538 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
539 } |
|
540 |
|
541 void QTmsVoipTest::AddClientSinkToStream() |
|
542 { |
|
543 gint status(QTMS_RESULT_SUCCESS); |
|
544 if (m_Uplink && m_ClientSink) |
|
545 { |
|
546 connect(static_cast<QTMSClientSink*> (m_ClientSink), |
|
547 SIGNAL(ProcessBuffer(const TMS::TMSBuffer*)), this, |
|
548 SLOT(ProcessBuffer(const TMS::TMSBuffer*))); |
|
549 status = m_Uplink->AddSink(m_ClientSink); |
|
550 } |
|
551 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
552 } |
|
553 |
|
554 |
|
555 |
|
556 void QTmsVoipTest::CreateMicSource() |
|
557 { |
|
558 gint status(QTMS_RESULT_SUCCESS); |
|
559 |
|
560 if (m_Factory && !m_MicSource) |
|
561 { |
|
562 status = m_Factory->CreateSource(TMS_SOURCE_MIC, m_MicSource); |
|
563 } |
|
564 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
565 } |
|
566 |
|
567 void QTmsVoipTest::AddMicSourceToStream() |
|
568 { |
|
569 gint status(QTMS_RESULT_SUCCESS); |
|
570 if (m_Uplink && m_MicSource) |
|
571 { |
|
572 status = m_Uplink->AddSource(m_MicSource); |
|
573 } |
|
574 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
575 } |
|
576 |
|
577 void QTmsVoipTest::CreateSpeakerSink() |
|
578 { |
|
579 gint status(QTMS_RESULT_SUCCESS); |
|
580 |
|
581 if (m_Factory && !m_SpeakerSink) |
|
582 { |
|
583 status = m_Factory->CreateSink(QTMS_SINK_SPEAKER, m_SpeakerSink); |
|
584 } |
|
585 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
586 } |
|
587 |
|
588 void QTmsVoipTest::AddSpeakerSinkToStream() |
|
589 { |
|
590 gint status(QTMS_RESULT_SUCCESS); |
|
591 if (m_Dnlink && m_SpeakerSink) |
|
592 { |
|
593 status = m_Dnlink->AddSink(m_SpeakerSink); |
|
594 } |
|
595 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
596 } |
|
597 |
|
598 void QTmsVoipTest::InitUplink() |
|
599 { |
|
600 QVERIFY(m_Uplink->Init() == QTMS_RESULT_SUCCESS); |
|
601 QTest::qWait(1000); |
|
602 //QCOMPARE(m_UplinkSpy->count(), 1 ); |
|
603 |
|
604 GetSupportedBitrates(); |
|
605 SelectMinBitrate(); |
|
606 SelectMaxBitrate(); |
|
607 GetBitrate(); |
|
608 |
|
609 ToggleVad(); |
|
610 GetVad(); |
|
611 |
|
612 SetUpLinkG711ALAW(); |
|
613 SetUpLinkG711uLAW(); |
|
614 GetUpLinkG711Mode(); |
|
615 |
|
616 SetUpLinkILBC20MS(); |
|
617 SetUpLinkILBC30MS(); |
|
618 GetUpLinkILBCMode(); |
|
619 |
|
620 } |
|
621 |
|
622 void QTmsVoipTest::InitDnlink() |
|
623 { |
|
624 QVERIFY(m_Dnlink->Init() == QTMS_RESULT_SUCCESS); |
|
625 QTest::qWait(1000); |
|
626 //QCOMPARE(m_DnlinkSpy->count(), 1 ); |
|
627 ToggleCng(); |
|
628 GetCng(); |
|
629 TogglePlc(); |
|
630 GetPlc(); |
|
631 |
|
632 SetDnLinkG711ALAW(); |
|
633 SetDnLinkG711uLAW(); |
|
634 GetDnLinkG711Mode(); |
|
635 |
|
636 SetDnLinkILBC20MS(); |
|
637 SetDnLinkILBC30MS(); |
|
638 GetDnLinkILBCMode(); |
|
639 |
|
640 } |
|
641 void QTmsVoipTest::DeinitUplink() |
|
642 { |
|
643 m_Uplink->Deinit(); |
|
644 QTest::qWait(1000); |
|
645 } |
|
646 |
|
647 void QTmsVoipTest::DeinitDnlink() |
|
648 { |
|
649 m_Dnlink->Deinit(); |
|
650 QTest::qWait(1000); |
|
651 } |
|
652 |
|
653 void QTmsVoipTest::StartUplink() |
|
654 { |
|
655 QVERIFY(m_Uplink->Start() == QTMS_RESULT_SUCCESS); |
|
656 QTest::qWait(1000); |
|
657 //QCOMPARE(m_UplinkSpy->count(), 2 ); |
|
658 } |
|
659 |
|
660 void QTmsVoipTest::StartDnlink() |
|
661 { |
|
662 QVERIFY(m_Dnlink->Start() == QTMS_RESULT_SUCCESS); |
|
663 QTest::qWait(1000); |
|
664 //QCOMPARE(m_DnlinkSpy->count(), 2 ); |
|
665 } |
|
666 void QTmsVoipTest::StopUplink() |
|
667 { |
|
668 #ifdef __TEST_CODE_COVERAGE__ |
|
669 QVERIFY(m_Uplink->Pause()== QTMS_RESULT_SUCCESS); |
|
670 QTest::qWait(1000); |
|
671 #endif //__TEST_CODE_COVERAGE__ |
|
672 |
|
673 QVERIFY(m_Uplink->Stop() == QTMS_RESULT_SUCCESS); |
|
674 QTest::qWait(1000); |
|
675 //QCOMPARE(m_UplinkSpy->count(), 3 ); |
|
676 } |
|
677 |
|
678 void QTmsVoipTest::StopDnlink() |
|
679 { |
|
680 #ifdef __TEST_CODE_COVERAGE__ |
|
681 QVERIFY(m_Dnlink->Pause() == QTMS_RESULT_SUCCESS); |
|
682 QTest::qWait(1000); |
|
683 #endif //__TEST_CODE_COVERAGE__ |
|
684 |
|
685 QVERIFY(m_Dnlink->Stop() == QTMS_RESULT_SUCCESS); |
|
686 QTest::qWait(1000); |
|
687 //QCOMPARE(m_DnlinkSpy->count(), 3 ); |
|
688 } |
|
689 |
|
690 void QTmsVoipTest::CloseUplink() |
|
691 { |
|
692 m_Uplink->Deinit(); |
|
693 QTest::qWait(1000); |
|
694 if (m_Uplink) |
|
695 { |
|
696 if (m_Gain) |
|
697 { |
|
698 QVERIFY(m_Uplink->RemoveEffect(m_Gain)== QTMS_RESULT_SUCCESS); |
|
699 } |
|
700 if (m_MicSource) |
|
701 { |
|
702 QVERIFY(m_Uplink->RemoveSource(m_MicSource)== QTMS_RESULT_SUCCESS); |
|
703 } |
|
704 if (m_ClientSink) |
|
705 { |
|
706 QVERIFY(m_Uplink->RemoveSink(m_ClientSink)== QTMS_RESULT_SUCCESS); |
|
707 } |
|
708 } |
|
709 } |
|
710 |
|
711 void QTmsVoipTest::CloseDownlink() |
|
712 { |
|
713 m_Dnlink->Deinit(); |
|
714 QTest::qWait(1000); |
|
715 if (m_Dnlink) |
|
716 { |
|
717 if (m_Vol) |
|
718 { |
|
719 QVERIFY(m_Dnlink->RemoveEffect(m_Vol)== QTMS_RESULT_SUCCESS); |
|
720 } |
|
721 if (m_ClientSource) |
|
722 { |
|
723 QVERIFY(m_Dnlink->RemoveSource(m_ClientSource)== QTMS_RESULT_SUCCESS); |
|
724 } |
|
725 if (m_SpeakerSink) |
|
726 { |
|
727 QVERIFY(m_Dnlink->RemoveSink(m_SpeakerSink) == QTMS_RESULT_SUCCESS); |
|
728 } |
|
729 } |
|
730 |
|
731 } |
|
732 |
|
733 void QTmsVoipTest::ResetUplnkFormat() |
|
734 { |
|
735 if (m_Uplink) |
|
736 { |
|
737 switch (m_UpLinkCodec) |
|
738 { |
|
739 case QTMS_FORMAT_PCM: |
|
740 m_Uplink->ResetFormat(m_PCM16EncFormatIntfc); |
|
741 break; |
|
742 case QTMS_FORMAT_AMR: |
|
743 m_Uplink->ResetFormat(m_AMRNBEncFormatIntfc); |
|
744 break; |
|
745 case QTMS_FORMAT_G711: |
|
746 m_Uplink->ResetFormat(m_G711EncFormatIntfc); |
|
747 break; |
|
748 case QTMS_FORMAT_G729: |
|
749 m_Uplink->ResetFormat(m_G729EncFormatIntfc); |
|
750 break; |
|
751 case QTMS_FORMAT_ILBC: |
|
752 m_Uplink->ResetFormat(m_ILBCEncFormatIntfc); |
|
753 break; |
|
754 default: |
|
755 break; |
|
756 } |
|
757 } |
|
758 |
|
759 } |
|
760 |
|
761 void QTmsVoipTest::ResetDnlnkFormat() |
|
762 { |
|
763 if (m_Dnlink) |
|
764 { |
|
765 switch (m_DnLinkCodec) |
|
766 { |
|
767 case QTMS_FORMAT_PCM: |
|
768 m_Dnlink->ResetFormat(m_PCM16DecFormatIntfc); |
|
769 break; |
|
770 case QTMS_FORMAT_AMR: |
|
771 m_Dnlink->ResetFormat(m_AMRNBDecFormatIntfc); |
|
772 break; |
|
773 case QTMS_FORMAT_G711: |
|
774 m_Dnlink->ResetFormat(m_G711DecFormatIntfc); |
|
775 break; |
|
776 case QTMS_FORMAT_G729: |
|
777 m_Dnlink->ResetFormat(m_G729DecFormatIntfc); |
|
778 break; |
|
779 case QTMS_FORMAT_ILBC: |
|
780 m_Dnlink->ResetFormat(m_ILBCDecFormatIntfc); |
|
781 break; |
|
782 default: |
|
783 break; |
|
784 } |
|
785 } |
|
786 } |
|
787 |
|
788 void QTmsVoipTest::CreateFormat_data() |
|
789 { |
|
790 QTest::addColumn<QTMSFormatType>("format"); |
|
791 |
|
792 #ifndef __WINSCW__ |
|
793 QTest::newRow("G711")<<QTMS_FORMAT_G711; |
|
794 QTest::newRow("G729")<<QTMS_FORMAT_G729; |
|
795 QTest::newRow("iLBC")<<QTMS_FORMAT_ILBC; |
|
796 QTest::newRow("AMR")<<QTMS_FORMAT_AMR; |
|
797 #endif |
|
798 QTest::newRow("PCM") << QTMS_FORMAT_PCM; |
|
799 } |
|
800 |
|
801 void QTmsVoipTest::CreateFormat() |
|
802 { |
|
803 gint decstatus(QTMS_RESULT_SUCCESS); |
|
804 gint encstatus(QTMS_RESULT_SUCCESS); |
|
805 gint setencstatus(QTMS_RESULT_SUCCESS); |
|
806 gint setdecstatus(QTMS_RESULT_SUCCESS); |
|
807 QFETCH(QTMSFormatType, format); |
|
808 |
|
809 m_DnLinkCodec = format; |
|
810 m_UpLinkCodec = format; |
|
811 |
|
812 switch (format) |
|
813 { |
|
814 case QTMS_FORMAT_G711: |
|
815 { |
|
816 decstatus = m_Factory->CreateFormat(QTMS_FORMAT_G711, |
|
817 m_G711DecFormatIntfc); |
|
818 encstatus = m_Factory->CreateFormat(QTMS_FORMAT_G711, |
|
819 m_G711EncFormatIntfc); |
|
820 setdecstatus = m_Dnlink->SetFormat(m_G711DecFormatIntfc); |
|
821 setencstatus = m_Uplink->SetFormat(m_G711EncFormatIntfc); |
|
822 qDebug("G.711 Set"); |
|
823 |
|
824 } |
|
825 break; |
|
826 case QTMS_FORMAT_G729: |
|
827 { |
|
828 decstatus = m_Factory->CreateFormat(QTMS_FORMAT_G729, |
|
829 m_G729DecFormatIntfc); |
|
830 encstatus = m_Factory->CreateFormat(QTMS_FORMAT_G729, |
|
831 m_G729EncFormatIntfc); |
|
832 setdecstatus = m_Dnlink->SetFormat(m_G729DecFormatIntfc); |
|
833 setdecstatus = m_Uplink->SetFormat(m_G729EncFormatIntfc); |
|
834 qDebug("G.729 Set"); |
|
835 } |
|
836 break; |
|
837 case QTMS_FORMAT_ILBC: |
|
838 { |
|
839 decstatus = m_Factory->CreateFormat(QTMS_FORMAT_ILBC, |
|
840 m_ILBCDecFormatIntfc); |
|
841 encstatus = m_Factory->CreateFormat(QTMS_FORMAT_ILBC, |
|
842 m_ILBCEncFormatIntfc); |
|
843 setdecstatus = m_Dnlink->SetFormat(m_ILBCDecFormatIntfc); |
|
844 setencstatus = m_Uplink->SetFormat(m_ILBCEncFormatIntfc); |
|
845 qDebug("iLBC Set"); |
|
846 } |
|
847 break; |
|
848 case QTMS_FORMAT_AMR: |
|
849 { |
|
850 decstatus = m_Factory->CreateFormat(QTMS_FORMAT_AMR, |
|
851 m_AMRNBDecFormatIntfc); |
|
852 encstatus = m_Factory->CreateFormat(QTMS_FORMAT_AMR, |
|
853 m_AMRNBEncFormatIntfc); |
|
854 setdecstatus = m_Dnlink->SetFormat(m_AMRNBDecFormatIntfc); |
|
855 setencstatus = m_Uplink->SetFormat(m_AMRNBEncFormatIntfc); |
|
856 qDebug("AMR-NB Set"); |
|
857 } |
|
858 break; |
|
859 case QTMS_FORMAT_PCM: |
|
860 { |
|
861 decstatus = m_Factory->CreateFormat(QTMS_FORMAT_PCM, |
|
862 m_PCM16DecFormatIntfc); |
|
863 encstatus = m_Factory->CreateFormat(QTMS_FORMAT_PCM, |
|
864 m_PCM16EncFormatIntfc); |
|
865 setdecstatus = m_Dnlink->SetFormat(m_PCM16DecFormatIntfc); |
|
866 setencstatus = m_Uplink->SetFormat(m_PCM16EncFormatIntfc); |
|
867 qDebug("PCM-16 Set"); |
|
868 } |
|
869 break; |
|
870 default: |
|
871 break; |
|
872 } |
|
873 |
|
874 QVERIFY(decstatus == QTMS_RESULT_SUCCESS); |
|
875 QVERIFY(encstatus == QTMS_RESULT_SUCCESS); |
|
876 QVERIFY(setdecstatus == QTMS_RESULT_SUCCESS); |
|
877 QVERIFY(setencstatus == QTMS_RESULT_SUCCESS); |
|
878 |
|
879 InitUplink(); |
|
880 InitDnlink(); |
|
881 } |
|
882 |
|
883 |
|
884 void QTmsVoipTest::ToggleVad() |
|
885 { |
|
886 //m_Vad = (m_Vad) ? EFalse : ETrue; |
|
887 |
|
888 m_Vad = ETrue; |
|
889 switch (m_UpLinkCodec) |
|
890 { |
|
891 case QTMS_FORMAT_G711: |
|
892 static_cast<QTMSG711Format*> (m_G711EncFormatIntfc)->SetVADMode( |
|
893 m_Vad); |
|
894 qDebug("G711 VAD set %d", m_Vad); |
|
895 break; |
|
896 case QTMS_FORMAT_G729: |
|
897 static_cast<QTMSG729Format*> (m_G729EncFormatIntfc)->SetVADMode( |
|
898 m_Vad); |
|
899 qDebug("G729 VAD set %d",m_Vad); |
|
900 break; |
|
901 case QTMS_FORMAT_ILBC: |
|
902 static_cast<QTMSILBCFormat*> (m_ILBCEncFormatIntfc)->SetVADMode( |
|
903 m_Vad); |
|
904 qDebug("iLBC VAD set %d",m_Vad); |
|
905 break; |
|
906 case QTMS_FORMAT_AMR: |
|
907 //static_cast<TMSAMRFormat*>(iAMRNBEncFormatIntfc)->SetVADMode(m_Vad); |
|
908 break; |
|
909 case QTMS_FORMAT_PCM: |
|
910 // Not supported; just for testing failing condition |
|
911 //static_cast<QTMSPCMFormat*>(iPCM16EncFormatIntfc)->SetVADMode(m_Vad); |
|
912 break; |
|
913 default: |
|
914 break; |
|
915 } |
|
916 } |
|
917 |
|
918 |
|
919 void QTmsVoipTest::GetVad() |
|
920 { |
|
921 gint status(QTMS_RESULT_SUCCESS); |
|
922 gboolean vad = EFalse; |
|
923 |
|
924 switch (m_UpLinkCodec) |
|
925 { |
|
926 case QTMS_FORMAT_G711: |
|
927 status = static_cast<QTMSG711Format*> (m_G711EncFormatIntfc)->GetVADMode( |
|
928 vad); |
|
929 qDebug("get G711 VAD: %d", vad); |
|
930 break; |
|
931 case QTMS_FORMAT_G729: |
|
932 status = static_cast<QTMSG729Format*> (m_G729EncFormatIntfc)->GetVADMode( |
|
933 vad); |
|
934 qDebug("get G729 VAD: %d", vad); |
|
935 break; |
|
936 case QTMS_FORMAT_ILBC: |
|
937 status = static_cast<QTMSILBCFormat*> (m_ILBCEncFormatIntfc)->GetVADMode( |
|
938 vad); |
|
939 qDebug("get iLBC VAD: %d", vad); |
|
940 break; |
|
941 default: |
|
942 return; |
|
943 } |
|
944 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
945 // QVERIFY(vad == m_Vad); |
|
946 |
|
947 |
|
948 } |
|
949 |
|
950 void QTmsVoipTest::ToggleCng() |
|
951 { |
|
952 // m_Cng = (m_Cng) ? EFalse : ETrue; |
|
953 |
|
954 m_Cng = ETrue; |
|
955 switch (m_DnLinkCodec) |
|
956 { |
|
957 case QTMS_FORMAT_G711: |
|
958 //case EG711_10MS: |
|
959 static_cast<QTMSG711Format*> (m_G711DecFormatIntfc)->SetCNG(m_Cng); |
|
960 qDebug("G711 CNG set %d", m_Cng); |
|
961 break; |
|
962 case QTMS_FORMAT_ILBC: |
|
963 static_cast<QTMSILBCFormat*> (m_ILBCDecFormatIntfc)->SetCNG(m_Cng); |
|
964 qDebug("iLBC CNG set %d", m_Cng); |
|
965 break; |
|
966 default: |
|
967 break; |
|
968 } |
|
969 } |
|
970 |
|
971 |
|
972 void QTmsVoipTest::GetCng() |
|
973 { |
|
974 gint status; |
|
975 gboolean cng = EFalse; |
|
976 switch (m_DnLinkCodec) |
|
977 { |
|
978 case QTMS_FORMAT_G711: |
|
979 status = static_cast<QTMSG711Format*>(m_G711DecFormatIntfc)->GetCNG(cng); |
|
980 qDebug("G711 CNG: %d", cng); |
|
981 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
982 break; |
|
983 case QTMS_FORMAT_ILBC: |
|
984 status = static_cast<QTMSILBCFormat*>(m_ILBCDecFormatIntfc)->GetCNG(cng); |
|
985 qDebug("iLBC CNG: %d", cng); |
|
986 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
987 break; |
|
988 default: |
|
989 break; |
|
990 } |
|
991 |
|
992 // QVERIFY(cng == m_Cng); |
|
993 |
|
994 } |
|
995 |
|
996 |
|
997 void QTmsVoipTest::TogglePlc() |
|
998 { |
|
999 // m_Plc = (m_Plc) ? EFalse : ETrue; |
|
1000 m_Plc = ETrue; |
|
1001 if (m_DnLinkCodec == QTMS_FORMAT_G711) |
|
1002 { |
|
1003 static_cast<QTMSG711Format*> (m_G711DecFormatIntfc)->SetPlc(m_Plc); |
|
1004 qDebug("G711 PLC set %d",m_Plc ); |
|
1005 } |
|
1006 } |
|
1007 |
|
1008 void QTmsVoipTest::GetPlc() |
|
1009 { |
|
1010 gboolean plc = EFalse; |
|
1011 if (m_G711DecFormatIntfc && m_DnLinkCodec == QTMS_FORMAT_G711) |
|
1012 { |
|
1013 gint status = |
|
1014 static_cast<QTMSG711Format*> (m_G711DecFormatIntfc)->GetPlc( |
|
1015 plc); |
|
1016 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1017 qDebug("G711 PLC: %d", plc); |
|
1018 // QVERIFY(plc == m_Plc); |
|
1019 } |
|
1020 } |
|
1021 |
|
1022 |
|
1023 |
|
1024 void QTmsVoipTest::SelectMinBitrate() |
|
1025 { |
|
1026 if (m_BitratesVector.size() > 0) |
|
1027 { |
|
1028 std::vector<guint>::iterator bitrate = m_BitratesVector.begin(); |
|
1029 iBitrate = *bitrate; |
|
1030 SetBitrate(iBitrate); |
|
1031 qDebug("BR set %d",iBitrate); |
|
1032 } |
|
1033 } |
|
1034 |
|
1035 |
|
1036 void QTmsVoipTest::SelectMaxBitrate() |
|
1037 { |
|
1038 if (m_BitratesVector.size() > 0) |
|
1039 { |
|
1040 iBitrate = m_BitratesVector.back(); |
|
1041 SetBitrate(iBitrate); |
|
1042 qDebug("BR set %d",iBitrate); |
|
1043 } |
|
1044 } |
|
1045 |
|
1046 |
|
1047 void QTmsVoipTest::SetBitrate(guint bitrate) |
|
1048 { |
|
1049 switch (m_UpLinkCodec) |
|
1050 { |
|
1051 case QTMS_FORMAT_G711: |
|
1052 static_cast<QTMSG711Format*> (m_G711EncFormatIntfc)->SetBitRate( |
|
1053 bitrate); |
|
1054 qDebug("Set BR %d",bitrate); |
|
1055 break; |
|
1056 case QTMS_FORMAT_G729: |
|
1057 static_cast<QTMSG729Format*> (m_G729EncFormatIntfc)->SetBitRate( |
|
1058 bitrate); |
|
1059 qDebug("Set BR %d",bitrate); |
|
1060 break; |
|
1061 case QTMS_FORMAT_ILBC: |
|
1062 static_cast<QTMSILBCFormat*> (m_ILBCEncFormatIntfc)->SetBitRate( |
|
1063 bitrate); |
|
1064 qDebug("Set BR %d",bitrate); |
|
1065 break; |
|
1066 case QTMS_FORMAT_AMR: |
|
1067 static_cast<QTMSAMRFormat*> (m_AMRNBEncFormatIntfc)->SetBitRate( |
|
1068 bitrate); |
|
1069 qDebug("Set BR %d",bitrate); |
|
1070 break; |
|
1071 case QTMS_FORMAT_PCM: |
|
1072 default: |
|
1073 break; |
|
1074 } |
|
1075 } |
|
1076 |
|
1077 |
|
1078 void QTmsVoipTest::GetSupportedBitrates() |
|
1079 { |
|
1080 gint numOfItems(0); |
|
1081 m_BitratesVector.clear(); |
|
1082 gint status = GetSupportedBitrates(m_BitratesVector); |
|
1083 |
|
1084 numOfItems = m_BitratesVector.size(); |
|
1085 qDebug("BR Count %d", numOfItems); |
|
1086 std::vector<guint>::iterator itBitrates = m_BitratesVector.begin(); |
|
1087 for (; itBitrates < m_BitratesVector.end(); itBitrates++) |
|
1088 { |
|
1089 qDebug("BR %d", *itBitrates); |
|
1090 } |
|
1091 } |
|
1092 |
|
1093 |
|
1094 gint QTmsVoipTest::GetSupportedBitrates(BitRateVector& aBrArr) |
|
1095 { |
|
1096 gint status(QTMS_RESULT_SUCCESS); |
|
1097 |
|
1098 switch (m_UpLinkCodec) |
|
1099 { |
|
1100 case QTMS_FORMAT_G711: |
|
1101 status = m_G711EncFormatIntfc->GetSupportedBitRates(aBrArr); |
|
1102 break; |
|
1103 case QTMS_FORMAT_G729: |
|
1104 status = m_G729EncFormatIntfc->GetSupportedBitRates(aBrArr); |
|
1105 break; |
|
1106 case QTMS_FORMAT_ILBC: |
|
1107 status = m_ILBCEncFormatIntfc->GetSupportedBitRates(aBrArr); |
|
1108 break; |
|
1109 case QTMS_FORMAT_AMR: |
|
1110 status = m_AMRNBEncFormatIntfc->GetSupportedBitRates(aBrArr); |
|
1111 break; |
|
1112 case QTMS_FORMAT_PCM: |
|
1113 // not supported, but test for correct error handling |
|
1114 //status = m_PCM16EncFormatIntfc->GetSupportedBitRates(aBrArr); |
|
1115 break; |
|
1116 default: |
|
1117 status = KErrNotSupported; |
|
1118 break; |
|
1119 } |
|
1120 |
|
1121 return status; |
|
1122 } |
|
1123 |
|
1124 |
|
1125 void QTmsVoipTest::GetBitrate() |
|
1126 { |
|
1127 guint bitrate; |
|
1128 switch (m_UpLinkCodec) |
|
1129 { |
|
1130 case QTMS_FORMAT_G711: |
|
1131 static_cast<QTMSG711Format*> (m_G711EncFormatIntfc)->GetBitRate( |
|
1132 bitrate); |
|
1133 qDebug("G711 bitrate: %d", bitrate); |
|
1134 break; |
|
1135 case QTMS_FORMAT_G729: |
|
1136 static_cast<QTMSG729Format*> (m_G729EncFormatIntfc)->GetBitRate( |
|
1137 bitrate); |
|
1138 qDebug("G729 bitrate: %d", bitrate); |
|
1139 break; |
|
1140 case QTMS_FORMAT_ILBC: |
|
1141 static_cast<QTMSILBCFormat*> (m_ILBCEncFormatIntfc)->GetBitRate( |
|
1142 bitrate); |
|
1143 qDebug("iLBC bitrate: %d", bitrate); |
|
1144 break; |
|
1145 case QTMS_FORMAT_AMR: |
|
1146 static_cast<QTMSAMRFormat*> (m_AMRNBEncFormatIntfc)->GetBitRate( |
|
1147 bitrate); |
|
1148 qDebug("AMR bitrate: %d", bitrate); |
|
1149 break; |
|
1150 case TMS_FORMAT_PCM: |
|
1151 default: |
|
1152 break; |
|
1153 } |
|
1154 } |
|
1155 |
|
1156 |
|
1157 void QTmsVoipTest::SetDnLinkG711ALAW() |
|
1158 { |
|
1159 if (m_G711DecFormatIntfc && m_DnLinkCodec == QTMS_FORMAT_G711) |
|
1160 { |
|
1161 gint status = static_cast<QTMSG711Format*> (m_G711DecFormatIntfc)->SetMode( |
|
1162 QTMS_G711_CODEC_MODE_ALAW); |
|
1163 qDebug("SetDnLinkG711ALAW status %d",status); |
|
1164 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1165 qDebug("DNL G.711 Mode Set: [aLaw]"); |
|
1166 } |
|
1167 } |
|
1168 |
|
1169 |
|
1170 void QTmsVoipTest::SetDnLinkG711uLAW() |
|
1171 { |
|
1172 if (m_G711DecFormatIntfc && m_DnLinkCodec == QTMS_FORMAT_G711) |
|
1173 { |
|
1174 gint status = static_cast<QTMSG711Format*> (m_G711DecFormatIntfc)->SetMode( |
|
1175 QTMS_G711_CODEC_MODE_MULAW); |
|
1176 qDebug("SetDnLinkG711uLAW status %d",status); |
|
1177 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1178 qDebug("DNL G.711 Mode Set: [uLaw]"); |
|
1179 } |
|
1180 } |
|
1181 |
|
1182 |
|
1183 void QTmsVoipTest::GetDnLinkG711Mode() |
|
1184 { |
|
1185 QTMSG711CodecMode mode; |
|
1186 if (m_G711DecFormatIntfc && m_DnLinkCodec == QTMS_FORMAT_G711) |
|
1187 { |
|
1188 gint status = |
|
1189 static_cast<QTMSG711Format*> (m_G711DecFormatIntfc)->GetMode( |
|
1190 mode); |
|
1191 qDebug("GetDnLinkG711Mode status %d",status); |
|
1192 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1193 if (mode == TMS_G711_CODEC_MODE_MULAW) |
|
1194 { |
|
1195 qDebug("DNL G711 Mode: [uLaw]"); |
|
1196 } |
|
1197 else |
|
1198 { |
|
1199 qDebug("DNL G711 Mode: [aLaw]"); |
|
1200 } |
|
1201 } |
|
1202 } |
|
1203 |
|
1204 |
|
1205 void QTmsVoipTest::SetDnLinkILBC20MS() |
|
1206 { |
|
1207 if (m_ILBCDecFormatIntfc && m_DnLinkCodec == QTMS_FORMAT_ILBC) |
|
1208 { |
|
1209 gint status = |
|
1210 static_cast<QTMSILBCFormat*> (m_ILBCDecFormatIntfc)->SetMode( |
|
1211 TMS_ILBC_CODEC_MODE_20MS_FRAME); |
|
1212 qDebug("SetDnLinkILBC20MS status %d",status); |
|
1213 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1214 qDebug("DNL iLBC Mode Set: [20ms]"); |
|
1215 } |
|
1216 } |
|
1217 |
|
1218 |
|
1219 void QTmsVoipTest::SetDnLinkILBC30MS() |
|
1220 { |
|
1221 if (m_ILBCDecFormatIntfc && m_DnLinkCodec == QTMS_FORMAT_ILBC) |
|
1222 { |
|
1223 gint status = |
|
1224 static_cast<QTMSILBCFormat*> (m_ILBCDecFormatIntfc)->SetMode( |
|
1225 TMS_ILBC_CODEC_MODE_30MS_FRAME); |
|
1226 qDebug("SetDnLinkILBC30MS status %d",status); |
|
1227 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1228 qDebug("DNL iLBC Mode Set: [30ms]"); |
|
1229 } |
|
1230 } |
|
1231 |
|
1232 |
|
1233 void QTmsVoipTest::GetDnLinkILBCMode() |
|
1234 { |
|
1235 QTMSILBCCodecMode mode; |
|
1236 if (m_ILBCDecFormatIntfc && m_DnLinkCodec == QTMS_FORMAT_ILBC) |
|
1237 { |
|
1238 gint status = |
|
1239 static_cast<QTMSILBCFormat*> (m_ILBCDecFormatIntfc)->GetMode( |
|
1240 mode); |
|
1241 qDebug("GetDnLinkILBCMode status %d",status); |
|
1242 |
|
1243 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1244 if (mode == QTMS_ILBC_CODEC_MODE_30MS_FRAME) |
|
1245 { |
|
1246 qDebug("DNL iLBC Mode: [30ms]"); |
|
1247 } |
|
1248 else if (mode == QTMS_ILBC_CODEC_MODE_20MS_FRAME) |
|
1249 { |
|
1250 qDebug("DNL iLBC Mode: [20ms]"); |
|
1251 } |
|
1252 } |
|
1253 } |
|
1254 |
|
1255 void QTmsVoipTest::SetUpLinkG711ALAW() |
|
1256 { |
|
1257 if (m_G711EncFormatIntfc && m_UpLinkCodec == QTMS_FORMAT_G711) |
|
1258 { |
|
1259 gint status = |
|
1260 static_cast<QTMSG711Format*> (m_G711EncFormatIntfc)->SetMode( |
|
1261 QTMS_G711_CODEC_MODE_ALAW); |
|
1262 |
|
1263 qDebug("SetUpLinkG711ALAW status %d",status); |
|
1264 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1265 qDebug("UPL G.711 Mode Set: [aLaw]"); |
|
1266 } |
|
1267 } |
|
1268 |
|
1269 void QTmsVoipTest::SetUpLinkG711uLAW() |
|
1270 { |
|
1271 if (m_G711EncFormatIntfc && m_UpLinkCodec == QTMS_FORMAT_G711) |
|
1272 { |
|
1273 gint status = |
|
1274 static_cast<QTMSG711Format*> (m_G711EncFormatIntfc)->SetMode( |
|
1275 QTMS_G711_CODEC_MODE_MULAW); |
|
1276 qDebug("SetUpLinkG711uLAW status %d",status); |
|
1277 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1278 qDebug("UPL G.711 Mode Set: [uLaw]"); |
|
1279 } |
|
1280 } |
|
1281 |
|
1282 void QTmsVoipTest::GetUpLinkG711Mode() |
|
1283 { |
|
1284 QTMSG711CodecMode mode; |
|
1285 if (m_G711EncFormatIntfc && m_UpLinkCodec == QTMS_FORMAT_G711) |
|
1286 { |
|
1287 gint status = |
|
1288 static_cast<QTMSG711Format*> (m_G711EncFormatIntfc)->GetMode( |
|
1289 mode); |
|
1290 qDebug("GetUpLinkG711Mode status %d",status); |
|
1291 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1292 if (mode == QTMS_G711_CODEC_MODE_MULAW) |
|
1293 { |
|
1294 qDebug("UPL G.711 Mode: [uLaw]"); |
|
1295 } |
|
1296 else if (mode == QTMS_G711_CODEC_MODE_ALAW) |
|
1297 { |
|
1298 qDebug("UPL G.711 Mode: [aLaw]"); |
|
1299 } |
|
1300 } |
|
1301 |
|
1302 } |
|
1303 |
|
1304 |
|
1305 void QTmsVoipTest::SetUpLinkILBC20MS() |
|
1306 { |
|
1307 if (m_ILBCEncFormatIntfc && m_UpLinkCodec == QTMS_FORMAT_ILBC) |
|
1308 { |
|
1309 gint status = |
|
1310 static_cast<QTMSILBCFormat*> (m_ILBCEncFormatIntfc)->SetMode( |
|
1311 QTMS_ILBC_CODEC_MODE_20MS_FRAME); |
|
1312 qDebug("SetUpLinkILBC20MS status %d",status); |
|
1313 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1314 qDebug("UPL iLBC Mode Set: [20ms]"); |
|
1315 } |
|
1316 } |
|
1317 |
|
1318 |
|
1319 void QTmsVoipTest::SetUpLinkILBC30MS() |
|
1320 { |
|
1321 if (m_ILBCEncFormatIntfc && m_UpLinkCodec == QTMS_FORMAT_ILBC) |
|
1322 { |
|
1323 gint status = |
|
1324 static_cast<QTMSILBCFormat*> (m_ILBCEncFormatIntfc)->SetMode( |
|
1325 QTMS_ILBC_CODEC_MODE_30MS_FRAME); |
|
1326 qDebug("SetUpLinkILBC30MS status %d",status); |
|
1327 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1328 qDebug("UPL iLBC Mode Set: [30ms]"); |
|
1329 } |
|
1330 } |
|
1331 |
|
1332 void QTmsVoipTest::GetUpLinkILBCMode() |
|
1333 { |
|
1334 QTMSILBCCodecMode mode; |
|
1335 if (m_ILBCEncFormatIntfc && m_UpLinkCodec == QTMS_FORMAT_ILBC) |
|
1336 { |
|
1337 gint status = |
|
1338 static_cast<QTMSILBCFormat*> (m_ILBCEncFormatIntfc)->GetMode( |
|
1339 mode); |
|
1340 qDebug("GetUpLinkILBCMode status %d",status); |
|
1341 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1342 if (mode == QTMS_ILBC_CODEC_MODE_30MS_FRAME) |
|
1343 { |
|
1344 qDebug("UPL iLBC Mode: [30ms]"); |
|
1345 } |
|
1346 else if (mode == QTMS_ILBC_CODEC_MODE_20MS_FRAME) |
|
1347 { |
|
1348 qDebug("UPL iLBC Mode: [20ms]"); |
|
1349 } |
|
1350 } |
|
1351 |
|
1352 } |
|
1353 |
|
1354 |
|
1355 void QTmsVoipTest::CreateStreamVol() |
|
1356 { |
|
1357 gint status(QTMS_RESULT_SUCCESS); |
|
1358 |
|
1359 if (m_Factory && m_Dnlink && !m_Vol) |
|
1360 { |
|
1361 m_Factory->CreateFormat(QTMS_FORMAT_PCM, m_PCM16DecFormatIntfc); |
|
1362 m_Dnlink->SetFormat(m_PCM16DecFormatIntfc); |
|
1363 |
|
1364 status = m_Factory->CreateEffect(QTMS_EFFECT_VOLUME, m_Vol); |
|
1365 |
|
1366 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1367 |
|
1368 connect(static_cast<QTMSVolumeEffect*> (m_Vol), |
|
1369 SIGNAL(EffectsEvent(const QTMSEffect&,QTMSSignalEvent)), |
|
1370 this, SLOT(EffectsEvent(const QTMSEffect&,QTMSSignalEvent))); |
|
1371 |
|
1372 if(m_Dnlink) |
|
1373 { |
|
1374 status = m_Dnlink->AddEffect(m_Vol); |
|
1375 } |
|
1376 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1377 |
|
1378 InitDnlink(); |
|
1379 |
|
1380 StreamVol(); |
|
1381 |
|
1382 } |
|
1383 } |
|
1384 |
|
1385 void QTmsVoipTest::StreamVol() |
|
1386 { |
|
1387 gint status(QTMS_RESULT_SUCCESS); |
|
1388 guint maxvol(0); |
|
1389 if (m_Vol) |
|
1390 { |
|
1391 status = static_cast<QTMSVolumeEffect*> (m_Vol)->GetMaxLevel(maxvol); |
|
1392 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1393 |
|
1394 status = static_cast<QTMSVolumeEffect*> (m_Vol)->SetLevel(maxvol); |
|
1395 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1396 QTest::qWait(1000); |
|
1397 |
|
1398 guint vol(0); |
|
1399 status = static_cast<QTMSVolumeEffect*> (m_Vol)->GetLevel(vol); |
|
1400 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1401 |
|
1402 QCOMPARE(vol,maxvol); |
|
1403 } |
|
1404 } |
|
1405 |
|
1406 void QTmsVoipTest::CreateStreamGain() |
|
1407 { |
|
1408 gint status(QTMS_RESULT_SUCCESS); |
|
1409 |
|
1410 if (m_Factory && m_Uplink && !m_Gain) |
|
1411 { |
|
1412 |
|
1413 m_Factory->CreateFormat(QTMS_FORMAT_PCM, m_PCM16EncFormatIntfc); |
|
1414 m_Uplink->SetFormat(m_PCM16EncFormatIntfc); |
|
1415 status = m_Factory->CreateEffect(QTMS_EFFECT_GAIN, m_Gain); |
|
1416 |
|
1417 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1418 |
|
1419 connect(static_cast<QTMSGainEffect*> (m_Gain), |
|
1420 SIGNAL(EffectsEvent(const QTMSEffect&,QTMSSignalEvent)), |
|
1421 this, |
|
1422 SLOT(EffectsEvent(const QTMSEffect&,QTMSSignalEvent))); |
|
1423 |
|
1424 status = m_Uplink->AddEffect(m_Gain); |
|
1425 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1426 |
|
1427 InitUplink(); |
|
1428 |
|
1429 StreamGain(); |
|
1430 } |
|
1431 } |
|
1432 |
|
1433 void QTmsVoipTest::StreamGain() |
|
1434 { |
|
1435 gint status(QTMS_RESULT_SUCCESS); |
|
1436 if (m_Gain) |
|
1437 { |
|
1438 guint maxgain(0); |
|
1439 static_cast<QTMSGainEffect*> (m_Gain)->GetMaxLevel(maxgain); |
|
1440 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1441 |
|
1442 static_cast<QTMSGainEffect*> (m_Gain)->SetLevel(maxgain); |
|
1443 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1444 QTest::qWait(1000); |
|
1445 |
|
1446 guint gain(0); |
|
1447 static_cast<QTMSGainEffect*> (m_Gain)->GetLevel(gain); |
|
1448 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1449 |
|
1450 QCOMPARE(gain,maxgain); |
|
1451 } |
|
1452 |
|
1453 } |
|
1454 |
|
1455 void QTmsVoipTest::CreateGlobalVol() |
|
1456 { |
|
1457 gint status(QTMS_RESULT_SUCCESS); |
|
1458 |
|
1459 if (m_Factory && !m_GlobalVol) |
|
1460 { |
|
1461 status = m_Factory->CreateEffect(QTMS_EFFECT_GLOBAL_VOL, m_GlobalVol); |
|
1462 |
|
1463 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1464 |
|
1465 connect(static_cast<QTMSGlobalVolEffect*> (m_GlobalVol), |
|
1466 SIGNAL(EffectsEvent(const QTMSEffect&,QTMSSignalEvent)), |
|
1467 this, SLOT(EffectsEvent(const QTMSEffect&,QTMSSignalEvent))); |
|
1468 |
|
1469 guint maxvol(0); |
|
1470 status = static_cast<QTMSGlobalVolEffect*>(m_GlobalVol)->GetMaxLevel( |
|
1471 maxvol); |
|
1472 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1473 qDebug("global max vol %d",maxvol); |
|
1474 |
|
1475 status = static_cast<QTMSGlobalVolEffect*>(m_GlobalVol)->SetLevel( |
|
1476 maxvol); |
|
1477 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1478 QTest::qWait(1000); |
|
1479 |
|
1480 guint vol(0); |
|
1481 status = static_cast<QTMSGlobalVolEffect*> (m_GlobalVol)->GetLevel(vol); |
|
1482 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1483 qDebug("global vol %d",vol); |
|
1484 |
|
1485 QCOMPARE(vol,maxvol); |
|
1486 |
|
1487 } |
|
1488 } |
|
1489 |
|
1490 |
|
1491 void QTmsVoipTest::CreateGlobalGain() |
|
1492 { |
|
1493 gint status(QTMS_RESULT_SUCCESS); |
|
1494 |
|
1495 if (m_Factory && !m_GlobalGain) |
|
1496 { |
|
1497 status = m_Factory->CreateEffect(QTMS_EFFECT_GLOBAL_GAIN, m_GlobalGain); |
|
1498 |
|
1499 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1500 |
|
1501 connect(static_cast<QTMSGlobalGainEffect*> (m_GlobalGain), |
|
1502 SIGNAL(EffectsEvent(const QTMSEffect&,QTMSSignalEvent)), |
|
1503 this, |
|
1504 SLOT(EffectsEvent(const QTMSEffect&,QTMSSignalEvent))); |
|
1505 |
|
1506 guint maxgain(0); |
|
1507 static_cast<QTMSGlobalGainEffect*>(m_GlobalGain)->GetMaxLevel(maxgain); |
|
1508 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1509 qDebug("global max gain %d",maxgain); |
|
1510 |
|
1511 static_cast<QTMSGlobalGainEffect*>(m_GlobalGain)->SetLevel(maxgain); |
|
1512 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1513 QTest::qWait(1000); |
|
1514 |
|
1515 guint gain(0); |
|
1516 static_cast<QTMSGlobalGainEffect*>(m_GlobalGain)->GetLevel(gain); |
|
1517 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1518 qDebug("global gain %d",gain); |
|
1519 |
|
1520 QCOMPARE(gain,maxgain); |
|
1521 |
|
1522 } |
|
1523 } |
|
1524 |
|
1525 void QTmsVoipTest::CreateRouting_data() |
|
1526 { |
|
1527 |
|
1528 QTest::addColumn<QTMSAudioOutput>("routing"); |
|
1529 |
|
1530 QTest::newRow("Public")<<QTMS_AUDIO_OUTPUT_PUBLIC; |
|
1531 QTest::newRow("Private")<<QTMS_AUDIO_OUTPUT_PRIVATE; |
|
1532 |
|
1533 |
|
1534 } |
|
1535 |
|
1536 void QTmsVoipTest::CreateRouting() |
|
1537 { |
|
1538 gint status(QTMS_RESULT_SUCCESS); |
|
1539 |
|
1540 QFETCH(QTMSAudioOutput, routing); |
|
1541 |
|
1542 if (m_Factory && !m_Routing) |
|
1543 { |
|
1544 m_UpLinkCodec = QTMS_FORMAT_PCM; |
|
1545 m_Factory->CreateFormat(QTMS_FORMAT_PCM, m_PCM16DecFormatIntfc); |
|
1546 m_Dnlink->SetFormat(m_PCM16DecFormatIntfc); |
|
1547 |
|
1548 InitDnlink(); |
|
1549 StartDnlink(); |
|
1550 |
|
1551 status = m_Factory->CreateGlobalRouting(m_Routing); |
|
1552 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1553 |
|
1554 m_RoutingSpy = new QSignalSpy(m_Routing, |
|
1555 SIGNAL(GlobalRoutingEvent(const QTMSGlobalRouting&, |
|
1556 QTMSSignalEvent, |
|
1557 QTMSAudioOutput))); |
|
1558 |
|
1559 QVERIFY( m_RoutingSpy->isValid() ); |
|
1560 |
|
1561 //QCOMPARE(m_RoutingSpy->count(), 0 ); |
|
1562 connect(m_Routing, |
|
1563 SIGNAL(GlobalRoutingEvent(const QTMSGlobalRouting&,QTMSSignalEvent,QTMSAudioOutput)), |
|
1564 this, |
|
1565 SLOT(GlobalRoutingEvent(const QTMSGlobalRouting&,QTMSSignalEvent,QTMSAudioOutput))); |
|
1566 } |
|
1567 |
|
1568 if(m_Routing) |
|
1569 { |
|
1570 status = m_Routing->SetOutput(routing); |
|
1571 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1572 #ifndef __WINSCW__ |
|
1573 QTest::qWait(1000); |
|
1574 //QCOMPARE(m_RoutingSpy->count(), 1 ); |
|
1575 #endif |
|
1576 QTMSAudioOutput current; |
|
1577 status = m_Routing->GetOutput(current); |
|
1578 DisplayDevice(current); |
|
1579 |
|
1580 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1581 #ifndef __WINSCW__ |
|
1582 QCOMPARE(routing,current); |
|
1583 #endif |
|
1584 StopDnlink(); |
|
1585 } |
|
1586 } |
|
1587 |
|
1588 |
|
1589 void QTmsVoipTest::DisplayDevice(QTMSAudioOutput device) |
|
1590 { |
|
1591 qDebug("Current Output:"); |
|
1592 |
|
1593 switch (device) |
|
1594 { |
|
1595 case QTMS_AUDIO_OUTPUT_NONE: |
|
1596 { |
|
1597 qDebug("none"); |
|
1598 } |
|
1599 break; |
|
1600 case QTMS_AUDIO_OUTPUT_PUBLIC: |
|
1601 { |
|
1602 qDebug("Public"); |
|
1603 } |
|
1604 break; |
|
1605 case QTMS_AUDIO_OUTPUT_PRIVATE: |
|
1606 { |
|
1607 qDebug("Private"); |
|
1608 } |
|
1609 break; |
|
1610 default: |
|
1611 break; |
|
1612 } |
|
1613 } |
|
1614 |
|
1615 |
|
1616 void QTmsVoipTest::CreateDnlinkDtmf() |
|
1617 { |
|
1618 gint status(QTMS_RESULT_SUCCESS); |
|
1619 GString* dtmfstring(NULL); |
|
1620 |
|
1621 if (m_Factory && m_Dnlink && !m_Dnlnkdtmf) |
|
1622 { |
|
1623 m_UpLinkCodec = QTMS_FORMAT_PCM; |
|
1624 m_Factory->CreateFormat(QTMS_FORMAT_PCM, m_PCM16DecFormatIntfc); |
|
1625 m_Dnlink->SetFormat(m_PCM16DecFormatIntfc); |
|
1626 |
|
1627 InitDnlink(); |
|
1628 |
|
1629 status = m_Factory->CreateDTMF(QTMS_STREAM_DOWNLINK, m_Dnlnkdtmf); |
|
1630 |
|
1631 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1632 |
|
1633 QSignalSpy dtmfspy(m_Dnlnkdtmf, |
|
1634 SIGNAL(DTMFEvent(const QTMSDTMF&,QTMSSignalEvent))); |
|
1635 |
|
1636 QVERIFY( dtmfspy.isValid() ); |
|
1637 |
|
1638 //QCOMPARE(dtmfspy.count(), 0 ); |
|
1639 |
|
1640 connect(m_Dnlnkdtmf, |
|
1641 SIGNAL(DTMFEvent(const QTMSDTMF&,QTMSSignalEvent)), this, |
|
1642 SLOT(DTMFEvent(const QTMSDTMF&,QTMSSignalEvent))); |
|
1643 |
|
1644 dtmfstring = g_string_new("4723"); |
|
1645 status = m_Dnlnkdtmf->SetTone(dtmfstring); |
|
1646 |
|
1647 m_Dnlnkdtmf->Start(); |
|
1648 QTest::qWait(1000); |
|
1649 g_string_free(dtmfstring, TRUE); |
|
1650 //QCOMPARE(dtmfspy.count(), 1 ); |
|
1651 |
|
1652 status = m_Dnlnkdtmf->Stop(); |
|
1653 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1654 QTest::qWait(1000); |
|
1655 //QCOMPARE(dtmfspy.count(), 2 ); |
|
1656 } |
|
1657 } |
|
1658 |
|
1659 void QTmsVoipTest::CreateRingTone() |
|
1660 { |
|
1661 |
|
1662 } |
|
1663 |
|
1664 |
|
1665 void QTmsVoipTest::CreateBuffer() |
|
1666 { |
|
1667 gint status(QTMS_RESULT_SUCCESS); |
|
1668 if (m_Factory) |
|
1669 { |
|
1670 QTMSBuffer* qtmsbuffer(NULL); |
|
1671 QTMSBufferType buftype(QTMS_BUFFER_MEMORY); |
|
1672 guint size(100); |
|
1673 status = m_Factory->CreateBuffer(QTMS_BUFFER_MEMORY, |
|
1674 size, qtmsbuffer); |
|
1675 QVERIFY(status == QTMS_RESULT_SUCCESS); |
|
1676 if (qtmsbuffer) |
|
1677 { |
|
1678 qtmsbuffer->GetType(buftype); |
|
1679 qtmsbuffer->GetDataSize(size); |
|
1680 qtmsbuffer->SetDataSize(size); |
|
1681 guint8* pbuf(NULL); |
|
1682 qtmsbuffer->GetDataPtr(pbuf); |
|
1683 guint64 ts(0); |
|
1684 qtmsbuffer->GetTimeStamp(ts); |
|
1685 qtmsbuffer->SetTimeStamp(ts); |
|
1686 m_Factory->DeleteBuffer(qtmsbuffer); |
|
1687 } |
|
1688 } |
|
1689 } |
|
1690 |
|
1691 |
|
1692 void QTmsVoipTest::FillBuffer(TMS::TMSBuffer& buffer) |
|
1693 { |
|
1694 //TODO: add loopback test and file playback |
|
1695 #ifdef __TEST_CODE_COVERAGE__ |
|
1696 if(m_ClientSource) |
|
1697 { |
|
1698 static_cast<QTMSClientSource*> (m_ClientSource)->BufferFilled( |
|
1699 buffer); |
|
1700 } |
|
1701 #endif |
|
1702 |
|
1703 } |
|
1704 |
|
1705 void QTmsVoipTest::BufferProcessed(TMS::TMSBuffer* /*buffer*/, gint /*reason*/) |
|
1706 { |
|
1707 } |
|
1708 |
|
1709 void QTmsVoipTest::ProcessBuffer(const TMS::TMSBuffer* buffer) |
|
1710 { |
|
1711 //TODO: add loopback test |
|
1712 #ifdef __TEST_CODE_COVERAGE__ |
|
1713 TMS::TMSBuffer* recBuf(NULL); |
|
1714 recBuf = const_cast<TMS::TMSBuffer*> (buffer); |
|
1715 if(m_ClientSink) |
|
1716 { |
|
1717 static_cast<QTMSClientSink*> (m_ClientSink)->BufferProcessed( |
|
1718 recBuf); |
|
1719 } |
|
1720 #endif |
|
1721 } |
|
1722 |
|
1723 |
|
1724 |
|
1725 void QTmsVoipTest::EffectsEvent(const QTMSEffect& tmseffect, |
|
1726 QTMSSignalEvent event) |
|
1727 { |
|
1728 QTMSEffectType effecttype; |
|
1729 const_cast<QTMSEffect&> (tmseffect).GetType(effecttype); |
|
1730 |
|
1731 QVERIFY(event.reason == QTMS_RESULT_SUCCESS); |
|
1732 |
|
1733 switch (effecttype) |
|
1734 { |
|
1735 case QTMS_EFFECT_GLOBAL_VOL: |
|
1736 { |
|
1737 switch (event.type) |
|
1738 { |
|
1739 case QTMS_EVENT_EFFECT_VOL_CHANGED: |
|
1740 qDebug("Global vol effect change"); |
|
1741 break; |
|
1742 default: |
|
1743 break; |
|
1744 } |
|
1745 } |
|
1746 break; |
|
1747 case QTMS_EFFECT_GLOBAL_GAIN: |
|
1748 { |
|
1749 switch (event.type) |
|
1750 { |
|
1751 case QTMS_EVENT_EFFECT_GAIN_CHANGED: |
|
1752 qDebug("Global gain effect change"); |
|
1753 break; |
|
1754 default: |
|
1755 break; |
|
1756 } |
|
1757 } |
|
1758 break; |
|
1759 case QTMS_EFFECT_VOLUME: |
|
1760 { |
|
1761 switch (event.type) |
|
1762 { |
|
1763 case QTMS_EVENT_EFFECT_GAIN_CHANGED: |
|
1764 qDebug("Stream vol effect change"); |
|
1765 break; |
|
1766 default: |
|
1767 break; |
|
1768 } |
|
1769 } |
|
1770 break; |
|
1771 case QTMS_EFFECT_GAIN: |
|
1772 { |
|
1773 switch (event.type) |
|
1774 { |
|
1775 case QTMS_EVENT_EFFECT_GAIN_CHANGED: |
|
1776 qDebug("Stream gain effect change"); |
|
1777 break; |
|
1778 default: |
|
1779 break; |
|
1780 } |
|
1781 } |
|
1782 break; |
|
1783 default: |
|
1784 break; |
|
1785 } |
|
1786 } |
|
1787 |
|
1788 |
|
1789 |
|
1790 void QTmsVoipTest::GlobalRoutingEvent(const QTMSGlobalRouting& /*routing*/, |
|
1791 QTMSSignalEvent event, QTMSAudioOutput /*output*/) |
|
1792 { |
|
1793 QVERIFY(event.reason == QTMS_RESULT_SUCCESS); |
|
1794 switch (event.type) |
|
1795 { |
|
1796 case QTMS_EVENT_ROUTING_AVAIL_OUTPUTS_CHANGED: |
|
1797 qDebug("Available outputs changed"); |
|
1798 break; |
|
1799 case QTMS_EVENT_ROUTING_OUTPUT_CHANGED: |
|
1800 qDebug("output changed"); |
|
1801 break; |
|
1802 case QTMS_EVENT_ROUTING_SET_OUTPUT_COMPLETE: |
|
1803 qDebug("set output complete"); |
|
1804 break; |
|
1805 default: |
|
1806 break; |
|
1807 } |
|
1808 |
|
1809 } |
|
1810 |
|
1811 void QTmsVoipTest::TMSStreamEvent(const QTMSStream& stream, |
|
1812 QTMSSignalEvent event) |
|
1813 { |
|
1814 |
|
1815 QVERIFY(event.reason == QTMS_RESULT_SUCCESS); |
|
1816 |
|
1817 gint streamId; |
|
1818 streamId = const_cast<QTMSStream&> (stream).GetStreamId(); |
|
1819 qDebug("StreamID %d",streamId); |
|
1820 gint state; |
|
1821 state = const_cast<QTMSStream&> (stream).GetState(); |
|
1822 QVERIFY(state == event.curr_state); |
|
1823 |
|
1824 switch (const_cast<QTMSStream&> (stream).GetStreamType()) |
|
1825 { |
|
1826 case QTMS_STREAM_UPLINK: |
|
1827 { |
|
1828 switch (event.type) |
|
1829 { |
|
1830 case QTMS_EVENT_STREAM_STATE_CHANGED: |
|
1831 { |
|
1832 switch (event.curr_state) |
|
1833 { |
|
1834 case QTMS_STREAM_INITIALIZED: |
|
1835 { |
|
1836 qDebug("Uplink initialized "); |
|
1837 break; |
|
1838 } |
|
1839 case QTMS_STREAM_UNINITIALIZED: |
|
1840 qDebug("Uplink uninitialized "); |
|
1841 break; |
|
1842 case QTMS_STREAM_PAUSED: |
|
1843 qDebug("Uplink paused "); |
|
1844 break; |
|
1845 case QTMS_STREAM_STARTED: |
|
1846 qDebug("Uplink started "); |
|
1847 break; |
|
1848 default: |
|
1849 break; |
|
1850 } |
|
1851 break; |
|
1852 } |
|
1853 default: |
|
1854 break; |
|
1855 } |
|
1856 break; |
|
1857 } |
|
1858 case QTMS_STREAM_DOWNLINK: |
|
1859 { |
|
1860 switch (event.type) |
|
1861 { |
|
1862 case QTMS_EVENT_STREAM_STATE_CHANGED: |
|
1863 { |
|
1864 switch (event.curr_state) |
|
1865 { |
|
1866 case QTMS_STREAM_INITIALIZED: |
|
1867 qDebug("Downlink initialized "); |
|
1868 break; |
|
1869 case QTMS_STREAM_UNINITIALIZED: |
|
1870 qDebug("Downlink uninitialized "); |
|
1871 break; |
|
1872 case QTMS_STREAM_PAUSED: |
|
1873 qDebug("Downlink paused "); |
|
1874 break; |
|
1875 case QTMS_STREAM_STARTED: |
|
1876 qDebug("Downlink started "); |
|
1877 break; |
|
1878 default: |
|
1879 break; |
|
1880 } |
|
1881 break; |
|
1882 } |
|
1883 default: |
|
1884 break; |
|
1885 } |
|
1886 break; |
|
1887 } |
|
1888 default: |
|
1889 break; |
|
1890 } |
|
1891 } |
|
1892 |
|
1893 |
|
1894 void QTmsVoipTest::RingtoneEvent(const QTMSRingTone& /*rt*/, |
|
1895 QTMSSignalEvent event) |
|
1896 { |
|
1897 QVERIFY(event.reason == QTMS_RESULT_SUCCESS); |
|
1898 switch (event.type) |
|
1899 { |
|
1900 case QTMS_EVENT_RINGTONE_OPEN_COMPLETE: |
|
1901 qDebug("RT Open Complete"); |
|
1902 break; |
|
1903 case QTMS_EVENT_RINGTONE_PLAY_COMPLETE: |
|
1904 qDebug("RT Play Complete"); |
|
1905 break; |
|
1906 default: |
|
1907 break; |
|
1908 } |
|
1909 } |
|
1910 |
|
1911 |
|
1912 void QTmsVoipTest::DTMFEvent(const QTMSDTMF& /*dtmf*/, QTMSSignalEvent event) |
|
1913 { |
|
1914 |
|
1915 QVERIFY(event.reason == QTMS_RESULT_SUCCESS); |
|
1916 switch (event.type) |
|
1917 { |
|
1918 case QTMS_EVENT_DTMF_TONE_STARTED: |
|
1919 qDebug("DTMF Started"); |
|
1920 break; |
|
1921 case QTMS_EVENT_DTMF_TONE_STOPPED: |
|
1922 qDebug("DTMF Stopped"); |
|
1923 break; |
|
1924 default: |
|
1925 break; |
|
1926 } |
|
1927 } |
|
1928 |
|
1929 |
|
1930 QTEST_MAIN_S60(QTmsVoipTest) |
|
1931 |
|
1932 #include "qtmsvoiptest.moc" |
|
1933 |