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