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