|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "UT_cmcemediasdpcodec.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/EUnitMacros.h> |
|
26 #include <digia/eunit/CEUnitAllocTestCaseDecorator.h> |
|
27 #include <mmcccodecinformation.h> |
|
28 #include "mcemediamanager.h" |
|
29 |
|
30 #define RESET()\ |
|
31 iServer->Reset() |
|
32 |
|
33 #include <sdpdocument.h> |
|
34 #include <sdpcodecstringpool.h> |
|
35 #include <sdpcodecstringconstants.h> |
|
36 #include <sdpmediafield.h> |
|
37 #include <sdpfmtattributefield.h> |
|
38 #include <sdprtpmapvalue.h> |
|
39 #include <sdpattributefield.h> |
|
40 #include "mceaudiosdpcodec.h" |
|
41 #include "mcevideosdpcodec.h" |
|
42 #include "cleanupresetanddestroy.h" |
|
43 #include "mcemediaidle.h" |
|
44 #include "mcenatpluginmanager.h" |
|
45 #include <sdpbandwidthfield.h> |
|
46 #include "mcetesthelper.h" |
|
47 _LIT8( KMceTestSdpAMR, "v=0\r\n\ |
|
48 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
49 s=-\r\n\ |
|
50 i=-\r\n\ |
|
51 c=IN IP4 10.20.180.72\r\n\ |
|
52 t=0 0\r\n\ |
|
53 m=audio 5078 RTP/AVP 0 96\r\n\ |
|
54 a=sendrecv\r\n\ |
|
55 a=curr:qos local sendrecv\r\n\ |
|
56 a=curr:qos remote none\r\n\ |
|
57 a=des:qos mandatory local sendrecv\r\n\ |
|
58 a=des:qos none remote sendrecv\r\n\ |
|
59 a=rtpmap:96 AMR/8000\r\n\ |
|
60 a=ptime:20\r\n\ |
|
61 a=maxptime:400\r\n\ |
|
62 a=fmtp:96 octet-align=0; mode-set=0,1,2,3,4,5,6,7\r\n"); |
|
63 |
|
64 _LIT8( KMceTestSdpPCMU, "v=0\r\n\ |
|
65 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
66 s=-\r\n\ |
|
67 i=-\r\n\ |
|
68 c=IN IP4 10.20.180.72\r\n\ |
|
69 t=0 0\r\n\ |
|
70 m=audio 5078 RTP/AVP 96\r\n\ |
|
71 a=sendrecv\r\n\ |
|
72 a=curr:qos local sendrecv\r\n\ |
|
73 a=curr:qos remote none\r\n\ |
|
74 a=des:qos mandatory local sendrecv\r\n\ |
|
75 a=des:qos none remote sendrecv\r\n\ |
|
76 a=rtpmap:96 PCMU/8000\r\n\ |
|
77 a=ptime:20\r\n\ |
|
78 a=maxptime:400\r\n\ |
|
79 a=fmtp:96 octet-align=0; mode-set=0,1,2,3,4,5,6,7\r\n"); |
|
80 |
|
81 _LIT8( KMceTestSdpPortZero, "v=0\r\n\ |
|
82 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
83 s=-\r\n\ |
|
84 i=-\r\n\ |
|
85 c=IN IP4 10.20.180.72\r\n\ |
|
86 t=0 0\r\n\ |
|
87 m=audio 0 RTP/AVP 96\r\n\ |
|
88 a=sendrecv\r\n\ |
|
89 a=curr:qos local sendrecv\r\n\ |
|
90 a=curr:qos remote none\r\n\ |
|
91 a=des:qos mandatory local sendrecv\r\n\ |
|
92 a=des:qos none remote sendrecv\r\n\ |
|
93 a=rtpmap:96 AMR/8000\r\n\ |
|
94 a=ptime:20\r\n\ |
|
95 a=maxptime:400\r\n\ |
|
96 a=fmtp:96 octet-align=0; mode-set=0,1,2,3,4,5,6,7\r\n"); |
|
97 |
|
98 |
|
99 _LIT8( KMceTestSdpPCMA, "v=0\r\n\ |
|
100 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
101 s=-\r\n\ |
|
102 i=-\r\n\ |
|
103 c=IN IP4 10.20.180.72\r\n\ |
|
104 t=0 0\r\n\ |
|
105 m=audio 5078 RTP/AVP 96\r\n\ |
|
106 a=sendrecv\r\n\ |
|
107 a=curr:qos local sendrecv\r\n\ |
|
108 a=curr:qos remote none\r\n\ |
|
109 a=des:qos mandatory local sendrecv\r\n\ |
|
110 a=des:qos none remote sendrecv\r\n\ |
|
111 a=rtpmap:96 PCMA/8000\r\n\ |
|
112 a=ptime:20\r\n\ |
|
113 a=maxptime:400\r\n\ |
|
114 a=fmtp:96 octet-align=0; mode-set=0,1,2,3,4,5,6,7\r\n"); |
|
115 |
|
116 _LIT8( KMceTestSdpAVC, "v=0\r\n\ |
|
117 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
118 s=-\r\n\ |
|
119 i=-\r\n\ |
|
120 c=IN IP4 10.20.180.72\r\n\ |
|
121 t=0 0\r\n\ |
|
122 m=video 5078 RTP/AVP 96\r\n\ |
|
123 a=sendrecv\r\n\ |
|
124 a=curr:qos local sendrecv\r\n\ |
|
125 a=curr:qos remote none\r\n\ |
|
126 a=des:qos mandatory local sendrecv\r\n\ |
|
127 a=des:qos none remote sendrecv\r\n\ |
|
128 a=rtpmap:96 H264/90000\r\n\ |
|
129 a=fmtp:96 profile-level-id=42800A\r\n"); |
|
130 |
|
131 _LIT8( KMceTestSdpAVC2, "v=0\r\n\ |
|
132 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
133 s=-\r\n\ |
|
134 i=-\r\n\ |
|
135 c=IN IP4 10.20.180.72\r\n\ |
|
136 t=0 0\r\n\ |
|
137 m=video 5078 RTP/AVP 96 97\r\n\ |
|
138 a=sendrecv\r\n\ |
|
139 a=curr:qos local sendrecv\r\n\ |
|
140 a=curr:qos remote none\r\n\ |
|
141 a=des:qos mandatory local sendrecv\r\n\ |
|
142 a=des:qos none remote sendrecv\r\n\ |
|
143 a=rtpmap:96 H264/90000\r\n\ |
|
144 a=fmtp:96 profile-level-id=42900B\r\n\ |
|
145 a=rtpmap:97 H264/90000\r\n\ |
|
146 a=fmtp:97 profile-level-id=42900B\r\n"); |
|
147 |
|
148 _LIT8( KMceTestSdpMulti, "v=0\r\n\ |
|
149 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
150 s=-\r\n\ |
|
151 i=-\r\n\ |
|
152 c=IN IP4 10.20.180.72\r\n\ |
|
153 t=0 0\r\n\ |
|
154 m=audio 5078 RTP/AVP 96 97\r\n\ |
|
155 a=sendrecv\r\n\ |
|
156 a=curr:qos local sendrecv\r\n\ |
|
157 a=curr:qos remote none\r\n\ |
|
158 a=des:qos mandatory local sendrecv\r\n\ |
|
159 a=des:qos none remote sendrecv\r\n\ |
|
160 a=rtpmap:96 AMR/8000\r\n\ |
|
161 a=fmtp:96 octet-align=0; mode-set=0,1,2,3,4,5,6,7\r\n\ |
|
162 a=rtpmap:97 PCMA/8000\r\n\ |
|
163 a=fmtp:97 octet-align=0;\r\n\ |
|
164 a=fmtp:97 mode-set=0,1,2,3,4,5,6,7\r\n"); |
|
165 |
|
166 _LIT8( KMceTestSdpMultiMissingPtFromMediaLine, "v=0\r\n\ |
|
167 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
168 s=-\r\n\ |
|
169 i=-\r\n\ |
|
170 c=IN IP4 10.20.180.72\r\n\ |
|
171 t=0 0\r\n\ |
|
172 m=audio 5078 RTP/AVP 96\r\n\ |
|
173 a=sendrecv\r\n\ |
|
174 a=curr:qos local sendrecv\r\n\ |
|
175 a=curr:qos remote none\r\n\ |
|
176 a=des:qos mandatory local sendrecv\r\n\ |
|
177 a=des:qos none remote sendrecv\r\n\ |
|
178 a=rtpmap:96 AMR/8000\r\n\ |
|
179 a=fmtp:96 octet-align=0; mode-set=0,1,2,3,4,5,6,7\r\n\ |
|
180 a=rtpmap:97 PCMA/8000\r\n\ |
|
181 a=fmtp:97 octet-align=0;\r\n\ |
|
182 a=fmtp:97 mode-set=0,1,2,3,4,5,6,7\r\n"); |
|
183 |
|
184 _LIT( KNullIpAddress, "0.0.0.0"); |
|
185 |
|
186 |
|
187 _LIT8( KMceTestSdpAMRWithb, "v=0\r\n\ |
|
188 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
189 s=-\r\n\ |
|
190 i=-\r\n\ |
|
191 c=IN IP4 10.20.180.72\r\n\ |
|
192 t=0 0\r\n\ |
|
193 m=audio 5078 RTP/AVP 96\r\n\ |
|
194 a=sendrecv\r\n\ |
|
195 b=AS:80\r\n\ |
|
196 a=curr:qos local sendrecv\r\n\ |
|
197 a=curr:qos remote none\r\n\ |
|
198 a=des:qos mandatory local sendrecv\r\n\ |
|
199 a=des:qos none remote sendrecv\r\n\ |
|
200 a=rtpmap:96 AMR/8000\r\n\ |
|
201 a=ptime:20\r\n\ |
|
202 a=maxptime:400\r\n\ |
|
203 a=fmtp:96 octet-align=0; mode-set=0,1,2,3,4,5,6,7\r\n"); |
|
204 |
|
205 |
|
206 _LIT8( KMceTestSdpAMRWithOutDirection, "v=0\r\n\ |
|
207 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
208 s=-\r\n\ |
|
209 i=-\r\n\ |
|
210 c=IN IP4 10.20.180.72\r\n\ |
|
211 t=0 0\r\n\ |
|
212 m=audio 5078 RTP/AVP 0 96\r\n\ |
|
213 a=curr:qos local sendrecv\r\n\ |
|
214 a=curr:qos remote none\r\n\ |
|
215 a=des:qos mandatory local sendrecv\r\n\ |
|
216 a=des:qos none remote sendrecv\r\n\ |
|
217 a=rtpmap:96 AMR/8000\r\n\ |
|
218 a=ptime:20\r\n\ |
|
219 a=maxptime:400\r\n\ |
|
220 a=fmtp:96 octet-align=0; mode-set=0,1,2,3,4,5,6,7\r\n"); |
|
221 |
|
222 |
|
223 _LIT8( KMceTestSdpHold, "v=0\r\n\ |
|
224 o=userb 1234567890 1234567890 IN IP4 10.20.180.72\r\n\ |
|
225 s=-\r\n\ |
|
226 i=-\r\n\ |
|
227 c=IN IP4 10.20.180.72\r\n\ |
|
228 t=0 0\r\n\ |
|
229 m=audio 5078 RTP/AVP 0 96\r\n\ |
|
230 a=sendonly\r\n\ |
|
231 a=rtpmap:96 AMR/8000\r\n\ |
|
232 a=ptime:20\r\n\ |
|
233 a=maxptime:400\r\n\ |
|
234 a=fmtp:96 octet-align=0; mode-set=0,1,2,3,4,5,6,7\r\n"); |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 // INTERNAL INCLUDES |
|
240 |
|
241 // CONSTRUCTION |
|
242 UT_CMceMediaSdpCodec* UT_CMceMediaSdpCodec::NewL() |
|
243 { |
|
244 UT_CMceMediaSdpCodec* self = UT_CMceMediaSdpCodec::NewLC(); |
|
245 CleanupStack::Pop(); |
|
246 |
|
247 return self; |
|
248 } |
|
249 |
|
250 UT_CMceMediaSdpCodec* UT_CMceMediaSdpCodec::NewLC() |
|
251 { |
|
252 UT_CMceMediaSdpCodec* self = new( ELeave ) UT_CMceMediaSdpCodec(); |
|
253 CleanupStack::PushL( self ); |
|
254 |
|
255 self->ConstructL(); |
|
256 |
|
257 return self; |
|
258 } |
|
259 |
|
260 // Destructor (virtual by CBase) |
|
261 UT_CMceMediaSdpCodec::~UT_CMceMediaSdpCodec() |
|
262 { |
|
263 } |
|
264 |
|
265 // Default constructor |
|
266 UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec() |
|
267 { |
|
268 } |
|
269 |
|
270 // Second phase construct |
|
271 void UT_CMceMediaSdpCodec::ConstructL() |
|
272 { |
|
273 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
274 // It generates the test case table. |
|
275 CEUnitTestSuiteClass::ConstructL(); |
|
276 } |
|
277 |
|
278 // METHODS |
|
279 |
|
280 |
|
281 void UT_CMceMediaSdpCodec::SetupL() |
|
282 { |
|
283 iServer = new (ELeave) CMceServerStub(); |
|
284 iManager = CMceMediaManager::NewL( *iServer ); |
|
285 |
|
286 // Make a dummy call to NatEnabled() to cause plugin to be loaded. |
|
287 // When the actual test case function uses the plugin, the plugin is already |
|
288 // loaded. Because if the test function would load the plugin, then EUnit |
|
289 // reports a memory leak, since the plugin is unloaded in Teardown(). |
|
290 iManager->NatPluginManager().NatEnabledL(); |
|
291 |
|
292 iSession = MceMediaManagerTestHelper::CreateMultimediaOutSessionL(); |
|
293 iManager->CreateSessionL( *iSession ); |
|
294 iSdpCodec = CMceAudioSdpCodec::NewL(); |
|
295 } |
|
296 |
|
297 |
|
298 void UT_CMceMediaSdpCodec::Setup2L() |
|
299 { |
|
300 iServer = new (ELeave) CMceServerStub(); |
|
301 iManager = CMceMediaManager::NewL( *iServer ); |
|
302 |
|
303 // Make a dummy call to NatEnabled() to cause plugin to be loaded. |
|
304 // When the actual test case function uses the plugin, the plugin is already |
|
305 // loaded. Because if the test function would load the plugin, then EUnit |
|
306 // reports a memory leak, since the plugin is unloaded in Teardown(). |
|
307 iManager->NatPluginManager().NatEnabledL(); |
|
308 |
|
309 iSession = MceMediaManagerTestHelper::CreateMultimediaOutSessionL( ETrue ); // Avc |
|
310 iManager->CreateSessionL( *iSession ); |
|
311 iSdpCodec = CMceAudioSdpCodec::NewL(); |
|
312 } |
|
313 |
|
314 void UT_CMceMediaSdpCodec::Teardown() |
|
315 { |
|
316 CMceComSession::Delete( iSession, *iManager ); |
|
317 delete iManager; |
|
318 iManager = NULL; |
|
319 delete iServer; |
|
320 iServer = NULL; |
|
321 delete iSdpCodec; |
|
322 iSdpCodec = NULL; |
|
323 |
|
324 } |
|
325 |
|
326 |
|
327 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_EncodeMediaOfferLL() |
|
328 { |
|
329 RStringF audio = MCE_SDP_STRING_AUDIOL(); |
|
330 RStringF protocol = SDP_STRINGL( SdpCodecStringConstants::EProtocolRtpAvp ); |
|
331 CSdpDocument* sdp = CSdpDocument::NewLC(); |
|
332 |
|
333 CSdpMediaField* audioLine = |
|
334 CSdpMediaField::NewLC( audio, 5005, protocol, _L8("0") ); |
|
335 |
|
336 EUNIT_ASSERT( audioLine->FormatList() == _L8("0") ); |
|
337 |
|
338 iSdpCodec->EncodeMediaOfferL( *iSession->Streams()[ 0 ], *audioLine, *sdp ); |
|
339 |
|
340 EUNIT_ASSERT( audioLine->FormatList() == _L8("96") ); |
|
341 |
|
342 iSession->iUseLocalPreconditions = ETrue; |
|
343 |
|
344 iSdpCodec->EncodeMediaOfferL( *iSession->Streams()[ 0 ], *audioLine, *sdp ); |
|
345 |
|
346 EUNIT_ASSERT( audioLine->FormatList() == _L8("96") ); |
|
347 |
|
348 CleanupStack::PopAndDestroy( audioLine ); |
|
349 |
|
350 CleanupStack::PopAndDestroy( sdp ); |
|
351 } |
|
352 |
|
353 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeMediaAnswerLL() |
|
354 { |
|
355 //Null tested |
|
356 |
|
357 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
358 CleanupStack::PushL( sdp ); |
|
359 |
|
360 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
361 CMceComMediaStream* mediaStream = iSession->Streams()[ 0 ]; |
|
362 |
|
363 iSdpCodec->AddCapabilityL( KMceSDPNameAMR ); |
|
364 iSdpCodec->AddCapabilityPayloadTypeL(KDefaultAmrNbPT); |
|
365 iSdpCodec->DecodeMediaAnswerL( *audioLine, |
|
366 *mediaStream, |
|
367 *sdp ); |
|
368 |
|
369 |
|
370 iSession->iUseLocalPreconditions = ETrue; |
|
371 |
|
372 iSdpCodec->DecodeMediaAnswerL( *audioLine, |
|
373 *mediaStream, |
|
374 *sdp ); |
|
375 |
|
376 CleanupStack::PopAndDestroy( sdp ); |
|
377 |
|
378 //wrong codec |
|
379 sdp = CSdpDocument::DecodeL( KMceTestSdpPCMU ); |
|
380 CleanupStack::PushL( sdp ); |
|
381 audioLine = sdp->MediaFields()[ 0 ]; |
|
382 mediaStream = iSession->Streams()[ 0 ]; |
|
383 |
|
384 EUNIT_ASSERT_LEAVE( iSdpCodec->DecodeMediaAnswerL( *audioLine, |
|
385 *mediaStream, |
|
386 *sdp ) ); |
|
387 |
|
388 CleanupStack::PopAndDestroy( sdp ); |
|
389 |
|
390 //port 0 |
|
391 sdp = CSdpDocument::DecodeL( KMceTestSdpPortZero ); |
|
392 CleanupStack::PushL( sdp ); |
|
393 audioLine = sdp->MediaFields()[ 0 ]; |
|
394 mediaStream = iSession->Streams()[ 0 ]; |
|
395 |
|
396 EUNIT_ASSERT_LEAVE( iSdpCodec->DecodeMediaAnswerL( *audioLine, |
|
397 *mediaStream, |
|
398 *sdp ) ); |
|
399 |
|
400 CleanupStack::PopAndDestroy( sdp ); |
|
401 |
|
402 // unused rtmap line |
|
403 sdp = CSdpDocument::DecodeL( KMceTestSdpMultiMissingPtFromMediaLine ); |
|
404 CleanupStack::PushL( sdp ); |
|
405 audioLine = sdp->MediaFields()[ 0 ]; |
|
406 mediaStream = iSession->Streams()[ 0 ]; |
|
407 |
|
408 iSdpCodec->DecodeMediaAnswerL( *audioLine, *mediaStream, *sdp ); |
|
409 |
|
410 EUNIT_ASSERT( |
|
411 static_cast<CMceComAudioStream*>( iSession->Streams()[ 0 ] )->Codecs().Count() == 1 ); |
|
412 CleanupStack::PopAndDestroy( sdp ); |
|
413 |
|
414 //no codecs |
|
415 sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
416 CleanupStack::PushL( sdp ); |
|
417 audioLine = sdp->MediaFields()[ 0 ]; |
|
418 mediaStream = iSession->Streams()[ 0 ]; |
|
419 |
|
420 mediaStream->DestroyCodecs(); |
|
421 |
|
422 EUNIT_ASSERT_LEAVE( iSdpCodec->DecodeMediaAnswerL( *audioLine, |
|
423 *mediaStream, |
|
424 *sdp ) ); |
|
425 |
|
426 CleanupStack::PopAndDestroy( sdp ); |
|
427 |
|
428 } |
|
429 |
|
430 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeMediaOfferLL() |
|
431 { |
|
432 |
|
433 CMceComSession::Delete( iSession, *iManager ); |
|
434 iSession = CMceComSession::NewL( CMceComSession::EInSession ); |
|
435 iManager->CreateSessionL( *iSession ); |
|
436 |
|
437 EUNIT_ASSERT( !iSdpCodec->IsSupported( KMceSDPNameAMR ) ); |
|
438 EUNIT_ASSERT( iSession->Streams().Count() == 0 ); |
|
439 |
|
440 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
441 CleanupStack::PushL( sdp ); |
|
442 |
|
443 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
444 CMceComMediaStream* mediaStream = NULL; |
|
445 |
|
446 EUNIT_ASSERT( |
|
447 iSdpCodec->DecodeMediaOfferL( *audioLine, mediaStream, *iSession, *sdp ) |
|
448 != KErrNone ); |
|
449 |
|
450 EUNIT_ASSERT( mediaStream == NULL ); |
|
451 EUNIT_ASSERT( iSession->Streams().Count() == 0 ); |
|
452 |
|
453 CleanupStack::PopAndDestroy( sdp ); |
|
454 |
|
455 iSdpCodec->AddCapabilityL( KMceSDPNameAMR ); |
|
456 iSdpCodec->AddCapabilityL( KMceSDPNamePCMU ); |
|
457 |
|
458 EUNIT_ASSERT( iSdpCodec->IsSupported( KMceSDPNameAMR ) ); |
|
459 |
|
460 sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
461 CleanupStack::PushL( sdp ); |
|
462 |
|
463 audioLine = sdp->MediaFields()[ 0 ]; |
|
464 mediaStream = NULL; |
|
465 |
|
466 EUNIT_ASSERT( |
|
467 iSdpCodec->DecodeMediaOfferL( *audioLine, mediaStream, *iSession, *sdp ) |
|
468 == KErrNone ); |
|
469 |
|
470 EUNIT_ASSERT( mediaStream ); |
|
471 EUNIT_ASSERT( mediaStream->iRemoteMediaPort == 5078 ); |
|
472 EUNIT_ASSERT( iSession->Streams().Count() == 1 ); |
|
473 |
|
474 CleanupStack::PopAndDestroy( sdp ); |
|
475 |
|
476 |
|
477 iSession->iUseRemotePreconditions = ETrue; |
|
478 |
|
479 EUNIT_ASSERT( iSdpCodec->IsSupported( KMceSDPNameAMR ) ); |
|
480 |
|
481 sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
482 CleanupStack::PushL( sdp ); |
|
483 |
|
484 audioLine = sdp->MediaFields()[ 0 ]; |
|
485 mediaStream = NULL; |
|
486 |
|
487 EUNIT_ASSERT( |
|
488 iSdpCodec->DecodeMediaOfferL( *audioLine, mediaStream, *iSession, *sdp ) |
|
489 == KErrNone ); |
|
490 |
|
491 EUNIT_ASSERT( mediaStream ); |
|
492 EUNIT_ASSERT( mediaStream->iRemoteMediaPort == 5078 ); |
|
493 EUNIT_ASSERT( iSession->Streams().Count() == 2 ); |
|
494 |
|
495 CleanupStack::PopAndDestroy( sdp ); |
|
496 |
|
497 sdp = CSdpDocument::DecodeL( KMceTestSdpMultiMissingPtFromMediaLine ); |
|
498 CleanupStack::PushL( sdp ); |
|
499 |
|
500 audioLine = sdp->MediaFields()[ 0 ]; |
|
501 mediaStream = NULL; |
|
502 |
|
503 EUNIT_ASSERT( |
|
504 iSdpCodec->DecodeMediaOfferL( *audioLine, mediaStream, *iSession, *sdp ) |
|
505 != KErrNone ); |
|
506 |
|
507 // EUNIT_ASSERT( mediaStream ); |
|
508 // EUNIT_ASSERT( mediaStream->iRemoteMediaPort == 5078 ); |
|
509 // EUNIT_ASSERT( iSession->Streams().Count() == 3 ); |
|
510 // EUNIT_ASSERT( |
|
511 // static_cast<CMceComAudioStream*>( iSession->Streams()[ 2 ] )->Codecs().Count() == 1 ); |
|
512 |
|
513 CleanupStack::PopAndDestroy( sdp ); |
|
514 |
|
515 } |
|
516 |
|
517 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeMediaUpdateLL() |
|
518 { |
|
519 |
|
520 iSdpCodec->AddCapabilityL( KMceSDPNameAMR ); |
|
521 iSdpCodec->AddCapabilityPayloadTypeL(KDefaultAmrNbPT); |
|
522 iSdpCodec->AddCapabilityL( KMceSDPNamePCMU ); |
|
523 iSdpCodec->AddCapabilityPayloadTypeL(KPcmuPayloadType); |
|
524 EUNIT_ASSERT( iSdpCodec->IsSupported( KMceSDPNameAMR ) ); |
|
525 EUNIT_ASSERT( iSession->Streams().Count() == 3 ); |
|
526 |
|
527 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
528 CleanupStack::PushL( sdp ); |
|
529 |
|
530 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
531 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
532 const RPointerArray<CMceComCodec>& codecs = iSdpCodec->CodecsL( *mediaStream ); |
|
533 |
|
534 EUNIT_ASSERT( codecs.Count() == 1 ); |
|
535 EUNIT_ASSERT( codecs[0]->iSdpName == KMceSDPNameAMR ); |
|
536 |
|
537 iSdpCodec->PrepareForDecodeL( *audioLine, mediaStream ); |
|
538 EUNIT_ASSERT( !codecs[0]->iIsNegotiated ); |
|
539 |
|
540 EUNIT_ASSERT( |
|
541 iSdpCodec->DecodeMediaUpdateL( *audioLine, *mediaStream, *sdp ) |
|
542 == KErrNone ); |
|
543 |
|
544 EUNIT_ASSERT( mediaStream->iRemoteMediaPort == 5078 ); |
|
545 EUNIT_ASSERT( iSession->Streams().Count() == 3 ); |
|
546 EUNIT_ASSERT( codecs.Count() == 2 ); |
|
547 EUNIT_ASSERT( codecs[0]->iSdpName == KMceSDPNameAMR ); |
|
548 EUNIT_ASSERT( codecs[0]->iIsNegotiated ); |
|
549 EUNIT_ASSERT( codecs[1]->iSdpName == KMceSDPNamePCMU ); |
|
550 EUNIT_ASSERT( codecs[1]->iIsNegotiated ); |
|
551 |
|
552 CleanupStack::PopAndDestroy( sdp ); |
|
553 |
|
554 iSession->iUseRemotePreconditions = ETrue; |
|
555 |
|
556 sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
557 CleanupStack::PushL( sdp ); |
|
558 |
|
559 audioLine = sdp->MediaFields()[ 0 ]; |
|
560 iSdpCodec->PrepareForDecodeL( *audioLine, mediaStream ); |
|
561 EUNIT_ASSERT( !codecs[0]->iIsNegotiated ); |
|
562 |
|
563 EUNIT_ASSERT( |
|
564 iSdpCodec->DecodeMediaUpdateL( *audioLine, *mediaStream, *sdp ) |
|
565 == KErrNone ); |
|
566 |
|
567 EUNIT_ASSERT( mediaStream ); |
|
568 EUNIT_ASSERT( mediaStream->iRemoteMediaPort == 5078 ); |
|
569 EUNIT_ASSERT( iSession->Streams().Count() == 3 ); |
|
570 EUNIT_ASSERT( codecs.Count() == 2 ); |
|
571 EUNIT_ASSERT( codecs[0]->iSdpName == KMceSDPNameAMR ); |
|
572 EUNIT_ASSERT( codecs[0]->iIsNegotiated ); |
|
573 EUNIT_ASSERT( codecs[1]->iSdpName == KMceSDPNamePCMU ); |
|
574 EUNIT_ASSERT( codecs[1]->iIsNegotiated ); |
|
575 codecs[1]->iPayloadType = 96; |
|
576 |
|
577 CleanupStack::PopAndDestroy( sdp ); |
|
578 |
|
579 EUNIT_ASSERT( iSdpCodec->IsSupported( KMceSDPNamePCMU ) ); |
|
580 |
|
581 sdp = CSdpDocument::DecodeL( KMceTestSdpPCMU ); |
|
582 CleanupStack::PushL( sdp ); |
|
583 |
|
584 audioLine = sdp->MediaFields()[ 0 ]; |
|
585 iSdpCodec->PrepareForDecodeL( *audioLine, mediaStream ); |
|
586 EUNIT_ASSERT( !codecs[0]->iIsNegotiated ); |
|
587 |
|
588 // Payload type not supported |
|
589 EUNIT_ASSERT( |
|
590 iSdpCodec->DecodeMediaUpdateL( *audioLine, *mediaStream, *sdp ) |
|
591 != KErrNone ); |
|
592 |
|
593 EUNIT_ASSERT( mediaStream->iRemoteMediaPort == 5078 ); |
|
594 EUNIT_ASSERT( iSession->Streams().Count() == 3 ); |
|
595 EUNIT_ASSERT( codecs.Count() == 2 ); |
|
596 EUNIT_ASSERT( codecs[0]->iSdpName == KMceSDPNameAMR ); |
|
597 EUNIT_ASSERT( codecs[1]->iSdpName == KMceSDPNamePCMU ); |
|
598 EUNIT_ASSERT( !codecs[0]->iIsNegotiated ); |
|
599 EUNIT_ASSERT( !codecs[1]->iIsNegotiated ); |
|
600 |
|
601 CleanupStack::PopAndDestroy( sdp ); |
|
602 |
|
603 EUNIT_ASSERT( !iSdpCodec->IsSupported( KMceSDPNamePCMA ) ); |
|
604 |
|
605 sdp = CSdpDocument::DecodeL( KMceTestSdpPCMA ); |
|
606 CleanupStack::PushL( sdp ); |
|
607 |
|
608 audioLine = sdp->MediaFields()[ 0 ]; |
|
609 iSdpCodec->PrepareForDecodeL( *audioLine, mediaStream ); |
|
610 EUNIT_ASSERT( !codecs[0]->iIsNegotiated ); |
|
611 EUNIT_ASSERT( !codecs[1]->iIsNegotiated ); |
|
612 |
|
613 EUNIT_ASSERT( |
|
614 iSdpCodec->DecodeMediaUpdateL( *audioLine, *mediaStream, *sdp ) |
|
615 != KErrNone ); |
|
616 |
|
617 EUNIT_ASSERT( iSession->Streams().Count() == 3 ); |
|
618 EUNIT_ASSERT( codecs.Count() == 2 ); |
|
619 EUNIT_ASSERT( codecs[0]->iSdpName == KMceSDPNameAMR ); |
|
620 EUNIT_ASSERT( codecs[1]->iSdpName == KMceSDPNamePCMU ); |
|
621 EUNIT_ASSERT( !codecs[0]->iIsNegotiated ); |
|
622 EUNIT_ASSERT( !codecs[1]->iIsNegotiated ); |
|
623 |
|
624 CleanupStack::PopAndDestroy( sdp ); |
|
625 |
|
626 } |
|
627 |
|
628 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_EncodeMediaAnswerLL() |
|
629 { |
|
630 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
631 CleanupStack::PushL( sdp ); |
|
632 |
|
633 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
634 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
635 |
|
636 iSdpCodec->EncodeMediaAnswerL( *mediaStream, *audioLine, *sdp ); |
|
637 |
|
638 EUNIT_ASSERT( audioLine->Port() != 0 ); |
|
639 |
|
640 CleanupStack::PopAndDestroy( sdp ); |
|
641 |
|
642 iSession->iUseRemotePreconditions = ETrue; |
|
643 |
|
644 sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
645 CleanupStack::PushL( sdp ); |
|
646 |
|
647 audioLine = sdp->MediaFields()[ 0 ]; |
|
648 mediaStream = iSession->Streams()[0]; |
|
649 |
|
650 iSdpCodec->EncodeMediaAnswerL( *mediaStream, *audioLine, *sdp ); |
|
651 |
|
652 EUNIT_ASSERT( audioLine->Port() != 0 ); |
|
653 |
|
654 CleanupStack::PopAndDestroy( sdp ); |
|
655 |
|
656 mediaStream->DestroyCodecs(); |
|
657 |
|
658 sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
659 CleanupStack::PushL( sdp ); |
|
660 |
|
661 audioLine = sdp->MediaFields()[ 0 ]; |
|
662 mediaStream = iSession->Streams()[0]; |
|
663 |
|
664 iSdpCodec->EncodeMediaAnswerL( *mediaStream, *audioLine, *sdp ); |
|
665 |
|
666 EUNIT_ASSERT( audioLine->Port() == 0 ); |
|
667 |
|
668 CleanupStack::PopAndDestroy( sdp ); |
|
669 |
|
670 } |
|
671 |
|
672 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_CleanAttributesL() |
|
673 { |
|
674 _LIT8( KAttrValue, "120"); |
|
675 RStringF audio = MCE_SDP_STRING_AUDIOL(); |
|
676 RStringF protocol = SDP_STRINGL( SdpCodecStringConstants::EProtocolRtpAvp ); |
|
677 CSdpAttributeField* attr = NULL; |
|
678 |
|
679 CSdpMediaField* audioLine = |
|
680 CSdpMediaField::NewLC( audio, 5005, protocol, _L8("0") ); |
|
681 |
|
682 attr = CSdpAttributeField::NewLC( SDP_STRINGL( SdpCodecStringConstants::EAttributeSendonly ), KNullDesC8 ); |
|
683 audioLine->AttributeFields().AppendL( attr ); |
|
684 CleanupStack::Pop( attr ); |
|
685 |
|
686 attr = CSdpAttributeField::CSdpAttributeField::NewLC( SDP_STRINGL( SdpCodecStringConstants::EAttributePtime ), KAttrValue ); |
|
687 audioLine->AttributeFields().AppendL( attr ); |
|
688 CleanupStack::Pop( attr ); |
|
689 |
|
690 EUNIT_ASSERT( audioLine->AttributeFields().Count() > 0 ); |
|
691 iSdpCodec->CleanAttributes( *audioLine ); |
|
692 |
|
693 |
|
694 EUNIT_ASSERT( audioLine->AttributeFields().Count() == 0 ); |
|
695 |
|
696 CleanupStack::PopAndDestroy( audioLine ); |
|
697 |
|
698 } |
|
699 |
|
700 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_PrepareForDecodeLL() |
|
701 { |
|
702 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
703 CleanupStack::PushL( sdp ); |
|
704 |
|
705 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
706 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
707 const RPointerArray<CMceComCodec>& codecs = iSdpCodec->CodecsL( *mediaStream ); |
|
708 |
|
709 codecs[0]->iIsNegotiated = ETrue; |
|
710 |
|
711 EUNIT_ASSERT( codecs.Count() == 1 ); |
|
712 EUNIT_ASSERT( codecs[0]->iIsNegotiated ); |
|
713 |
|
714 iSdpCodec->PrepareForDecodeL( *audioLine, mediaStream ); |
|
715 |
|
716 EUNIT_ASSERT( !codecs[0]->iIsNegotiated ); |
|
717 |
|
718 |
|
719 codecs[0]->iIsNegotiated = ETrue; |
|
720 iSdpCodec->PrepareForDecodeL( *audioLine, NULL ); |
|
721 |
|
722 EUNIT_ASSERT( codecs[0]->iIsNegotiated ); |
|
723 |
|
724 mediaStream->DestroyCodecs(); |
|
725 iSdpCodec->PrepareForDecodeL( *audioLine, mediaStream ); |
|
726 |
|
727 |
|
728 CleanupStack::PopAndDestroy( sdp ); |
|
729 |
|
730 |
|
731 } |
|
732 |
|
733 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_EncodeClientAttributesLL() |
|
734 { |
|
735 |
|
736 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
737 CleanupStack::PushL( sdp ); |
|
738 |
|
739 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
740 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
741 audioLine->AttributeFields().ResetAndDestroy(); |
|
742 audioLine->BandwidthFields().ResetAndDestroy(); |
|
743 EUNIT_ASSERT( audioLine->AttributeFields().Count() == 0 ); |
|
744 EUNIT_ASSERT( audioLine->BandwidthFields().Count() == 0 ); |
|
745 |
|
746 delete mediaStream->iLocalMediaSDPLines; |
|
747 mediaStream->iLocalMediaSDPLines = NULL; |
|
748 |
|
749 EUNIT_ASSERT( mediaStream->iLocalMediaSDPLines == NULL ); |
|
750 EUNIT_ASSERT_LEAVE( iSdpCodec->EncodeClientAttributesL( *mediaStream, *audioLine ) ); |
|
751 EUNIT_ASSERT( audioLine->AttributeFields().Count() == 0 ); |
|
752 EUNIT_ASSERT( audioLine->BandwidthFields().Count() == 0 ); |
|
753 |
|
754 mediaStream->iLocalMediaSDPLines = new (ELeave) CDesC8ArrayFlat( 5 ); |
|
755 |
|
756 iSdpCodec->EncodeClientAttributesL( *mediaStream, *audioLine ); |
|
757 EUNIT_ASSERT( audioLine->AttributeFields().Count() == 0 ); |
|
758 EUNIT_ASSERT( audioLine->BandwidthFields().Count() == 0 ); |
|
759 |
|
760 audioLine->AttributeFields().ResetAndDestroy(); |
|
761 audioLine->BandwidthFields().ResetAndDestroy(); |
|
762 MCE_DELETE( mediaStream->iLocalMediaSDPLines ); |
|
763 mediaStream->iLocalMediaSDPLines = new (ELeave) CDesC8ArrayFlat( 5 ); |
|
764 mediaStream->iLocalMediaSDPLines->AppendL( _L8("a=curr:qos local none\r\n") ); |
|
765 |
|
766 iSdpCodec->EncodeClientAttributesL( *mediaStream, *audioLine ); |
|
767 EUNIT_ASSERT( audioLine->AttributeFields().Count() == 1 ); |
|
768 EUNIT_ASSERT( audioLine->BandwidthFields().Count() == 0 ); |
|
769 |
|
770 audioLine->AttributeFields().ResetAndDestroy(); |
|
771 audioLine->BandwidthFields().ResetAndDestroy(); |
|
772 MCE_DELETE( mediaStream->iLocalMediaSDPLines ); |
|
773 mediaStream->iLocalMediaSDPLines = new (ELeave) CDesC8ArrayFlat( 5 ); |
|
774 mediaStream->iLocalMediaSDPLines->AppendL( _L8("b=AS:17\r\n") ); |
|
775 iSdpCodec->EncodeClientAttributesL( *mediaStream, *audioLine ); |
|
776 EUNIT_ASSERT( audioLine->AttributeFields().Count() == 0 ); |
|
777 EUNIT_ASSERT( audioLine->BandwidthFields().Count() == 1 ); |
|
778 |
|
779 iSdpCodec->CleanAttributes(*audioLine); |
|
780 EUNIT_ASSERT( audioLine->AttributeFields().Count() == 0 ); |
|
781 EUNIT_ASSERT( audioLine->BandwidthFields().Count() == 0 ); |
|
782 MCE_DELETE( mediaStream->iLocalMediaSDPLines ); |
|
783 mediaStream->iLocalMediaSDPLines = new (ELeave) CDesC8ArrayFlat( 5 ); |
|
784 mediaStream->iLocalMediaSDPLines->AppendL( _L8("A=curr:qos local none\r\n") ); |
|
785 EUNIT_ASSERT_LEAVE( iSdpCodec->EncodeClientAttributesL( *mediaStream, *audioLine ) ); |
|
786 EUNIT_ASSERT( audioLine->AttributeFields().Count() == 0 ); |
|
787 EUNIT_ASSERT( audioLine->BandwidthFields().Count() == 0 ); |
|
788 |
|
789 |
|
790 audioLine->AttributeFields().ResetAndDestroy(); |
|
791 audioLine->BandwidthFields().ResetAndDestroy(); |
|
792 MCE_DELETE( mediaStream->iLocalMediaSDPLines ); |
|
793 mediaStream->iLocalMediaSDPLines = new (ELeave) CDesC8ArrayFlat( 5 ); |
|
794 mediaStream->iLocalMediaSDPLines->AppendL( _L8("B=AS:17\r\n") ); |
|
795 EUNIT_ASSERT_LEAVE( iSdpCodec->EncodeClientAttributesL( *mediaStream, *audioLine ) ); |
|
796 EUNIT_ASSERT( audioLine->AttributeFields().Count() == 0 ); |
|
797 EUNIT_ASSERT( audioLine->BandwidthFields().Count() == 0 ); |
|
798 |
|
799 |
|
800 audioLine->AttributeFields().ResetAndDestroy(); |
|
801 audioLine->BandwidthFields().ResetAndDestroy(); |
|
802 MCE_DELETE( mediaStream->iLocalMediaSDPLines ); |
|
803 mediaStream->iLocalMediaSDPLines = new (ELeave) CDesC8ArrayFlat( 5 ); |
|
804 mediaStream->iLocalMediaSDPLines->AppendL( _L8("x=foo:faa\r\n") ); |
|
805 EUNIT_ASSERT_LEAVE( iSdpCodec->EncodeClientAttributesL( *mediaStream, *audioLine ) ); |
|
806 EUNIT_ASSERT( audioLine->AttributeFields().Count() == 0 ); |
|
807 EUNIT_ASSERT( audioLine->BandwidthFields().Count() == 0 ); |
|
808 CleanupStack::PopAndDestroy( sdp ); |
|
809 |
|
810 } |
|
811 |
|
812 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeClientAttributesLL() |
|
813 { |
|
814 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMRWithb ); |
|
815 CleanupStack::PushL( sdp ); |
|
816 |
|
817 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
818 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
819 |
|
820 EUNIT_ASSERT( mediaStream->iRemoteMediaSDPLines->Count() == 0 ); |
|
821 |
|
822 iSdpCodec->DecodeClientAttributesL( *audioLine, *mediaStream ); |
|
823 EUNIT_ASSERT( mediaStream->iRemoteMediaSDPLines->Count() == 8 ); |
|
824 EUNIT_ASSERT( mediaStream->BoundStreamL().iRemoteMediaSDPLines->Count() == 8 ); |
|
825 |
|
826 CleanupStack::PopAndDestroy( sdp ); |
|
827 |
|
828 MCE_DELETE( mediaStream->iRemoteMediaSDPLines ); |
|
829 mediaStream->iRemoteMediaSDPLines = new (ELeave) CDesC8ArrayFlat( 5 ); |
|
830 EUNIT_ASSERT( mediaStream->iRemoteMediaSDPLines->Count() == 0 ); |
|
831 |
|
832 sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
833 CleanupStack::PushL( sdp ); |
|
834 |
|
835 audioLine = sdp->MediaFields()[ 0 ]; |
|
836 iSdpCodec->DecodeClientAttributesL( *audioLine, *mediaStream ); |
|
837 EUNIT_ASSERT( mediaStream->iRemoteMediaSDPLines->Count() == 7 ); |
|
838 EUNIT_ASSERT( mediaStream->BoundStreamL().iRemoteMediaSDPLines->Count() == 7 ); |
|
839 |
|
840 CleanupStack::PopAndDestroy( sdp ); |
|
841 |
|
842 mediaStream->BindL( NULL ); |
|
843 |
|
844 sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
845 CleanupStack::PushL( sdp ); |
|
846 |
|
847 audioLine = sdp->MediaFields()[ 0 ]; |
|
848 iSdpCodec->DecodeClientAttributesL( *audioLine, *mediaStream ); |
|
849 EUNIT_ASSERT( mediaStream->iRemoteMediaSDPLines->Count() == 7 ); |
|
850 EUNIT_ASSERT( !mediaStream->BoundStream() ) |
|
851 |
|
852 CleanupStack::PopAndDestroy( sdp ); |
|
853 |
|
854 } |
|
855 |
|
856 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeRemoteRtcpFieldLL() |
|
857 { |
|
858 CSdpDocument* sdp = CSdpDocument::DecodeLC( KMceTestSdpAMR ); |
|
859 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
860 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
861 |
|
862 // Valid rtcp attributes |
|
863 |
|
864 // No RCTP attribute |
|
865 iSdpCodec->DecodeRemoteRtcpFieldL( *audioLine, *mediaStream ); |
|
866 EUNIT_ASSERT_EQUALS( 0, mediaStream->iRemoteRtcpPort ) |
|
867 EUNIT_ASSERT( mediaStream->iRemoteRtcpAddress.IsUnspecified() ) |
|
868 |
|
869 // RTCP attribute with both IP address and port present |
|
870 CSdpAttributeField* rtcp = |
|
871 CSdpAttributeField::DecodeLC( _L8( "a=rtcp:53020 IN IP4 1.2.3.4\r\n" ) ); |
|
872 audioLine->AttributeFields().AppendL( rtcp ); |
|
873 CleanupStack::Pop( rtcp ); |
|
874 iSdpCodec->DecodeRemoteRtcpFieldL( *audioLine, *mediaStream ); |
|
875 EUNIT_ASSERT_EQUALS( 53020, mediaStream->iRemoteRtcpPort ) |
|
876 EUNIT_ASSERT_EQUALS( INET_ADDR( 1,2,3,4 ), mediaStream->iRemoteRtcpAddress.Address() ) |
|
877 audioLine->AttributeFields().ResetAndDestroy(); |
|
878 |
|
879 // RTCP attribute with both IP address and port present |
|
880 rtcp = CSdpAttributeField::DecodeLC( _L8( "a=rtcp:53000\r\n" ) ); |
|
881 audioLine->AttributeFields().AppendL( rtcp ); |
|
882 CleanupStack::Pop( rtcp ); |
|
883 mediaStream->iRemoteRtcpAddress.Init( KAfInet ); |
|
884 iSdpCodec->DecodeRemoteRtcpFieldL( *audioLine, *mediaStream ); |
|
885 EUNIT_ASSERT_EQUALS( 53000, mediaStream->iRemoteRtcpPort ) |
|
886 EUNIT_ASSERT( mediaStream->iRemoteRtcpAddress.IsUnspecified() ) |
|
887 audioLine->AttributeFields().ResetAndDestroy(); |
|
888 |
|
889 // Attributes that look similar to rtcp, but are not |
|
890 |
|
891 // Used by some video implementations |
|
892 rtcp = CSdpAttributeField::DecodeLC( _L8( "a=rtcp-fb:* nack pli\r\n" ) ); |
|
893 audioLine->AttributeFields().AppendL( rtcp ); |
|
894 CleanupStack::Pop( rtcp ); |
|
895 mediaStream->iRemoteRtcpAddress.Init( KAfInet ); |
|
896 mediaStream->iRemoteRtcpPort = 0; |
|
897 iSdpCodec->DecodeRemoteRtcpFieldL( *audioLine, *mediaStream ); |
|
898 EUNIT_ASSERT_EQUALS( 0, mediaStream->iRemoteRtcpPort ) |
|
899 EUNIT_ASSERT( mediaStream->iRemoteRtcpAddress.IsUnspecified() ) |
|
900 audioLine->AttributeFields().ResetAndDestroy(); |
|
901 |
|
902 // Used by some VoIP implementations |
|
903 rtcp = CSdpAttributeField::DecodeLC( _L8( "a=rtcpping:T:14\r\n" ) ); |
|
904 audioLine->AttributeFields().AppendL( rtcp ); |
|
905 CleanupStack::Pop( rtcp ); |
|
906 iSdpCodec->DecodeRemoteRtcpFieldL( *audioLine, *mediaStream ); |
|
907 EUNIT_ASSERT_EQUALS( 0, mediaStream->iRemoteRtcpPort ) |
|
908 EUNIT_ASSERT( mediaStream->iRemoteRtcpAddress.IsUnspecified() ) |
|
909 audioLine->AttributeFields().ResetAndDestroy(); |
|
910 |
|
911 CleanupStack::PopAndDestroy( sdp ); |
|
912 } |
|
913 |
|
914 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_EncodelocalRtcpAttrLL() |
|
915 { |
|
916 _LIT8( KMatchRtcp,"*rtcp*" ); |
|
917 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
918 CleanupStack::PushL( sdp ); |
|
919 |
|
920 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
921 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
922 |
|
923 mediaStream->iLocalMediaPort = 0;//rtp port |
|
924 mediaStream->Session()->iLocalIpAddress.Input(_L("")) ; |
|
925 iSdpCodec->EncodelocalRtcpAttrL( *audioLine, *mediaStream ); |
|
926 //check the encode value |
|
927 TBool enable = EFalse; |
|
928 |
|
929 if ( !iManager->NatPluginManager().NatEnabledL() ) |
|
930 { |
|
931 iSdpCodec->DecodeRemoteRtcpFieldL( *audioLine, *mediaStream ); |
|
932 EUNIT_ASSERT( mediaStream->iRemoteRtcpPort == 0 ); |
|
933 } |
|
934 |
|
935 //now enable nat |
|
936 //iManager->NatPluginManager()->iNatEnable |
|
937 // remove sdp lines |
|
938 RPointerArray<CSdpAttributeField>& attrfields = audioLine->AttributeFields(); |
|
939 for ( TInt i = 0; i < attrfields.Count(); i++ ) |
|
940 { |
|
941 CSdpAttributeField* attrfield = attrfields[i]; |
|
942 RStringF attribute; |
|
943 attribute = attrfield->Attribute(); |
|
944 |
|
945 if ( attribute.DesC().Match ( KMatchRtcp ) != KErrNotFound ) |
|
946 { |
|
947 attrfields.Remove( i ); |
|
948 delete attrfield; |
|
949 } |
|
950 } |
|
951 |
|
952 |
|
953 /*case 2*/ |
|
954 mediaStream->iLocalMediaPort = 53020; |
|
955 mediaStream->Session()->iLocalIpAddress.Input(_L("126.16.64.4")) ; |
|
956 if ( enable ) |
|
957 { |
|
958 |
|
959 iSdpCodec->EncodelocalRtcpAttrL( *audioLine, *mediaStream ); |
|
960 //check the encode value |
|
961 iSdpCodec->DecodeRemoteRtcpFieldL( *audioLine, *mediaStream ); |
|
962 //rtcp port = rtp port + 1 |
|
963 EUNIT_ASSERT( mediaStream->iRemoteRtcpPort == 53021 ); |
|
964 EUNIT_ASSERT( mediaStream->iRemoteRtcpAddress |
|
965 == mediaStream->Session()->iLocalIpAddress); |
|
966 |
|
967 // remove sdp lines |
|
968 attrfields = audioLine->AttributeFields(); |
|
969 for ( TInt i = 0; i < attrfields.Count(); i++ ) |
|
970 { |
|
971 CSdpAttributeField* attrfield = attrfields[i]; |
|
972 RStringF attribute; |
|
973 attribute = attrfield->Attribute(); |
|
974 |
|
975 if ( attribute.DesC().Match ( KMatchRtcp ) != KErrNotFound ) |
|
976 { |
|
977 attrfields.Remove( i ); |
|
978 delete attrfield; |
|
979 } |
|
980 } |
|
981 //case 3 |
|
982 mediaStream->iLocalMediaPort = 53020; |
|
983 mediaStream->Session()->iLocalIpAddress.Input( KNullIpAddress ) ; |
|
984 iSdpCodec->EncodelocalRtcpAttrL( *audioLine, *mediaStream ); |
|
985 //check the encode value |
|
986 iSdpCodec->DecodeRemoteRtcpFieldL( *audioLine, *mediaStream ); |
|
987 //rtcp port = rtp port + 1 |
|
988 EUNIT_ASSERT( mediaStream->iRemoteRtcpPort == 53021 ); |
|
989 EUNIT_ASSERT( mediaStream->iRemoteRtcpAddress |
|
990 != mediaStream->Session()->iLocalIpAddress); |
|
991 mediaStream->Session()->iLocalIpAddress.Input(_L("126.16.64.4")) ; |
|
992 EUNIT_ASSERT( mediaStream->iRemoteRtcpAddress |
|
993 == mediaStream->Session()->iLocalIpAddress); |
|
994 } |
|
995 CleanupStack::PopAndDestroy( sdp ); |
|
996 |
|
997 |
|
998 } |
|
999 |
|
1000 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_TypeL() |
|
1001 { |
|
1002 |
|
1003 RStringF audio = MCE_SDP_STRING_AUDIOL(); |
|
1004 RStringF protocol = SDP_STRINGL( SdpCodecStringConstants::EProtocolRtpAvp ); |
|
1005 CSdpAttributeField* direction = NULL; |
|
1006 RPointerArray<CSdpAttributeField> sessionAttributes; |
|
1007 MceCleanupResetAndDestroyPushL( sessionAttributes ); |
|
1008 |
|
1009 CSdpMediaField* audioLine = |
|
1010 CSdpMediaField::NewLC( audio, 5005, protocol, _L8("0") ); |
|
1011 |
|
1012 EUNIT_ASSERT( iSdpCodec->Type( *audioLine, sessionAttributes ) == SdpCodecStringConstants::EAttributeSendrecv ); |
|
1013 |
|
1014 direction = CSdpAttributeField::NewLC( SDP_STRINGL( SdpCodecStringConstants::EAttributeSendonly ), KNullDesC8 ); |
|
1015 audioLine->AttributeFields().AppendL( direction ); |
|
1016 CleanupStack::Pop( direction ); |
|
1017 |
|
1018 EUNIT_ASSERT( iSdpCodec->Type( *audioLine, sessionAttributes ) == SdpCodecStringConstants::EAttributeSendonly ); |
|
1019 |
|
1020 CleanupStack::PopAndDestroy( audioLine ); |
|
1021 CleanupStack::PopAndDestroy();//sessionAttributes |
|
1022 |
|
1023 } |
|
1024 |
|
1025 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodePreconditionsLL() |
|
1026 { |
|
1027 RStringF audio = MCE_SDP_STRING_AUDIOL(); |
|
1028 RStringF protocol = SDP_STRINGL( SdpCodecStringConstants::EProtocolRtpAvp ); |
|
1029 |
|
1030 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
1031 CSdpMediaField* audioLine = |
|
1032 CSdpMediaField::NewLC( audio, 5005, protocol, _L8("0") ); |
|
1033 |
|
1034 iSession->iSessionModifiers[ KMcePreconditions ] = KMcePreconditionsNotUsed; |
|
1035 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1036 |
|
1037 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleOfferer ); |
|
1038 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1039 |
|
1040 |
|
1041 iSession->iSessionModifiers[ KMcePreconditions ] = KMcePreconditionsSupported; |
|
1042 EUNIT_ASSERT( !iSession->iUseLocalPreconditions ); |
|
1043 EUNIT_ASSERT( !iSession->iUseRemotePreconditions ); |
|
1044 |
|
1045 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleOfferer ); |
|
1046 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1047 |
|
1048 iSession->iUseRemotePreconditions = ETrue; |
|
1049 |
|
1050 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleOfferer ); |
|
1051 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1052 |
|
1053 iSession->iUseLocalPreconditions = EFalse; |
|
1054 iSession->iUseRemotePreconditions = EFalse; |
|
1055 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleAnswerer ); |
|
1056 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1057 |
|
1058 iSession->iUseLocalPreconditions = ETrue; |
|
1059 |
|
1060 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleAnswerer ); |
|
1061 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1062 |
|
1063 |
|
1064 iSession->iUseLocalPreconditions = ETrue; |
|
1065 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleOfferer ); |
|
1066 EUNIT_ASSERT( mediaStream->Preconditions().Count() ); |
|
1067 |
|
1068 iSession->iUseRemotePreconditions = ETrue; |
|
1069 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleAnswerer ); |
|
1070 EUNIT_ASSERT( mediaStream->Preconditions().Count() ); |
|
1071 |
|
1072 //secure precondition |
|
1073 iSession->iSessionModifiers[ KMcePreconditions ] = KMcePreconditionsNotUsed; |
|
1074 EUNIT_ASSERT( mediaStream->Preconditions().Count() == 1 ); //qos precondition |
|
1075 |
|
1076 /* |
|
1077 |
|
1078 if ((aRole == EMceRoleOfferer && |
|
1079 aStream.Session()->iClientCryptoSuites.Count() |
|
1080 && aStream.Session()->Modifier( KMceSecPreconditions ) |
|
1081 == KMcePreconditionsE2ESupported ) |
|
1082 */ |
|
1083 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleOfferer ); |
|
1084 EUNIT_ASSERT( mediaStream->Preconditions().Count() ==1 ); |
|
1085 |
|
1086 iSession->iSessionModifiers[ KMceSecPreconditions ] = KMcePreconditionsE2ESupported; |
|
1087 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleOfferer ); |
|
1088 EUNIT_ASSERT( mediaStream->Preconditions().Count() ==1 ); |
|
1089 |
|
1090 mediaStream->Session()->iClientCryptoSuites.Append( EAES_CM_128_HMAC_SHA1_32 ); |
|
1091 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleOfferer ); |
|
1092 EUNIT_ASSERT( mediaStream->Preconditions().Count() == 1 ); |
|
1093 |
|
1094 /* |
|
1095 aRole ==EMceRoleAnswerer && ( |
|
1096 aStream.Session()->iRemoteSecPreconditionsRequired || |
|
1097 aStream.Session()->iClientCryptoSuites.Count() ))) |
|
1098 |
|
1099 */ |
|
1100 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleAnswerer ); |
|
1101 EUNIT_ASSERT( mediaStream->Preconditions().Count() ==1 ); |
|
1102 |
|
1103 mediaStream->Session()->iRemoteSecPreconditionsRequired = ETrue; |
|
1104 mediaStream->Session()->iClientCryptoSuites.Reset(); |
|
1105 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleAnswerer ); |
|
1106 EUNIT_ASSERT( mediaStream->Preconditions().Count() ==1 ); |
|
1107 |
|
1108 mediaStream->Session()->iClientCryptoSuites.Append( EAES_CM_128_HMAC_SHA1_32 ); |
|
1109 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleAnswerer ); |
|
1110 EUNIT_ASSERT( mediaStream->Preconditions().Count() ==1 ); |
|
1111 |
|
1112 mediaStream->Session()->iRemoteSecPreconditionsRequired = EFalse; |
|
1113 //add audio line |
|
1114 CSdpAttributeField* preconds = CSdpAttributeField::DecodeL( _L8("a=curr:sec e2e sendrecv\r\n") ); |
|
1115 CleanupStack::PushL( preconds ); |
|
1116 |
|
1117 audioLine->AttributeFields().AppendL( preconds ); |
|
1118 CleanupStack::Pop( preconds ); |
|
1119 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleOfferer ); |
|
1120 EUNIT_ASSERT( mediaStream->Preconditions().Count() == 2 ); |
|
1121 |
|
1122 |
|
1123 |
|
1124 mediaStream->Session()->iRemoteSecPreconditionsRequired = ETrue; |
|
1125 iSdpCodec->DecodePreconditionsL( *audioLine, *mediaStream, EMceRoleAnswerer ); |
|
1126 EUNIT_ASSERT( mediaStream->Preconditions().Count() == 2 ); |
|
1127 |
|
1128 CleanupStack::PopAndDestroy( audioLine ); |
|
1129 |
|
1130 |
|
1131 } |
|
1132 |
|
1133 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_EncodePreconditionsLL() |
|
1134 { |
|
1135 |
|
1136 RStringF audio = MCE_SDP_STRING_AUDIOL(); |
|
1137 RStringF protocol = SDP_STRINGL( SdpCodecStringConstants::EProtocolRtpAvp ); |
|
1138 |
|
1139 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
1140 CSdpMediaField* audioLine = |
|
1141 CSdpMediaField::NewLC( audio, 5005, protocol, _L8("0") ); |
|
1142 |
|
1143 iSession->iSessionModifiers[ KMcePreconditions ] = KMcePreconditionsNotUsed; |
|
1144 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1145 |
|
1146 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleOfferer ); |
|
1147 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1148 |
|
1149 |
|
1150 iSession->iSessionModifiers[ KMcePreconditions ] = KMcePreconditionsSupported; |
|
1151 EUNIT_ASSERT( !iSession->iUseLocalPreconditions ); |
|
1152 EUNIT_ASSERT( !iSession->iUseRemotePreconditions ); |
|
1153 |
|
1154 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleOfferer ); |
|
1155 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1156 |
|
1157 iSession->iUseRemotePreconditions = ETrue; |
|
1158 |
|
1159 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleOfferer ); |
|
1160 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1161 |
|
1162 iSession->iUseLocalPreconditions = EFalse; |
|
1163 iSession->iUseRemotePreconditions = EFalse; |
|
1164 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleAnswerer ); |
|
1165 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1166 |
|
1167 iSession->iUseLocalPreconditions = ETrue; |
|
1168 |
|
1169 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleAnswerer ); |
|
1170 EUNIT_ASSERT( !mediaStream->Preconditions().Count() ); |
|
1171 |
|
1172 |
|
1173 iSession->iUseLocalPreconditions = ETrue; |
|
1174 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleOfferer ); |
|
1175 EUNIT_ASSERT( mediaStream->Preconditions().Count() ); |
|
1176 |
|
1177 iSession->iUseRemotePreconditions = ETrue; |
|
1178 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleAnswerer ); |
|
1179 EUNIT_ASSERT( mediaStream->Preconditions().Count() ); |
|
1180 |
|
1181 //secure precondition |
|
1182 |
|
1183 |
|
1184 mediaStream->Session()->Modifier( KMceSecPreconditions ) = KMcePreconditionsNotUsed; |
|
1185 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleOfferer ); |
|
1186 EUNIT_ASSERT( mediaStream->Preconditions().Count() == 1 ); |
|
1187 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleAnswerer ); |
|
1188 EUNIT_ASSERT( mediaStream->Preconditions().Count() == 1 ); |
|
1189 |
|
1190 |
|
1191 mediaStream->Session()->Modifier( KMceSecPreconditions ) = KMcePreconditionsE2ESupported; |
|
1192 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleAnswerer ); |
|
1193 EUNIT_ASSERT( mediaStream->Preconditions().Count() == 1 ); |
|
1194 |
|
1195 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleOfferer ); |
|
1196 EUNIT_ASSERT( mediaStream->Preconditions().Count() == 1 ); |
|
1197 |
|
1198 //added |
|
1199 EUNIT_DISABLE_ALLOC_DECORATOR; |
|
1200 mediaStream->Session()->iClientCryptoSuites.Append( EAES_CM_128_HMAC_SHA1_32 ); |
|
1201 EUNIT_ENABLE_ALLOC_DECORATOR; |
|
1202 |
|
1203 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleAnswerer ); |
|
1204 EUNIT_ASSERT( mediaStream->Preconditions().Count() == 2 ); |
|
1205 |
|
1206 mediaStream->Session()->SecureSessionL(); |
|
1207 |
|
1208 iSdpCodec->EncodePreconditionsL( *mediaStream, *audioLine, EMceRoleAnswerer ); |
|
1209 EUNIT_ASSERT( mediaStream->Preconditions().Count() == 2 ); |
|
1210 |
|
1211 CleanupStack::PopAndDestroy( audioLine ); |
|
1212 |
|
1213 } |
|
1214 |
|
1215 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_EncodeFmtpAttributeLL() |
|
1216 { |
|
1217 |
|
1218 _LIT8( KFmtp, "octet-align=0; mode-set=7"); |
|
1219 |
|
1220 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
1221 const RPointerArray<CMceComCodec>& codecs = iSdpCodec->CodecsL( *mediaStream ); |
|
1222 RStringF audio = MCE_SDP_STRING_AUDIOL(); |
|
1223 RStringF protocol = SDP_STRINGL( SdpCodecStringConstants::EProtocolRtpAvp ); |
|
1224 |
|
1225 CSdpMediaField* audioLine = |
|
1226 CSdpMediaField::NewLC( audio, 5005, protocol, _L8("0") ); |
|
1227 |
|
1228 EUNIT_ASSERT( audioLine->FormatAttributeFields().Count() == 0 ); |
|
1229 |
|
1230 delete codecs[0]->iFmtpAttr; |
|
1231 codecs[0]->iFmtpAttr = NULL; |
|
1232 codecs[0]->iFmtpAttr = KFmtp().AllocL(); |
|
1233 |
|
1234 iSdpCodec->EncodeFmtpAttributeL( *codecs[0], *audioLine ); |
|
1235 EUNIT_ASSERT( audioLine->FormatAttributeFields().Count() == 1 ); |
|
1236 |
|
1237 delete codecs[0]->iFmtpAttr; |
|
1238 codecs[0]->iFmtpAttr = NULL; |
|
1239 codecs[0]->iFmtpAttr = KNullDesC8().AllocL(); |
|
1240 |
|
1241 iSdpCodec->EncodeFmtpAttributeL( *codecs[0], *audioLine ); |
|
1242 EUNIT_ASSERT( audioLine->FormatAttributeFields().Count() == 1 ); |
|
1243 |
|
1244 delete codecs[0]->iFmtpAttr; |
|
1245 codecs[0]->iFmtpAttr = NULL; |
|
1246 |
|
1247 iSdpCodec->EncodeFmtpAttributeL( *codecs[0], *audioLine ); |
|
1248 EUNIT_ASSERT( audioLine->FormatAttributeFields().Count() == 1 ); |
|
1249 |
|
1250 CleanupStack::PopAndDestroy( audioLine ); |
|
1251 |
|
1252 |
|
1253 } |
|
1254 |
|
1255 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeFmtpLinesLL() |
|
1256 { |
|
1257 /* CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
1258 const RPointerArray<CMceComCodec>& codecs = iSdpCodec->CodecsL( *mediaStream ); |
|
1259 CMceComCodec::TIterator iterator( codecs ); |
|
1260 |
|
1261 CMceComCodec* codec = codecs[0]; |
|
1262 |
|
1263 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpMulti ); |
|
1264 CleanupStack::PushL( sdp ); |
|
1265 |
|
1266 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
1267 |
|
1268 codec->iIsNegotiated = ETrue; |
|
1269 iSdpCodec->DecodeFmtpLinesL( *audioLine, iterator ); |
|
1270 EUNIT_ASSERT( codec->iFmtpAttr->Length() > 0 ); |
|
1271 |
|
1272 codec->iIsNegotiated = EFalse; |
|
1273 delete codec->iFmtpAttr; |
|
1274 codec->iFmtpAttr = NULL; |
|
1275 codec->iFmtpAttr = KNullDesC8().AllocL(); |
|
1276 |
|
1277 iSdpCodec->DecodeFmtpLinesL( *audioLine, iterator ); |
|
1278 EUNIT_ASSERT( codec->iFmtpAttr->Length() == 0 ); |
|
1279 iterator.Reset(); |
|
1280 |
|
1281 codec->iIsNegotiated = ETrue; |
|
1282 codec->iPayloadType = 300; |
|
1283 delete codec->iFmtpAttr; |
|
1284 codec->iFmtpAttr = NULL; |
|
1285 codec->iFmtpAttr = KNullDesC8().AllocL(); |
|
1286 |
|
1287 iSdpCodec->DecodeFmtpLinesL( *audioLine, iterator ); |
|
1288 EUNIT_ASSERT( codec->iFmtpAttr->Length() > 0 ); |
|
1289 |
|
1290 mediaStream->RemoveCodecFromListL( 0 ); |
|
1291 CleanupStack::PushL( codec ); |
|
1292 |
|
1293 iSdpCodec->DecodeFmtpLinesL( *audioLine, iterator ); |
|
1294 iterator.Reset(); |
|
1295 |
|
1296 codec->iIsNegotiated = ETrue; |
|
1297 codec->iPayloadType = 96; |
|
1298 delete codec->iFmtpAttr; |
|
1299 codec->iFmtpAttr = NULL; |
|
1300 codec->iFmtpAttr = KNullDesC8().AllocL(); |
|
1301 |
|
1302 mediaStream->AddCodecL( codec ); |
|
1303 CleanupStack::Pop( codec ); |
|
1304 |
|
1305 codec = CMceComG711Codec::NewLC( KMceSDPNamePCMU() ); |
|
1306 codec->iIsNegotiated = ETrue; |
|
1307 codec->iPayloadType = 97; |
|
1308 mediaStream->AddCodecL( codec ); |
|
1309 CleanupStack::Pop( codec ); |
|
1310 |
|
1311 iSdpCodec->DecodeFmtpLinesL( *audioLine, iterator ); |
|
1312 EUNIT_ASSERT( codecs[0]->iFmtpAttr->Length() > 0 ); |
|
1313 EUNIT_ASSERT( codecs[1]->iFmtpAttr->Length() > 0 ); |
|
1314 iterator.Reset(); |
|
1315 |
|
1316 |
|
1317 CleanupStack::PopAndDestroy( sdp ); |
|
1318 */ |
|
1319 } |
|
1320 |
|
1321 |
|
1322 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_ValidateSdpL() |
|
1323 { |
|
1324 |
|
1325 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
1326 CleanupStack::PushL( sdp ); |
|
1327 |
|
1328 RStringF audio = MCE_SDP_STRING_AUDIOL(); |
|
1329 RStringF protocol = SDP_STRINGL( SdpCodecStringConstants::EProtocolRtpAvp ); |
|
1330 |
|
1331 CSdpMediaField* audioLine = |
|
1332 CSdpMediaField::NewLC( audio, 5005, protocol, _L8("0") ); |
|
1333 |
|
1334 EUNIT_ASSERT( iSdpCodec->ValidateSdpL( *audioLine, *sdp ) == KErrNone ); |
|
1335 |
|
1336 CleanupStack::PopAndDestroy( audioLine ); |
|
1337 |
|
1338 audioLine = |
|
1339 CSdpMediaField::NewLC( audio, 5005, protocol, _L8("96") ); |
|
1340 |
|
1341 EUNIT_ASSERT( iSdpCodec->ValidateSdpL( *audioLine, *sdp ) == KMceSipBadRequest ); |
|
1342 |
|
1343 CleanupStack::PopAndDestroy( audioLine ); |
|
1344 |
|
1345 audioLine = sdp->MediaFields()[ 0 ]; |
|
1346 |
|
1347 EUNIT_ASSERT( iSdpCodec->ValidateSdpL( *audioLine, *sdp ) == KErrNone ); |
|
1348 |
|
1349 CleanupStack::PopAndDestroy( sdp ); |
|
1350 |
|
1351 } |
|
1352 |
|
1353 |
|
1354 |
|
1355 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeDirectionLL() |
|
1356 { |
|
1357 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
1358 CleanupStack::PushL( sdp ); |
|
1359 iSession->SdpSession().iOOldSchool = 1; // OldSchool Tried Already |
|
1360 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
1361 CMceComMediaStream* mediaStream = iSession->Streams()[ 0 ]; |
|
1362 |
|
1363 TMceNegotiationRole aRole = EMceRoleOfferer; |
|
1364 iSdpCodec->DecodeDirectionL(*audioLine, *mediaStream, *sdp, aRole ); |
|
1365 |
|
1366 // EUNIT_ASSERT( iSession->SdpSession().iOOldSchool == 0 ); iOOldSchool may not be modified in DecodeDirectionL |
|
1367 EUNIT_ASSERT( mediaStream->Direction() == SdpCodecStringConstants::EAttributeSendrecv ); |
|
1368 CleanupStack::PopAndDestroy( sdp ); |
|
1369 |
|
1370 |
|
1371 sdp = CSdpDocument::DecodeL( KMceTestSdpAMR ); |
|
1372 CleanupStack::PushL( sdp ); |
|
1373 iSession->SdpSession().iOOldSchool = 0; // OldSchool Tried Already |
|
1374 audioLine = sdp->MediaFields()[ 0 ]; |
|
1375 mediaStream = iSession->Streams()[ 0 ]; |
|
1376 |
|
1377 aRole = EMceRoleOfferer; |
|
1378 iSdpCodec->UpdateDirectionL(*audioLine, *mediaStream, *sdp ); |
|
1379 |
|
1380 EUNIT_ASSERT( iSession->SdpSession().iOOldSchool == 0 ); |
|
1381 EUNIT_ASSERT( mediaStream->Direction() == SdpCodecStringConstants::EAttributeSendrecv ); |
|
1382 CleanupStack::PopAndDestroy( sdp ); |
|
1383 |
|
1384 |
|
1385 sdp = CSdpDocument::DecodeL( KMceTestSdpAMRWithOutDirection ); |
|
1386 CleanupStack::PushL( sdp ); |
|
1387 iSession->SdpSession().iOOldSchool = 0; // OldSchool Tried Already |
|
1388 audioLine = sdp->MediaFields()[ 0 ]; |
|
1389 mediaStream = iSession->Streams()[ 0 ]; |
|
1390 |
|
1391 aRole = EMceRoleOfferer; |
|
1392 |
|
1393 //Check that Direction is not changed if it's not offered. |
|
1394 iSdpCodec->DecodeDirectionL(*audioLine, *mediaStream, *sdp, aRole ); |
|
1395 |
|
1396 EUNIT_ASSERT( iSession->SdpSession().iOOldSchool == 0 ); |
|
1397 EUNIT_ASSERT( mediaStream->Direction() == SdpCodecStringConstants::EAttributeSendrecv ); |
|
1398 CleanupStack::PopAndDestroy( sdp ); |
|
1399 |
|
1400 sdp = CSdpDocument::DecodeL( KMceTestSdpAMRWithOutDirection ); |
|
1401 CleanupStack::PushL( sdp ); |
|
1402 iSession->SdpSession().iOOldSchool = 0; // OldSchool Tried Already |
|
1403 audioLine = sdp->MediaFields()[ 0 ]; |
|
1404 mediaStream = iSession->Streams()[ 0 ]; |
|
1405 |
|
1406 aRole = EMceRoleOfferer; |
|
1407 iSdpCodec->UpdateDirectionL(*audioLine, *mediaStream, *sdp); |
|
1408 |
|
1409 EUNIT_ASSERT( iSession->SdpSession().iOOldSchool == 0 ); |
|
1410 EUNIT_ASSERT( mediaStream->Direction() == SdpCodecStringConstants::EAttributeSendrecv ); |
|
1411 CleanupStack::PopAndDestroy( sdp ); |
|
1412 |
|
1413 // Check if we offer Sendonly and receive Sendonly and oldschool is allowed |
|
1414 // We try with Oldschool hold and assume that other |
|
1415 // party did not understand the hold request |
|
1416 |
|
1417 // SDP Answer to be decoded contains sendonly direction attribute |
|
1418 sdp = CSdpDocument::DecodeL( KMceTestSdpHold ); |
|
1419 CleanupStack::PushL( sdp ); |
|
1420 |
|
1421 audioLine = sdp->MediaFields()[ 0 ]; |
|
1422 mediaStream = iSession->Streams()[ 0 ]; |
|
1423 |
|
1424 // Set Local Streams as Sendonly |
|
1425 mediaStream->SetDirection( SdpCodecStringConstants::EAttributeRecvonly ); |
|
1426 |
|
1427 aRole = EMceRoleOfferer; |
|
1428 |
|
1429 // Set the flage that OldSchool is supported |
|
1430 iSession->Modifier( KMceMediaDirection ) = KMceMediaDirectionWithAddress; |
|
1431 |
|
1432 MCE_EUNIT_ASSERT_LEAVE( iSdpCodec->DecodeDirectionL(*audioLine, *mediaStream, *sdp, aRole )); |
|
1433 |
|
1434 // Ensure old school to be used next |
|
1435 EUNIT_ASSERT( iSession->SdpSession().iOOldSchool == 1 ); |
|
1436 |
|
1437 CleanupStack::PopAndDestroy( sdp ); |
|
1438 |
|
1439 } |
|
1440 |
|
1441 |
|
1442 void UT_CMceMediaSdpCodec::UT_CMceMediaSdpCodec_DecodeRtpmapLinesLL() |
|
1443 { |
|
1444 TMceNegotiationRole role = EMceRoleOfferer; |
|
1445 CSdpDocument* sdp = CSdpDocument::DecodeL( KMceTestSdpPCMU ); |
|
1446 CleanupStack::PushL( sdp ); |
|
1447 |
|
1448 CSdpMediaField* audioLine = sdp->MediaFields()[ 0 ]; |
|
1449 CMceComMediaStream* mediaStream = iSession->Streams()[0]; |
|
1450 const RPointerArray<CMceComCodec>& codecs = iSdpCodec->CodecsL( *mediaStream ); |
|
1451 codecs[0]->iSdpName = KPCMUSdpName; |
|
1452 |
|
1453 EUNIT_ASSERT(iSdpCodec->DecodeRtpmapLinesL( *audioLine, *mediaStream, role ) == 0); |
|
1454 CleanupStack::PopAndDestroy( sdp ); |
|
1455 |
|
1456 // Test avc decoding |
|
1457 CMceVideoSdpCodec* videoSdpCodec = CMceVideoSdpCodec::NewL(); |
|
1458 CleanupStack::PushL( videoSdpCodec ); |
|
1459 videoSdpCodec->AddCapabilityL( KMceSDPNameH264 ); |
|
1460 videoSdpCodec->AddCapabilityPayloadTypeL( 100 ); |
|
1461 sdp = NULL; |
|
1462 sdp = CSdpDocument::DecodeL( KMceTestSdpAVC ); |
|
1463 CleanupStack::PushL( sdp ); |
|
1464 |
|
1465 CSdpMediaField* videoLine = sdp->MediaFields()[ 0 ]; |
|
1466 mediaStream = iSession->Streams()[1]; // video |
|
1467 |
|
1468 EUNIT_ASSERT(videoSdpCodec->DecodeRtpmapLinesL( *videoLine, *mediaStream, role ) == 1); |
|
1469 CleanupStack::PopAndDestroy( sdp ); |
|
1470 const RPointerArray<CMceComCodec>& codecs1 = videoSdpCodec->CodecsL( *mediaStream ); |
|
1471 codecs1[0]->iIsNegotiated = 0; |
|
1472 |
|
1473 // No exact match for AVC codec in aswer, offered codec is still used as at |
|
1474 // least SDP name matches |
|
1475 sdp = NULL; |
|
1476 sdp = CSdpDocument::DecodeL( KMceTestSdpAVC2 ); |
|
1477 CleanupStack::PushL( sdp ); |
|
1478 |
|
1479 videoLine = sdp->MediaFields()[ 0 ]; |
|
1480 EUNIT_ASSERT(videoSdpCodec->DecodeRtpmapLinesL( *videoLine, *mediaStream, role ) == 2); |
|
1481 EUNIT_ASSERT(codecs1[0]->iPayloadType == 96); |
|
1482 CleanupStack::PopAndDestroy( sdp ); |
|
1483 |
|
1484 CleanupStack::PopAndDestroy( videoSdpCodec ); |
|
1485 sdp = CSdpDocument::DecodeL( KMceTestSdpMulti ); |
|
1486 CleanupStack::PushL( sdp ); |
|
1487 |
|
1488 TMceComFactory factory; |
|
1489 audioLine = sdp->MediaFields()[ 0 ]; |
|
1490 mediaStream = iSession->Streams()[0]; |
|
1491 |
|
1492 CMceComAudioCodec* pcma = |
|
1493 static_cast<CMceComAudioCodec*>(factory.AudioCodecFactory().CreateLC( KPCMASdpName() )); |
|
1494 |
|
1495 pcma->InitializeL(*mediaStream); |
|
1496 pcma->iPayloadType = 93; |
|
1497 pcma->iIsNegotiated = 0; |
|
1498 mediaStream->AddCodecL( pcma ); |
|
1499 CleanupStack::Pop( pcma ); |
|
1500 iSdpCodec->AddCapabilityL( KAMRSdpName ); |
|
1501 iSdpCodec->AddCapabilityPayloadTypeL( 100 ); |
|
1502 iSdpCodec->AddCapabilityL( KPCMASdpName ); |
|
1503 iSdpCodec->AddCapabilityPayloadTypeL( 100 ); |
|
1504 |
|
1505 const RPointerArray<CMceComCodec>& codecs2 = iSdpCodec->CodecsL( *mediaStream ); |
|
1506 codecs2[0]->iSdpName = KAMRSdpName; |
|
1507 codecs2[1]->iSdpName = KPCMASdpName; |
|
1508 |
|
1509 EUNIT_ASSERT(iSdpCodec->DecodeRtpmapLinesL( *audioLine, *mediaStream, role ) == 2); |
|
1510 EUNIT_ASSERT(codecs2[1]->iPayloadType == 97); |
|
1511 |
|
1512 CleanupStack::PopAndDestroy( sdp ); |
|
1513 |
|
1514 } |
|
1515 |
|
1516 |
|
1517 // TEST TABLE |
|
1518 |
|
1519 EUNIT_BEGIN_TEST_TABLE( |
|
1520 UT_CMceMediaSdpCodec, |
|
1521 "CMceMediaSdpCodec tests", |
|
1522 "UNIT" ) |
|
1523 |
|
1524 EUNIT_TEST ( |
|
1525 "EncodeMediaOfferL test", |
|
1526 "CMceMediaSdpCodec", |
|
1527 "EncodeMediaOfferL", |
|
1528 "FUNCTIONALITY", |
|
1529 SetupL, UT_CMceMediaSdpCodec_EncodeMediaOfferLL, Teardown) |
|
1530 |
|
1531 EUNIT_TEST ( |
|
1532 "DecodeMediaAnswerL test", |
|
1533 "CMceMediaSdpCodec", |
|
1534 "DecodeMediaAnswerL", |
|
1535 "FUNCTIONALITY", |
|
1536 SetupL, UT_CMceMediaSdpCodec_DecodeMediaAnswerLL, Teardown) |
|
1537 |
|
1538 EUNIT_TEST ( |
|
1539 "DecodeMediaOfferL test", |
|
1540 "CMceMediaSdpCodec", |
|
1541 "DecodeMediaOfferL", |
|
1542 "FUNCTIONALITY", |
|
1543 SetupL, UT_CMceMediaSdpCodec_DecodeMediaOfferLL, Teardown) |
|
1544 |
|
1545 EUNIT_TEST ( |
|
1546 "DecodeMediaUpdateL test", |
|
1547 "CMceMediaSdpCodec", |
|
1548 "DecodeMediaUpdateL", |
|
1549 "FUNCTIONALITY", |
|
1550 SetupL, UT_CMceMediaSdpCodec_DecodeMediaUpdateLL, Teardown) |
|
1551 |
|
1552 EUNIT_TEST ( |
|
1553 "EncodeMediaAnswerL test", |
|
1554 "CMceMediaSdpCodec", |
|
1555 "EncodeMediaAnswerL", |
|
1556 "FUNCTIONALITY", |
|
1557 SetupL, UT_CMceMediaSdpCodec_EncodeMediaAnswerLL, Teardown) |
|
1558 |
|
1559 EUNIT_TEST ( |
|
1560 "CleanAttributes test", |
|
1561 "CMceMediaSdpCodec", |
|
1562 "CleanAttributes", |
|
1563 "FUNCTIONALITY", |
|
1564 SetupL, UT_CMceMediaSdpCodec_CleanAttributesL, Teardown) |
|
1565 |
|
1566 EUNIT_TEST ( |
|
1567 "PrepareForDecodeL test", |
|
1568 "CMceMediaSdpCodec", |
|
1569 "PrepareForDecodeL", |
|
1570 "FUNCTIONALITY", |
|
1571 SetupL, UT_CMceMediaSdpCodec_PrepareForDecodeLL, Teardown) |
|
1572 |
|
1573 EUNIT_TEST ( |
|
1574 "EncodeClientAttributesL test", |
|
1575 "CMceMediaSdpCodec", |
|
1576 "EncodeClientAttributesL", |
|
1577 "FUNCTIONALITY", |
|
1578 SetupL, UT_CMceMediaSdpCodec_EncodeClientAttributesLL, Teardown) |
|
1579 |
|
1580 EUNIT_TEST ( |
|
1581 "DecodeClientAttributesL test", |
|
1582 "CMceMediaSdpCodec", |
|
1583 "DecodeClientAttributesL", |
|
1584 "FUNCTIONALITY", |
|
1585 SetupL, UT_CMceMediaSdpCodec_DecodeClientAttributesLL, Teardown) |
|
1586 |
|
1587 |
|
1588 EUNIT_TEST ( |
|
1589 "DecodeRemoteRtcpFieldL test", |
|
1590 "CMceMediaSdpCodec", |
|
1591 "DecodeRemoteRtcpFieldL", |
|
1592 "FUNCTIONALITY", |
|
1593 SetupL, UT_CMceMediaSdpCodec_DecodeRemoteRtcpFieldLL, Teardown) |
|
1594 |
|
1595 EUNIT_TEST ( |
|
1596 "TypeL test", |
|
1597 "CMceMediaSdpCodec", |
|
1598 "Type", |
|
1599 "FUNCTIONALITY", |
|
1600 SetupL, UT_CMceMediaSdpCodec_TypeL, Teardown) |
|
1601 |
|
1602 EUNIT_TEST ( |
|
1603 "DecodePreconditionsL test", |
|
1604 "CMceMediaSdpCodec", |
|
1605 "DecodePreconditionsL", |
|
1606 "FUNCTIONALITY", |
|
1607 SetupL, UT_CMceMediaSdpCodec_DecodePreconditionsLL, Teardown) |
|
1608 |
|
1609 EUNIT_TEST ( |
|
1610 "EncodePreconditionsL test", |
|
1611 "CMceMediaSdpCodec", |
|
1612 "EncodePreconditionsL", |
|
1613 "FUNCTIONALITY", |
|
1614 SetupL, UT_CMceMediaSdpCodec_EncodePreconditionsLL, Teardown) |
|
1615 |
|
1616 EUNIT_TEST ( |
|
1617 "EncodeFmtpAttributeL test", |
|
1618 "CMceMediaSdpCodec", |
|
1619 "EncodeFmtpAttributeL", |
|
1620 "FUNCTIONALITY", |
|
1621 SetupL, UT_CMceMediaSdpCodec_EncodeFmtpAttributeLL, Teardown) |
|
1622 |
|
1623 EUNIT_TEST ( |
|
1624 "DecodeFmtpLinesL test", |
|
1625 "CMceMediaSdpCodec", |
|
1626 "DecodeFmtpLinesL", |
|
1627 "FUNCTIONALITY", |
|
1628 SetupL, UT_CMceMediaSdpCodec_DecodeFmtpLinesLL, Teardown) |
|
1629 |
|
1630 EUNIT_TEST ( |
|
1631 "ValidateSdp test", |
|
1632 "CMceMediaSdpCodec", |
|
1633 "ValidateSdp", |
|
1634 "FUNCTIONALITY", |
|
1635 SetupL, UT_CMceMediaSdpCodec_ValidateSdpL, Teardown) |
|
1636 |
|
1637 EUNIT_TEST ( |
|
1638 "Encode rtcp sdp attr test", |
|
1639 "CMceMediaSdpCodec", |
|
1640 "EncodelocalRtcpAttr", |
|
1641 "FUNCTIONALITY", |
|
1642 SetupL, UT_CMceMediaSdpCodec_EncodelocalRtcpAttrLL, Teardown) |
|
1643 |
|
1644 |
|
1645 EUNIT_TEST ( |
|
1646 "DecodeDirection test", |
|
1647 "CMceMediaSdpCodec", |
|
1648 "DecodeDirectionAttribute", |
|
1649 "FUNCTIONALITY", |
|
1650 SetupL, UT_CMceMediaSdpCodec_DecodeDirectionLL, Teardown) |
|
1651 |
|
1652 EUNIT_TEST ( |
|
1653 "DecodeRtpmapLines test", |
|
1654 "CMceMediaSdpCodec", |
|
1655 "DecodeRtpmapLines", |
|
1656 "FUNCTIONALITY", |
|
1657 Setup2L, UT_CMceMediaSdpCodec_DecodeRtpmapLinesLL, Teardown) |
|
1658 |
|
1659 |
|
1660 EUNIT_END_TEST_TABLE |
|
1661 |
|
1662 |
|
1663 |
|
1664 // END OF FILE |