|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Provide interface for the client requestin availability class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "musavadefaultoptionhandler.h" |
|
20 #include "musavasharedobject.h" |
|
21 #include "muslogger.h" |
|
22 #include "musavasip.h" |
|
23 #include "musavasettingsimp.h" |
|
24 #include "sipservertransaction.h" |
|
25 #include "mussettings.h" |
|
26 #include "musavacapability.h" |
|
27 #include "musavacapabilitycontext.h" |
|
28 #include "musavanetworkmodestatus.h" |
|
29 |
|
30 #include <sipstrings.h> |
|
31 #include <siptransactionbase.h> |
|
32 #include <sipheaderbase.h> |
|
33 #include <sipservertransaction.h> |
|
34 #include <sipcontenttypeheader.h> |
|
35 #include <sdpcodecstringpool.h> |
|
36 #include <sipresponseelements.h> |
|
37 #include <siprequestelements.h> |
|
38 #include <sipmessageelements.h> |
|
39 #include <sipconnection.h> |
|
40 #include <sipcontactheader.h> |
|
41 #include <sdpdocument.h> |
|
42 #include <sdpattributefield.h> |
|
43 #include <sdpmediafield.h> |
|
44 #include <sdpconnectionfield.h> |
|
45 #include <sdporiginfield.h> |
|
46 #include <sdprtpmapvalue.h> |
|
47 #include <sdpfmtattributefield.h> |
|
48 #include <e32math.h> |
|
49 #include <uriutils.h> |
|
50 |
|
51 |
|
52 const TInt KMaxNumAsStringSize = 16; |
|
53 _LIT8( KMUSAVAOriginFieldUser, "-"); |
|
54 |
|
55 |
|
56 // -------------------------------------------------------------------------- |
|
57 // Symbian two-phase constructor |
|
58 // -------------------------------------------------------------------------- |
|
59 // |
|
60 CMusAvaDefaultOptionHandler* CMusAvaDefaultOptionHandler::NewL( |
|
61 MMusAvaAvailabilityObserver& aObserver, |
|
62 CMusAvaSettingsImp& aConcreteSettings ) |
|
63 { |
|
64 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::NewL()" ) |
|
65 CMusAvaDefaultOptionHandler* self = CMusAvaDefaultOptionHandler::NewLC( |
|
66 aObserver, |
|
67 aConcreteSettings ); |
|
68 CleanupStack::Pop( self ); |
|
69 |
|
70 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::NewL()" ) |
|
71 return self; |
|
72 } |
|
73 |
|
74 |
|
75 // ------------------------------------------------------------------------- |
|
76 // Two-phased constructor. |
|
77 // ------------------------------------------------------------------------- |
|
78 // |
|
79 CMusAvaDefaultOptionHandler* CMusAvaDefaultOptionHandler::NewLC( |
|
80 MMusAvaAvailabilityObserver& aObserver, |
|
81 CMusAvaSettingsImp& aConcreteSettings ) |
|
82 { |
|
83 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::NewLC()" ) |
|
84 CMusAvaDefaultOptionHandler* self = new( ELeave ) |
|
85 CMusAvaDefaultOptionHandler( aObserver, aConcreteSettings ); |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL(); |
|
88 |
|
89 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::NewLC()" ) |
|
90 return self; |
|
91 } |
|
92 |
|
93 |
|
94 // ------------------------------------------------------------------------- |
|
95 // Constructor. |
|
96 // ------------------------------------------------------------------------- |
|
97 // |
|
98 CMusAvaDefaultOptionHandler::CMusAvaDefaultOptionHandler( |
|
99 MMusAvaAvailabilityObserver& aObserver, |
|
100 CMusAvaSettingsImp& aConcreteSettings ) |
|
101 :CMusAvaAvailability( aObserver ), |
|
102 iSettings( aConcreteSettings ) |
|
103 { |
|
104 } |
|
105 |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // Symbian 2nd phase constructor can leave. |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 void CMusAvaDefaultOptionHandler::ConstructL() |
|
112 { |
|
113 MUS_LOG( "mus: [MUSAVA] -> CMusAvaDefaultOptionHandler::ConstructL()" ) |
|
114 iSharedObj = CMusAvaSharedObject::GetSingletonL(); |
|
115 iSharedObj->MusAvaSip().AddAdapterL( |
|
116 ( MMusAvaSipConnectionAdapter& ) *this ); |
|
117 iSharedObj->MusAvaSip().AddAdapterL( ( MMusAvaSipAdapter& ) *this ); |
|
118 SIPStrings::OpenL(); |
|
119 SdpCodecStringPool::OpenL(); |
|
120 iOperatorVariant = MultimediaSharingSettings::OperatorVariantSettingL(); |
|
121 // set this only for static availability modules |
|
122 iState = MMusAvaObserver::EMusAvaStatusAvailable ; |
|
123 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::ConstructL()" ) |
|
124 } |
|
125 |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // Destructor. |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 CMusAvaDefaultOptionHandler::~CMusAvaDefaultOptionHandler() |
|
132 { |
|
133 MUS_LOG( "mus: [MUSAVA] -> CMusAvaDefaultOptionHandler::\ |
|
134 ~CMusAvaDefaultOptionHandler()" ) |
|
135 |
|
136 if ( iSharedObj ) |
|
137 { |
|
138 iSharedObj->DeleteSingleton(); |
|
139 } |
|
140 SIPStrings::Close(); |
|
141 SdpCodecStringPool::Close(); |
|
142 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::\ |
|
143 ~CMusAvaDefaultOptionHandler()" ) |
|
144 } |
|
145 |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // A SIP request outside a dialog has been received from the network. |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 TInt CMusAvaDefaultOptionHandler::IncomingRequest( |
|
152 CSIPServerTransaction* aTransaction ) |
|
153 { |
|
154 MUS_LOG( "mus: [MUSAVA] -> CMusAvaDefaultOptionHandler::\ |
|
155 IncomingRequest()" ) |
|
156 TInt err = KErrNotFound; |
|
157 if( aTransaction->Type() == SIPStrings::StringF( SipStrConsts::EOptions ) |
|
158 //&& !Available( MMusAvaObserver::EMusAvaOptionHandler ) |
|
159 ) |
|
160 { |
|
161 TRAP( err, IncomingOptionRequestL( aTransaction ) ) |
|
162 if( !err ) |
|
163 { |
|
164 delete aTransaction; |
|
165 } |
|
166 } |
|
167 else |
|
168 { |
|
169 MUS_LOG( "mus: [MUSAVA] Not OPTIONS request or not handled in defaultOptionHandler" ) |
|
170 } |
|
171 |
|
172 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::\ |
|
173 IncomingRequest()" ) |
|
174 return err; |
|
175 } |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // Starts the loopy execution. |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 void CMusAvaDefaultOptionHandler::DoExecuteL() |
|
185 { |
|
186 MUS_LOG( "mus: [MUSAVA] -> CMusAvaDefaultOptionHandler::\ |
|
187 ExecutePatternL()" ) |
|
188 // set status available |
|
189 SetState( MMusAvaObserver::EMusAvaStatusAvailable ); |
|
190 |
|
191 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::\ |
|
192 ExecutePatternL()" ) |
|
193 } |
|
194 |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // CMusAvaDefaultOptionHandler::Name |
|
198 // |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 MMusAvaObserver::TAvailabilityName CMusAvaDefaultOptionHandler::Name() |
|
202 { |
|
203 MUS_LOG( "mus: [MUSAVA] CMusAvaDefaultOptionHandler::Name()" ) |
|
204 return MMusAvaObserver::EMusAvaDefaultOptionHandler; |
|
205 } |
|
206 |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // CMusAvaDefaultOptionHandler::IncomingRequest |
|
210 // |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 TInt CMusAvaDefaultOptionHandler::IncomingRequest( |
|
214 TUint32 aIapId, |
|
215 CSIPServerTransaction* aTransaction ) |
|
216 { |
|
217 MUS_LOG( "mus: [MUSAVA] -> CMusAvaDefaultOptionHandler::\ |
|
218 IncomingRequest()" ) |
|
219 MUS_LOG1( "mus: [MUSAVA] Iap ( %d )", aIapId ) |
|
220 TInt err = KErrNotFound; |
|
221 CSIPConnection* connection = NULL; |
|
222 if( aTransaction->Type() == SIPStrings::StringF( SipStrConsts::EOptions ) |
|
223 && !Available( MMusAvaObserver::EMusAvaOptionHandler ) ) |
|
224 { |
|
225 MUS_LOG( "mus: [MUSAVA] create CSIPConnection" ) |
|
226 TRAP( err, connection = CSIPConnection::NewL( |
|
227 iSharedObj->MusAvaSip().Sip(), |
|
228 aIapId, |
|
229 iSharedObj->MusAvaSip().ConnectionObserver() ) ); |
|
230 |
|
231 if( err != KErrNone ) |
|
232 { |
|
233 MUS_LOG1( "mus: [MUSAVA] CSIPConnection error ( %d )", err ) |
|
234 } |
|
235 else |
|
236 { |
|
237 MUS_LOG( "mus: [MUSAVA] create CSIPConnection" ) |
|
238 TRAP_IGNORE( IncomingOptionRequestL ( aTransaction ) ) |
|
239 delete connection; |
|
240 delete aTransaction; |
|
241 } |
|
242 } |
|
243 else |
|
244 { |
|
245 MUS_LOG( "mus: [MUSAVA] Not OPTIONS request or not handled in defaultOptionHandler" ) |
|
246 } |
|
247 |
|
248 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::\ |
|
249 IncomingRequest()" ) |
|
250 return err; |
|
251 } |
|
252 |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // CMusAvaDefaultOptionHandler::TimedOut |
|
256 // |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 TInt CMusAvaDefaultOptionHandler::TimedOut(CSIPServerTransaction& |
|
260 /*aTransaction*/ ) |
|
261 { |
|
262 MUS_LOG( "mus: [MUSAVA] CMusAvaDefaultOptionHandler::ConstructL()" ) |
|
263 return KErrNotSupported; |
|
264 } |
|
265 |
|
266 |
|
267 // ------------------------------------------------------------------------- |
|
268 // CMusAvaDefaultOptionHandler::IncomingOptionRequestL |
|
269 // |
|
270 // ------------------------------------------------------------------------- |
|
271 // |
|
272 void CMusAvaDefaultOptionHandler::IncomingOptionRequestL( |
|
273 CSIPServerTransaction* aTransaction ) |
|
274 { |
|
275 MUS_LOG( "mus: [MUSAVA] -> CMusAvaDefaultOptionHandler::\ |
|
276 IncomingOptionRequestL()" ) |
|
277 |
|
278 MusSettingsKeys::TActivation activation = |
|
279 MultimediaSharingSettings::ActivationSettingL(); |
|
280 |
|
281 if ( activation == MusSettingsKeys::ENever ) |
|
282 { |
|
283 MUS_LOG( "mus: [MUSAVA] Sending 603 Decline" ) |
|
284 NoCapabilityResponseL( aTransaction, |
|
285 KMUSAVASIPDecline, |
|
286 SipStrConsts::EPhraseDecline ); |
|
287 } |
|
288 else |
|
289 { |
|
290 MUS_LOG( "mus: [MUSAVA] Sending 480 Temporarily Unavilable" ) |
|
291 NoCapabilityResponseL( aTransaction, |
|
292 KMUSAVASIPTemporarilyUnavailable, |
|
293 SipStrConsts::EPhraseTemporarilyNotAvailable ); |
|
294 } |
|
295 |
|
296 MUS_LOG( "mus: [MUSAVA] <- \ |
|
297 CMusAvaDefaultOptionHandler::IncomingOptionRequest()" ) |
|
298 } |
|
299 |
|
300 // ------------------------------------------------------------------------ |
|
301 // Send Response to reques. |
|
302 // |
|
303 // ------------------------------------------------------------------------ |
|
304 void CMusAvaDefaultOptionHandler::ResponseL( |
|
305 CSIPResponseElements* aResponseElements, |
|
306 CSIPServerTransaction* aTransaction ) |
|
307 { |
|
308 MUS_LOG( "mus: [MUSAVA] -> CMusAvaDefaultOptionHandler::ResponseL" ) |
|
309 |
|
310 if ( ( aTransaction->StateL() == CSIPTransactionBase::ETrying || |
|
311 aTransaction->StateL() == CSIPTransactionBase::EProceeding ) && |
|
312 aTransaction->ResponseAllowed() ) |
|
313 { |
|
314 aTransaction->SendResponseL( aResponseElements ); |
|
315 MUS_LOG( " Send response" ) |
|
316 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::ResponseL" ) |
|
317 } |
|
318 else |
|
319 { |
|
320 MUS_LOG( "mus: [MUSAVA] Not allow to sent response " ) |
|
321 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::ResponseL" ) |
|
322 User::Leave( KErrNotReady ); |
|
323 } |
|
324 } |
|
325 |
|
326 |
|
327 // ------------------------------------------------------------------------ |
|
328 // Send response to request. |
|
329 // |
|
330 // ------------------------------------------------------------------------ |
|
331 void CMusAvaDefaultOptionHandler::NoCapabilityResponseL( |
|
332 CSIPServerTransaction* aTransaction, |
|
333 TUint aStatusCode, |
|
334 SipStrConsts::TStrings aReason ) |
|
335 { |
|
336 MUS_LOG( "mus: [MUSAVA] -> CMusAvaDefaultOptionHandler::SendResponseL()" ) |
|
337 MUS_LOG( "mus: [MUSAVA] Create response elements " ) |
|
338 CSIPResponseElements* respElem = NULL; |
|
339 |
|
340 if( iOperatorVariant == MusSettingsKeys::EOperatorSpecific ) |
|
341 { |
|
342 MUS_LOG( "mus: [MUSAVA] Operator Specific response" ) |
|
343 respElem = CreateResponseL( *aTransaction ); |
|
344 CleanupStack::PushL( respElem ); |
|
345 } |
|
346 else |
|
347 { |
|
348 MUS_LOG( "mus: [MUSAVA] Standard response" ) |
|
349 RStringF reasonPhrase = |
|
350 SIPStrings::StringF( aReason ); |
|
351 respElem = |
|
352 CSIPResponseElements::NewLC( aStatusCode, reasonPhrase ); |
|
353 } |
|
354 |
|
355 ResponseL( respElem, aTransaction ); |
|
356 MUS_LOG( "mus: [MUSAVA] Response sent " ) |
|
357 CleanupStack::Pop( respElem ); |
|
358 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::SendResponseL()" ) |
|
359 } |
|
360 |
|
361 |
|
362 // ------------------------------------------------------------------------ |
|
363 // CMusAvaDefaultOptionHandler::CreateResponseL |
|
364 // |
|
365 // ---------------------------------------------------------------------------- |
|
366 // |
|
367 CSIPResponseElements* CMusAvaDefaultOptionHandler::CreateResponseL( |
|
368 CSIPServerTransaction& aTransaction ) |
|
369 { |
|
370 HBufC8* sdpBody = NULL; |
|
371 CSIPResponseElements* respElem = |
|
372 CSIPResponseElements::NewLC( KMUSAVASIP200, |
|
373 SIPStrings::StringF(SipStrConsts::EPhraseOk) ); |
|
374 |
|
375 RPointerArray<CSIPHeaderBase> responseHeaders; |
|
376 CSIPHeaderBase::PushLC( &responseHeaders ); |
|
377 |
|
378 const CUri8& uri = aTransaction.RequestElements()->RemoteUri(); |
|
379 CSIPContactHeader* contact = MusAvaCapabilityContext::ContactHeaderLC( |
|
380 uri, SIPStrings::StringF( SipStrConsts::EEmpty ) ); |
|
381 responseHeaders.AppendL( contact ); |
|
382 CleanupStack::Pop( contact ); |
|
383 |
|
384 CSIPMessageElements& messageElements = respElem->MessageElements(); |
|
385 messageElements.SetUserHeadersL( responseHeaders ); |
|
386 CleanupStack::Pop( &responseHeaders ); |
|
387 |
|
388 CSIPContentTypeHeader* contenType = |
|
389 CSIPContentTypeHeader::NewLC( SIPStrings::StringF( |
|
390 SipStrConsts::EApplication).DesC(), |
|
391 KMUSAVASIPMediaSubTypeSDP ); |
|
392 |
|
393 // Set content |
|
394 CSdpDocument* sdpDocument = CreateSDPL( aTransaction ); |
|
395 CleanupStack::PushL( sdpDocument ); |
|
396 sdpBody = ToTextL( *sdpDocument ); |
|
397 CleanupStack::PopAndDestroy( sdpDocument ); |
|
398 CleanupStack::PushL( sdpBody ); |
|
399 messageElements.SetContentL( sdpBody, contenType ); |
|
400 CleanupStack::Pop( sdpBody ); |
|
401 CleanupStack::Pop( contenType ); |
|
402 CleanupStack::Pop( respElem ); |
|
403 return respElem; |
|
404 } |
|
405 |
|
406 |
|
407 // ------------------------------------------------------------------------ |
|
408 // Create SDP response. |
|
409 // |
|
410 // ------------------------------------------------------------------------ |
|
411 CSdpDocument* CMusAvaDefaultOptionHandler::CreateSDPL( |
|
412 CSIPServerTransaction& aTransaction ) |
|
413 { |
|
414 MUS_LOG( "mus: [MUSAVA] -> CMusAvaDefaultOptionHandler::CreateSDPL" ) |
|
415 // Origin field |
|
416 TPtrC8 localHost; |
|
417 RStringF hostType; |
|
418 RStringF netType = SDPStringL( SdpCodecStringConstants::ENetType ); |
|
419 CSdpDocument* sdpDocument = CSdpDocument::NewLC(); |
|
420 LocalHostL( aTransaction,localHost,hostType); |
|
421 CSdpOriginField* originField = CreateOriginFieldL(localHost,hostType); |
|
422 sdpDocument->SetOriginField(originField); |
|
423 // Connection field |
|
424 CSdpConnectionField* connectionField = |
|
425 CSdpConnectionField::NewL( netType, hostType, localHost ); |
|
426 sdpDocument->SetConnectionField( connectionField ); |
|
427 |
|
428 MUS_LOG( "mus: [MUSAVA] Adding application attribute to SDP" ) |
|
429 //application |
|
430 CSdpAttributeField* application = |
|
431 CSdpAttributeField::NewLC( |
|
432 SDPStringL( SdpCodecStringConstants::EMediaApplication ), |
|
433 KCapabilitySwisApplication ); |
|
434 |
|
435 sdpDocument->AttributeFields().AppendL( application ); |
|
436 CleanupStack::Pop( application ); |
|
437 |
|
438 MUS_LOG( "mus: [MUSAVA] Adding type attribute to SDP" ) |
|
439 //type |
|
440 RStringF typeStr = SDPStringL( KCapabilitySDPAttributeNameType ); |
|
441 CleanupClosePushL( typeStr ); |
|
442 CSdpAttributeField* type = |
|
443 CSdpAttributeField::NewL( typeStr, KCapabilitySDPAttributeType ); |
|
444 CleanupStack::PopAndDestroy();//typeStr |
|
445 CleanupStack::PushL( type ); |
|
446 |
|
447 sdpDocument->AttributeFields().AppendL( type ); |
|
448 CleanupStack::Pop( type ); |
|
449 |
|
450 // Fast startup mode |
|
451 CMusAvaCapability::AddFastModeL( *sdpDocument ); |
|
452 |
|
453 MUS_LOG( "mus: [MUSAVA] Adding media line to SDP" ) |
|
454 //media line |
|
455 CSdpMediaField* mediaLine = |
|
456 MediaLineLC( SDPStringL( SdpCodecStringConstants::EMediaVideo ), |
|
457 KCapabilitySwisFormatList ); |
|
458 |
|
459 //rtpmap |
|
460 MUS_LOG( "mus: [MUSAVA] Adding rtpmap to SDP" ) |
|
461 //adding H.264 codec to SDP |
|
462 CSdpFmtAttributeField* rtpMapH264 = |
|
463 RtpMapLineLC( KCapabilitySDPAttributeCodecH264, |
|
464 KCapabilitySDPAttributePayloadTypeH264, |
|
465 KCapabilitySDPAttributeClockrate ); |
|
466 |
|
467 mediaLine->FormatAttributeFields().AppendL( rtpMapH264 ); |
|
468 CleanupStack::Pop( rtpMapH264 ); |
|
469 |
|
470 //H.263 codec |
|
471 CSdpFmtAttributeField* rtpMapH263 = RtpMapLineLC( |
|
472 KCapabilitySDPAttributeCodecH263, |
|
473 KCapabilitySDPAttributePayloadType, |
|
474 KCapabilitySDPAttributeClockrate ); |
|
475 |
|
476 mediaLine->FormatAttributeFields().AppendL( rtpMapH263 ); |
|
477 CleanupStack::Pop( rtpMapH263 ); |
|
478 |
|
479 sdpDocument->MediaFields().AppendL( mediaLine ); |
|
480 CleanupStack::Pop( mediaLine ); |
|
481 CleanupStack::Pop( sdpDocument ); |
|
482 MUS_LOG( "mus: [MUSAVA] <- CMusAvaDefaultOptionHandler::CreateSDPL" ) |
|
483 return sdpDocument; |
|
484 } |
|
485 |
|
486 |
|
487 // ---------------------------------------------------------------------------- |
|
488 // CMusAvaDefaultOptionHandler::CreateOriginFieldL |
|
489 // |
|
490 // ---------------------------------------------------------------------------- |
|
491 // |
|
492 CSdpOriginField* CMusAvaDefaultOptionHandler::CreateOriginFieldL( |
|
493 const TDesC8& aLocalHost, |
|
494 const RStringF& aHostType) const |
|
495 { |
|
496 #ifdef UNIT_TESTING |
|
497 TInt64 sessionID = 452027953; |
|
498 #else |
|
499 TTime now; |
|
500 now.UniversalTime(); |
|
501 TInt64 rand = now.Int64(); |
|
502 TInt64 sessionID = Math::Rand( rand ); |
|
503 #endif |
|
504 |
|
505 return CSdpOriginField::NewL( |
|
506 KMUSAVAOriginFieldUser, |
|
507 sessionID, |
|
508 sessionID, |
|
509 SDPStringL( SdpCodecStringConstants::ENetType ), |
|
510 aHostType, |
|
511 aLocalHost); |
|
512 } |
|
513 |
|
514 |
|
515 // ---------------------------------------------------------------------------- |
|
516 // CMusAvaDefaultOptionHandler::LocalHostL |
|
517 // |
|
518 // ---------------------------------------------------------------------------- |
|
519 // |
|
520 void CMusAvaDefaultOptionHandler::LocalHostL( |
|
521 const CSIPServerTransaction& aRequest, |
|
522 TPtrC8& aLocalHost, |
|
523 RStringF& aHostType ) |
|
524 { |
|
525 RStringPool strPool = SdpCodecStringPool::StringPoolL(); |
|
526 |
|
527 const CUri8& uri = aRequest.RequestElements()->RemoteUri(); |
|
528 |
|
529 aLocalHost.Set( uri.Uri().Extract( EUriHost ) ); |
|
530 |
|
531 if ( UriUtils::HostType( aLocalHost ) == UriUtils::EIPv6Host ) |
|
532 { |
|
533 aHostType = strPool.StringF( SdpCodecStringConstants::EAddressType, |
|
534 SdpCodecStringPool::StringTableL() ); |
|
535 } |
|
536 else |
|
537 { |
|
538 aHostType = strPool.StringF( |
|
539 SdpCodecStringConstants::EAddressTypeIP4, |
|
540 SdpCodecStringPool::StringTableL() ); |
|
541 } |
|
542 } |
|
543 |
|
544 |
|
545 // ---------------------------------------------------------------------------- |
|
546 // CMusAvaDefaultOptionHandler::SDPStringL |
|
547 // |
|
548 // ---------------------------------------------------------------------------- |
|
549 // |
|
550 RStringF CMusAvaDefaultOptionHandler::SDPStringL( const TDesC8& aString ) |
|
551 { |
|
552 return SdpCodecStringPool::StringPoolL().OpenFStringL( aString ); |
|
553 } |
|
554 |
|
555 |
|
556 // ---------------------------------------------------------------------------- |
|
557 // CMusAvaDefaultOptionHandler::SDPStringL |
|
558 // |
|
559 // ---------------------------------------------------------------------------- |
|
560 // |
|
561 RStringF CMusAvaDefaultOptionHandler::SDPStringL( TInt aStringIndex ) |
|
562 { |
|
563 return SdpCodecStringPool::StringPoolL(). |
|
564 StringF( aStringIndex, SdpCodecStringPool::StringTableL() ); |
|
565 } |
|
566 |
|
567 |
|
568 // ----------------------------------------------------------------------------- |
|
569 // CMusAvaDefaultOptionHandler::MediaLineLC |
|
570 // |
|
571 // ----------------------------------------------------------------------------- |
|
572 // |
|
573 CSdpMediaField* CMusAvaDefaultOptionHandler::MediaLineLC( |
|
574 const RStringF& aMedia, |
|
575 const TDesC8& aFormatList ) const |
|
576 { |
|
577 return CSdpMediaField::NewLC( aMedia, |
|
578 NULL, |
|
579 SDPStringL( |
|
580 SdpCodecStringConstants::EProtocolRtpAvp ), |
|
581 aFormatList ); |
|
582 } |
|
583 |
|
584 |
|
585 // ---------------------------------------------------------------------------- |
|
586 // CMusAvaDefaultOptionHandler::RtpMapLineLC |
|
587 // |
|
588 // ---------------------------------------------------------------------------- |
|
589 // |
|
590 CSdpFmtAttributeField* CMusAvaDefaultOptionHandler::RtpMapLineLC( |
|
591 const TDesC8& aCodec, |
|
592 const TUint64 aPayloadType, |
|
593 const TUint64 aClockRate, |
|
594 const TDesC8& aParams ) const |
|
595 { |
|
596 HBufC8* clockrate = HBufC8::NewLC( KMaxNumAsStringSize ); |
|
597 clockrate->Des().Num( aClockRate, EDecimal ); |
|
598 HBufC8* payload = HBufC8::NewLC( KMaxNumAsStringSize ); |
|
599 payload->Des().Num( aPayloadType, EDecimal ); |
|
600 |
|
601 |
|
602 TSdpRtpmapValue rtpmapValue( aCodec, |
|
603 *clockrate, |
|
604 aParams ); |
|
605 |
|
606 |
|
607 HBufC8* rtpmap = rtpmapValue.EncodeL(); |
|
608 CleanupStack::PushL( rtpmap ); |
|
609 |
|
610 CSdpFmtAttributeField* rtpmapAttribute = |
|
611 CSdpFmtAttributeField::NewL( SDPStringL( |
|
612 SdpCodecStringConstants::EAttributeRtpmap ), |
|
613 *payload, |
|
614 *rtpmap ); |
|
615 |
|
616 CleanupStack::PopAndDestroy( rtpmap ); |
|
617 CleanupStack::PopAndDestroy( payload ); |
|
618 CleanupStack::PopAndDestroy( clockrate ); |
|
619 |
|
620 CleanupStack::PushL( rtpmapAttribute ); |
|
621 |
|
622 return rtpmapAttribute; |
|
623 } |
|
624 |
|
625 |
|
626 // -------------------------------------------------------------------------- |
|
627 // CMusAvaDefaultOptionHandler::ToTextL |
|
628 // |
|
629 // -------------------------------------------------------------------------- |
|
630 // |
|
631 HBufC8* CMusAvaDefaultOptionHandler::ToTextL( CSdpDocument& aSdpContent ) |
|
632 { |
|
633 HBufC8* content = NULL; |
|
634 |
|
635 CBufFlat* encBuf = CBufFlat::NewL( KMUSAVAMaxLengthOfSDPMessage ); |
|
636 CleanupStack::PushL( encBuf ); |
|
637 RBufWriteStream writeStream( *encBuf, 0 ); |
|
638 writeStream.PushL(); |
|
639 writeStream.Open( *encBuf, 0 ); |
|
640 aSdpContent.EncodeL( writeStream ); |
|
641 writeStream.Close(); |
|
642 CleanupStack::PopAndDestroy();//writeStream |
|
643 |
|
644 content = encBuf->Ptr( 0 ).AllocL(); |
|
645 CleanupStack::PopAndDestroy( encBuf ); |
|
646 |
|
647 return content; |
|
648 } |