multimediacommsengine/mmceshared/src/mcecomaudiocodec.cpp
changeset 0 1bce908db942
child 30 4c9e1ec7a69e
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     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 
       
    21 #include "mcecomaudiocodec.h"
       
    22 #include "mceamrcodec.h"
       
    23 #include "mceg711codec.h"   
       
    24 #include "mceg729codec.h"    
       
    25 #include  "mceilbccodec.h"  
       
    26 
       
    27 #include "mceserial.h"
       
    28 #include "mceevents.h"
       
    29 
       
    30 #include "mcecomrtpsource.h"
       
    31 #include "mcertpsource.h"
       
    32 
       
    33 #ifdef MCE_COMMON_SERVER_SIDE
       
    34 
       
    35 #include <mmcccodecinformation.h>
       
    36 #include "mcesrvstream.h"
       
    37 #include "mcesrvsource.h"
       
    38 #include "mcemmlogs.h"
       
    39 
       
    40 #endif//MCE_COMMON_SERVER_SIDE
       
    41 
       
    42 // CONSTANTS
       
    43 const TUint KMceSamplingFreq8000 = 8000;
       
    44 
       
    45 // ============================ MEMBER FUNCTIONS ===============================
       
    46 
       
    47     
       
    48 // -----------------------------------------------------------------------------
       
    49 // CMceComAudioCodec::NewL
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CMceComAudioCodec* CMceComAudioCodec::NewL( TBuf8<KMceMaxSdpNameLength> aSdpName )
       
    53     {
       
    54     CMceComAudioCodec* self = NewLC( aSdpName );
       
    55     CleanupStack::Pop( self );
       
    56     return self;
       
    57     
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CMceComAudioCodec::NewLC
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CMceComAudioCodec* CMceComAudioCodec::NewLC( TBuf8<KMceMaxSdpNameLength> aSdpName )
       
    65     {
       
    66     CMceComAudioCodec* self = new (ELeave) CMceComAudioCodec();
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL( aSdpName );
       
    69     return self;
       
    70     }
       
    71 
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CMceComAudioCodec::~CMceComAudioCodec
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 CMceComAudioCodec::~CMceComAudioCodec()
       
    78     {
       
    79     }
       
    80     
       
    81 // -----------------------------------------------------------------------------
       
    82 // CMceComAudioCodec::CMceComAudioCodec
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 CMceComAudioCodec::CMceComAudioCodec()
       
    86   : CMceComCodec(),
       
    87     iEnableVAD( EFalse ),
       
    88     iSamplingFreq( 0 ),
       
    89     iPTime( 0 ),
       
    90     iMaxPTime( 0 ),
       
    91     iRedPayloadType( KMcePayloadTypeUndefined ),
       
    92     iRedCount( 0 ),
       
    93     iComfortNoiseEnabled( EFalse )
       
    94     {
       
    95     }
       
    96 
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CMceComAudioCodec::ConstructL
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 CMceComAudioCodec* CMceComAudioCodec::CloneL()
       
   103     {
       
   104     CMceComAudioCodec* copy = new (ELeave) CMceComAudioCodec();
       
   105     CleanupStack::PushL( copy );
       
   106     copy->ConstructL( *this );
       
   107     CleanupStack::Pop( copy );
       
   108     return copy;
       
   109     
       
   110     }
       
   111 
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CMceComAudioCodec::ConstructL
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void CMceComAudioCodec::ConstructL( TBuf8<KMceMaxSdpNameLength> aSdpName )
       
   118     {
       
   119     CMceComCodec::ConstructL( aSdpName );
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CMceComAudioCodec::ConstructL
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 void CMceComAudioCodec::ConstructL( CMceComAudioCodec& aCodec )
       
   127     {
       
   128     CMceComCodec::ConstructL( aCodec );
       
   129     
       
   130     iEnableVAD = aCodec.iEnableVAD;
       
   131 	iSamplingFreq = aCodec.iSamplingFreq;	
       
   132 	iPTime = aCodec.iPTime;
       
   133 	iMaxPTime = aCodec.iMaxPTime;
       
   134 	
       
   135 	iRedPayloadType = aCodec.iRedPayloadType;
       
   136     iRedCount = aCodec.iRedCount;
       
   137     iComfortNoiseEnabled = aCodec.iComfortNoiseEnabled;
       
   138     }
       
   139 
       
   140 
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CMceComAudioCodec::InternalizeFlatL
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 void CMceComAudioCodec::InternalizeFlatL( RReadStream& aReadStream )
       
   147     {
       
   148     CMceComCodec::InternalizeFlatL( aReadStream );
       
   149     
       
   150     iEnableVAD = static_cast<TBool>( aReadStream.ReadUint8L() );
       
   151 	iSamplingFreq = aReadStream.ReadUint16L();
       
   152 	iPTime = aReadStream.ReadUint16L();
       
   153 	iMaxPTime = aReadStream.ReadUint16L();
       
   154 	
       
   155 	iRedPayloadType = aReadStream.ReadUint8L();
       
   156 	iRedCount = aReadStream.ReadUint16L();
       
   157 	iComfortNoiseEnabled = static_cast<TBool>( aReadStream.ReadUint8L() );
       
   158     }
       
   159     
       
   160 // -----------------------------------------------------------------------------
       
   161 // CMceComAudioCodec::ExternalizeFlatL
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 void CMceComAudioCodec::ExternalizeFlatL( RWriteStream& aWriteStream )
       
   165     {
       
   166     CMceComCodec::ExternalizeFlatL( aWriteStream );
       
   167     
       
   168     aWriteStream.WriteUint8L( iEnableVAD );
       
   169     aWriteStream.WriteUint16L( iSamplingFreq );
       
   170     aWriteStream.WriteUint16L( iPTime );
       
   171     aWriteStream.WriteUint16L( iMaxPTime ); 
       
   172     
       
   173     aWriteStream.WriteUint8L( iRedPayloadType );
       
   174     aWriteStream.WriteUint16L( iRedCount ); 
       
   175     aWriteStream.WriteUint8L( iComfortNoiseEnabled );
       
   176     }
       
   177 
       
   178 
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CMceComAudioCodec::UpdateL
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 void CMceComAudioCodec::UpdateL( CMceComCodec& aUpdate )
       
   185     {
       
   186     CMceComCodec::UpdateL( aUpdate );
       
   187 
       
   188     CMceComAudioCodec& update = static_cast<CMceComAudioCodec&>( aUpdate );
       
   189 
       
   190     iEnableVAD = update.iEnableVAD;
       
   191     iSamplingFreq = update.iSamplingFreq;
       
   192     
       
   193     if ( IS_RECEIVESTREAM( iStream ) )
       
   194         {
       
   195         iPTime = update.iPTime;
       
   196         iMaxPTime = update.iMaxPTime;
       
   197         }
       
   198         
       
   199     iRedPayloadType = update.iRedPayloadType;
       
   200     iRedCount = update.iRedCount;
       
   201     iComfortNoiseEnabled = update.iComfortNoiseEnabled;
       
   202     }
       
   203 
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CMceComAudioCodec::Factory
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 TMceComAudioCodecFactory CMceComAudioCodec::Factory()
       
   210     {
       
   211     return TMceComAudioCodecFactory();
       
   212     }
       
   213 
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // CMceComAudioCodec::CompareSdpIndex
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 TInt CMceComAudioCodec::CompareSdpIndex( 
       
   220     const CMceComAudioCodec& aIndex1, const CMceComAudioCodec& aIndex2 )
       
   221     {
       
   222     // NOTE: if zero (equals) is returned from here, order is strangely anyway
       
   223     // changed. Returning positive value if indexes are equal is for avoiding
       
   224     // this quirk.
       
   225 
       
   226     if ( aIndex1.iCodecSdpIndex >= aIndex2.iCodecSdpIndex )
       
   227         {
       
   228         return (1);
       
   229         }
       
   230     else if ( aIndex1.iCodecSdpIndex < aIndex2.iCodecSdpIndex )
       
   231         {
       
   232         return (-1);
       
   233         }
       
   234     else
       
   235         {
       
   236         return (0);
       
   237         }
       
   238     }
       
   239 
       
   240 
       
   241 // -----------------------------------------------------------------------------
       
   242 // CMceComAudioCodec::SetSamplingFreq
       
   243 // -----------------------------------------------------------------------------
       
   244 //
       
   245 TInt CMceComAudioCodec::SetSamplingFreq( TUint aSamplingFreq )
       
   246     {
       
   247     if ( KMceSamplingFreq8000 == aSamplingFreq )
       
   248         {
       
   249         iSamplingFreq = aSamplingFreq;
       
   250         return KErrNone;
       
   251         }
       
   252     else
       
   253         {
       
   254         return KErrNotSupported;
       
   255         }
       
   256     }
       
   257 
       
   258 
       
   259 // -----------------------------------------------------------------------------
       
   260 // CMceComAudioCodec::SetPTime
       
   261 // -----------------------------------------------------------------------------
       
   262 //
       
   263 TInt CMceComAudioCodec::SetPTime( TUint aPTime )
       
   264     {
       
   265     if ( ( 0 < aPTime ) && ( aPTime <= iMaxPTime ) )
       
   266         {
       
   267         iPTime = aPTime;
       
   268         return KErrNone;
       
   269         }
       
   270     else
       
   271         {
       
   272         return KErrNotSupported;
       
   273         }
       
   274     }
       
   275 
       
   276 
       
   277 // -----------------------------------------------------------------------------
       
   278 // CMceComAudioCodec::SetMaxPTime
       
   279 // -----------------------------------------------------------------------------
       
   280 //
       
   281 TInt CMceComAudioCodec::SetMaxPTime( TUint aMaxPTime )
       
   282     {
       
   283     if ( ( 0 < aMaxPTime ) && ( iPTime <= aMaxPTime ) )
       
   284         {
       
   285         iMaxPTime = aMaxPTime;
       
   286         return KErrNone;
       
   287         }
       
   288     else
       
   289         {
       
   290         return KErrNotSupported;
       
   291         }
       
   292     }
       
   293 
       
   294 #ifdef MCE_COMMON_SERVER_SIDE
       
   295 
       
   296 
       
   297 // -----------------------------------------------------------------------------
       
   298 // CMceComAudioCodec::operator=
       
   299 // -----------------------------------------------------------------------------
       
   300 //
       
   301 /*lint -e1539 */
       
   302 CMceComCodec& CMceComAudioCodec::operator=( CMccCodecInformation& aMccCodec )
       
   303     {
       
   304 
       
   305 	iPayloadType = aMccCodec.PayloadType();
       
   306 	iBitrate = aMccCodec.Bitrate();
       
   307 	iAllowedBitrates = aMccCodec.AllowedBitrates();
       
   308 	iCodecMode = aMccCodec.CodecMode();
       
   309 	iFourCC = aMccCodec.FourCC();
       
   310 	iFrameSize = aMccCodec.FrameSize();
       
   311 
       
   312     iEnableVAD = aMccCodec.VAD();
       
   313 	iSamplingFreq = aMccCodec.SamplingFreq();
       
   314 	iPTime = aMccCodec.PTime();
       
   315 	iMaxPTime = aMccCodec.MaxPTime();
       
   316 	
       
   317 	iRedPayloadType = aMccCodec.RedundancyPT();
       
   318 	iRedCount = aMccCodec.RedCount();
       
   319 	iComfortNoiseEnabled = 
       
   320 	    ( aMccCodec.ComfortNoiseGeneration() != KPayloadTypeUndefined );
       
   321     return *this;
       
   322     
       
   323     }
       
   324     
       
   325 // -----------------------------------------------------------------------------
       
   326 // CMceComAudioCodec::DoMccDecodeL
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 void CMceComAudioCodec::DoMccDecodeL( CMccCodecInformation& aMccCodec )
       
   330     {
       
   331     //copy values, which are not explicitely in SDP, from mcc codec
       
   332 	iSamplingFreq = aMccCodec.SamplingFreq();
       
   333 	
       
   334 	iBitrate = aMccCodec.Bitrate();
       
   335 	iRedPayloadType = aMccCodec.RedundancyPT();
       
   336 	iRedCount = aMccCodec.RedCount();
       
   337 	iComfortNoiseEnabled = aMccCodec.ComfortNoiseGeneration();
       
   338 	//copy the value of VAD which are received from MO side
       
   339 	iEnableVAD = aMccCodec.VAD();
       
   340     }
       
   341 
       
   342 // -----------------------------------------------------------------------------
       
   343 // CMceComAudioCodec::DoMccEncodeL
       
   344 // -----------------------------------------------------------------------------
       
   345 //
       
   346 void CMceComAudioCodec::DoMccEncodeL( CMccCodecInformation& aMccCodec,
       
   347                                       CMceSrvStream& aStream )
       
   348     {
       
   349     User::LeaveIfError( aMccCodec.SetSamplingFreq( iSamplingFreq ) );
       
   350     
       
   351     // Packet times are negotiated at session or media line level but all 
       
   352     // codecs in a group may not support all packet times. In this case 
       
   353     // codec's defaults are taken into use so that session negotiation is not 
       
   354     // unnecessary failed.
       
   355     if ( KErrNone != aMccCodec.SetMaxPTime( iMaxPTime ) )
       
   356         {
       
   357 	    iMaxPTime = aMccCodec.MaxPTime();
       
   358 	    }
       
   359     
       
   360     if ( KErrNone != aMccCodec.SetPTime( iPTime ) )
       
   361         {
       
   362         iPTime = aMccCodec.PTime();
       
   363         }
       
   364     
       
   365     User::LeaveIfError( aMccCodec.EnableVAD( iEnableVAD ) );
       
   366     User::LeaveIfError( aMccCodec.SetBitrate( iBitrate ) );
       
   367     
       
   368     if ( aStream.Source().Data().iType == KMceRTPSource )
       
   369         {
       
   370         CMceComRtpSource& rtpSource = 
       
   371 		    static_cast<CMceComRtpSource&> ( aStream.Source().Data() );
       
   372 		
       
   373 		User::LeaveIfError( 
       
   374     	    aMccCodec.SetJitterBufInactivityTimeOut( rtpSource.iInactivityTimer ) );
       
   375     	User::LeaveIfError( 
       
   376     	    aMccCodec.SetJitterBufThreshold( rtpSource.iBufferTreshold ) );
       
   377     	User::LeaveIfError( 
       
   378     	    aMccCodec.SetJitterBufBufferLength( rtpSource.iBufferLength ) );
       
   379         }
       
   380     
       
   381     DoMccEncodeComfortNoiseL( aMccCodec, aStream );
       
   382     DoMccEncodeRedundancyL( aMccCodec, aStream );
       
   383     }
       
   384 
       
   385 
       
   386 // -----------------------------------------------------------------------------
       
   387 // CMceComAudioCodec::DoMccValidateL
       
   388 // -----------------------------------------------------------------------------
       
   389 //
       
   390 CMceComCodec* CMceComAudioCodec::DoMccValidateL( CMccCodecInformation& aMccCodec,
       
   391                                                  CMceSrvStream& aStream,
       
   392                                                  TMceNegotiationRole aRole )
       
   393     {
       
   394     //if answerer mcc codec represents the received offer and codec the answer
       
   395     //if offerer codec represents the sent offer and mcc codec the answer
       
   396     TBool notValid = aRole == EMceRoleAnswerer ?
       
   397                   ( iAllowedBitrates && aMccCodec.AllowedBitrates() == 0 ||
       
   398 	                iAllowedBitrates > aMccCodec.AllowedBitrates() ) :
       
   399                   ( iAllowedBitrates && aMccCodec.AllowedBitrates() == 0 ||
       
   400 	                iAllowedBitrates < aMccCodec.AllowedBitrates() );
       
   401 	
       
   402 	User::LeaveIfError( notValid ? KErrNotSupported : KErrNone );
       
   403 	//Explicitly call default implementation of DoMccValidateL in base class
       
   404 	// to enable the check for codecMode
       
   405 	return CMceComCodec::DoMccValidateL( aMccCodec, aStream, aRole);  
       
   406     }
       
   407     
       
   408 // -----------------------------------------------------------------------------
       
   409 // CMceComAudioCodec::DoMccRequireSignalling
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 TInt CMceComAudioCodec::DoMccRequireSignalling( 
       
   413     const CMceSrvStream& aStream,
       
   414     const CMccCodecInformation& aMccCurentCodec, 
       
   415     const CMccCodecInformation& aMccUpdateCodec ) const
       
   416     {
       
   417     TInt action = KMceNoSignalling;
       
   418 
       
   419     if ( aStream.StreamType() == CMceComMediaStream::EReceiveStream ||
       
   420          aStream.StreamType() == CMceComMediaStream::EReceiveOnlyStream )
       
   421         {
       
   422         if ( aMccCurentCodec.PTime() != aMccUpdateCodec.PTime() ||
       
   423              aMccCurentCodec.MaxPTime() != aMccUpdateCodec.MaxPTime() )
       
   424             {
       
   425             action = KMceRequiresSignalling;
       
   426             }
       
   427         }
       
   428         
       
   429     return action;
       
   430     
       
   431     }
       
   432     
       
   433 // -----------------------------------------------------------------------------
       
   434 // CMceComAudioCodec::DoMccAdjustL
       
   435 // -----------------------------------------------------------------------------
       
   436 //
       
   437 void CMceComAudioCodec::DoMccAdjustL( CMccCodecInformation& aMccCodec,
       
   438                                       CMceSrvStream& aStream )
       
   439     {
       
   440 	if( aStream.Data().iStreamType == CMceComMediaStream::ESendStream ||
       
   441         aStream.Data().iStreamType == CMceComMediaStream::ESendOnlyStream )
       
   442 		{
       
   443 	    // Do nothing if iPTime or iMaxPTime is greater than codecs supports.
       
   444 	    // Then codecs default values is used.
       
   445 		aMccCodec.SetPTime( iPTime );
       
   446 		aMccCodec.SetMaxPTime( iMaxPTime );
       
   447 		User::LeaveIfError( aMccCodec.SetBitrate( iBitrate ) );
       
   448 		
       
   449 		DoMccEncodeComfortNoiseL( aMccCodec, aStream );
       
   450 		}
       
   451     }
       
   452 
       
   453 // -----------------------------------------------------------------------------
       
   454 // CMceComAudioCodec::DoSetDefaultFmtpAttributeL
       
   455 // -----------------------------------------------------------------------------
       
   456 //
       
   457 void CMceComAudioCodec::DoSetDefaultFmtpAttributeL()
       
   458     {
       
   459     // NOP
       
   460     }
       
   461 
       
   462 // -----------------------------------------------------------------------------
       
   463 // CMceComAudioCodec::DoDecodeAudioL
       
   464 // -----------------------------------------------------------------------------
       
   465 //
       
   466 
       
   467 void CMceComAudioCodec::DoDecodeAudioL( 
       
   468     TInt aCodecIndex,
       
   469     RPointerArray<CMceSrvStream>& aStreams,
       
   470     CMceComAudioStream& aAudio,
       
   471     CMceMediaManager& aManager )
       
   472     {
       
   473     if ( aCodecIndex == 0 || IS_RECEIVESTREAM( &aAudio ) )
       
   474         {
       
   475         SetEnabled( ETrue );
       
   476         }
       
   477 
       
   478     for( TInt sinkNdx = 0; sinkNdx < aAudio.Sinks().Count(); sinkNdx++ )
       
   479         {
       
   480         CMceSrvStream* srvStream = 
       
   481             CMceSrvStream::NewL( aManager, 
       
   482                                  aAudio, 
       
   483                                  *aAudio.Source(),
       
   484                                  *aAudio.Sinks()[ sinkNdx ],
       
   485                                  *this );
       
   486         CleanupStack::PushL( srvStream );
       
   487         MCEMM_DEBUG_STREAM( "CMceComAudioCodec::DoDecodeAudioL(): decoded audio", 
       
   488                             *srvStream );
       
   489         aStreams.AppendL( srvStream );
       
   490         CleanupStack::Pop( srvStream );
       
   491         } 
       
   492     }
       
   493 
       
   494 // -----------------------------------------------------------------------------
       
   495 // CMceComAudioCodec::DoMccEncodeComfortNoiseL
       
   496 // -----------------------------------------------------------------------------
       
   497 //
       
   498 void CMceComAudioCodec::DoMccEncodeComfortNoiseL( 
       
   499     CMccCodecInformation& aMccCodec,
       
   500     CMceSrvStream& aStream )
       
   501     {
       
   502     // If CN codec is not anymore present in session, disable comfort noise
       
   503     // generation from this codec.
       
   504     CMceComAudioCodec* searchCodec = Factory().CreateCodecLC( KMceSDPNameCn() );
       
   505     
       
   506     CMceComCodec* cnCodec = aStream.Data().FindCodecL( *searchCodec );
       
   507     
       
   508     iComfortNoiseEnabled = cnCodec ? cnCodec->iIsNegotiated : EFalse;
       
   509     
       
   510     // KPayloadTypeUndefined is used if cn is disabled   
       
   511     TUint8 comforNoisePt = 
       
   512         iComfortNoiseEnabled ? cnCodec->iPayloadType : KPayloadTypeUndefined;
       
   513     
       
   514     // If cn is disabled, handle removing the codec here
       
   515     if ( !iComfortNoiseEnabled )
       
   516     	{
       
   517     	aStream.Data().RemoveCodecL( cnCodec );
       
   518     	if ( aStream.Data().BoundStream() )
       
   519             {
       
   520             CMceComCodec* boundCnCodec = 
       
   521             	aStream.Data().BoundStreamL().FindCodecL( *searchCodec );
       
   522             	
       
   523            	aStream.Data().BoundStreamL().RemoveCodecL( boundCnCodec );
       
   524             }
       
   525     	}
       
   526     	
       
   527     CleanupStack::PopAndDestroy( searchCodec );
       
   528     
       
   529     // All codecs do not necessarily support cn, ignore errors
       
   530     aMccCodec.SetComfortNoiseGeneration( comforNoisePt );
       
   531     }
       
   532 
       
   533 // -----------------------------------------------------------------------------
       
   534 // CMceComAudioCodec::DoMccEncodeRedundancyL
       
   535 // -----------------------------------------------------------------------------
       
   536 //    
       
   537 void CMceComAudioCodec::DoMccEncodeRedundancyL( 
       
   538     CMccCodecInformation& aMccCodec,
       
   539     CMceSrvStream& aStream )
       
   540     {
       
   541     // If red codec is not anymore present in session, disable redundancy
       
   542     // from this codec.
       
   543     CMceComAudioCodec* searchCodec = Factory().CreateCodecLC( KMceSDPNameRed() );
       
   544     
       
   545     CMceComCodec* dtmfCodec = aStream.Data().FindCodecL( *searchCodec );
       
   546     if ( !dtmfCodec || !dtmfCodec->iIsNegotiated )
       
   547         {
       
   548         iRedPayloadType = KMcePayloadTypeUndefined;
       
   549         iRedCount = 0;
       
   550         }
       
   551         
       
   552     CleanupStack::PopAndDestroy( searchCodec );
       
   553     
       
   554     User::LeaveIfError( aMccCodec.SetRedundancyPT( iRedPayloadType ) );
       
   555 	User::LeaveIfError( aMccCodec.SetRedCount( iRedCount ) );
       
   556     }
       
   557 
       
   558 // -----------------------------------------------------------------------------
       
   559 // CMceComAudioCodec::UpdateSendCodec
       
   560 // -----------------------------------------------------------------------------
       
   561 //
       
   562 void CMceComAudioCodec::UpdateSendCodec( 
       
   563     TInt& aCodecIndex, 
       
   564     CMceComAudioStream& aAudio, 
       
   565     CMceComAudioCodec& aCodec )
       
   566     { 
       
   567     if ( aCodecIndex == 0 && 
       
   568         IS_SENDSTREAM( &aAudio ) && 
       
   569         aCodec.SendSupported() &&
       
   570         aCodec.iIsNegotiated )
       
   571         {
       
   572         // Changing send codec
       
   573         aCodec.SetEnabled( ETrue );
       
   574         aCodecIndex = KErrNotFound;
       
   575         }
       
   576     }
       
   577                                                   
       
   578 #endif// MCE_COMMON_SERVER_SIDE
       
   579