multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemessagesdpcodec.cpp
branchrcs
changeset 49 64c62431ac08
child 50 1d8943dd8be6
equal deleted inserted replaced
44:fb024d5e35fa 49:64c62431ac08
       
     1 /*
       
     2 * Copyright (c) 2005 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 // INCLUDE FILES
       
    21 #include <e32base.h>
       
    22 #include <e32std.h>
       
    23 #include <e32def.h>
       
    24 #include <stringpool.h>
       
    25 
       
    26 #include <sdpdocument.h>
       
    27 #include <sdpcodecstringconstants.h>
       
    28 #include <sdpcodecstringpool.h>
       
    29 #include <sdpmediafield.h>
       
    30 #include <sdpattributefield.h>
       
    31 #include <sdprtpmapvalue.h>
       
    32 #include <sdpfmtattributefield.h>
       
    33 #include <sdporiginfield.h>
       
    34 #include <e32err.h>
       
    35 #include <uricommon.h>
       
    36 #include <uri8.h>
       
    37 #include <uriutils.h>
       
    38 #include <SdpConnectionField.h>
       
    39 
       
    40 #include "mcemediadefs.h"
       
    41 #include "mcemessagesdpcodec.h"
       
    42 #include "mcecommessagestream.h"
       
    43 #include "mcemessagestream.h"
       
    44 #include "mcecommessagecodec.h"
       
    45 #include "mcemediadefs.h"
       
    46 #include "mcecomfactory.h"
       
    47 #include "mcemmlogs.h"
       
    48 #include "mcecommsrpsource.h"
       
    49 #include "mcecomexternalsink.h"
       
    50 #include "mcecomexternalsource.h"
       
    51 #include "mcecommsrpsink.h"
       
    52 #include "mcecommediasource.h"
       
    53 #include "mcedefs.h"
       
    54 #include "mcecomendpoint.h"
       
    55 #include <mcemsrpsink.h>
       
    56 #include <mcemsrpsource.h>
       
    57 #include <mcemessagesink.h>
       
    58 #include <mcemessagesource.h>
       
    59 #include "mcecommessagesink.h"
       
    60 #include "mcecommessagesource.h"
       
    61 #include "mcemsrpsink.h"
       
    62 #include "mceexternalsource.h"
       
    63 #include "mceexternalsink.h"
       
    64 
       
    65 
       
    66 // ================= MEMBER FUNCTIONS =======================
       
    67 
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CMceMessageSdpCodec::NewL
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 CMceMessageSdpCodec* CMceMessageSdpCodec::NewL()
       
    74     {
       
    75     MCEMM_DEBUG( "CMceMessageSdpCodec::CMceMessageSdpCodec::NewL, Entry" )
       
    76     RStringF message = MCE_SDP_STRING_MESSAGEL();
       
    77     /*
       
    78     RStringPool sPool;
       
    79     RStringF message =sPool.OpenFStringL(KMceMediaMessage);
       
    80     */    
       
    81         
       
    82     CMceMessageSdpCodec* self = new (ELeave) CMceMessageSdpCodec( message );
       
    83     CleanupStack::PushL( self );
       
    84     self->ConstructL();
       
    85     CleanupStack::Pop( self );
       
    86 
       
    87     MCEMM_DEBUG( "CMceMessageSdpCodec::CMceMessageSdpCodec::NewL, Exit" )
       
    88     return self;
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CMceMessageSdpCodec::CMceMessageSdpCodec
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 CMceMessageSdpCodec::CMceMessageSdpCodec( RStringF aMedia )
       
    96     : CMceMediaSdpCodec( aMedia )
       
    97     {
       
    98     }
       
    99 
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CMceMessageSdpCodec::~CMceMessageSdpCodec
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 CMceMessageSdpCodec::~CMceMessageSdpCodec()
       
   106     { 
       
   107     MCEMM_DEBUG( "CMceMessageSdpCodec::~CMceMessageSdpCodec, Entry" )
       
   108     iNetType.Close();
       
   109     iAddressType.Close();
       
   110     iAcceptTypesStr.Close();
       
   111     iPathStr.Close();
       
   112     iAcceptWrappedTypesStr.Close();
       
   113     iFileSelectorStr.Close();
       
   114     iFileTransferidStr.Close();  
       
   115     iFileDispositionStr.Close();
       
   116     iConnectionStr.Close();
       
   117     MCEMM_DEBUG( "CMceMessageSdpCodec::~CMceMessageSdpCodec, Exit" )
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CMceMessageSdpCodec::Encodes
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 TBool CMceMessageSdpCodec::Encodes( const CMceComMediaStream& aStream ) const
       
   125     {
       
   126     return aStream.iStreamType != CMceComMediaStream::ELocalStream &&
       
   127            aStream.iType == KMceMessage;
       
   128     }
       
   129 
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CMceMessageSdpCodec::EncodeRtpmapAttributeLC
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 CSdpFmtAttributeField* CMceMessageSdpCodec::EncodeRtpmapAttributeLC( CMceComCodec& /*aCodec*/ ) const
       
   136     {
       
   137     MCEMM_DEBUG( "CMceMessageSdpCodec::EncodeRtpmapAttributeLC(), Entry" )
       
   138     
       
   139     CSdpFmtAttributeField* rtpmapAttribute = NULL;
       
   140     
       
   141     CleanupStack::PushL( rtpmapAttribute );
       
   142     
       
   143     MCEMM_DEBUG( "CMceMessageSdpCodec::EncodeRtpmapAttributeLC(), Exit" )
       
   144     return rtpmapAttribute;
       
   145     }
       
   146 
       
   147 
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CMceMessageSdpCodec::EncodeMessageMediaAttributesL
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 
       
   154 void CMceMessageSdpCodec::EncodeMessageMediaAttributesL( CMceComMessageStream& aStream, 
       
   155                                                             CSdpMediaField& aMediaLine)                                             
       
   156      {
       
   157      // Message stream level attributes will be set through client SDP attributes.
       
   158     MCEMM_DEBUG( "CMceMessageSdpCodec::EncodeMessageMediaAttributesL, Entry" )
       
   159      CMceComMsrpSource* msrpSource = NULL;
       
   160      CMceComMsrpSink* msrpSink = NULL;
       
   161      if ( (aStream.iStreamType == CMceComMediaStream::ESendOnlyStream) ||
       
   162              (aStream.iStreamType == CMceComMediaStream::ESendStream))
       
   163          {
       
   164          for(TInt i=0; i<aStream.Sinks().Count(); i++)
       
   165              {
       
   166              if ( (aStream.Sinks())[i]->iType == KMceMSRPSink)
       
   167                  {
       
   168                  msrpSink = dynamic_cast<CMceComMsrpSink*>( aStream.Sinks()[i]);
       
   169                  break;
       
   170                  }
       
   171              }
       
   172          }
       
   173         else  //it meamsn it is sendrecv stream so the parameters are expected to be set to msrpSink
       
   174          {
       
   175          __ASSERT_ALWAYS(aStream.Source()->iType == KMceMSRPSource, User::Leave(KErrArgument));
       
   176          msrpSource = dynamic_cast<CMceComMsrpSource*>( aStream.Source());
       
   177          }
       
   178      
       
   179      __ASSERT_ALWAYS(msrpSource!=NULL || msrpSink!= NULL, User::Leave(KErrNotFound));
       
   180      
       
   181      RPointerArray<CMceComMediaSink> &sinks = aStream.Sinks(); //== KMceMessageSink
       
   182      
       
   183      if( (aStream.iSource->iType == KMceMSRPSource && sinks[0]->iType == KMceMessageSink) || aStream.iSource->iType == KMceMessageSource) // down link
       
   184          {
       
   185          if(aStream.iLocalMsrpPath.Length() && ( aStream.Session()->Streams().Count() != 2 || aStream.iStreamType != CMceComMediaStream::ESendOnlyStream) )
       
   186              {
       
   187              if (iPathStr.DesC().Length() == 0 )
       
   188                  {
       
   189                  iPathStr = SdpCodecStringPool::StringPoolL().OpenFStringL(KMceSDPNamePath);
       
   190                  CleanupClosePushL( iPathStr );
       
   191                  }
       
   192              
       
   193              HBufC16* localPath = HBufC16::NewLC(256);
       
   194              localPath->Des().Copy(aStream.iLocalMsrpPath);
       
   195              CUri8* uri = UriUtils::CreateUriL(*localPath);
       
   196              
       
   197              // if the realy is supported then the last entry will always indicates its own MSRP URI
       
   198              SetHostAddrFromPathAttrL(uri->Uri(), aMediaLine); 
       
   199              // Set local port number from the msrp path
       
   200              //SetPortFromPathAttrL((TUriC8&)uri->Uri(), aStream);            
       
   201              // Create the path SDP attr and append this to media line
       
   202              CSdpAttributeField* pathAttr = CSdpAttributeField::NewLC( iPathStr, aStream.iLocalMsrpPath);                     
       
   203              MCEMM_DEBUG_SVALUE( "path Attribute value from MSRP stack:", aStream.iLocalMsrpPath )         
       
   204              aMediaLine.AttributeFields().AppendL( pathAttr );
       
   205              CleanupStack::Pop(pathAttr);
       
   206              CleanupStack::PopAndDestroy(localPath);
       
   207              if (iPathStr.DesC().Length() != 0 )
       
   208                  CleanupStack::PopAndDestroy(&iPathStr);
       
   209              
       
   210              delete uri;
       
   211              }
       
   212          }
       
   213      else if(aStream.iSource->iType == KMceMessageSource && msrpSink->iType == KMceMSRPSink) // message uplink
       
   214          {
       
   215          //NOP
       
   216          }
       
   217      else
       
   218          {
       
   219          SetPathAttributeL(aStream, msrpSource, msrpSink, aMediaLine);
       
   220          }
       
   221     // EncodeFileAttributeL( aStream, aMediaLine );
       
   222      SetAcceptTypesAttributeL(msrpSource, msrpSink, aMediaLine);
       
   223      SetAcceptWrappedAttributeL(msrpSource, msrpSink, aMediaLine);
       
   224      SetFileShareAttributeL(msrpSource, msrpSink, aMediaLine);
       
   225      
       
   226      // Set Information attribute
       
   227      HBufC8* infoPtr = msrpSource!=NULL ? msrpSource->iSessInfo : msrpSink->iSessInfo;
       
   228      if (infoPtr != NULL)
       
   229          aMediaLine.SetInfoL(infoPtr->Des());
       
   230 
       
   231      // set msrp conneciton attribute
       
   232      SetConnectionAttributeL(aStream, aMediaLine);
       
   233      MCEMM_DEBUG( "CMceMessageSdpCodec::EncodeMessageMediaAttributesL, Exit" )
       
   234      }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CMceMessageSdpCodec::EncodeMediaAttributesL
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 void CMceMessageSdpCodec::EncodeMediaAttributesL( CMceComCodec& /*aCodec*/, 
       
   241                                                 CSdpMediaField& /*aMediaLine*/, 
       
   242                                                 CSdpFmtAttributeField& /*aRtpmap*/ ) const
       
   243     {
       
   244     MCEMM_DEBUG( "CMceMessageSdpCodec::EncodeMediaAttributesL(), Entry" )
       
   245     MCEMM_DEBUG( "CMceMessageSdpCodec::EncodeMediaAttributesL(), Exit" )
       
   246     }
       
   247     
       
   248 // -----------------------------------------------------------------------------
       
   249 // CMceMessageSdpCodec::DecodeMediaAttributesL 
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 void CMceMessageSdpCodec::DecodeMediaAttributesL(
       
   253     CSdpMediaField& /*aMediaLine*/, 
       
   254     CMceComCodec& /*aCodec*/,
       
   255     CSdpFmtAttributeField& /*aRtpmap*/ ) const
       
   256     {
       
   257     MCEMM_DEBUG( "CMceMessageSdpCodec::DecodeMediaAttributesL(), Entry ")
       
   258 
       
   259     MCEMM_DEBUG("CMceMessageSdpCodec::DecodeMediaAttributesL(), Exit ")
       
   260     }
       
   261 
       
   262 
       
   263 // -----------------------------------------------------------------------------
       
   264 // CMceMessageSdpCodec::CreateStreamLC
       
   265 // -----------------------------------------------------------------------------
       
   266 //
       
   267 CMceComMediaStream* CMceMessageSdpCodec::CreateStreamLC( TInt aType ) const
       
   268     {
       
   269     MCEMM_DEBUG( "CMceMessageSdpCodec::CreateStreamLC(), Entry" )
       
   270    CMceComMessageStream* messagestream = NULL;
       
   271             
       
   272     if( aType == SdpCodecStringConstants::EAttributeSendonly )
       
   273         {
       
   274         // downlink
       
   275         MCEMM_DEBUG( "create downlink" )
       
   276         messagestream = CreateDownlinkStreamL();
       
   277         }
       
   278     else if( aType == SdpCodecStringConstants::EAttributeRecvonly )        
       
   279         {
       
   280         // uplink 
       
   281         MCEMM_DEBUG( "create uplink" )
       
   282         messagestream = CreateUplinkStreamL();
       
   283         }
       
   284     else
       
   285         {
       
   286         // sendrcv 
       
   287         // create two way stream
       
   288         // create downlink
       
   289         MCEMM_DEBUG( "create two-way stream" )
       
   290         messagestream = CreateDownlinkStreamL();
       
   291         CleanupStack::PushL( messagestream );
       
   292         // create bounded uplink
       
   293        CMceComMessageStream *boundUplink = CreateUplinkStreamL();
       
   294         CleanupStack::PushL( boundUplink );
       
   295         messagestream->BindL( boundUplink );
       
   296         CleanupStack::Pop( boundUplink ); 
       
   297         CleanupStack::Pop( messagestream );
       
   298         }
       
   299     
       
   300     CleanupStack::PushL( messagestream );
       
   301     
       
   302     MCEMM_DEBUG( "CMceMessageSdpCodec::CreateStreamLC(), Exit" )
       
   303     return messagestream;
       
   304     
       
   305     }
       
   306 
       
   307 
       
   308 // -----------------------------------------------------------------------------
       
   309 // CMceMessageSdpCodec::UpdateStreamL
       
   310 // -----------------------------------------------------------------------------
       
   311 //
       
   312 void CMceMessageSdpCodec::UpdateStreamL( CMceComMediaStream& aStream, TInt aDirection ) const
       
   313     {
       
   314     MCEMM_DEBUG( "CMceMessageSdpCodec::UpdateStreamL(), Entry ")
       
   315     MCE_DEFINE_AUDIO( stream, aStream );
       
   316 
       
   317    CMceComMessageStream* messagestream = NULL;
       
   318    CMceComMessageStream& amessagestream = (CMceComMessageStream&)( aStream );
       
   319     TInt streamType = stream.SdpStreamType();
       
   320     
       
   321     if ( aDirection != SdpCodecStringConstants::EAttributeInactive )
       
   322         {
       
   323         switch( streamType )
       
   324             {
       
   325             case SdpCodecStringConstants::EAttributeRecvonly:
       
   326                 {
       
   327                 //if direction is changed
       
   328                 if ( aDirection != SdpCodecStringConstants::EAttributeSendonly )
       
   329                     {
       
   330                     MCEMM_DEBUG( "update from recvonly to send" )
       
   331                     MCEMM_DEBUG( "create uplink" )
       
   332                     messagestream = CreateUplinkStreamL();
       
   333                     }
       
   334                 break;
       
   335                 }
       
   336             case SdpCodecStringConstants::EAttributeSendonly:
       
   337                 {
       
   338                 //if direction is changed
       
   339                 if ( aDirection != SdpCodecStringConstants::EAttributeRecvonly )
       
   340                     {
       
   341                     MCEMM_DEBUG( "update from sendonly to recv" )
       
   342                     MCEMM_DEBUG( "create downlink" )
       
   343                     messagestream = CreateDownlinkStreamL();
       
   344                     }
       
   345                 break;
       
   346                 }
       
   347             case SdpCodecStringConstants::EAttributeSendrecv:
       
   348             default:
       
   349                 {
       
   350                 break;
       
   351                 }
       
   352             }
       
   353         }
       
   354         
       
   355     if ( messagestream )
       
   356         {
       
   357         CleanupStack::PushL( messagestream );
       
   358 
       
   359         MCEMM_DEBUG( "cloning codecs" )
       
   360         
       
   361         for( TInt index = 0; index < amessagestream.CodecCount(); ++index )
       
   362             {
       
   363             // No ceodecs for message stream presently
       
   364             CMceComMessageCodec* codec = static_cast<CMceComMessageCodec*>( amessagestream.CodecL( index )->CloneL() );
       
   365             CleanupStack::PushL( codec );
       
   366             
       
   367             MCEMM_DEBUG_SVALUE( "cloned codec", codec->iSdpName )
       
   368             
       
   369             messagestream->AddCodecL( codec );
       
   370             CleanupStack::Pop( codec );
       
   371             }
       
   372 
       
   373         amessagestream.BindL( messagestream );
       
   374         messagestream->InitializeL( *amessagestream.Session() );
       
   375         
       
   376         MCEMM_DEBUG( "binded stream created" )
       
   377         CleanupStack::Pop( messagestream ); 
       
   378         }
       
   379     
       
   380     MCEMM_DEBUG( "CMceMessageSdpCodec::UpdateStreamL(), Exit" )
       
   381     }
       
   382 
       
   383 // -----------------------------------------------------------------------------
       
   384 // CMceMessageSdpCodec::CreateCodecLC
       
   385 // -----------------------------------------------------------------------------
       
   386 //
       
   387 CMceComCodec* CMceMessageSdpCodec::CreateCodecLC( CSdpFmtAttributeField& /*aRtpmap*/ ) const
       
   388     {
       
   389     MCEMM_DEBUG( "CMceMessageSdpCodec::CreateCodecLC(), Entry" )
       
   390     
       
   391     CMceComCodec* codec = NULL;
       
   392 
       
   393     TPtrC8 codecName(KMceSDPNameMsrp);
       
   394         
       
   395     TMceComMessageCodecFactory factory;
       
   396     codec =  factory.CreateLC( codecName );
       
   397     
       
   398     //Junk Value for dummy msrp codec
       
   399     codec->iPayloadType = 90;  // dummy payload type + using unassigned value
       
   400     MCEMM_DEBUG_SVALUE( "created codec", codecName )
       
   401         
       
   402     MCEMM_DEBUG( "CMceMessageSdpCodec::CreateCodecLC(), Exit" )
       
   403     return codec;
       
   404     }
       
   405 
       
   406 
       
   407 // -----------------------------------------------------------------------------
       
   408 // CMceMessageSdpCodec::CreateCodecLC
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 CMceComCodec* CMceMessageSdpCodec::CreateCodecLC( TUint /*aPayload*/, 
       
   412                                                 CSdpMediaField& /*aMediaLine*/ ) const
       
   413     {
       
   414     MCEMM_DEBUG( "CMceMessageSdpCodec::CreateCodecLC( payload ), Entry" )
       
   415 
       
   416     TMceComMessageCodecFactory factory;  
       
   417     CMceComMessageCodec* codec = NULL;
       
   418     
       
   419     TUint aPayload = 90;  // dummy payload type + using unassigned value
       
   420     codec = factory.CreateCodecLC( aPayload );
       
   421     MCEMM_DEBUG( "CMceMessageSdpCodec::CreateCodecLC( payload ), Exit" )
       
   422    
       
   423     return codec;
       
   424     }
       
   425 
       
   426     
       
   427 // -----------------------------------------------------------------------------
       
   428 // CMceMessageSdpCodec::DecodeSessionMediaAttributesL
       
   429 // -----------------------------------------------------------------------------
       
   430 //
       
   431 void CMceMessageSdpCodec::DecodeSessionMediaAttributesL( CMceComMediaStream& /*aStream*/, 
       
   432                                                        CSdpDocument& /*aSdpDocument*/ ) const
       
   433     {
       
   434     MCEMM_DEBUG( "CMceMessageSdpCodec::DecodeSessionMediaAttributesL(), Entry" )
       
   435     MCEMM_DEBUG( "CMceMessageSdpCodec::DecodeSessionMediaAttributesL(), Exit" )
       
   436     }
       
   437     
       
   438 // -----------------------------------------------------------------------------
       
   439 // CMceMessageSdpCodec::CreateUplinkStreamL
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 CMceComMessageStream* CMceMessageSdpCodec::CreateUplinkStreamL() const
       
   443     {
       
   444     MCEMM_DEBUG( "CMceMessageSdpCodec::CreateUplinkStreamL(), Entry" )
       
   445     
       
   446    CMceComMessageStream *messagestream =CMceComMessageStream::NewL();
       
   447     CleanupStack::PushL( messagestream );
       
   448     // uplink           
       
   449     CMceComMessageSource* messageSource = CMceComMessageSource::NewL();
       
   450     CleanupStack::PushL( messageSource );
       
   451     //messageSource->InitializeL( static_cast<CMceComMessageStream&> ( *messagestream ) );
       
   452     messageSource->InitializeL( *messagestream);
       
   453     messagestream->SetSourceL( messageSource );
       
   454     CleanupStack::Pop( messageSource );
       
   455     CMceComMsrpSink* msrpSink = CMceComMsrpSink::NewL();
       
   456     CleanupStack::PushL( msrpSink );
       
   457     msrpSink->InitializeL( *messagestream);
       
   458     messagestream->AddSinkL( msrpSink );
       
   459     CleanupStack::Pop( msrpSink ); 
       
   460     CleanupStack::Pop( messagestream );
       
   461     
       
   462     MCEMM_DEBUG( "CMceMessageSdpCodec::CreateUplinkStreamL(), Exit" )
       
   463     
       
   464     return messagestream;
       
   465     }
       
   466 
       
   467 
       
   468 // -----------------------------------------------------------------------------
       
   469 // CMceMessageSdpCodec::CodecsL
       
   470 // -----------------------------------------------------------------------------
       
   471 //
       
   472 const RPointerArray<CMceComCodec>& CMceMessageSdpCodec::CodecsL( CMceComMediaStream& aStream ) const
       
   473     {
       
   474     __ASSERT_ALWAYS( aStream.iType == KMceMessage, User::Leave( KErrArgument ) );
       
   475     MCE_DEFINE_MESSAGE( stream, aStream );
       
   476 
       
   477     return reinterpret_cast< const RPointerArray< CMceComCodec >& >( stream.Codecs() );
       
   478     
       
   479     }
       
   480 
       
   481 
       
   482 // -----------------------------------------------------------------------------
       
   483 // CMceMessageSdpCodec::CreateDownlinkStreamL
       
   484 // -----------------------------------------------------------------------------
       
   485 //
       
   486 CMceComMessageStream* CMceMessageSdpCodec::CreateDownlinkStreamL() const
       
   487     {
       
   488     MCEMM_DEBUG( "CMceMessageSdpCodec::CreateDownlinkStreamL(), Entry" )
       
   489 
       
   490    CMceComMessageStream *messagestream =CMceComMessageStream::NewL();
       
   491     CleanupStack::PushL( messagestream ); 
       
   492     // downlink         
       
   493     CMceComMsrpSource* msrpSource = CMceComMsrpSource::NewL();
       
   494     CleanupStack::PushL( msrpSource );
       
   495     //msrpSource->InitializeL( static_cast<CMceComMessageStream&> ( *messagestream ) );
       
   496     msrpSource->InitializeL( ( *messagestream ) );
       
   497     messagestream->SetSourceL( msrpSource );
       
   498     CleanupStack::Pop( msrpSource );
       
   499     CMceComMessageSink* sink = CMceComMessageSink::NewL();
       
   500     CleanupStack::PushL( sink );
       
   501     sink->InitializeL( ( *messagestream ) );
       
   502     messagestream->AddSinkL( sink );
       
   503     CleanupStack::Pop( sink ); 
       
   504     CleanupStack::Pop( messagestream );
       
   505     
       
   506     MCEMM_DEBUG( "CMceMessageSdpCodec::CreateDownlinkStreamL(), Exit" )
       
   507     
       
   508     return messagestream;
       
   509     }
       
   510 
       
   511 
       
   512 // -----------------------------------------------------------------------------
       
   513 // CMceMessageSdpCodec::SetHostAddrFromPathAttrL
       
   514 // -----------------------------------------------------------------------------
       
   515 //
       
   516 void CMceMessageSdpCodec::SetHostAddrFromPathAttrL(const TUriC8& aMsrpUri, 
       
   517         CSdpMediaField& aMediaLine)
       
   518     {
       
   519     MCEMM_DEBUG("\n CMceMessageSdpCodec::SetHostAddrPortFromPathAttr : Entry");
       
   520     TUriParser8 parser;
       
   521     TInt parseValue = parser.Parse(aMsrpUri.UriDes()); 
       
   522     
       
   523     MCEMM_DEBUG_DVALUE("\n CMceMessageSdpCodec::SetHostAddrPortFromPathAttr: Parsed return value for MSRP URI: ", 
       
   524             parseValue);
       
   525     User::LeaveIfError(parseValue);
       
   526     TBuf8<50> host = parser.Extract(EUriHost);
       
   527     
       
   528     // check the type of the host and create the conneciton filed and insert it into the media field
       
   529     CSdpConnectionField* ConnFld = NULL;
       
   530     
       
   531     iNetType = SdpCodecStringPool::StringPoolL().StringF(SdpCodecStringConstants::ENetType,
       
   532                     SdpCodecStringPool::StringTableL());
       
   533     CleanupClosePushL(iNetType);
       
   534     
       
   535     if (UriUtils::HostType( host ) == UriUtils::ETextHost) // it is in www.example.com format
       
   536         {
       
   537         iAddressType = SdpCodecStringPool::StringPoolL().StringF(SdpCodecStringConstants::EAddressTypeIP4, 
       
   538                 SdpCodecStringPool::StringTableL());
       
   539         CleanupClosePushL(iAddressType);
       
   540         ConnFld = CSdpConnectionField::NewL(iNetType, iAddressType, host);
       
   541         }
       
   542     else
       
   543         {
       
   544         if (UriUtils::HostType( host ) == UriUtils::EIPv6Host)
       
   545             {
       
   546             iAddressType = SdpCodecStringPool::StringPoolL().StringF(SdpCodecStringConstants::EAddressType, 
       
   547                     SdpCodecStringPool::StringTableL());
       
   548             CleanupClosePushL(iAddressType);
       
   549             ConnFld = CSdpConnectionField::NewL(iNetType, iAddressType, host);
       
   550             }
       
   551         else
       
   552             {
       
   553             iAddressType = SdpCodecStringPool::StringPoolL().StringF(SdpCodecStringConstants::EAddressTypeIP4, 
       
   554                             SdpCodecStringPool::StringTableL());
       
   555             CleanupClosePushL(iAddressType);
       
   556             ConnFld = CSdpConnectionField::NewL(iNetType, iAddressType, host);
       
   557             }
       
   558         }
       
   559     __ASSERT_ALWAYS(ConnFld!=NULL, User::Leave(KErrArgument));
       
   560     CleanupStack::PushL(ConnFld);
       
   561     // clear the connecitons fileds if exists
       
   562     if (aMediaLine.ConnectionFields().Count() > 0)
       
   563         {
       
   564         CSdpConnectionField* connField = aMediaLine.ConnectionFields()[0];
       
   565         __ASSERT_ALWAYS(connField!=NULL, User::Leave(KErrArgument));
       
   566         connField->SetAddressL(iNetType, iAddressType, host);
       
   567         CleanupStack::PopAndDestroy(ConnFld);    // delete the created conneciton filed as the parameters are set in above line
       
   568         }
       
   569     else
       
   570         {
       
   571         aMediaLine.ConnectionFields().AppendL(ConnFld);
       
   572         CleanupStack::Pop(ConnFld);
       
   573         }
       
   574     
       
   575     if (iAddressType.DesC().Length()!=0)
       
   576             CleanupStack::PopAndDestroy(&iAddressType);
       
   577     
       
   578     if (iNetType.DesC().Length() != 0)
       
   579         CleanupStack::PopAndDestroy(&iNetType);
       
   580     
       
   581     
       
   582     MCEMM_DEBUG("\n CMceMessageSdpCodec::SetHostAddrPortFromPathAttr : Exit");
       
   583     }
       
   584 	
       
   585             
       
   586 // -----------------------------------------------------------------------------
       
   587 // CMceMessageSdpCodec::SetAcceptTypesAttributeL
       
   588 // -----------------------------------------------------------------------------
       
   589 //
       
   590 void CMceMessageSdpCodec::SetAcceptTypesAttributeL(CMceComMsrpSource* msrpSource, 
       
   591         CMceComMsrpSink* msrpSink, 
       
   592         CSdpMediaField& aMediaLine)
       
   593     {
       
   594     MCEMM_DEBUG( "CMceMessageSdpCodec::SetAcceptTypesAttributeL, Entry" )
       
   595     if (iAcceptTypesStr.DesC().Length() == 0 )
       
   596         {
       
   597         iAcceptTypesStr = SdpCodecStringPool::StringPoolL().
       
   598                 OpenFStringL(KMceSDPNameAcceptTypes);
       
   599         CleanupClosePushL(iAcceptTypesStr);
       
   600         }
       
   601     
       
   602     // Set accept-types attribute. 
       
   603     // If no value is provided then add * as a default value for this attribute 
       
   604     TBuf8<100> mediaTypes;
       
   605     TInt acceptTypescount = 
       
   606     msrpSource!=NULL ? msrpSource->iAcceptTypes.MdcaCount(): msrpSink->iAcceptTypes.MdcaCount();
       
   607     if (acceptTypescount == 0 )
       
   608         {
       
   609         // Default value is * . Means the applicaiton receives any type of media
       
   610         _LIT8(KStar,"*");
       
   611         mediaTypes.Append(KStar);
       
   612         }
       
   613     else
       
   614         {
       
   615         for (TInt i=0; i<acceptTypescount;i++)
       
   616             {
       
   617             mediaTypes.Append(
       
   618                     msrpSource!=NULL? (msrpSource->iAcceptTypes).MdcaPoint(i) : (msrpSink->iAcceptTypes).MdcaPoint(i));
       
   619             if (i+1 < acceptTypescount)
       
   620                 {
       
   621                 mediaTypes.Append(_L8(" "));           
       
   622                 }
       
   623             } 
       
   624         }         
       
   625     // Create the accept-types SDP attr and append this to media line
       
   626     CSdpAttributeField* acceptTypesAttr = CSdpAttributeField::NewLC( iAcceptTypesStr, mediaTypes);
       
   627     MCEMM_DEBUG_SVALUE( "accept-types Attribute :",  mediaTypes)
       
   628     aMediaLine.AttributeFields().AppendL( acceptTypesAttr );
       
   629     CleanupStack::Pop(acceptTypesAttr);
       
   630     
       
   631     if (iAcceptTypesStr.DesC().Length() != 0)
       
   632         {
       
   633         CleanupStack::PopAndDestroy(&iAcceptTypesStr);
       
   634         }
       
   635     
       
   636     MCEMM_DEBUG( "CMceMessageSdpCodec::SetAcceptTypesAttributeL, Exit" )
       
   637     }
       
   638 
       
   639 
       
   640 // -----------------------------------------------------------------------------
       
   641 // CMceMessageSdpCodec::SetPathAttributeL
       
   642 // -----------------------------------------------------------------------------
       
   643 //     
       
   644 void CMceMessageSdpCodec::SetPathAttributeL(CMceComMessageStream& aStream, 
       
   645         CMceComMsrpSource* msrpSource, 
       
   646         CMceComMsrpSink* msrpSink,
       
   647         CSdpMediaField& aMediaLine)
       
   648     {
       
   649     MCEMM_DEBUG( "CMceMessageSdpCodec::SetPathAttributeL, Entry" )
       
   650     // check if pathstr is initialized or not. if ot initialized then initialize it..
       
   651     if (iPathStr.DesC().Length() == 0 )
       
   652         {
       
   653         iPathStr = SdpCodecStringPool::StringPoolL().OpenFStringL(KMceSDPNamePath);
       
   654         CleanupClosePushL(iPathStr);
       
   655         }
       
   656     
       
   657     TInt MsrpUriCount =  msrpSource!=NULL? msrpSource->iPath.Count():msrpSink->iPath.Count(); 
       
   658          
       
   659     // Set path attribute
       
   660     HBufC8* pathValue1 = HBufC8::NewLC(200);
       
   661     TUriC8 *uri = NULL;
       
   662          
       
   663     for (TInt i=0; i<MsrpUriCount;i++)
       
   664         { 
       
   665         if (msrpSource!=NULL)
       
   666             {
       
   667             uri = msrpSource->iPath[i];
       
   668             }
       
   669         else
       
   670             {
       
   671             uri = msrpSink->iPath[i];
       
   672             }
       
   673         pathValue1->Des().Append( uri->UriDes());
       
   674                  
       
   675         if (i+1 < MsrpUriCount)
       
   676             {
       
   677             pathValue1->Des().Append(_L8(" "));
       
   678             }
       
   679         }
       
   680     if (uri != NULL)
       
   681         {
       
   682         // extract the host address only if the user configured to use the path attr for this purpose
       
   683         if (aStream.iUseMsrpPathAttrForHostAddrAndPort)
       
   684             {
       
   685             // if the realy is supported then the last entry will always indicates its own MSRP URI
       
   686             SetHostAddrFromPathAttrL(*uri, aMediaLine); 
       
   687             }
       
   688         // Create the path SDP attr and append this to media line
       
   689         CSdpAttributeField* pathAttr = CSdpAttributeField::NewLC( iPathStr, *pathValue1);                     
       
   690         MCEMM_DEBUG_SVALUE( "path Attribute value:", pathValue1->Des() )         
       
   691         aMediaLine.AttributeFields().AppendL( pathAttr );
       
   692         CleanupStack::Pop(pathAttr);
       
   693         }
       
   694     CleanupStack::PopAndDestroy(pathValue1);
       
   695     if (iPathStr.DesC().Length() != 0 )
       
   696                 CleanupStack::PopAndDestroy(&iPathStr);
       
   697     MCEMM_DEBUG( "CMceMessageSdpCodec::SetPathAttributeL, Exit" )
       
   698     }
       
   699 
       
   700 
       
   701 // -----------------------------------------------------------------------------
       
   702 // CMceMessageSdpCodec::SetAcceptWrappedAttributeL
       
   703 // -----------------------------------------------------------------------------
       
   704 //
       
   705 void CMceMessageSdpCodec::SetAcceptWrappedAttributeL(CMceComMsrpSource* msrpSource, 
       
   706         CMceComMsrpSink* msrpSink,
       
   707         CSdpMediaField& aMediaLine)
       
   708     {
       
   709     MCEMM_DEBUG( " CMceMessageSdpCodec::SetAcceptWrappedAttributeL, Entry" )
       
   710     if (iAcceptWrappedTypesStr.DesC().Length() == 0 )
       
   711         {
       
   712         iAcceptWrappedTypesStr = SdpCodecStringPool::StringPoolL().
       
   713                 OpenFStringL(KMceSDPNameAcceptWrappedTypes);
       
   714         CleanupClosePushL(iAcceptWrappedTypesStr);
       
   715         }
       
   716     
       
   717         
       
   718     //Set Accept-Wrapped-Types attribute if its setted by client.
       
   719     TBool temp = msrpSource!=NULL? msrpSource->iWrappedTypes : msrpSink->iWrappedTypes;
       
   720     
       
   721     if (temp)
       
   722         {
       
   723         TBuf8<50> wrappedTypes;
       
   724         if (msrpSource!=NULL)
       
   725             {
       
   726             wrappedTypes.Copy(msrpSource->iAcceptWrappedTypes);
       
   727             }else
       
   728                 {
       
   729                 wrappedTypes.Copy(msrpSink->iAcceptWrappedTypes);
       
   730                 }
       
   731         // Create the accept-wrapped-types SDP attr and append this to media line
       
   732         CSdpAttributeField* acceptTypesAttr = CSdpAttributeField::NewLC( iAcceptWrappedTypesStr, wrappedTypes);
       
   733         MCEMM_DEBUG_SVALUE( "accept-wrapped-types Attribute :",  wrappedTypes)
       
   734         aMediaLine.AttributeFields().AppendL( acceptTypesAttr );
       
   735         CleanupStack::Pop(acceptTypesAttr);
       
   736         }
       
   737     if (iAcceptWrappedTypesStr.DesC().Length() != 0 )
       
   738         {
       
   739         CleanupStack::PopAndDestroy(&iAcceptWrappedTypesStr);
       
   740         }
       
   741     
       
   742     MCEMM_DEBUG( " CMceMessageSdpCodec::SetAcceptWrappedAttributeL, Exit" )
       
   743     }
       
   744 
       
   745 
       
   746 // -----------------------------------------------------------------------------
       
   747 // CMceMessageSdpCodec::SetConnectionAttributeL
       
   748 // -----------------------------------------------------------------------------
       
   749 //
       
   750 void CMceMessageSdpCodec::SetConnectionAttributeL(CMceComMessageStream& aStream,
       
   751         CSdpMediaField& aMediaLine)
       
   752     {
       
   753     MCEMM_DEBUG( " CMceMessageSdpCodec::SetConnectionAttributeL, Entry" )
       
   754     __ASSERT_ALWAYS(aStream.iType == KMceMessage, User::Leave(KErrArgument));
       
   755     if (iConnectionStr.DesC().Length() == 0 )
       
   756         {
       
   757         iConnectionStr = SdpCodecStringPool::StringPoolL().
       
   758             OpenFStringL(KMceSDPNameConnection);
       
   759         CleanupClosePushL(iConnectionStr);
       
   760             }
       
   761     TBuf8<30> connAttr;
       
   762     aStream.iMsrpConnUsage ? connAttr.Append(_L8("existing")) : connAttr.Append(_L8("new"));
       
   763     // Create the connection SDP attr and append this to media line
       
   764     CSdpAttributeField* connectionAttr = CSdpAttributeField::NewLC( iConnectionStr, connAttr);
       
   765     
       
   766     aMediaLine.AttributeFields().AppendL( connectionAttr );
       
   767     CleanupStack::Pop(connectionAttr);
       
   768     
       
   769     if (iConnectionStr.DesC().Length() != 0 )
       
   770         {
       
   771         CleanupStack::PopAndDestroy(&iConnectionStr);   
       
   772         }
       
   773     MCEMM_DEBUG( " CMceMessageSdpCodec::SetConnectionAttributeL, Exit" )
       
   774     }
       
   775 
       
   776 
       
   777 
       
   778 // -----------------------------------------------------------------------------
       
   779 // CMceMessageSdpCodec::SetFileShareAttributeL
       
   780 // -----------------------------------------------------------------------------
       
   781 //
       
   782 void CMceMessageSdpCodec::SetFileShareAttributeL(CMceComMsrpSource* msrpSource, 
       
   783         CMceComMsrpSink* msrpSink,
       
   784         CSdpMediaField& aMediaLine)
       
   785     {
       
   786     MCEMM_DEBUG( " CMceMessageSdpCodec::SetFileShareAttributeL, Entry" )
       
   787 
       
   788     //Set File sharing Negotiation attributes if its called by Client.iFileShare
       
   789     if(msrpSource!=NULL ? msrpSource->iFileShare : msrpSink->iFileShare)
       
   790         {
       
   791         if ( iFileSelectorStr.DesC().Length() == 0)
       
   792             {
       
   793             iFileSelectorStr = SdpCodecStringPool::StringPoolL().OpenFStringL(KMCESDPNameFileselector);
       
   794             CleanupClosePushL(iFileSelectorStr);
       
   795             }
       
   796         // file-selector : 'name' attribute
       
   797         HBufC16* fileName = msrpSource!=NULL ? msrpSource->iFileName : msrpSink->iFileName;
       
   798         if (NULL != fileName && fileName->Des().Length())
       
   799             {
       
   800             HBufC8* fileSelector = HBufC8::NewLC(350);
       
   801             fileSelector->Des().Append(KMceSDPFileName);
       
   802             fileSelector->Des().Append('"');
       
   803             fileSelector->Des().Append(fileName->Des());
       
   804             fileSelector->Des().Append('"');
       
   805            
       
   806             TInt fileSize = 0;
       
   807             fileSize = msrpSource!=NULL ? msrpSource->iFileSize : msrpSink->iFileSize;
       
   808             if (fileSize == 0 )
       
   809                 {
       
   810                 // find file size
       
   811                 RFs fs;
       
   812                 User::LeaveIfError(fs.Connect()); 
       
   813                 TEntry entry;
       
   814                 //TBuf16<256> filenameDes;
       
   815                 //filenameDes.Copy( fileName->Des());
       
   816                 User::LeaveIfError(fs.Entry(fileName->Des(), entry));
       
   817                 fileSize = entry.iSize; 
       
   818                 fs.Close();
       
   819                 }
       
   820             fileSelector->Des().Append(KMceSDPFileSize); 
       
   821             fileSelector->Des().AppendNum(fileSize);
       
   822             
       
   823             // default file disposition value is attachment.
       
   824             
       
   825             // file-selector : 'type' attribute
       
   826             HBufC8* fileType = NULL;
       
   827             fileType = msrpSource!=NULL ? msrpSource->iFileType : msrpSink->iFileType;
       
   828             if (fileType->Des().Length())
       
   829                 {
       
   830                 fileSelector->Des().Append(KMceSDPFileType);
       
   831                 fileSelector->Des().Append(fileType->Des());
       
   832                 }
       
   833             
       
   834             // Create the file-selector SDP attribute and append this to media line
       
   835             CSdpAttributeField* fileSelectorAttr = CSdpAttributeField::NewLC( iFileSelectorStr, *fileSelector);
       
   836             MCEMM_DEBUG_SVALUE( "file-selector-types Attribute :",  fileSelector->Des())
       
   837             aMediaLine.AttributeFields().AppendL( fileSelectorAttr );
       
   838             CleanupStack::Pop(fileSelectorAttr);
       
   839             CleanupStack::PopAndDestroy(fileSelector);
       
   840             }
       
   841             
       
   842         // Set file-disposition attribute
       
   843         TBuf8<25>  dispositionValue;
       
   844         if (msrpSource!=NULL)
       
   845             {
       
   846             dispositionValue.Copy(msrpSource->iDispositionValue);
       
   847             }
       
   848         else
       
   849             {
       
   850             dispositionValue.Copy(msrpSink->iDispositionValue);
       
   851             }
       
   852         
       
   853         if (dispositionValue != KNullDesC8 )
       
   854             {
       
   855             if ( iFileDispositionStr.DesC().Length() == 0)
       
   856                 {
       
   857                 iFileDispositionStr = SdpCodecStringPool::StringPoolL().OpenFStringL(KMCESDPNameFiledisposition);
       
   858                 CleanupClosePushL(iFileDispositionStr);
       
   859                 }
       
   860             // Create the file-disposition-types SDP attr and append this to media line
       
   861             CSdpAttributeField* filedispAttr = CSdpAttributeField::NewLC( iFileDispositionStr, dispositionValue);
       
   862             MCEMM_DEBUG_SVALUE( "file-disposition-types Attribute :",  dispositionValue)
       
   863             aMediaLine.AttributeFields().AppendL( filedispAttr );
       
   864             CleanupStack::Pop(filedispAttr);
       
   865             }
       
   866             
       
   867         // Set file-transfer-id attribute
       
   868         TBuf8<32> fileTransferid;
       
   869         fileTransferid = msrpSource!=NULL?msrpSource->iFileTransferid:msrpSink->iFileTransferid;
       
   870             
       
   871         if ( fileTransferid != KNullDesC8 )
       
   872             {
       
   873             if (iFileTransferidStr.DesC().Length() == 0 )
       
   874                 {
       
   875                 iFileTransferidStr = SdpCodecStringPool::StringPoolL().
       
   876                     OpenFStringL(KMCESDPNameFiletransferid);
       
   877                 CleanupClosePushL(iFileTransferidStr);
       
   878                 }
       
   879             // Create the file-transfer-id SDP attribute and append to media line
       
   880             CSdpAttributeField* filetransferAttr = CSdpAttributeField::NewLC( iFileTransferidStr, fileTransferid);
       
   881             MCEMM_DEBUG_SVALUE( "file-transfer-id Attribute :",  fileTransferid)
       
   882             aMediaLine.AttributeFields().AppendL( filetransferAttr );
       
   883             CleanupStack::Pop(filetransferAttr);
       
   884             }
       
   885     
       
   886         if (iFileTransferidStr.DesC().Length() != 0 )
       
   887             {
       
   888             CleanupStack::PopAndDestroy(&iFileTransferidStr);
       
   889             }
       
   890     
       
   891         if ( iFileDispositionStr.DesC().Length() != 0)
       
   892             {
       
   893             CleanupStack::PopAndDestroy(&iFileDispositionStr);
       
   894             }
       
   895     
       
   896         if ( iFileSelectorStr.DesC().Length() != 0)
       
   897             {
       
   898             CleanupStack::PopAndDestroy(&iFileSelectorStr);
       
   899             }
       
   900         }
       
   901     
       
   902     MCEMM_DEBUG( " CMceMessageSdpCodec::SetFileShareAttributeL, Exit" )
       
   903     }
       
   904 
       
   905 // -----------------------------------------------------------------------------
       
   906 // CMceMediaSdpCodec::DecodeClientAttributesL
       
   907 // -----------------------------------------------------------------------------
       
   908 //
       
   909 void CMceMessageSdpCodec::DecodeClientAttributesL( 
       
   910     CSdpMediaField& aMediaLine, 
       
   911     CMceComMediaStream& aStream ) const
       
   912     {
       
   913     MCEMM_DEBUG("CMceMessageSdpCodec::DecodeClientAttributesL, Entry" )
       
   914     __ASSERT_ALWAYS(aStream.iType == KMceMessage, User::Leave(KErrArgument));
       
   915             
       
   916     CMceMediaSdpCodec::DecodeClientAttributesL(aMediaLine, aStream);
       
   917     
       
   918     CMceComMessageStream* msgStrm =(CMceComMessageStream*) (&aStream);
       
   919     
       
   920     CMceComMsrpSource* msrpSource = NULL;
       
   921     CMceComMsrpSink* msrpSink = NULL;
       
   922              
       
   923     //Decode client specific attributes and populate the source/sinks accordingly
       
   924     if (IS_RECEIVESTREAM(msgStrm))
       
   925         msrpSource = (CMceComMsrpSource*)(msgStrm->Source());
       
   926     else
       
   927         {
       
   928         for(TInt i=0; i<aStream.Sinks().Count(); i++)
       
   929             {
       
   930             if ( (aStream.Sinks())[i]->iType == KMceMSRPSink)
       
   931                 {
       
   932                 msrpSink = (CMceComMsrpSink*)( aStream.Sinks()[i]);
       
   933                 break;
       
   934                 }
       
   935             }
       
   936         }
       
   937         
       
   938     CBufFlat* encodeBuf = NULL;
       
   939         
       
   940     for ( TInt i = 0; i < aMediaLine.AttributeFields().Count(); i++ )
       
   941         {
       
   942         encodeBuf = CBufFlat::NewL( KMceExternalizeBufferExpandSize );
       
   943         CleanupStack::PushL( encodeBuf );
       
   944         RBufWriteStream writeStream( *encodeBuf, 0 );
       
   945         writeStream.PushL();
       
   946         
       
   947         // extract the MSRP path attribute if it exists 
       
   948         aMediaLine.AttributeFields()[ i ]->EncodeL( writeStream );
       
   949         MCEMM_DEBUG_SVALUE( "found attribute", encodeBuf->Ptr( 0 ) )
       
   950         TInt aPath = encodeBuf->Ptr(0).FindC(_L8("Path:"));
       
   951         if(aPath != KErrNotFound)
       
   952             {
       
   953             TInt length = encodeBuf->Ptr(0).Size();
       
   954             aStream.iRemoteMsrpPath = encodeBuf->Ptr(0).Mid(aPath+5, length-aPath-5-2);
       
   955             }
       
   956         
       
   957         // Extracts the connection setup accribute and set it if it exists
       
   958         TInt aSetup = encodeBuf->Ptr(0).FindC(_L8("setup:"));
       
   959         if(aSetup != KErrNotFound)
       
   960             {
       
   961             TInt length = encodeBuf->Ptr(0).Size();
       
   962             aStream.iConnStatus = encodeBuf->Ptr(0).Mid(aSetup+6, length-aSetup-6-2);
       
   963             }
       
   964         
       
   965         //extract the file sharing attributes and set them accordingly
       
   966         TInt fileSelectorId = encodeBuf->Ptr(0).FindC(_L8("file-selector:"));
       
   967         if ( fileSelectorId != KErrNotFound)
       
   968             {
       
   969             HBufC16* fileName = HBufC::NewL(256);
       
   970             TBuf8<50> fileSize;
       
   971             HBufC8* fileType = HBufC8::NewL(256);
       
   972             
       
   973             // Get file name, file size and file type.
       
   974             // look for name, type and size parameters
       
   975             TPtr8 fileSelectorData =  encodeBuf->Ptr(14);
       
   976             TInt nameIndex = encodeBuf->Ptr(0).FindC(_L8("name:"));
       
   977             if (nameIndex >= 0)
       
   978                 {
       
   979                 TPtr8 nameBuf = encodeBuf->Ptr(nameIndex);
       
   980                 //nameBuf.Copy (encodeBuf->Ptr(nameIndex) );
       
   981                 TInt spaceOffset = nameBuf.Locate(' ') ;
       
   982                 if (spaceOffset != KErrNotFound )
       
   983                     {
       
   984                     fileName->Des().Copy(nameBuf.Mid(6, (spaceOffset-6-1 ))/*, (spaceOffset-6-1 )*/ );
       
   985                     }else
       
   986                         {
       
   987                         TInt crlfOffset = nameBuf.FindC(_L8("\r\n") ) ;
       
   988                         if (crlfOffset != KErrNotFound )
       
   989                             {
       
   990                             fileName->Des().Copy(nameBuf.Mid(6, (crlfOffset-6-1 ))/*, (crlfOffset-6-1 )*/);
       
   991                             }
       
   992                         }
       
   993                 }
       
   994             // Find the file size if exists in the file selector
       
   995             TInt fileSizeIndex =  encodeBuf->Ptr(0).FindC(_L8("size:"));
       
   996             if (fileSizeIndex >= 0 && fileSizeIndex < encodeBuf->Size())
       
   997                 {
       
   998                 TPtr8 sizeBuf = encodeBuf->Ptr(fileSizeIndex);
       
   999                 TInt spaceOffset = sizeBuf.Locate(' ') ;
       
  1000                 if (spaceOffset != KErrNotFound)
       
  1001                     {
       
  1002                     fileSize.Copy( sizeBuf.Mid(5, spaceOffset-5));
       
  1003                     }else
       
  1004                         {
       
  1005                         TInt crlfOffset = sizeBuf.FindC(_L8("\r\n") ) ;
       
  1006                         if (crlfOffset != KErrNotFound )
       
  1007                             {
       
  1008                             fileSize.Copy(sizeBuf.Mid(5, (crlfOffset-5 )));
       
  1009                             }
       
  1010                         }
       
  1011                     }
       
  1012             
       
  1013             // Find the file type if exists in file selector
       
  1014             TInt fileTypeIndex =  encodeBuf->Ptr(0).FindC(_L8("type:"));
       
  1015             if (fileTypeIndex >=0 && fileTypeIndex < encodeBuf->Size())
       
  1016                 {
       
  1017                 TPtr8 typeBuf = encodeBuf->Ptr(fileTypeIndex);
       
  1018                 TInt spaceOffset = typeBuf.Locate(' ') ;
       
  1019                 if (spaceOffset != KErrNotFound)
       
  1020                     {
       
  1021                     fileType->Des().Copy(typeBuf.Mid(5, spaceOffset-5));
       
  1022                     }else
       
  1023                         {
       
  1024                         TInt crlfOffset = typeBuf.FindC(_L8("\r\n") ) ;
       
  1025                         if (crlfOffset != KErrNotFound )
       
  1026                             {
       
  1027                             fileType->Des().Copy( typeBuf.Mid(5, (crlfOffset-5 )) );
       
  1028                             }
       
  1029                         }
       
  1030                 }
       
  1031                 if (NULL != msrpSource )
       
  1032                     {
       
  1033                     msrpSource->iFileName = fileName;
       
  1034                     msrpSource->iFileType = fileType;
       
  1035                     TLex8 lex(fileSize);
       
  1036                     lex.Val(msrpSource->iFileSize);
       
  1037                     msrpSource->iFileShare = ETrue;
       
  1038                     }
       
  1039                 else
       
  1040                     {
       
  1041                     msrpSink->iFileName = fileName;
       
  1042                     msrpSink->iFileType =  fileType;
       
  1043                     TLex8 lex(fileSize);
       
  1044                     lex.Val(msrpSink->iFileSize);
       
  1045                     msrpSink->iFileShare = ETrue;
       
  1046                     }
       
  1047                 }
       
  1048         
       
  1049         // look for the file-transfer-id
       
  1050         TInt fileTransferID= encodeBuf->Ptr(0).FindC(_L8("file-transfer-id:"));
       
  1051         if ( fileTransferID != KErrNotFound)
       
  1052             {
       
  1053             TBuf8<32> fileTransferid;
       
  1054             
       
  1055             TInt length = encodeBuf->Ptr(0).Size();
       
  1056             fileTransferid = encodeBuf->Ptr(0).Mid(fileTransferID+17, length-fileTransferID-17-2);
       
  1057             // the code is pending
       
  1058             if (NULL != msrpSource)
       
  1059                 msrpSource->iFileTransferid = fileTransferid;
       
  1060             else
       
  1061                 msrpSink->iFileTransferid = fileTransferid;
       
  1062             }
       
  1063         
       
  1064         CleanupStack::PopAndDestroy(); // writeStream
       
  1065         CleanupStack::PopAndDestroy( encodeBuf ); // encodeBuf
       
  1066         }
       
  1067     MCEMM_DEBUG("CMceMessageSdpCodec::DecodeClientAttributesL, Exit" )
       
  1068     }
       
  1069 	
       
  1070 	
       
  1071 	// -----------------------------------------------------------------------------
       
  1072 // CMceMessageSdpCodec::CreateFormatListL
       
  1073 // -----------------------------------------------------------------------------
       
  1074 //
       
  1075 HBufC8* CMceMessageSdpCodec::CreateFormatListL( CMceComCodec::TIterator& /*aCodecs*/ ) const
       
  1076     {
       
  1077     MCEMM_DEBUG("CMceMessageSdpCodec::CreateFmtListL(), Entry ")
       
  1078         
       
  1079     HBufC8* fmtList = HBufC8::NewL( KMceSdpFormatListLength );
       
  1080     TPtr8 fmtListPtr( fmtList->Des() );
       
  1081     
       
  1082     // codecs can be NULL if the data path is being taken care by the applicaiton
       
  1083     // irrespective of codecs the format list for message stream should be *
       
  1084     _LIT8(KSdpFmtListValueStar,"*");
       
  1085     fmtListPtr.Append(KSdpFmtListValueStar); 
       
  1086     
       
  1087     MCEMM_DEBUG("CMceMessageSdpCodec::CreateFmtListL(), Exit ")
       
  1088         
       
  1089     return fmtList;
       
  1090     }
       
  1091 	
       
  1092 	// -----------------------------------------------------------------------------
       
  1093 // CMceMessageSdpCodec::DecodeStaticPayloadsL
       
  1094 // -----------------------------------------------------------------------------
       
  1095 //
       
  1096 TInt CMceMessageSdpCodec::DecodeStaticPayloadsL( CSdpMediaField& aMediaLine,
       
  1097                 CMceComMediaStream& aStream,
       
  1098                 RArray<TUint>& aPayloadTypes,
       
  1099                 TMceNegotiationRole aRole ) const
       
  1100     {
       
  1101     MCEMM_DEBUG("CMceMediaSdpCodec::DecodeStaticPayloadsL(), Entry ")
       
  1102     TInt decoded = 0;
       
  1103 
       
  1104     DecodeFormatListL( aMediaLine, aPayloadTypes );
       
  1105     TInt index = 0;
       
  1106     
       
  1107     if ( IS_SENDSTREAM(&aStream))
       
  1108                 {
       
  1109                 if ( (aStream.Source()->Type() == KMceExternalSource) ||
       
  1110                         (aStream.Source()->Type() == KMceMessageSource)  )
       
  1111                     {
       
  1112                     decoded++;
       
  1113                     return decoded;
       
  1114                     }
       
  1115                 }else
       
  1116                     {
       
  1117                     for (TInt i=0; i<aStream.Sinks().Count();i++)
       
  1118                         {
       
  1119                         if ( (aStream.Sinks()[i]->Type() == KMceExternalSink) ||
       
  1120                                 (aStream.Sinks()[i]->Type() == KMceMSRPSink) )
       
  1121                             {
       
  1122                             decoded++;
       
  1123                             return decoded;
       
  1124                             }
       
  1125                         }
       
  1126                     }
       
  1127     
       
  1128     while( index < aPayloadTypes.Count() )
       
  1129         {
       
  1130         TUint payload = aPayloadTypes[ index++ ];
       
  1131         if ( payload < KMinDynamicPT )
       
  1132             {
       
  1133             CMceComCodec* codec = FindCodec( payload, aStream );
       
  1134             if ( aRole == EMceRoleAnswerer )
       
  1135                 {
       
  1136                 if ( !codec )
       
  1137                     {
       
  1138                     codec = CreateCodecLC( payload, aMediaLine );
       
  1139                     if ( codec )
       
  1140                         {
       
  1141                         codec->InitializeL( aStream );
       
  1142                         codec->iIsNegotiated = ETrue;
       
  1143                         MCEMM_DEBUG_SVALUE("adding codec", codec->iSdpName )
       
  1144                         aStream.AddCodecL( codec );
       
  1145                         CleanupStack::Pop( codec );
       
  1146                         decoded++;
       
  1147                         }
       
  1148                     }
       
  1149                 else
       
  1150                     {
       
  1151                     codec->iIsNegotiated = ETrue;
       
  1152                     decoded++;
       
  1153                     }
       
  1154                 }
       
  1155             else if ( codec && aRole == EMceRoleOfferer )
       
  1156                 {
       
  1157                 codec->iIsNegotiated = ETrue;
       
  1158                 decoded++;
       
  1159                 }
       
  1160             }
       
  1161         }
       
  1162         
       
  1163     MCEMM_DEBUG_DVALUE("decoded codecs", decoded )
       
  1164     MCEMM_DEBUG("CMceMediaSdpCodec::DecodeStaticPayloadsL(), Exit ")
       
  1165     return decoded;
       
  1166     }
       
  1167 	
       
  1168 	// -----------------------------------------------------------------------------
       
  1169 // CMceMediaSdpCodec::DecodeFormatListL
       
  1170 // -----------------------------------------------------------------------------
       
  1171 //
       
  1172 void CMceMessageSdpCodec::DecodeFormatListL( 
       
  1173     CSdpMediaField& aMedia, 
       
  1174     RArray<TUint>& aPayloadTypes ) const
       
  1175     {
       
  1176     MCEMM_DEBUG("CMceMessageSdpCodec::DecodeFormatListL(), Entry ")
       
  1177     
       
  1178     User::LeaveIfError( DecodeFormatList( aMedia, aPayloadTypes ) );
       
  1179         
       
  1180     MCEMM_DEBUG("CMceMessageSdpCodec::DecodeFormatListL(), Exit ")   
       
  1181     }
       
  1182 
       
  1183 
       
  1184 // -----------------------------------------------------------------------------
       
  1185 // CMceMessageSdpCodec::DecodeFormatList
       
  1186 // -----------------------------------------------------------------------------
       
  1187 //
       
  1188 TInt CMceMessageSdpCodec::DecodeFormatList( CSdpMediaField& aMedia, 
       
  1189                                RArray<TUint>& aPayloadTypes ) const
       
  1190     {
       
  1191     MCEMM_DEBUG("CMceMessageSdpCodec::DecodeFormatList(), Entry ")
       
  1192     
       
  1193     const TDesC8& payloadlist = aMedia.FormatList();
       
  1194     MCEMM_DEBUG_SVALUE( "decoded format list", payloadlist )
       
  1195     TLex8 payloads( payloadlist );
       
  1196     TInt error = KErrNone;
       
  1197     //  Validate the formalist list if it is *
       
  1198     if (payloadlist.Compare(_L8("*")) == 0 )
       
  1199         {
       
  1200         TUint msrpPayloadtype = 90; // dummy payload type + using unassigned value
       
  1201         error = aPayloadTypes.Append( msrpPayloadtype );
       
  1202         MCEMM_DEBUG("CMceMessageSdpCodec::DecodeFormatList(), Exit ") 
       
  1203         return error;   
       
  1204         } 
       
  1205     else
       
  1206         {
       
  1207         return KErrNotSupported;
       
  1208         }
       
  1209     }
       
  1210